最近有工夫闲下来看看一直想研究的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