• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPA Embeddable and MappedSuperclass

 
Fredrik Liden
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can an entity be both Embeddable and MappedSuperclass at the same time?

In one place of the model it's used as an embeddable but in another place it needs to be inherited from.
 
xsunil kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can define any entity which is Embedded and MappedSuperclass at the same time. Below is the syntax to use this.

@Embeddable
@MappedSuperclass
public class AddressEmbedded implements Serializable{
// properties values and their getter/ setter methods.
}

-Sunil
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!