aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate: adding underscore to attibute names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: adding underscore to attibute names" Watch "Hibernate: adding underscore to attibute names" New topic
Author

Hibernate: adding underscore to attibute names

David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

We're using annotations to map a class to a table in another schema, but the column names used in the queries generated by Hibernate are wrong, even when the column name is specified.


The hibernate query tries to load 'user_id', similarly the firstName, middleName and lastName are referred to as 'first_name', 'middle_name' and 'last_name' respectively.
The table already exists and is not created by Hibernate (it is SELECT only) and is running in MySQL 5.1 with Hibernate 3 and Spring.
I go around it by pointing it to a view in the remote schema instead, but I'd prefer it to work correctly.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

That's a strange one. Are you sure the annotations are being picked up by Hibernate? Any hibernate boot logs?

[My Blog] [JavaRanch Journal]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459



Note that this is also related to my other thread, while I believe it is related to the tmp user only having SELECT access on the User_ table so that Hibernate cannot use the DB Metadata to query the table. BUT I'm still confused as to why the annotations are not honoured.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

Going by those logs, it seems to be picking up *.hbm.xml file(s) from some place. Do you see any of those around in your application?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I double checked, but no.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: adding underscore to attibute names