我的实体类:
public class ACCOUNT implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@Column(name = "USERNAME")
private String Username;
@Column(name = "PASSWORD")
private String Password;
public ACCOUNT(String user,String pass)
{
this.Username=user;
this.Password=pass;
}
// geter and setter
我的persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>com.materialshop.server.Datastore.ACCOUNT</class>
<exclude-unlisted-classes/>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.nontx.atomic" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
</persistence>
现在持久化帐户,它是成功的
ACCOUNT ac=new ACCOUNT("admin","123");
em.persist(ac);
我检查了
http://localhost:8888/_ah/admin
是的,有 1 个记录管理员和 123 个 ACOUNT 实体
但是当我使用 JPQL 获取所有实体时,它返回 null
Query q=new Query("SELECT ac FROM ACCOUNT ac");
List<ACCOUNT> list=q.getResultList();
即使
em.find(ACCOUNT.class,"admin");
也返回 null
我错过了什么 ?请帮助我,非常感谢您的帮助