• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection fields

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think that I already know the response but I also want to know your opinion. According with the specs :

The persistent fields or properties of an entity may be of the following types: Java primitive types; java.lang.String; other Java serializable types (including wrappers of the primitive types, java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar[7], java.sql.Date, java.sql.Time, java.sql.Timestamp, user-defined serializable types, byte[], Byte[], char[], and Character[]); enums; entity types and/or collections of entity types; and embeddable classes (see section 2.1.5).


Only this, that's means I can not have a field like this :
private Map<String, String> myMap.

This will ends with an deploy exception. Right ?

Regards,
Mihai



Regards,
Mihai
 
Angelika Angley
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can map Collection, List (ie ordered lists, not indexed lists), Map and Set. EJB3 allows you to map Maps using as a key one of the target entity property using @MapKey(name="myProperty").

I guess it goes under "other Java serializable types ".
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angelika

The @MapKey can be used only for java.util.Map.

Is used to specify the map key for associations of type Map.
If a persistent field or property other than the primary key is used as a map key then it is expected to have a uniqueness constraint associated with it.


that means the only collection what I can use without to envolve any relational fields. So basically I can not have non relational collections fields.

Regards,
Mihai
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic