• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Collection mapping of Elements in JPA

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

This is regarding an example from the JPA book.



Where VacationEntry is marked with an Embedable annotation. My question is:

Is the Embedded annotation optional and that the ElementCollection is enough to make the Persistence Provider to be aware that vacationBookings is of Embedded type?
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

From JPA spec (http://download.oracle.com/javaee/6/api/javax/persistence/Embedded.html)
"Specifies a persistent field or property of an entity whose value is an instance of an embeddable class. The embeddable class must be annotated as Embeddable. "

For me it means you should use it for single attributes, not collections. Howewer, the annotation api doesnt deny it, and with eclipselink, and hibernate it works for me.
but in the xml api, which is better-defined, its not allowed.

So I think you should not use it,
the generic type, or the targetClass attribute of @ElementCollection is enough.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic