-->
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.  [ 2 posts ] 
Author Message
 Post subject: "Unit of Work" implementation in Hibernate
PostPosted: Fri May 07, 2004 3:03 pm 
Newbie

Joined: Fri May 07, 2004 2:35 pm
Posts: 4
Hello,

First of all I'm really sorry for the cross-posting (I post the same message to domaindrivendesign --- http://groups.yahoo.com/group/domaindri ... ssage/1014).

I'd like to know if there's such "Unit of Work implementation in Hibernate? To give context for this discussion, here's the link to explanation about "Unit of Work" -- http://domaindrivendesign.org/discussio ... fWork.html

I was told by someone that most ORM tool have this feature (although they might name it differently) -- http://groups.yahoo.com/group/domaindri ... ssage/1013.

This link explains how I got into this "Unit of Work" question: http://groups.yahoo.com/group/domaindri ... essage/997

Finally, here's my question to this forum (thanks in advance):
-----
Hmm, "unit of work"? Ok, my search on google lead me to these pages:

- RepositoryAndUnitOfWork (http://domaindrivendesign.org/discussio ... fWork.html)
- Hibernate API (http://www.hibernate.org/hib_docs/api/n ... ction.html)
- Spring API (http://www.springframework.org/docs/api ... essor.html)

At this moment I don't know how they're interrelated. Nick's post that mentioned "unit of work" (http://groups.yahoo.com/group/domaindri ... ssage/1002) gave me the impression that it's equal to Transaction (?). And the hibernate API that mentions "unit of work" strengthen that impression.

Before I go further crawling for more info on the web, could you help me by clarifying the effect of "unit of work"? Your explanation suggest that it's an ability of ORM tool (like Hibernate) to call "session.save(anObject)" after we do something on that object that makes it dirty [the session.save() call takes place when tx.commit() is called], right?

Like this:
---
net.sf.hibernate.Transaction tx = hibernateSession.beginTransaction();
Object anObject = hibernateSession.load(AClass.class, new Long(123));
anObject.doSomething(); //doSomething change the value of some attributes of anObject
tx.commit();//all the changes we've made to anObject will be saved.
---
???

All this time I always call session.saveOrUpdate(anObject) manually after modifying its state. Like this:
---
net.sf.hibernate.Transaction tx = hibernateSession.beginTransaction();
Object anObject = hibernateSession.load(AClass.class, new Long(123));
anObject.doSomething(); //doSomething change the value of some attributes of anObject
hibernateSession.update(anObject);
tx.commit();
---

Oooppss.... so I've been using Hibernate the wrong way then (?). Is there anything I need to set in Hibernate configuration to activate this "unit of work" feature?

Best regards,
Raka (http://www.jroller.com/page/donraka & http://www.geocities.com/wirama_putra/w ... rmasastra/)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 3:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
unitOfWork in TopLink == session in Hibernate

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.