Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replacing *.hbm.xml files with @Annotations.

 
Jan Erik Robertsen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three java classes that are persisted using hibernate. I want to switch from using *.hbm.xml files to annotations on these classes. However the db has additional tables that are created by tags in hbm.xml. Is there a way to create these extra tables using annotations without having to create additional java classes.


One of the java classes that result in two tables in db:




hbm.xml file for the Attribute class:




The resulting sql script:



Any help is much apprecated.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering if the @SecondaryTable annotation might do the trick? Here's an example:


Mapping One Class to Two Tables with Hibernate and JPA

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic