Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法将JPA实体添加到数据库_Java_Jpa_Ejb - Fatal编程技术网

Java 无法将JPA实体添加到数据库

Java 无法将JPA实体添加到数据库,java,jpa,ejb,Java,Jpa,Ejb,我在坚持实体时遇到问题: @Stateless @LocalBean public class TestExampleBean { private TestEntity r; // simple table: ID, NAME (Auto generated from sql table so I think the class code is ok!) @PersistenceContext(unitName = "Test-ejbPU") private Ent

我在坚持实体时遇到问题:

@Stateless
@LocalBean
public class TestExampleBean {

    private TestEntity r;  // simple table: ID, NAME (Auto generated from sql table so I think the class code is ok!)

    @PersistenceContext(unitName = "Test-ejbPU")
    private EntityManager em;

    public void save() {
        // Print statements will execute here if added so this methods does run

        r = new TestEntity();
        r.setName("TESTER");

        em.persist(r);
    }

}
这个EJB的save方法是从JSF管理的bean调用的。实体具有ID和NAME(VARCHAR)属性


我无法在数据库中获得任何持久性。。。但是glassfish服务器上没有显示错误。

假设您添加了
em.flush()结尾,查看异常。无异常..您是否尝试将
@Transactional(value=TxType.REQUIRED)
添加到
save()
中,为什么不查看JPA提供程序日志以了解发生了什么?!是否缺少任何依赖项(应存在相关实体)?