2013-02-11 3 views
0

나 최대 절전 모드 4 메이븐 함께 일하고 있어요 :최대 절전 모드 테이블 외래 키 삽입 : @ OneToMany/@ ManyToOne 관계

package tn.onp.mvno.model; 


@Entity 
@Table(name="PERSON") 
public class Person { 

private int id; 
private String name; 
private String surname; 
private String email; 
private String adresse; 
private String MobilePhone; 

/** 
    * Get User Id 
    * 
    * @return int - User Id 
    */ 
@Id 
@GeneratedValue 
@Column(name="ID") 
public int getId() { 
    return id; 
} 

/** 
    * Set User Id 
    * 
    * @param int - User Id 
    */ 
public void setId(int id) { 
    this.id = id; 
} 


} 

package tn.onp.mvno.model; 


@Entity 
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS) 
@Table(name="USER") 
public class User extends Person{ 

private String SIMCardNumber; 
private String SIMCardValidityDate; 
private Collection<Call> calls; 
private Collection<Credit> credits; 




@Column(name="SIMCARDNUMBER", unique = true, nullable = false) 
public String getSIMCardNumber() { 
return SIMCardNumber; 
} 




public void setSIMCardNumber(String sIMCardNumber) { 
SIMCardNumber = sIMCardNumber; 
} 


@Column(name="SIMCARDVALIDITYDATE", nullable = false) 

public String getSIMCardValidityDate() { 
return SIMCardValidityDate; 
} 




public void setSIMCardValidityDate(String sIMCardValidityDate) { 
SIMCardValidityDate = sIMCardValidityDate; 
    } 




@OneToMany(fetch = FetchType.LAZY, mappedBy = "user") 
public Collection<Call> getCalls() { 
return calls; 
} 




public void setCalls(Collection<Call> calls) { 
this.calls = calls; 
} 
    } 

Call.java

@Entity 
@Table(name="CALL") 
public class Call { 

private String callId; 
private String telNumber; 
private String term; 
private String duration; 
private String direction; 
private User user; 
/** Get the callId 
* @return the callId 
*/ 
@Id 
@GeneratedValue 
    @Column(name="CALLID") 
public String getCallId() { 
    return callId; 
} 
/** Set the callId 
* @param callId the callId to set 
*/ 
public void setCallId(String callId) { 
    this.callId = callId; 
} 
/** Get the telNumber 
* @return the telNumber 
*/ 
@Column(name="TELNUMBER") 
public String getTelNumber() { 
    return telNumber; 
} 
/** Set the telNumber 
* @param telNumber the telNumber to set 
*/ 
public void setTelNumber(String telNumber) { 
    this.telNumber = telNumber; 
} 
/** Get the term 
* @return the term 
*/ 
@Column(name="TERM") 
public String getTerm() { 
    return term; 
} 
/** Set the term 
* @param term the term to set 
*/ 
public void setTerm(String term) { 
    this.term = term; 
} 
/** Get the duration 
* @return the duration 
*/ 
@Column(name="DURATION") 
public String getDuration() { 
    return duration; 
} 
/** Set the duration 
* @param duration the duration to set 
*/ 
public void setDuration(String duration) { 
    this.duration = duration; 
} 
/** Get the direction 
* @return the direction 
*/ 
@Column(name="DIRECTION") 
public String getDirection() { 
    return direction; 
} 
/** Set the direction 
* @param direction the direction to set 
*/ 
public void setDirection(String direction) { 
    this.direction = direction; 
} 
/** Get the user 
* @return the user 
*/ 
@ManyToOne(fetch = FetchType.LAZY) 
@JoinColumn(name = "id") 
public User getUser() { 
    return user; 
} 
/** Set the user 
* @param user the user to set 
*/ 
public void setUser(User user) { 
    this.user = user; 
} 

} 내가 배포

바람둥이 서버에 응용 프로그램 및 실행이 오류 :

INFO: HHH000227: Running hbm2ddl schema export 
Hibernate: alter table CALL drop foreign key FK1F725EE04824FE 
févr. 11, 2013 5:53:38 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 
ERROR: HHH000389: Unsuccessful: alter table CALL drop foreign key FK1F725EE04824FE 
févr. 11, 2013 5:53:38 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 
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 'CALL drop foreign key 
FK1F725EE04824FE' at line 1 
Hibernate: drop table if exists CALL 

févr. 11, 2013 5:53:38 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 
ERROR: HHH000389: Unsuccessful: drop table if exists CALL 
févr. 11, 2013 5:53:38 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 
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 'CALL' at line 1 
Hibernate: drop table if exists CREDIT 
Hibernate: drop table if exists PERSON 
Hibernate: create table CALL (CALLID varchar(255) not null auto_increment, DIRECTION 
varchar(255), DURATION varchar(255), TELNUMBER varchar(255), TERM varchar(255), id 
integer, primary key (CALLID)) 
févr. 11, 2013 5:53:38 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 
ERROR: HHH000389: Unsuccessful: create table CALL (CALLID varchar(255) not null 
auto_increment, DIRECTION varchar(255), DURATION varchar(255), TELNUMBER varchar(255), 
TERM varchar(255), id integer, primary key (CALLID)) 
févr. 11, 2013 5:53:38 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 
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 'CALL (CALLID varchar(255) not 
null auto_increment, DIRECTION varchar(255), DURAT' at line 1 

답변

1

CALLreserved word입니다. 다른 테이블 이름을 선택하십시오.

+0

나는 그것을 바꾼다. 그러나 나는 이것을 얻고있다 : févr. 11, 2013 6:25:04 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 오류 : HHH000389 : 실패 : 테이블 PHONECALL (CALLID varchar (255)가 아닌 auto_increment, DIRECTION varchar (255), DURATION varchar (255) , TELNUMBER varchar (255), TERM varchar (255), ID 정수, 기본 키 (CALLID)) févr. 11, 2013 6:25:04 PM org.hibernate.tool.hbm2ddl.SchemaExport perform 오류 : 'CALLID'열의 잘못된 열 지정자 – AmiraGL

+1

varchar에서 auto_increment를 사용할 수 없습니다. 그 번호가 필요합니다. ID는 정수 또는 Long이어야하며, 다른 방법으로 생성되어야합니다. –

+0

오 하나님, 너무 당혹 스럽군요. – AmiraGL

관련 문제