• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to deal with Transaction when using JDO

 
Sean Li
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a structure of:
struts action -> facade -> business class -> DAO -> JDO.
If I don't use any container managed transaction, I know I must have a transaction object to explicitly start and commit transaction. I just don't know when and where.

Can somebody help me?
 
Eric Lemaitre
Ranch Hand
Posts: 538
Eclipse IDE Hibernate Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean !

Nothing special to say, you call your facade with "high level methods" while facade makes the real JDO like stuff : pm = PMFactory.getPersistanceManager(), ... Transaction tx = pm.getTransaction(), ... tx.begin(), ... tx.commit() [or tx.rollback()], ... pm.close().

I don't see real interest of DAO pattern (not DTO or Value Object) because JDO is already itself an abstraction of Data Access in general. Other patterns you state are relevant, facade for Session Beans with JDO allows to avoid the need for Entity Beans for example.

Best regards.
 
Sean Li
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I'm new to JDO, and I just realised maybe DAO is not needed, cause once you got a instance of persistence object, you can change it everywhere, and it stores to database automatically.

From you answer, I can see you prefer start you transaction in facade. which is what I thought. but I recentely got an idea from our architect that he prepers to start the transaction when a request comes in. which means happens in struts action.

I know it works, but it is a good way or standard way to deal with transaction?

hope can get more idea, thanks.
 
Sean Li
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody have a look of this question again?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic