-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate default variable name mapping.
PostPosted: Wed Jul 07, 2010 6:55 am 
Newbie

Joined: Wed Jul 07, 2010 6:25 am
Posts: 1
I was wondering if it was possible to change the default variable mapping in Hibernate for variables with no "@" mark-up.

The Java code at the moment uses the variable name "id" for the primary in all of the Java classes that represent tables in the database. At the moment, to join these up, we have to go through and manually insert a @Column( name = "TableName_Id" ) in order to get the generated column names to match our naming convention. I was hoping that there was some way to change how Hibernate deals with variables without "@" annotations - right now all it does it take the exact variable name when generating the column names, so it ends up trying to find a column in each table called "id", which doesn't exist.

I know about NamingStrategy - we currently use a class extending DefaultNamingStrategy to make sure that foreign keys are named according to our standard - but there is no way to use this to make the change I require; if a variable doesn't have a "@" tag, I don't think any method in NamingStrategy is ever called. I find this rather odd behaviour - I would have expected Hibernate to insert a @Column( name = varName ) or similar for any variables in an @Entity class which weren't marked up with @Transient or another @ annotation...

Cheers,
Stephen


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

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.