Thanks for you're answer and I do like Stripersist, but what I need is an easy way to work with multiple transactions in the same thread.
For example, you implement a counter that needs to be updated to the database, independent of the fact if the action bean thinks it opportune to store the modified model object from a form. Thus the counter, will need it's own independent session/transaction for doing this (you don't want to accidentally update you're model objects you use in you're view). Spring transaction support this declarative, by letting annotated methods start new transactions. These transactions will end with the end of the method, after that you're old transaction is back in business. How do solve a situation like this? On 22-06-10 16:45, Nikolaos Giannopoulos wrote: > 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 ------------------------------------------------------------------------------ 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