Unfortunately if one looks at the bernate APIs like many other JBoss products they have a a class typically called Configuration to hold most if not all the main config stuff. Unfortunately they (JBoss) seem to like to hold "Strings" for parameters and class to locate instances. Almost always its often impossible to simply set an actual premade ready to go setup.
Unfortunately if one looks at the bernate APIs like many other JBoss products they have a a class typically called Configuration to hold most if not all the main config stuff. Unfortunately they (JBoss) seem to like to hold "Strings" for parameters and class to locate instances. Almost always its often impossible to simply set an actual premade ready to go setup.
I am about to try something similar to the following for the very same reason you are mentioning. Create an implementation of TransactionManagerLookup include a setter which takes a TM and sets a thread local variable + instance. Pass the name of TML inside the properties you pass to the Configuration.
When Your TML startsup copy the thread local variable to your instance fie.d. Clear the threadlocal once everything is done.
OK, thanks, I suppose the right anwser would be to open a bug for as it's a the configurability on their side that is at fault. – mleduque Feb 14 at 11:52.
Typically spring+hibernate don't require it. You can use a simple JpaTransactionManager / bernateTransactionManager. If you really want JTA, then you will need a JTA provider.
If not running in an application server, check this question for how to use JTA in a servlet container. (Also take a look at this question) Finally, hibernate docs specify that, for container-managed transactions: Declarative transaction demarcation is a standard feature of EJB, also known as container-managed transactions (CMT). In EJB 2.
X you would use XML deployment descriptors to create your transaction assembly. In EJB 3. X you can use JDK 5.0 annotation metadata directly in your source code, a much less verbose approach.
To enable CMT transaction demarcation for EJBs in bernate configuration: set hibernate.transaction. Manager_lookup_class to a lookup strategy for your JEE container set hibernate.transaction. Factory_class to org.hibernate.transaction.
CMTTransactionFactory The second point is perhaps something you've missed? What the documentation says in addition to that (the next section) is that if you want declarative transaction, hibernate is not where you should look at. You'd need to create an interceptor.
That's exactly what spring transaction managers are. And that would be my choice given your technology stack (Spring). If you wish not to rely on a single JTA provider, then make two builds.
For example maven has "maven profiles", which allow to make builds for different environments.
Yes, JTA is required. I wonder why people always assume it's possible to answer a question by omitting one of the elements. For 'lookup_class' and 'factory_class', I didn't miss that part, but I must not be dependend on the JEE container that is used, the application is to be deployed on (at least) two different application servers.
– mleduque Dec 13 '10 at 16:55 @mleduque people with broader view on technology assume some things because of their experience. For example I've rarely seen a spring app with JTA, while I've seen many cases when people throw themselves into it without actually needing it. For the rest of your comment - see my update.
– Bozho Dec 13 '10 at 18:32 why would anyone use the Spring TM layer... it does not do anything its just another layer with different method names and adds no new or better functionality over JTA. In the end its going to do a jndi lookup (if one uses the JTA impl) which ends up in the same problem of magic Strings and singletons. – mP.
Jan 31 at 0:09 @mP - spring transaction management does not use JTA. It has its own transaction managers that do a pretty good job. Apart from that - it provides an abstraction over different transactional technologies.So you can annotate your objects and if you later switch the transaction management strategies, just change a few configurations.
– Bozho Jan 31 at 8:11.
Well, you can't really do the same thing with JTA. – mleduque Dec 13 '10 at 17:00.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.