1

I use play framework !! But when I run my project it give me this

org.hibernate.exception.SQLGrammarException: could not execute query

who can help me ?

this is my model:

package models;
import java.util.*;
import javax.persistence.*;
import play.db.jpa.*;
import play.db.jpa.Model;

@Entity
@Table(name="GxkAccount")
public class GxkAccount extends Model {

    private String Account;
    private String Psw;

    public String getAccount() {
        return Account;
    }
    public void setAccount(String account) {
        Account = account;
    }
    public String getPsw() {
        return Psw;
    }
    public void setPsw(String psw) {
        Psw = psw;
    }

    public static List<GxkAccount> GetList()
    {
        List<GxkAccount> infoList=GxkAccount.findAll();
        return infoList;
    }


}
1
  • 1
    Please share the full exception message. And if you can have the actual query generated by Hibernate, that would be great. Commented Nov 3, 2010 at 3:42

3 Answers 3

4

You are completely missing the mapping annotations for the properties of your class.

P.S. Please try to follow the Java naming conventions

Sign up to request clarification or add additional context in comments.

1 Comment

@niels: Then the generated query is essentially needed.
1

Using mysql, we also faced this type of issue. We found in play framework application.conf:

jpa.dialect=org.hibernate.dialect.PostgreSQLDialect

we replaced this with

jpa.dialect=org.hibernate.dialect.MySqlDialect.

This solved the problem. If you are facing this issue you can try out this configuration setting.

Comments

0

We also faced the same issue. We were having create in the xml and @GeneratedValue on the id column. The resolution is remove the @GeneratedValue annotation and put the value of the id manually, also the jpa takes long by default so give long value e.g 1l.

To do the auto generation follow some another rule.

The issue around the JPA related auto generated Id is resolved as below:

Modify the Person.java model class to have the following annotations for the Id attribute:

@Id
@TableGenerator(name="TABLE_GEN",table="T_GENERATOR",pkColumnName="GEN_KEY",pkColumnValue="TEST",valueColumnName="GEN_VALUE",initialValue=1,allocationSize=1)
@GeneratedValue(strategy=GenerationType.TABLE, generator="TABLE_GEN")
public Long Id;

This will create a table in the mysql schema called T_GNERATOR which will have the tracking of the next value for Id and JPA over hibernate knows how to retrieve this value. The assumption is that the initial value for the Id is 1 and it is incremented by 1 on each new insertion into it as is obvious from the attributes of the annotation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.