Kdeveloper,

With JPA you are responsible for starting, committing and rolling back transactions. What does that mean - it means that the functionality is there you just need to make the appropriate calls.

Stripersist takes care of automatically making those calls for you i.e. Stripersist automatically starts a transaction for you. You commit it explicitly or it gets automatically rolled back if it wasn't committed.

For example Freddy's classes have the following say 2 methods:

   protected void save(T object, String persistenceUnitName) {
       Stripersist.getEntityManager(persistenceUnitName).persist(object);
   }

   protected void commit(String persistenceUnitName) {
Stripersist.getEntityManager(persistenceUnitName).getTransaction().commit();
   }

ASIDE: If you only have one persistence unit then not specifying it will use the default.

So for example we have the following in an action bean:

this.invitee = this.inviteeDao.findByEmail("nikol...@brightminds.org");

       if (this.invitee == null) {
           this.invitee = new Invitee();
           this.invitee.setFirstName("Nikolaos");
           this.invitee.setLastName("Giannopoulos");
           this.inviteeDao.save(this.invitee);
       }

       Share share = new Share();
       share.setUserId(this.invitee.getId());
       share.setType(ShareType.PHOTO);

       this.shareDao.save(share);
this.shareDao.commit(share); // Commits the full transaction!!!!

Is there something missing that you would need?

ASIDE: We have even baked Sharding on top of Stripersist and it works quite well ;-)

The beauty of JPA + Stripersist + Hibernate is that I can focus on the important things like Sharding and all the other stuff like persisting, transactions, etc... requires absolutely minimal code.

HTH,

--Nikolaos



kdeveloper wrote:
On 22-06-10 0:08, Nikolaos Giannopoulos wrote:
ASIDE: I didn't really like all the work that has to be done to glue
together Spring and Hibernate and am VERY happy using Stripes with JPA,
Stripersist, and Hibernate as it allows me to focus on my Entity classes
a simple persistence.xml... . Freddy's book also has an excellent DAO
super class that heavily leverages generics so you end up with minimal
DAO code in your subclasses... .

Freddy's his DAO's are a great start. But I need an easy way to initiate new transactions, because otherwise side effects will unintentional result in committing model object that are used in the action beans.

I don't think Stripersist directly supports it, or am I wrong?


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to