Java JPQL JPA访问谷歌数据存储

Java JPQL JPA访问谷歌数据存储,java,google-cloud-datastore,jpql,Java,Google Cloud Datastore,Jpql,我的实体类: 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,Stri

我的实体类:

     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
my 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>
我查过了

     http://localhost:8888/_ah/admin 
是的,有一个账户实体,有1个记录管理员和123

但当我使用JPQL获取所有实体时,它返回null

Query q=new Query("SELECT ac FROM ACCOUNT ac");
List<ACCOUNT> list=q.getResultList();
也返回null


我错过什么了吗?请帮助我,非常感谢您的帮助

afaik getResultList()应该返回空列表,如果没有结果,则返回NOTNULL。空值可能在EmtityManager中。由于查询是一个接口,您的代码甚至不应该编译。我认为您需要@Entity注释吗?
Query q=new Query("SELECT ac FROM ACCOUNT ac");
List<ACCOUNT> list=q.getResultList();
 em.find(ACCOUNT.class,"admin");