• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EJB 3.0 from O'Reilly

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

On page 77, it says,

The persist() method throws a TransactionRequiredException if this method is invoked on a transaction-scoped persistence context. Is this statement correct with respect to entities?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I expected, found this from the errata for the book,

http://oreilly.com/catalog/9780596009786/errata/9780596009786.unconfirmed
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jothi

can you please specify the complete name of the book you are referring.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Enterprise JavaBeans 3.0 (5th Edition), listed in the SCBCD Links
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jothi,

The persist() method throws a TransactionRequiredException if this method is invoked on a transaction-scoped persistence context.


what are your doubts about this statement ? The "correction" from O'Reilly sounds

{77} top paragraph;
the second sentence, "TransactionRequiredException is thrown if this method is invoked on a transaction-scoped persistence context." should be "TransactionRequiredException is thrown if this method is NOT invoked on a transaction-scoped persistence context."


This statement is definitely wrong! See JPA spec 3.1.1, page 47:

The persist, merge, remove, and refresh methods must be invoked within a transaction context when an entity manager with a transaction-scoped persistence context is used. If there is no transaction context, the javax.persistence.TransactionRequiredException is thrown.


If the entity manager uses an extended persistence context these methods can be called even without a transaction context.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To emphasize what Ralph says, 3.3 Persistence Context Lifetime says :

When an EntityManager with an extended persistence context is used, the persist, remove, merge, and refresh operations may be called regardless of whether a transaction is active. The effects of these operations will be committed to the database when the extended persistence context is enlisted in a transaction and the transaction commits.



I think they wanted to say : TransactionRequiredException is thrown if this method is NOT invoked within a transaction context when a transaction-scoped persistence context is used.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Christophe, thanks for the link. I was shortly looking for it, but didn't found it.
 
Do not set lab on fire. Or this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic