我有一个带有以下注释的父类
@PersistenceCapable(table = "my_parent_table", objectIdClass = Myclass.PK.class, detachable = "true", identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
@Discriminator(strategy = DiscriminatorStrategy.VALUE_MAP, column = "discriminator", value = "0")
现在我所有的子类都有以下注释,除了注释的value
属性@Discriminator
当然不同,注释的属性也table
不同@PersistanceCapable
。
@PersistenceCapable(detachable = "true", table = "my_table")
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
@Discriminator(value = "1")
通过一个用 注释的 DAO 类,@Persistence
我使用以下方法作为 PoC
public List<MyParentClass> test() {
PersistenceManager pm = null;
try {
pm = getPM();
Query q = pm.newQuery(MyParentClass.class);
return (List<MyParentClass>) q.execute();
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
} finally {
pm.close();
}
}