• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transaction Scoped Context

 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to spec, the object returned from the find method is detached object. When I run the same on JBOSS, i get it managed. This is being checked using Entity Manager's contain method. I am using Transaction scoped context
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
the object will result as detached if you are not in a transaction.
Consider that if you return the object from an ejb method with its own transaction, this could happen.
Can you post your code?
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah you are right

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void findUser() {
em.getTransaction();
User user = em.find(User.class, 2);
System.out.println(user.getName());
System.out.println(em.contains(user));
}

This prints false.

with required,

it prints true.
 
reply
    Bookmark Topic Watch Topic
  • New Topic