This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
Similar Threads
Hibernate replacing my tables
what changes should i made in save method in one-to-many relationships
SecondaryTable Mapping
autogenerating db-schema cascade=CascadeType.REMOVE but no ON DELETE CASCADE
Cascading non foreign key to Child Table