hibernate自动建表
Posted kisstear
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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; } }
以上是关于hibernate自动建表的主要内容,如果未能解决你的问题,请参考以下文章
Hiberntate不能自动建表的问题:hibernate.(*)
hibernate不能自动建表:MySQLSyntaxErrorException: Table '' doesn't exist