SpringSide学习笔记一

最近有工夫闲下来看看一直想研究的SpringSide,学习之余整理陆续整理出我的学习笔记,还望高手大牛们指教.

HelloWorld
1.了解HSQL数据库
配置:
第一步,导入jar包
第二步,编写helloworld.properties和helloworld.script
第三步,数据库url设为:jdbc.url=jdbc:hsqldb:res:/hsqldb/helloworld即可.
2.HelloWorld中的Hibernate Annotation

HelloWorld中的Annotation还是比较简单的.

持久化类只需要声明@Entity并且为ID配上@Id及相应的生成器就行了.

可以看到,在spring的配置文件中,Hibernate Session已经由LocalSessionFactory改成org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean,

下面是持久化类的配置

 

在HelloWorld中,还给出了一个更为详细的User Hibernate Annotation配置

package org.springside.helloworld.model;

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 javax.persistence.UniqueConstraint;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 用户.
 * <p/>
 * 这是一个Hibernate Annotation 式配置的详细版本.
 * 包含JDK1.4下的JavaDoc式配置 与JDK5.0的annotation配置
 *
 * @author Schweigen
 * @hibernate.class table="user"
 */
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name = "user", uniqueConstraints =
{@UniqueConstraint(columnNames = {"name"})})
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@BatchSize(size = 5)
public class UserFullVersion {
 private Integer id;

 private String name;

 private String email;

 private

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值