0

我有这样的实体类

包 org.organization.domain;

@Entity
@Table(name = "GenPersonnel")
public class GenPersonnel implements java.io.Serializable {

    //class members and setters, getteres are ommited. Nothing special

}

此类位于另一个 jar 中,该 jar 作为 maven 依赖项插入到主项目中。如果我只知道类名作为字符串参数而没有完全限定名,如何通过 JNDI 获取此类对象?在这种情况下

 String entityClazz = "GenPersonnel"
 InitialContext ic = new InitialContext();
 Object clasObject = ic.lookup(entityClazz);

任何帮助表示赞赏

4

1 回答 1

1

You can't lookup EJB 3 Entity from JNDI, you can lookup only EJB Session bean.

Look at this post about EJB JNDI lookup.

To manage Entity you have to use EntityManager, look at this article.

于 2013-06-18T09:00:02.887 回答