• 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

questions on entity bulk operations

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a hard time here to understand some points from the persistence spec:

Question #1 - The persistence context is not synchronized with the result of the bulk update or delete.



The persistence context is not synchronized with the result of the bulk update or delete.

Caution should be used when executing bulk update or delete operations because they may result in inconsistencies between the database and the entities in the active persistence context. In general, bulk update and delete operations should only be performed within a separate transaction or at the beginning of a transaction (before entities have been accessed whose state might be affected by such operations
.



Based on the above quote, I found one mock exam question and answer:




The result on this code will be returning "normal". The explaination on this is:


Bulk updates are not reflected in the existing persistence context. So it will return "normal".




How someone explain it so I can understand better?


Question #2 - bulk operation bypassing optimistic locking checks.

spec says:



Bulk update maps directly to a database update operation, bypassing optimistic locking checks. Portable applications must manually update the value of the version column, if desired, and/or manually validate the value of the version column.



My question - since I don't have real work experience on EJB, I am wondering in the real project, anyone had used the bulk operations? It sounds like a common operation to me. But since there would be no optimistic locking checks performed on the bulk operation, I am wondering how do you control the concurrency problem? Just make sure operations should only be performed within a separate transaction or at the beginning of a transaction as stated in the spec???



thanks

Helen Ge
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic