View Full Version : BMP Entity Bean with Spring + iBATIS
ndijkstra
Sep 8th, 2004, 02:33 PM
Hi, i have a question about transactions.
Suppose i have BMP entity beans, persisted using iBATIS with a DataSource configured with Spring's IOC. Is it possible to use the Application Server's declarative transaction (either locar or global) demarcation with this configuration?
Thanks
Loumeister
Sep 8th, 2004, 11:14 PM
I know it's possible with SLSBs - I'm using those as a Facade for Spring/Hibernate DAOs that are POJOs. I don't see why it would be any different for BMP. See my post in the forum with regard to the solution.
Lou
p.s. Why are you using BMP? It's pretty heavy weight as opposed to POJOs.
ndijkstra
Sep 9th, 2004, 07:20 AM
Loumeister, could you post a link to the post you are refering to?
I'm not really winlling to implement BMP but just was considering as an alternative.
I'm seriously thinking about the possibility of not using EJBs at all or just SLSBs as facades. Even with the latter configuration, is it possible to use container transaction demarcation and DAOs with a datasource defined with Spring's IOC?
Rod Johnson
Sep 9th, 2004, 12:56 PM
I'm seriously thinking about the possibility of not using EJBs at all or just SLSBs as facades. Even with the latter configuration, is it possible to use container transaction demarcation and DAOs with a datasource defined with Spring's IOC?
You can use EJB CMT in combination with Spring data access (JDBC, iBATIS/whatever).
Suppose i have BMP entity beans, persisted using iBATIS with a DataSource configured with Spring's IOC
If you want to use EJB CMT you need the app server to manage the DataSource (via JNDI). You could use Spring data access to make the DataSource available to application code, using JndiObjectFactoryBean.
I've very seldom seen a legitimate use for BMP, where it adds value compared to just doing the underlying data access without the BMP layer.
Loumeister
Sep 10th, 2004, 01:35 AM
Loumeister, could you post a link to the post you are refering to?
Yes, check out this thread in the Hibernate Forums: http://forum.hibernate.org/viewtopic.php?t=929516
We use SLSB+BEA CMT+Spring+Hibernate all very easily. SLSB is our business tier; CMT gives us tx demarcation; Spring gives us Session-per-transsaction management transparently and AOP; Hibernate persistence.
HTH,
Lou
ndijkstra
Sep 10th, 2004, 09:45 AM
Hi Lou,
i've been watching your post and there's something i don't understand. Why did you use
<property name="hibernate.transaction.manager_lookup_class">
net.sf.hibernate.transaction.WeblogicTransactionMa nagerLookup
</property>
in hibernate's configuration?
If i use in hibernatel.cfg.xml
<property name="hibernate.transaction.factory_class">
net.st.hibernate.transaction.JTATransactionFactory
</property>
and in applicationContext.xml
<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>jdbc/myDataSource</value></property>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFact oryBean">
<property name="dataSource">
<ref local="myDataSource"/>
</property>
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
won't i be able to delegate transaction demarcation to the one declared in my CMT Beans?
Loumeister
Sep 10th, 2004, 10:47 AM
You need to use that to tie Hibernate to vendor implementation of CMT. Hibernate offers such a manager look-up for WebSphere, BEA, etc. Check out their documentation if you have a different app server. I believe JTATransactionFactory would be used if you were using Spring to demarcate transactions, which is also a viable option as well.
Lou
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.