-->
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.  [ 4 posts ] 
Author Message
 Post subject: Generate getter for SQL names of columns
PostPosted: Wed Nov 28, 2007 12:36 pm 
Newbie

Joined: Wed Nov 02, 2005 11:00 am
Posts: 12
Location: Austria, Vienna
Hi,

Is there a way to get the SQL column name from Hibernate.

I don't want to use Strings for creating Restrictions because changes in the data model and the Hibernate Beans wouldn't result in compiler errors. So a changed column name would produce errors at runtime instead of compile time.

My idea was that the Hibernate Tools would create extra methods which return the SQL column name for a property, like:

getPkUserId() ... Property in Hibernate Bean representing the primary key of a table

getPkUserIdSqlName() ... Method which returns the SQL column name as string

So I could use these methods in Criterias and would get a compile error if the column name has changed -> because the Hibernate tools renamed the according getter.

I searched a lot but didn't find anything. I can't understand why nobody would have the same problem / idea?

I already asked this question in the Hibernate forum but I didn't get a stisfying answer:

http://forum.hibernate.org/viewtopic.ph ... highlight=

Thanks!

RĂ¼diger Engelberger


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 6:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
others have had the same idea, search in jira i even think there might be a patch on it.

its trivial/simple to do - just setup another template that generates an class or interface (better IMO) and generate constants for the properties you want.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 29, 2007 5:11 am 
Newbie

Joined: Wed Nov 02, 2005 11:00 am
Posts: 12
Location: Austria, Vienna
Hi,

Thanks for your hint. I searched in Hibernate JIRA but only found some old discussions (2003/2004) on this topic. e.g.:

http://opensource.atlassian.com/project ... se/HBX-422

Some suggestions have been rejected, so it seems to me that at the moment there's no solution on this problem!?

Am I right?

Thanks!

RĂ¼diger Engelberger


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 29, 2007 5:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh there is patch you can look at or simply just write your own custom template.

So there is definitly a way to do this.

_________________
Max
Don't forget to rate


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