码迷,mamicode.com
首页 > Web开发 > 详细

hibernate自动建表

时间:2016-05-31 16:05:15      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

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自动建表

标签:

原文地址:http://www.cnblogs.com/kisstear/p/5545948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!