[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Re: How to use @BasicMap for a HashMap whose key values are entities

BasicMap and BasicCollection support basic types as the keys and values. As part of the JPA 2.0 work already completed in trunk for EclipseLink 2.0 the new javax.persistence.ElementCollection mapping allows mappings with values being basic, embedables and if using a map the key can be basic, embeddable, or and entity.

here is an example from the spec:

@Entity
public class VideoStore {
   @Id int id;
   String name;
   Address location;
   ...
   @ElementCollection
   @CollectionTable(name="INVENTORY",
                   joinColumns=@JoinColumn(name="STORE"))
   @Column(name="COPIES_IN_STOCK")
   @MapKeyJoinColumn(name="MOVIE", referencedColumnName="ID")
   Map<Movie, Integer> videoInventory;
   ...
}

This support is completed in EclipseLink trunk's nightly builds and future milestone builds.

Doug