当hinernate尝试将此类映射到MySQL数据库时
/*
*To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package projekat.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.*;
import org.apache.tapestry5.beaneditor.NonVisual;
/**
*
* @author nikola
*/
@Entity
public class Student implements Serializable {
@Id
@NonVisual
@GeneratedValue(strategy = GenerationType.AUTO)
@Basic(optional = false)
private Long kljuc;
@Basic(optional = false)
private String ime;
@Basic(optional = false)
private String prezime;
@Basic(optional = false)
private Integer index;
@ManyToMany
private List<Grupa> grupaList = new ArrayList<Grupa>();
public NewClass() {
}
public Long getKljuc() {
return kljuc;
}
public void setKljuc(Long kljuc) {
this.kljuc = kljuc;
}
public String getIme() {
return ime;
}
public void setIme(String ime) {
this.ime = ime;
}
public String getPrezime() {
return prezime;
}
public void setPrezime(String prezime) {
this.prezime = prezime;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public List<Grupa> getGrupaList() {
return grupaList;
}
public void setGrupaList(List<Grupa> grupaList) {
this.grupaList = grupaList;
}
@Override
public int hashCode() {
int hash = 5;
hash = 83 * hash + Objects.hashCode(this.kljuc);
hash = 83 * hash + Objects.hashCode(this.ime);
hash = 83 * hash + Objects.hashCode(this.prezime);
hash = 83 * hash + Objects.hashCode(this.index);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Student other = (Student) obj;
if (!Objects.equals(this.kljuc, other.kljuc)) {
return false;
}
if (!Objects.equals(this.ime, other.ime)) {
return false;
}
if (!Objects.equals(this.prezime, other.prezime)) {
return false;
}
if (!Objects.equals(this.index, other.index)) {
return false;
}
return true;
}
@Override
public String toString() {
return "Student{" + "ime=" + ime + ", prezime=" + prezime + ", index=" + index + '}';
}
}
以下输出显示在 tomcat 日志中
Unsuccessful: create table Student (kljuc bigint not null auto_increment, ime varchar(255) not null, index integer not null, prezime varchar(255) not null, primary key (kljuc))
20:03:30,540 ERROR SchemaExport:387 - 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 'integer not null, prezime varchar(255) not null, primary key (kljuc))' at line 1