package com.hn3l.website.entity; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import org.hibernate.annotations.GenericGenerator; @Entity public class Address implements Serializable { private static final long serialVersionUID = -8300572285485402602L; @Id @Column(length = 36, nullable = false) @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "guid") private String id; // 收获信息id private String aPhone; // 手机 private String aStreet; // 街道 private String aName; // 收货人 private int aQPhone; // 区号 private int aGPhone; // 固话号 private int aFPhone; // 分机号 private int aZip; // 邮编 private int asort; // 收货地址排序 private int isDef; // 是否默认 public String getId() { return id; } public void setId(String id) { this.id = id; } public String getaPhone() { return aPhone; } public void setaPhone(String aPhone) { this.aPhone = aPhone; } public String getaStreet() { return aStreet; } public void setaStreet(String aStreet) { this.aStreet = aStreet; } public String getaName() { return aName; } public void setaName(String aName) { this.aName = aName; } public int getaQPhone() { return aQPhone; } public void setaQPhone(int aQPhone) { this.aQPhone = aQPhone; } public int getaGPhone() { return aGPhone; } public void setaGPhone(int aGPhone) { this.aGPhone = aGPhone; } public int getaFPhone() { return aFPhone; } public void setaFPhone(int aFPhone) { this.aFPhone = aFPhone; } public int getaZip() { return aZip; } public void setaZip(int aZip) { this.aZip = aZip; } public int getAsort() { return asort; } public void setAsort(int asort) { this.asort = asort; } public int getIsDef() { return isDef; } public void setIsDef(int isDef) { this.isDef = isDef; } }
这是代码...项目是用的反向生成数据库表,报错如下:
DEPRECATED : use org.hibernate.id.UUIDGenerator instead with custom org.hibernate.id.UUIDGenerationStrategy implementation <------------- (org.hibernate.id.GUIDGenerator.java:400) 2014-07-21 23:42:28,009 WARN
Unsuccessful: create table Order (id varchar(36) not null unique, aStreet varchar(255), cid varchar(36) unique, city integer not null, district integer not null, no varchar(255), oDesc longtext, oFhrq datetime, oFkrq datetime, oPayment double precision, oShrq datetime, oState integer not null, oWlgs varchar(100), oXdrq datetime, province integer not null, uid varchar(255), primary key (id)) <------------- (org.hibernate.tool.hbm2ddl.SchemaUpdate.java:454) 2014-07-21 23:42:30,309 ERROR
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Order (
id varchar(36) not null unique,
aStreet varchar(255),
' at line 1 <------------- (org.hibernate.tool.hbm2ddl.SchemaUpdate.java:454) 2014-07-21 23:42:30,310 ERROR
奇怪的是其他表都是用这种主键生成策略生成的 都没有问题 就这个表有问题,大神求解万分感谢....
异常:
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use
错误原因: Configuration cfg = new Configuration(); SessionFactory sf = cfg.configure().buildSessionFactory();
解决方法:
Hibernate配置文件中,若带有 ,则说明映射类时,采用了Annotation方式。在初始化数控等离子切割机http://www.158cnc.comConfiguation时,应使用AnnoationConfiguration,代码如下: Configuration cfg = new AnnotationConfiguration(); SessionFactory sf = cfg.configure().buildSessionFactory();
既然其他表都可以。估计配置就没问题。我能想到的就是你表名用了关键字。谢谢,嘿嘿马虎了你的order是数据库关键字导致的吧?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。