集成 Flex, Spring, Hibernate 构建应用程序
2010-01-04 00:00:00 来源:WEB开发网
清单 10. HibernateContext.xml <beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
default-lazy-init="true">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.
config.PropertyPlaceholderConfigurer">
<property name="location">
<value>
WEB-INF/hibernate.properties
</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.
annotation.AnnotationSessionFactoryBean">
<property name="annotatedClasses">
<list>
<value>com.psdemo.core.domain.Client</value>
<value>com.psdemo.core.domain.Product</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.format_sql">
${hibernate.format_sql}
</prop>
......
<prop key="hibernate.connection.driver_class">
${jdbc.driverClassName}
</prop>
<prop key="hibernate.connection.url">
${jdbc.url}
</prop>
<prop key="hibernate.connection.username">
${jdbc.username}
</prop>
<prop key="hibernate.connection.password">
${jdbc.password}
</prop>
</props>
</property>
</bean>
<bean class="org.springframework.beans.factory.
annotation.RequiredAnnotationBeanPostProcessor"/>
<bean id="txManager"
class="org.springframework.orm.
hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
清单 11. Hiberante 实体类 Client.java package com.psdemo.core.domain;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name="client")
public class Client implements Serializable{
private static final long serialVersionUID = 2L;
@Id
@Column(name="username")
private String username;
@Column(name="password")
private String password;
public String getUsername(){
return username;
}
public void setUsername(String username){
this.username = username;
}
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password = password;
}
}
- ››Flex和JavaScript互操作
- ››Flex 自定义组件外观
- ››Spring MVC与JAX-RS比较与分析
- ››集成医疗保健服务,第 2 部分: 使用 Apache Servi...
- ››Flex Accessibility 全键盘支持和扩展
- ››FlexPaper 1.3.1 发布,在线PDF显示
- ››集成医疗保健服务,第 1 部分: 将 Enterprise Ser...
- ››Spring 框架的设计理念与设计模式分析
- ››Spring Web Flow 2 中流管理的持久化
- ››集成 Rational Software Architect 和 Rational D...
- ››Spring 事务管理高级应用难点剖析: 第 2 部分
- ››Spring 事务管理高级应用难点剖析: 第 3 部分
更多精彩
赞助商链接