Transaction management in Virgo [message #1058822] |
Wed, 15 May 2013 09:17 |
Lars Behnke Messages: 4 Registered: May 2013 |
Junior Member |
|
|
Hello,
After searching this forum and doing some internet research and lots of trial and error, I am still stuck with the question what would be the best option to handle transactions in Virgo. I am using:
- Spring 3.1
- Hibernate 3.6.0
- PostgreSQL 9.2
- Virgo 3.6.1
- Java 7 on Ubuntu 12.10, 64bit
I currently ended up with this design:
- A configuration bundle exports JDBC and hibernate properties as a service.
- All (currently three) OSGi bundles that contain Hibernate entities import these properties as a service. Furthermore, each of these bundles sets up an own pooled datasource, session factory and transaction manager (HibernateTransactionManager).
- A am not using JTA. If an operation spans multiple transactional service calls, a "best effort" strategy handles potential errors.
I am not happy with this solution, though and wonder what is currently considered "best practice" in my scenario.
I'd prefer a solution like this:
- A central registry of persistent entities that all bundles can contribute to.
- A single pooled datasource
- A single session factory that is consumed by all multiple bundles
- A single transaction manager that is consumed by multiple bundles
Is this feasible in an OSGi environment? If so, how??
[Updated on: Tue, 21 May 2013 06:36] Report message to a moderator
|
|
|
|
Re: Transaction management in Virgo [message #1059129 is a reply to message #1058975] |
Thu, 16 May 2013 21:20 |
Lars Behnke Messages: 4 Registered: May 2013 |
Junior Member |
|
|
Sebastian,
thanks for your reply. The linked posts made some things clearer.
I conclude that these are my options:
(1) Using JDBC transactions that do not cross bundle boundaries. Multiple bundles should not share persistent entities. Error handling in an best effort strategy (actually, thats what I am doing now)
(2) Using a JTA implementation such as Atomikos to enable transactions across multiple bundles.
BTW: Hibernate 3.6 repackaged as OSGi bundle(s) works for me perfectly.
[Updated on: Thu, 16 May 2013 21:27] Report message to a moderator
|
|
|
|
|
|
Re: Transaction management in Virgo [message #1062813 is a reply to message #1059834] |
Mon, 10 June 2013 20:27 |
Lars Behnke Messages: 4 Registered: May 2013 |
Junior Member |
|
|
For the sake of completeness:
Another interesting approach to modularize the Hibernate sessionfactory on theserverside.com:
www.theserverside.com/news/thread.tss?thread_id=63223
@pascal: Thanks for the links. I'll investgate the projects.
Sorry for not posting a valid URL. The forum policy prevents this.
[Updated on: Mon, 10 June 2013 20:30] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04643 seconds