gpt4 book ai didi

java - 无法执行语句 SQL 语法异常

转载 作者:行者123 更新时间:2023-12-02 05:09:43 24 4
gpt4 key购买 nike

这是我的实体类。

@Entity
public class Store implements Serializable {

private static final long serialVersionUID = 1L;

public Store() {
}

@Id
private int id;
private String code;
private String password;
private String forgetPasswordNote;
private String key;
private String ownerId;
private String storeLink;
private String activationCode;
private String name;
private String homepageUrl;
private String sessionToken;
private Date dateCreated;
private Date expireDate;
private Date lastModified;
private String nmPassword;
private String storeType;
private String premium;
private double money;
private boolean refreshed;
private String country;
private String lang;
private String varId;
private String fbPageId;
private boolean fbEnabled;
private boolean informative;
private boolean active;
private String fbEnabledBy;
private String ipAddress;
private String comments;
private float commission;
private String picasaEmail;
// all getter and setter goes here

}

这是我的 Controller

@Controller
public class RegController {
@RequestMapping(value = "/create/database")
public String createDatabase(ModelMap map, HttpServletRequest request) {
Store store = new Store();
store.setId(1);
store.setCode("1");
System.out.println("test worl");
@SuppressWarnings("deprecation")
SessionFactory sessionFactory = new Configuration().configure()
.buildSessionFactory();
try {
Session session = sessionFactory.openSession();
session.beginTransaction();
session.save(store);
session.getTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.toString());
}
return "home";
}
}

当我运行 url localhost:8080/MyApp/create/database 时,我收到错误。 org.hibernate.exception.SQLGrammarException:无法执行语句我的 entites 类上有保留关键字吗?

最佳答案

我发现解决方案 key 是 mysql 数据库上的保留关键字,因此我只需将 key 更改为 storekey 即可,一切正常。

关于java - 无法执行语句 SQL 语法异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27437559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com