For example:
@MappedSuperclass @AutoProperty public class MappedSuperClass implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) private long id; private String s; // Setter, Getters, Constructors, Pojomatic... }
@Entity @AutoProperty public class InheritingMappedSuperClass extends MappedSuperClass { private String s2; // Setter, Getters, Constructors... }
JPA.INSTANCE.clear(); InheritingMappedSuperClass ce = new InheritingMappedSuperClass(); ce.setS("QQQ"); ce.setS2("DDD"); JPA.INSTANCE.save(ce); JPA.INSTANCE.clear(); InheritingMappedSuperClass retr = JPA.INSTANCE.get( InheritingMappedSuperClass.class, ce.getId()); System.out.println("Source == Retrieved: " + (ce==retr)); System.out.println(retr);
Source == Retrieved: false InheritingMappedSuperClass{id: {1}, s: {QQQ}, s2: {DDD}}
No comments:
Post a Comment