当前位置:  开发笔记 > 编程语言 > 正文

JPA - 未知的实体bean类

如何解决《JPA-未知的实体bean类》经验,为你挑选了1个好方法。

希望我能正确解释这个问题.我有3个课程来处理我的实体.

@MappedSuperclass
public abstract class Swab implements ISwab {
...
    private Collection accounts;
...
}

@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);
    List s = 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.



1> 小智..:

在persistence.xml中的class标签中定义此实体

推荐阅读
yzh148448
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有