• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mixing annotations and xml mapping

 
Steve Staarask
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an issue where I need to do an XML mapping for one of the attributes in my entity class that is using only annotations. XML mapping is more flexible and there is a case I need it for.

So lets call Entity A the class that is using only annotations. I know we can't mix annotations and xml for a given entity. The attribute I need to use XML mapping for is an attribute in Entity A and is a simple long (a column from a different table)


So the current setup:




The annotations above column_x just are not working properly. I need XML mapping. Is there a way I can make this work? My thinking was what if I had a wrapper class (mapping to no table) over long_column_x, stored its mapping information in a .xml file. Is this possible? The key parts here are

1) What would my annotations in Entity A look like?
2) Is it even possible in hibernate to have a .xml configuration for a class that doesn't map to a table (but one of its fields/columns does)? I DO NOT want to create a .xml file for an entity mapping to Table B.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic