hibernate自动建表
x'ml配置文件
<!-- 扫描所有实体类 --> <property name="packagesToScan"> <list> <value>com.fit.core.pojo</value> </list> </property>
//关键diamagnetic
<prop key="hibernate.hbm2ddl.auto">update</prop>
实体类
package com.fit.core.pojo; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** */ @Entity @Table(name="tbl_interview") public class TblInterview { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @ManyToOne @JoinColumn(name="party_worker") private User partyWorker; @Temporal(TemporalType.DATE) @Column(name="start_date", length=30, nullable=true) private Date startDate; @Column(name="request_content", nullable=true) private String requestContent; @Column(length=50, nullable=true) private String topic; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public User getPartyWorker() { return partyWorker; } public void setPartyWorker(User partyWorker) { this.partyWorker = partyWorker; } public Date getStartDate() { return startDate; } public void setStartDate(Date startDate) { this.startDate = startDate; } public String getRequestContent() { return requestContent; } public void setRequestContent(String requestContent) { this.requestContent = requestContent; } public String getTopic() { return topic; } public void setTopic(String topic) { this.topic = topic; } }