开发者

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

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 setAcc开发者_JS百科ount(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;
    }


}


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

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜