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

Mapping two entity classes to one table

 
Sara El-Kady
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I have two classes each annotated with @Entity but I want them to be mapped in one table in the DB.
Is it possible to be done? if yes, please tell me how?

Thanks,
 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe to look at embedded entities??
 
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
Well, if you wanted to do something like this:



Your code might look something like this:


Here's a little tutorial on the topic. Enjoy!
Mapping Two Entity Classes to One Table: A Tutorial


 
Sara El-Kady
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, that was really helpful actually.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic