Hi,

according to the JPA spec, the NoResultException should not cause
transaction rollback, but seems some JPA implementations of the JPA
violate the rule
http://forum.springsource.org/showthread.php?t=43547

I was lazy to test it by myself, but at the forum is a way to force
specific exceptions not to cause rollback. I did not test on GAE
(sorry, no time, I will leave it in your capable hands)

On our project we checked for item count first, but on GAE it would
consumate you additional CPU cycles :(

Perun

On 25 mar, 02:03, lp <lucio.picc...@gmail.com> wrote:
> that previous example code was too complex... phew it was a late night
>
> this a simpler example of the a method that does a rollback when a
> NoResultException is thrown.
>
> even if the exception is handled it doesnt matter the txn is rollback and no
> commits are done.
>
> if the NoResultException is NOT thrown the method commits correctly.
>
> is this voodoo or something?
>
> @Transactional( propagation=Propagation.NOT_SUPPORTED)
>     public void txnMethod( Collection<Long> list) throws
> ApplicationExecption{
>
>         for (Iterator<Long> iterator = list.iterator(); iterator.hasNext();)
> {
>                 Long fbId = iterator.next();
>                 PositionUser user = null;
>                 final Query query =
> em.createNamedQuery(PositionUser.FIND_BY_FB_ID);
>                 query.setParameter("facebookId", fbId);
>                 try {
>                     user = (PositionUser) query.getSingleResult();
>                 }
>                catch (NoResultException e) {
>                     log.info( "error occured:" + e.toString() );
>                 }catch (NonUniqueResultException e) {
>                     throw new ApplicationExecption(e);
>                 }
>
>                 if(user!= null) {
>                     user.setAccuracy(5000);
>                     em.merge(user);            
>                 }
>             }
>
>     }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to