日期:2014-05-17  浏览次数:20786 次

hibernate怎么通过实体类创建数据库表
我想通过Java的实体类创建数据库表,我该怎么做啊!搞了好长时间没弄出来,求大神帮忙啊!

------解决方案--------------------
这个网上很多 。搜搜看看。
------解决方案--------------------


import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class UserInfo {                 

private int id;                      
private String username;             
private String userpwd;              
private String userphone;           
private String others;              

private Set<HireInfo> hireinfos = new HashSet<HireInfo>(); 
private Set<Magdebrug> magdebrugs = new HashSet<Magdebrug>(); 

@Id
@GeneratedValue
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpwd() {
return userpwd;
}
public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
}
public String getUserphone() {
return userphone;
}
public void setUserphone(String userphone) {
this.userphone = userphone;
}
public String getOthers() {
return others;
}
public void setOthers(String others) {
this.others = others;
}

@OneToMany(mappedBy="userinfo")
public Set<HireInfo> getHireinfos() {
return hireinfos;
}
public void setHireinfos(Set<HireInfo> hireinfos) {
this.hireinfos = hireinfos;
}

@OneToMany(mappedBy="userinfo")
public Set<Magdebrug> getMagdebrugs() {
return magdebrugs;
}
public void setMagdebrugs(Set<Magdebrug> magdebrug