aspose file tools*
The moose likes Object Relational Mapping and the fly likes Replacing *.hbm.xml files with @Annotations. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Replacing *.hbm.xml files with @Annotations." Watch "Replacing *.hbm.xml files with @Annotations." New topic
Author

Replacing *.hbm.xml files with @Annotations.

Jan Erik Robertsen
Greenhorn

Joined: Feb 05, 2010
Posts: 1
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

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Replacing *.hbm.xml files with @Annotations.