Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on SecondaryTable Annotation

 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I fail to understand the use of this Annotation as in theory we could do the same thing with @JoinColumn annotation and the @ManyToOne relationship. TSo why do we need this afteral when we have some other alternativs?
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@SecondaryTable enables you, to use fields from a secondary table directly in your entity. That means you need to define just one entity. The other techniques like @OneToOne or @ManyToOne need two entities.

So, if there is no further need for an entity consisting of fields from the secondary table, one might prefer to use @Secondary table.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ralf! [ ] I had not pointed out the obvious!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic