• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replacing *.hbm.xml files with @Annotations.

 
Jan Erik Robertsen
Greenhorn
Posts: 1
  • 0
  • 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
  • 0
  • 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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic