hibernate注解问题

279778325 发布于 2014/07/21 23:48
阅读 384
收藏 0
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


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





加载中
0
小99
小99
既然其他表都可以。估计配置就没问题。我能想到的就是你表名用了关键字。
279778325
279778325
谢谢,嘿嘿 马虎了
0
小99
小99
你的order是数据库关键字导致的吧?
返回顶部
顶部