-->
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.  [ 2 posts ] 
Author Message
 Post subject: can't do bulk delete with many-to-one property in hibernate3
PostPosted: Wed May 11, 2005 3:48 am 
Newbie

Joined: Wed May 11, 2005 3:06 am
Posts: 2
I want do bulk delete and use many-to-one property in where-clause:
mycode:
Code:
String sql = "delete User  where group.id=100";
session.createQuery(sql).executeUpdate();

result, hibernate generated SQL:
Code:
delete from ums_user where user0_.id=100

and throw exception:
Code:
(Hibernate operation): encountered SQLException [General error,  message from server: "Unknown table 'user0_' in where clause"]; nested exception is java.sql.SQLException: General error,  message from server: "Unknown table 'user0_' in where clause"

My Hibernate version:hibernate3.0.1,hibernate3.0.3
part of my Mapping documents:
Code:
<hibernate-mapping>
   <class name="example.entity.User" dynamic-update="false"
      dynamic-insert="false" table="ums_user" >
      <id name="id" column="id" type="java.lang.Long" unsaved-value="null">
      <generator class="native"></generator>
      </id>
      <property name="name" type="java.lang.String"  column="name" />
              <many-to-one name="group" column="group_id"/>
   </class>
</hibernate-mapping>

<hibernate-mapping>
   <class name="example.entity.Group" dynamic-update="false"
      dynamic-insert="false" table="ums_group" lazy="false">
      <id name="id" column="id" type="java.lang.Long" unsaved-value="null">
         <generator class="native"></generator>
      </id>
      <property name="name" type="java.lang.String"  column="name" />           
   </class>

</hibernate-mapping>

though i can complete this bulk delete in this way:
my code:
Code:
String sql = "delete User  where group_id=100";
session.createQuery(sql).executeUpdate();

hibernate generated SQL:
Code:
delete from ums_user where group_id=100

but, it's not HQL.


Top
 Profile  
 
 Post subject: reason: bulk delete HQL cannot have an alias ?
PostPosted: Thu Jun 02, 2005 4:51 am 
Newbie

Joined: Wed May 11, 2005 3:06 am
Posts: 2
HQL:
Code:
FROM User WHERE group.id =100

hibernate generate SQL:
Code:
user0_.id as id, user0_.name as name6_, user0_.account as account6_, user0_.group_id as group4_6_, user0_.password as password6_ from ums_user user0_ where user0_.id=100


if use many-to-one property in where-clause, must use alias
but,now,bulk delete HQL cannot have an alias

bulk delete HQL maybe support alias


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.