File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Hybrid persistence layer ..? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Hybrid persistence layer ..?" Watch "Hybrid persistence layer ..?" New topic
Author

Hybrid persistence layer ..?

Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Is it allright to build a hybrid persistence layer (hibernate, cmps and bmps) in the same app?

Thanks,
ltcmelo
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
As long as you use DataSources and let the outermost Session EJB's manage transactions, yes.

Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Roland Barcia
author
Ranch Hand

Joined: Apr 15, 2004
Posts: 177
Keep in mind though that if you mix data access code in the same transaction, that uncommitted data may be maintained in different locations.

So, if your CMP is updated and then the BMP through a stored proc (within the same transaction) for example expects to see that uncommitted data (possible if not a Serializable isolation level), you will have a problem because most containers do not push uncommited data from CMP till commit time for performence.


Roland Barcia<br />STSM - ISSW Lead Web 2.0 Architect
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
So, if separate my app in use cases and implement the persistence layer of those use cases in different techonologies, i'm allright?

Clearing...
Suppose i have 3 big use cases in my system, if i implement
- use case 1 with CMPs
- use case 2 with hibernate
- use case 3 with jdo
and theese use cases don't interfer in each other, i don't need to worry about this kinda of transaction stuff. Am i right?

Thanks,
ltcmelo
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3879
So long as the transactions in each use case stay out of each others way (don't update the same tables) then yes. If they do, then all of the problems that Roland discusses must be addressed.

Kyle
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hybrid persistence layer ..?
 
Similar Threads
how many layers in jpetstore application ?
project architecture
Best Practices - Exception Handling Mechanism
Thread in JEE
EJB entity 3.0 vs Hibernate