Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Use of Embeddable annotation

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

I'm trying to fully understand this annotation. From what I read from the Pro EJB 3 book is that for an user entity when we have the address information in the user itself, then we could very well make it as a seperate entity and mark it as embedabble and use this entity in the user. But normally we model the aaddress class as a seperate entity as it will be a physical table representation in the database. So this example does not justifies to me the need for Embeddable. Can anyone here help me with a better example?
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For example, you can have Name class.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...
What i think is you use @Embeddable annotation to designate persistent objects that need
not have an identity(something like a primary key in DB scenario) of their own. They are simply used as convenient data holders/groupings.(Am i correct..?)
 
Joe Harry
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ravi Kiran Savirigana wrote:hi...
What i think is you use @Embeddable annotation to designate persistent objects that need
not have an identity(something like a primary key in DB scenario) of their own. They are simply used as convenient data holders/groupings.(Am i correct..?)



Yes, this looks like a valid point to me. But there is another scenario where in you use this annotation. When you have to represent an Id class....which looks totally in contrary to what you said (data holders/groupings not have an identity...). What I feel is the real use of this class is like reusable chunk of a POJO that I can use across multiple entities and override the defaults (using @AttributeOverrides...) as and when needed.
 
Ranch Hand
Posts: 193
Mac OS X Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


But there is another scenario where in you use this annotation. When you have to represent an Id class....which looks totally in contrary to what you said (data holders/groupings not have an identity...). What I feel is the real use of this class is like reusable chunk of a POJO that I can use across multiple entities and override the defaults (using @AttributeOverrides...) as and when needed.


I think that the @Embeddable class itself is ignorant of whether it is used as Properties or Id. From this point of view, it is simply served as a data holders/groupings. How this grouping is used (either ID by @EmbeddedId or properties by @Embedded) is dependant on the "consumer" of the Embeddable class.
 
Men call me Jim. Women look past me to this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic