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
|