首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

hibernate3与spring2零配备

2012-10-26 
hibernate3与spring2零配置?ssh除了xml配置之外,还可以用标注式配置:(1)spring 与 hibernate Annotation配

hibernate3与spring2零配置

?ssh除了xml配置之外,还可以用标注式配置:

(1)spring 与 hibernate Annotation配置(entry)? http://zw7534313.iteye.com/blog/691546

(2)spring 与 hibernate Annotation配置(dao)?? http://zw7534313.iteye.com/blog/691529

(3)Spring注解方式管理事务?? http://zw7534313.iteye.com/blog/691398

(4)spring 与 hibernate Annotation配置(applicationContext.xml)???????

????????????????????????? http://zw7534313.iteye.com/blog/691538

(5)Test.java

public class Test {

?public static void main(String[] args) {

??ClassPathXmlApplicationContext app=new ClassPathXmlApplicationContext("applicationContext.xml");
??CompanyDao dao=(CompanyDao)app.getAutowireCapableBeanFactory()
??.createBean(CompanyDao.class);

?

CompanyService service=(CompanyService)app.getAutowireCapableBeanFactory()
??.createBean(CompanyService.class);
??TCompanyInfo tCompany=new TCompanyInfo();
??tCompany.setInfoTitle(" 2 this is a test.w");
??
??service.test(tCompany); //事务配置在service中,@Transactional事务,如果出现了SQLException,进入catch块中,再抛出一个预定义的运行时异常,才能rollback.

}

}

?

?

@Id
@Column(name = "ID_PROJECT", unique = true, nullable = false, scale = 0, insertable = false, updatable = false)
@GeneratedValue(generator = "seq_id_project",strategy=)
@GenericGenerator(name = "seq_id_project", strategy = "org.hibernate.id.enhanced.TableGenerator", parameters = { @Parameter(name = "segment_value", value = "SEQ_ID_PROJECT"), @Parameter(name = "initial_value", value = "1000"), @Parameter(name = "optimizer", value = "pooled"), @Parameter(name = "increment_size", value = "10") })
public long getIdProject() {
???? return this.idProject;
}

?

?

    <context:annotation-config/>?? ????<context:component-scan?base-package="se.posten.ida">?? ????<context:include-filter?type="regex"?expression=".*DAOImpl"?/>?? ????<context:include-filter?type="regex"?expression=".*ServiceImpl"?/>?? ??</context:component-scan>??

<context:component-scan />还允许定义过滤器将基包下的某些类纳入或排除。

????? Spring支持以下4种类型的过滤方式:

???????? 过滤器类型???????? 表达式范例?????????????????????????????????????????????????????????? 说明

注解???????????????? org.example.SomeAnnotation?????????????????????????? 将所有使用SomeAnnotation注解的类过滤出来
类名指定?????????? org.example.SomeClass??????????????????????????????????? 过滤指定的类
正则表达式??????? com\.kedacom\.spring\.annotation\.web\..*???? 通过正则表达式过滤一些类
AspectJ表达式?? org.example..*Service+??????????????????????????????????? 通过AspectJ表达式过滤一些类

?

?

@PostConstruct 的 postConstruct1() 方法将在 Spring 容器启动时,创建 Boss Bean 的时候被触发执行,而标注了 @PreDestroy 注释的 preDestroy1() 方法将在 Spring 容器关闭前销毁 Boss Bean 的时候被触发执行。

?

?

热点排行