About Question enthuware.oce-jpad.v6.2.587 :

Moderator: admin

Post Reply
Posts: 1
Joined: Thu Nov 15, 2018 3:31 pm

About Question enthuware.oce-jpad.v6.2.587 :

Post by Martin »

Why is a @ElementCollection Annotation correct? It clearly states that when the map has an Entity as key, it must be a relationship Annotation. The ElementCollection is for embeddables and primitives only.

Site Admin
Posts: 10062
Joined: Fri Sep 10, 2010 9:26 pm

Re: About Question enthuware.oce-jpad.v6.2.587 :

Post by admin »

ElementCollection can be used for entities also. Example 2 on page 396 of JPA 2.0 specification uses it:

Code: Select all

public class VideoStore {
  @Id int id;
  String name;
  Address location;
  @MapKeyJoinColumn(name="MOVIE", referencedColumnName="ID")
  Map<Movie, Integer> videoInventory;

  public class Movie {
  @Id long id;
  String title;
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 65 guests