Is it possible to use a map with a non-entity class in JPA? If yes, how should it be annotated correctly?
@Entity
class A {
@HowShouldIAnnotateThis?
private Map<B, Integer> myMap = new HashMap<B, Integer>();
}
@Entity
class B {
...
}
From stackoverflow
-
You cannot do this with JPA 1.0. Some implementations provide proprietary extensions (such as EclipseLink's
@BasicMap) which you could use if you don't mind coupling your application to the given JPA provider.JPA 2.0 will provide similar functionality with
@ElementCollection.
0 comments:
Post a Comment