AnnotationSessionFactoryBean 用于创建基于JPA注解的SessionFactory

AnnotationSessionFactoryBean 拓展了LocalSessionFactoryBean类,增强的功能是:可以根据实体类的注解获取ORM的配置信息,也允许混合使用XML配置和注解配置对象关系映射,Hibernate内部自动整合这些元数据信息,并不会冲突。
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">none</prop>
                <prop key="hibernate.format_sql">false</prop>
            </props>
        </property>
        <property name="packagesToScan" >
            <list>
                <value>com.lyf.web.domain</value>
                <value>com.lyf.webapp.domain</value>
            </list>
        </property>
    </bean>
package com.lyf.web.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @descript:
 * @date: 2015年7月2日 下午4:55:09
 */
@Entity
@Table(name = "t_user_ext")
public class UserExt {

    @Id
    @GeneratedValue
    private Integer id;

    @Column(nullable = false , unique=true)
    private Integer userId;


    private String ext1;


    public Integer getId() {
        return id;
    }


    public void setId(Integer id) {
        this.id = id;
    }


    public Integer getUserId() {
        return userId;
    }


    public void setUserId(Integer userId) {
        this.userId = userId;
    }


    public String getExt1() {
        return ext1;
    }


    public void setExt1(String ext1) {
        this.ext1 = ext1;
    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值