How to not use (disable) transaction manager in spring configuration?
I'm doing simple app that will add rows to database, so no need in any transactions.
So, is it possible configure in xml, not to create any transaction managers?
PS: i use hibernate if this matters anyhow.
If you don't configure a Transaction Manager, neither will Spring. Just don't add any <tx:> tags and don't configure any PlatformTransactionManager beans (in your case HibernateTransactionManager).
Related
I have an application that needs to access two databases. I am trying to use Spring transactions to accomplish this.
1) Since I have two databases and a transaction manager takes a datasource as a parameter, must I configure two transaction managers, with each #Transactional specifying the correct transaction manager to use? ex: #Transcational("database1"), #Transactional("database2").
2) Since #EnableTransactionManagement will look for a single transaction manager to use for all transactions, I do not think I can use this annotation. Is that the case? Can I still utilize transactions with #Transactional("database") and no #EnableTransactionManagement?
Please look to the relevant documentation: http://docs.spring.io/spring-framework/docs/4.2.x/spring-framework-reference/html/transaction.html#tx-multiple-tx-mgrs-with-attransactional
I need to implement Ehcache in a project that uses Spring version 3.1 and Websphere. I tried to google something about this topic but I could'nt find anything. Have you guys ever used those three tools together? Thanks in advance.
As per EhCache docs,It will NOT detect Websphere Transaction Manager automatically,.
Automatically Detected Transaction Managers
Ehcache automatically detects and uses the following transaction
managers in the following order:
GenericJNDI (e.g. Glassfish, JBoss, JTOM and any others that register
themselves in JNDI at the standard location of
java:/TransactionManager
Weblogic (since 2.4.0)
Bitronix
Atomikos
No configuration is required; they work out of the box. The first found
is used.
And you can configure it as below.
If your Transaction Manager is not in the above list or you wish to
change the priority, provide your own lookup class based on an
implementation of net.sf.ehcache.transaction.manager.TransactionManagerLookup and
specify it in place of the DefaultTransactionManagerLookup in
ehcache.xml:
<transactionManagerLookup
class= "com.mycompany.transaction.manager.MyTransactionManagerLookupClass"
properties="" propertySeparator=":"/>
And to integrate & Use Spring with EhCache, refer this link
From Spring docs,
36.3 Declarative annotation-based caching For caching declaration, the abstraction provides a set of Java annotations:
#Cacheable triggers cache population #CacheEvict triggers cache eviction
#CachePut updates the cache without interfering with the method execution
#Caching regroups multiple cache operations to be applied on a
method
#CacheConfig shares some common cache-related settings at class-level
Hibernate, I don't want to use #Transactional Annotaion,
I want to create it manually.
SO how can i create Manual Transaction in it..?
You could use programmatic transaction manager see here
I have a spring application which is based on Spring Batch. By default spring batch introduces transaction for its steps (i.e. at reader,writer and processor) . There are certain stages where I don't really need transaction to be enabled. Because transaction is enabled unnecessary for these methods its giving me some runtime errors as I am making call to two different databases in one method.
Is there any annotation which spring provides to DISABLE transaction for a specific set of methods ?
OR is there anything available in spring batch which can allow me to get rid of transaction either completely or declarative
I am even open to the solution which can disable transaction globally.
Any link , paper will greatly be appreciated.
Thanks in advance
Samir
Spring Batch is inherently transactional. Even if your datasources are not transactional, the semantics of the JobRepository require it. The closest you can get with Spring Batch and not being transactional is using the ResourcelessTransactionManager. This transaction manager is essentially a no-op transaction manager that just keeps track of if an operation is within the scope of a transaction or not.
I'm using spring with JPA. And I've got two EntityManagers that contain different entities (different modules of one application), and both point to the same datasource.
Can I use both of them in one transaction (using single TransactionManager) ?
Do I have to use JTA for that ? If so what is the best option to use it under tomcat ?
How do I configure it in spring ?
Both standard JPA transactions and Spring's JpaTransactionManager are bound to a single EntityManager. They cannot talk to multiple managers, and so cann't coordinate a transaction across them.
If you need to do this, you either need to merge your entity manager configs so you have just one EntityManager, or use JTA transactions (via Spring's JtaTransactionManager).
If you're using Tomcat (which has no out-of-the-box JTA support), then you'll need to find a third party JTA implementation.