I am new to spring and hibernate. I am trying to copy data from one database to another. I have two datasources defined in the applicationContext file . I need to have a transaction across the two hibernate session factories so that once I insert into database 2, I can go ahead and delete from database 1, is this possible declaratively in spring ?
I tried it based on the example on the spring website and it does not work.
Yes, Spring supports JTA transactions across multiple datasources. You will need to use org.springframework.transaction.jta.JtaTransactionManager, which of course means you will need to have a JTA implementation available. If you are running within a full J2EE Server this shouldn't be a problem... if not you could always integrate a standalone JTA implementation such as JOTM.