-->
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: HQL bulk statements and mapping names
PostPosted: Fri Feb 17, 2006 9:21 am 
Newbie

Joined: Fri Jul 08, 2005 6:28 am
Posts: 4
Hibernate version: 3.1

To create a SQL-statement like
UPDATE person set pers_type = null where pers_type = <something>

One would expect the following HQL to do this:
"update " + Person.MAPPING_NAME + " set "
+ Person.PROPERTY_TYPE + " = null where "
+ Person.PROPERTY_TYPE + " = :type";

While it really is necessary to use the mapping names
for the table and the field after "set", in the where-clause
the mapping name is not translated to the database column
name - so I have to use the column name directly:

"update " + Person.MAPPING_NAME + " set "
+ Person.PROPERTY_TYPE + " = null where "
+ Person.COLUMN_TYPE + " = :type";

Person.PROPERTY_TYPE = "type"
Person.COLUMN_TYPE = "pers_type"

Am I doing something wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 10:03 am 
Regular
Regular

Joined: Wed Feb 08, 2006 3:59 pm
Posts: 75
Just a guess : isn't 'type' a reserved word in HQL and/or SQL ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 17, 2006 10:07 am 
Newbie

Joined: Fri Jul 08, 2005 6:28 am
Posts: 4
Sorry, this was only a (badly chosen) example.
I have this problem with various tables and columns:
always in the "where"-clause I need to use the real
column name, not the mapping-name, as otherwise
the mapping-name will be part of the resulting SQL.


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.