hibernate注解方式

原创 2017年01月03日 15:26:38

spring_hibernate.xml

<!-- spring和 Hibernate整合 --> 
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">  
        <property name="dataSource" ref="dataSource"></property>  
        <property name="hibernateProperties">
            <props>
                <prop key="dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="myeclipse.connection.profile">MyEclipse MySQL</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
            </props>
        </property>
         <!-- 注解写法 -->
         <property name="annotatedClasses" >
           <list>
             <value>com.ssh.entity.SimpleProfessional</value>
           </list>
        </property> 

    </bean>

SimpleProfessional实体类

package com.ssh.entity;

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.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * Professional entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name="professional",catalog="oa")
public class SimpleProfessional implements java.io.Serializable {

    // Fields

    /**
     * 
     */
    private static final long serialVersionUID = 9008124251016810039L;
    private Integer professionalId;
    private String professionalName;
    private Date professionalDate;
    // Constructors

    /** default constructor */
    public SimpleProfessional() {
    }

    public SimpleProfessional(Integer professionalId, String professionalName) {
        super();
        this.professionalId = professionalId;
        this.professionalName = professionalName;
    }

    /** full constructor */
    public SimpleProfessional(String professionalName, Date professionalDate) {
        this.professionalName = professionalName;
        this.professionalDate = professionalDate;
    }

    // Property accessors

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @GenericGenerator(name = "professionalGenerator", strategy = "native")
    @Column(name="professional_id")
    public Integer getProfessionalId() {
        return this.professionalId;
    }

    public void setProfessionalId(Integer professionalId) {
        this.professionalId = professionalId;
    }

    @Column(name="professional_name")
    public String getProfessionalName() {
        return this.professionalName;
    }

    public void setProfessionalName(String professionalName) {
        this.professionalName = professionalName;
    }

    @Column(name="professional_date",length=10)
    public Date getProfessionalDate() {
        return this.professionalDate;
    }

    public void setProfessionalDate(Date professionalDate) {
        this.professionalDate = professionalDate;
    }

    @Override
    public String toString() {
        return "Professional [professionalId=" + professionalId
                + ", professionalName=" + professionalName
                + ", professionalDate=" + professionalDate + "]";
    }

}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

4、Hibernate 实体关系映射(二、单边多对一关系 注解、xml两种方式)

单边多对一与单边一对多关系相反,多的一方有一方的

Hibernate注解方式、HQL查询

  • 2017-08-17 16:39
  • 8.17MB
  • 下载

4、Hibernate 实体关系映射(一、单边一对多关系 注解、xml两种方式)

单边一对多关系是指一方有集合属性,半酣

hibernate annotation注解方式来处理映射关系

hibernate annotation注解方式来处理映射关系 在hibernate中,通常配置对象关系映射关系有两种,一种是基于xml的方式,另一种是基于annotation的注解...

02_hibernate5快速入门_注解的方式

Hibernate5,注解的方式配置
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)