JPQL query return null when get list of entity

53 views
Skip to first unread message

Klong Vu

unread,
Dec 14, 2012, 8:58:18 AM12/14/12
to google-a...@googlegroups.com
My entity class :

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" ?>
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence

    <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>

Now persist account and it was successful

ACCOUNT ac=new ACCOUNT("admin","123");
em.persist(ac);

I checked http://localhost:8888/_ah/admin and yes ,there is ACOUNT entity with 1 record admin and 123

but when I use JPQL to get all entity , it returned null

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

even with 

em.find(ACCOUNT.class,"admin"); return null too 

Did i miss something ? Please help me , very grateful for your help
Reply all
Reply to author
Forward
0 new messages