-->
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: Column names truncated into short aliases by QueryTranslator
PostPosted: Wed Oct 15, 2003 1:34 pm 
Regular
Regular

Joined: Mon Sep 08, 2003 10:05 am
Posts: 50
Location: Dublin, Ireland
When I retrieve a "Table" object using session.find(), and it subsequently gets updated back to the database (even though I do not make any change to the table object anywhere). I get a "Attempt to insert NULL value into column 'DESCRIPTION', table 'clientdb.dbo.CDB_TABLE'" error as a result..

I can explain why Hibernate thinks the object is dirty: when I do the find, the HQL column name generated does not match the name in the mapping file:

HQL: from CDB_TABLE in class com.kbcam.core.entity.Table where CDB_TABLE.description = ?
SQL: select CDB_TABLE.tableId as tableId, CDB_TABLE.description as descript2_ from CDB_TABLE CDB_TABLE where (CDB_TABLE.description=? )

Note that in the generated SQL, the description column has been aliased as "descript2_" (ie truncated) so it does not get matched to the "description" attribute in the class.

My question is this: how do I prevent the QueryTranslator from truncating the name to produce a shortened alias name?

Alternatively, do I have to change the mapping files?? (This is not as good for me, because the mapping files are generated automatically using XDoclet, God bless it)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 1:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
your analysis of the problem is completely wrong. The SQL is fine. Check for a broken get/set pair.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 4:09 am 
Regular
Regular

Joined: Mon Sep 08, 2003 10:05 am
Posts: 50
Location: Dublin, Ireland
Close enough for me! It turned out to be that the parameter to the setDescription column was mis-spelt, so the field was *not* getting set, even if the setter was called, resulting in Hibernate seeing the field as "dirty". Fixing the setter fixed the issue.


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.