Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

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

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

share|improve this question
This site is a place to get reviews of your working code. It's not a place for debugging questions. – sepp2k Dec 15 '12 at 12:17

closed as off topic by Jeff Vanzella, svick, Glenn Rogers, Brian Reichle, Paul Dec 15 '12 at 5:54

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

I don't have experience with JPQL but this doesn't look like a proper SQL query:

Query q=new Query("SELECT ac FROM ACCOUNT ac");

It should either be:

SELECT * FROM ACCOUNT

or:

SELECT ac.* FROM ACCOUNT ac
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.