• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: adding underscore to attibute names

 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a strange one. Are you sure the annotations are being picked up by Hibernate? Any hibernate boot logs?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I double checked, but no.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic