希望我能正确解释这个问题.我有3个课程来处理我的实体.
@MappedSuperclass public abstract class Swab implements ISwab { ... private Collectionaccounts; ... } @Entity @Table(name="switches") @DiscriminatorColumn(name="type") @DiscriminatorValue(value="DMS500") public class DmsSwab extends Swab implements ISwab, Serializable { ... private ObjectPool pool; ... @Transient public ObjectPool getPool(){ return pool; } ... } @Entity(name="swab_accounts") public class SwabAccounts implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int swab_account_id; private int swab_id; ... }
在EJB中,查询正在以这种方式进行
DmsSwab dms = em.find(DmsSwab.class, 2); Lists = new ArrayList (1); s.add(dms);
我的persistence.xml看起来像这样:
oracle.toplink.essentials.PersistenceProvider com.dcom.sap.dms.DmsSwab com.dcom.sap.jpa.SwabAccounts
我收到此错误:
java.lang.IllegalArgumentException: Unknown entity bean class: class com.dcom.sap.dms.DmsSwab, please verify that this class has been marked with the @Entity annotation. com.dcom.sap.SwabException: java.lang.IllegalArgumentException: Unknown entity bean class: class com.dcom.sap.dms.DmsSwab, please verify that this class has been marked with the @Entity annotation. Caused by: java.lang.IllegalArgumentException: Unknown entity bean class: class com.dcom.sap.dms.DmsSwab, please verify that this class has been marked with the @Entity annotation. at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.findInternal(EntityManagerImpl.java:306) at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.find(EntityManagerImpl.java:148)
我正在使用随附的glassfish版本运行netbeans 6.1.MySql 5.0.
在persistence.xml中的class标签中定义此实体