开发者社区> 问答> 正文

有关于 Hibernate 注解报错 问题

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

奇怪的是其他表都是用这种主键生成策略生成的 都没有问题 就这个表有问题,大神求解万分感谢....

展开
收起
爵霸 2016-03-04 13:54:35 2638 0
1 条回答
写回答
取消 提交回答
  • 既然其他表都可以。估计配置就没问题。我能想到的就是你表名用了关键字。

    2019-07-17 18:52:12
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载