-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Trying to do ACID operations with 2 type of transactions
PostPosted: Mon Apr 30, 2007 3:53 am 
Newbie

Joined: Mon Apr 30, 2007 3:07 am
Posts: 3
Hi to all,

I had spend a few days trying to solve a problem that is now a headache. Probably I forget something or I can´t be able to see the solution for myself, so I'll be pleased is someone can help me to get a solution.

I'm developing an application with is own and old persistence layer. This persistence layer uses transactions to operate with the database (I'll name them "legacy transactions"). This persistence layer make CRUD operations (create, read, update and delete) in some tables of the database (old tables)

Well, actually we're developing new modules for this application and we're using hibernate instead of the old persistence layer, so the new modules are using hibernate transactions to operate with the new tables in the database.

The problem appears when is necessary write or update in old and new tables simultaneously in an unique ACID operation. There are a persistence layer for the old tables and hibernate for the new tables, so the write or update operation in the old table is made with "legacy transactions" and the write or update operation in the new table is made with hibernate transactions.

I've tried to solve the problem in a few ways, but I'm able to write or in old tables or in new tables, never in both. Before explain you my "experiments" I'll pleased if someone can explain me if this unique ACID operation with two transactions is possible. If not, I'll study another alternatives.

Thanks in advance for your time and sorry for my English :),
Raúl


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 4:46 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
If you need to access legacy tables in your new hibernate module, you could write a JDBC DAO for tables that arn't mapped in hibernate yet.

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 5:22 am 
Newbie

Joined: Mon Apr 30, 2007 3:07 am
Posts: 3
Thanks for your answer,

There are no problem with the access itself, the problem appears when is necessary write in an old and in a new table simultaneously in an unique ACID operation.

I can do CRUD operations in the old and in the new tables separately, but I'm trying to do this together.

The problem in a lowest level is that I have 2 commits and 2 rollbacks, one commit and a rollback for the "legacy transaction" and another commit and rollback for the hibernate transaction, but I need to do only 1 commit and only 1 rollback to perform all operations in old and new tables. I´ve tried to "mix" the transactions but my attempts failed and at last I'm not sure if it's possible.

Any help will be greatly appreciated


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 30, 2007 6:43 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Are you using Spring? You could put both legacy and new transactions in a service method and then if anything goes wrong Spring might be able to roll back both the legacy and new transations through AOP.
Might be worth posting on the Spring forums.

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 3:00 am 
Newbie

Joined: Mon Apr 30, 2007 3:07 am
Posts: 3
Sorry for the lateness, I was out of the office.

No, I'm not using Spring in our proyect. But I suppose it can be a solution.

Does somebody know if there is a Hibernate "native" solution to do ACID operations with 2 different transactions? I would rather not use Spring libraries to solve this.

As I said before, any help will be greatly appreciated.
Raúl


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 3:13 am 
Newbie

Joined: Thu May 03, 2007 2:30 am
Posts: 18
You could pass in a transaction from the outside, cant you?

So you could declare a transactionScope and pass it in?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.