简体   繁体   English

org.hibernate.exception.SQLGrammarException:无法执行查询

[英]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 org.hibernate.exception.SQLGrammarException:无法执行查询

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


}

You are completely missing the mapping annotations for the properties of your class. 您完全缺少类属性的映射注释。

PS Please try to follow the Java naming conventions PS请尝试遵循Java命名约定

Using mysql, we also faced this type of issue. 使用mysql,我们也面临此类问题。 We found in play framework application.conf : 我们在播放框架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. 我们已经在id列的xml和@GeneratedValue中创建了。 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 eg 1l . 解决方法是删除@GeneratedValue批注,然后手动输入id的值,默认情况下,jpa需要long ,因此请提供长值,例如1l

To do the auto generation follow some another rule. 要进行自动生成,请遵循另一条规则。

The issue around the JPA related auto generated Id is resolved as below: 与JPA相关的自动生成ID的问题已通过以下方式解决:

Modify the Person.java model class to have the following annotations for the Id attribute: 修改Person.java模型类,使其对Id属性具有以下注释:

@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. 这将在mysql模式中创建一个名为T_GNERATOR的表,该表将跟踪休眠状态下Id和JPA的下一个值,而Hibernate知道如何检索该值。 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. 假设是,Id的初始值为1,并且从注释的属性可以明显看出,它在每次新插入时都增加1。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 嵌套的异常是org.hibernate.exception.SQLGrammarException:无法执行查询 - nested exception is org.hibernate.exception.SQLGrammarException: could not execute query 如何解决 org.hibernate.exception.SQLGrammarException: 无法执行查询 - How to solve org.hibernate.exception.SQLGrammarException: could not execute query RuntimeException:org.hibernate.exception.SQLGrammarException:无法执行查询 - RuntimeException: org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.exception.SQLGrammarException:无法再次执行查询 - org.hibernate.exception.SQLGrammarException: could not execute query again org.hibernate.exception.SQLGrammarException:无法执行语句 - org.hibernate.exception.SQLGrammarException: could not execute statement org.hibernate.exception.SQLGrammarException:无法执行JDBC批更新 - org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update org.hibernate.exception.SQLGrammarException:无法执行 JDBC 批量更新 - org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update org.hibernate.exception.SQLGrammarException:无法执行语句 - org.hibernate.exception.SQLGrammarException: could not execute statement 嵌套的异常是org.hibernate.exception.SQLGrammarException:无法执行查询-添加了“ 0_” - nested exception is org.hibernate.exception.SQLGrammarException: could not execute query - “0_” added javax.persistence.PersistenceException:org.hibernate.exception.SQLGrammarException:无法执行查询 - javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM