WEB开发网
开发学院软件开发Java 集成 Flex, Spring, Hibernate 构建应用程序 阅读

集成 Flex, Spring, Hibernate 构建应用程序

 2010-01-04 00:00:00 来源:WEB开发网   
核心提示: 清单 10. HibernateContext.xml<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-in


清单 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; 
   } 
 } 

上一页  2 3 4 5 6 7 8 9 10  下一页

Tags:集成 Flex Spring

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接