readOnly flag on Spring Transactional annotation and persistent context

Viewed 70

Reading about the readOnly flag on Spring transactional annotation, it says from the javadoc "This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction".

  1. But its said that marking with readOnly, the entities retrieved from database wont be stored in the persistent context or other way to say it is that the firt level cache is disabled because entities wont be stored in the persistent context. Is this right?
  2. If this is right, why if I call entityManager.contains() it always returns true although I marked the transactional with readOnly true?
  3. How can I test really with JPA if the entities are really stored in the persistent context?

Thanks

0 Answers
Related