-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: could not insert/select ids for bulk update
PostPosted: Tue May 16, 2006 9:06 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
Hibernate version:
version 3.1.2

Name and version of the database you are using:
MySQL 4.0.18-standard

Mapping documents:
case 1:
Code:
    <class name="Person" table="person">
        <id name="id" column="id">
            <generator class="native"/>
        </id>

        <version name="version"/>
        <property name="name"/>
        <property name="surname"/>
       
    </class>


case 2:
Code:
    <class name="Person" table="person">
        <id name="id" column="id">
            <generator class="native"/>
        </id>

        <version name="version"/>
        <property name="name"/>
        <property name="surname"/>
       
        <joined-subclass name="Male" table="male">
            <key column="pid"/>
            <property name="car"/>
        </joined-subclass>       
    </class>



Code between sessionFactory.openSession() and session.close():
session.createQuery("update Person set surname = :foo").setString("foo", "example.com").executeUpdate();

The generated SQL (show_sql=true):
case 1: update person set surname=?

case 2: Hibernate: insert into HT_person select person0_.id as id from person person0_
16 Μαϊ 2006 3:57:29 μμ org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1146, SQLState: 42S02
16 Μαϊ 2006 3:57:29 μμ org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Table 'test.HT_person' doesn't exist
16 Μαϊ 2006 3:57:29 μμ org.hibernate.hql.ast.exec.AbstractStatementExecutor$2 doWork
WARNING: unable to drop temporary id table after use
java.sql.SQLException: Unknown table 'HT_person'



Hello

I bulk update a property of Person which works fine (case 1).

If I have a class Male extending Person, the bulk update cannot happen on that Person class (case 2). I found that out by commenting out the <joined-subclass> element in the Person.hbm.xml and made the bulk update work, but of course this is not what I want as then I will not be able to find instances of the Male class.

am I doing something wrong?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 9:21 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
My table is MyISAM and I have configured hibernate with: <property name="hibernate.dialect">org.hibernate.dialect.MySQLMyISAMDialect</property>

The sql query generated tries to "INSERT INTO" into a table which does not exist. Does hibernate create temporary tables? This query cannot be executed anyway, even if I try to do so from my mysql client tool.

The sql query is: insert into HT_person select person0_.id as id from person person0_

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 7:45 am 
Beginner
Beginner

Joined: Fri May 12, 2006 9:58 am
Posts: 32
Just ignore everything. I was using a mysql user which did not have this privilege (creating temp tables).

Also MySQL 4.0 does not support subqueries, which are needed to perfrom the operation mentioned above. But this is also mentioned here: http://www.hibernate.org/80.html


thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.