Skip to content
This repository

There are annotations to work with Collections (java.util.Set, java.util.List, java.util.Map):

  • SetData informs the field is java.util.Set, it is necessary inform a class of the collection within a classData.

  • ListData informs the field is java.util.List, you should inform a class of the collections within classData.

  • MapData inform the field is java.util.Map, you should inform the key and value of the map's collection with classkey and classValue respectively.

  • ElementCollection by standardization of JPA 2.0 this annotation recognize automatically the collection, but this collection just can be: java.util.List, java.util.Set and java.util.Map.

MapData

 @Entity(name="resumebook")
 public class Book {

 @Id
 @Column(name="booksname")
 private String name;

 @MapData
 private Map chapterResume;
 //getter and setter
 }

ListData

 @Entity(name="shopping")
 public class ShoppingList {

 @Id
 private String name;

 @Column(name="day")
 private Date day;

 @ListData
 @Column(name="frutis")
 private List fruits;

 @Column(name="storeName")
 private String storeName;

 //getter and setter

 }

SetData

 @Entity(name="contact")
 public class Contact implements Serializable {

 @Id
 @Column(name="id")
 private String name;

 @Column(name="emails")
 @SetData
 private Set<String> emails;

 //getter and setter

}

ElementCollection

    @Entity(name = "collection")
    public class CollectionBean {

@Id
private UUID id;

@ElementCollection
@Column(name = "mapBean")
private Map<String, String> map;

@ElementCollection
@Column(name = "setBean")
private Set<String> set;

@ElementCollection
@Column(name = "listBean")
private List<String> list;
    // getter and setter
    }
Something went wrong with that request. Please try again.