@Entity @Table(name = "MyCustomCollectionBean") class CustomConvertedCollectionBean { @Column(name="mySet", converter=ObjectConverter.class) private Set<Integer> mySet = new HashSet<Integer>(); public Set<Integer> getMySet() { return mySet; } public void setMySet(Set<Integer> mySet) { this.mySet = mySet; } public CustomConvertedCollectionBean addItem(Integer myInt) { mySet.add(myInt); return this; } }
private void processColumnCustomAnnotation(Field f, me.prettyprint.hom.annotations.Column anno, PropertyDescriptor pd, CFMappingDef<?> cfMapDef) throws InstantiationException, IllegalAccessException { PropertyMappingDefinition md = new PropertyMappingDefinition(pd, anno.name(), anno.converter()); // if collection type and default converter then make note of collection type for later use Class<?> type = pd.getPropertyType(); if (Collection.class.isAssignableFrom(type) && md.isDefaultConverter()) { md.setCollectionType(type); } cfMapDef.addPropertyDefinition(md); } }
@Entity @Table(name = "MyCollectionBean") class CollectionBean { @Column(name="mySet") private Set<Integer> mySet = new HashSet<Integer>(); public Set<Integer> getMySet() { return mySet; } public void setMySet(Set<Integer> mySet) { this.mySet = mySet; } public CollectionBean addItem(Integer myInt) { mySet.add(myInt); return this; } }
@Entity @DiscriminatorValue("couch") public class Couch extends Furniture { @Column(name="foldOutBed") private boolean foldOutBed; @Column(name="numCushions", converter=VariableIntegerConverter.class) private int numCushions; public boolean isFoldOutBed() { return foldOutBed; } public void setFoldOutBed(boolean foldOutBed) { this.foldOutBed = foldOutBed; } public int getNumCushions() { return numCushions; } public void setNumCushions(int numCushions) { this.numCushions = numCushions; } }
@Entity public abstract class MyAbstractGreenTestBean extends MyTestBean { @Column(name="myGreenStuff") private int myGreenStuff;
private String id; @Column(name="mySet", converter=ObjectConverter.class) private Collection<Integer> myCollection = new HashSet<Integer>();
public class MyBlueTestBean extends MyTestBean { @Column(name="mySet") private Set<Integer> mySet = new HashSet<Integer>();