Derby 是一种功能完备的关系数据库,具有能与大型企业数据库相抗衡的能力。不要让它极小的规模(2 MB)和成本(0 美元)给骗了。
Derby 是纯事务型的,当和 J2EE 服务器的 JTA 事务管理器一起使用时,可以参与全局(分布式)事务。
Derby 数据库系统(二进制文件和数据库)可以复制到任何带有 J2SE JVM 的平台,并且无需重新编译或作其他修改就能运行。
缺省配置下的 Derby 数据库系统不需要进行单独的管理。它的引擎在 J2EE 服务器 JVM 进程中运行,成为系统集成的一部分。
applicationContext-hibernate.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="exampleDataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>
<property name="url">
<value>jdbc:derby:springexample;create=true</value>
</property>
</bean>
<bean id="exampleHibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">
net.sf.hibernate.dialect.DerbyDialect
</prop>
<prop key="hibernate.query.substitutions">
true 'T', false 'F'
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dbcp.maxActive">10</prop>
<prop key="hibernate.dbcp.whenExhaustedAction">2</prop>
<prop key="hibernate.dbcp.maxWait">20000</prop>
<prop key="hibernate.dbcp.maxIdle">10</prop>
<prop key="hibernate.dbcp.ps.maxActive">10</prop>
<prop key="hibernate.dbcp.ps.whenExhaustedAction">
2
</prop>
<prop key="hibernate.dbcp.ps.maxWait">20000</prop>
<prop key="hibernate.dbcp.ps.maxIdle">10</prop>
<prop key="hibernate.dbcp.validationQuery">
select 1 from dual
</prop>
<prop key="hibernate.dbcp.testOnBorrow">true</prop>
<prop key="hibernate.dbcp.testOnReturn">true</prop>
</props>
</property>
</bean>
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>com/meagle/bo/Order.hbm.xml</value>
<value>com/meagle/bo/OrderLineItem.hbm.xml</value>
</list>
</property>
<property name="dataSource">
<ref local="exampleDataSource" />
</property>
<property name="hibernateProperties">
<ref bean="exampleHibernateProperties" />
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="mySessionFactory" />
</property>
</bean>
<!-- ***** ORDER SERVICE *****-->
<bean id="orderService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="myTransactionManager" />
</property>
<property name="target">
<ref local="orderTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">
PROPAGATION_REQUIRED,readOnly,-OrderException
</prop>
<prop key="save*">
PROPAGATION_REQUIRED,-OrderException,-OrderMinimumAmountException
</prop>
</props>
</property>
</bean>
<!-- OrderTarget primary business object implementation -->
<bean id="orderTarget"
class="com.meagle.service.spring.OrderServiceSpringImpl">
<property name="orderDAO">
<ref local="orderDAO" />
</property>
</bean>
<!-- DAO object: Hibernate implementation -->
<bean id="orderDAO"
class="com.meagle.service.dao.hibernate.OrderHibernateDAO">
<property name="sessionFactory">
<ref local="mySessionFactory" />
</property>
</bean>
</beans>
posted on 2006-03-06 23:01
square 阅读(3904)
评论(1) 编辑 收藏