You should call Persist before running the Query in pressButton.
You are querying the same collection (Person) which contains the transient instance, right? So what should the entityManager do? Overwrite your transient instance? Looks like it is reminding you to save it before doing the Query ...
Hi ingo, thanks for reply!
I just used
from Personon pressButton query as an example, but a query on any other entity does the same behavior.
Actually, there is a lot of workarounds that I can use, flush the session before run the query is one, don't set person.getOrder().add(o) at that moment is another.
But what I am trying to understand is if this is the expected behavior.
I don't think so, because the conversation is in manual flushmode and I am using seam managed persistence context and a seam transaction manager (ejb-transaction).
I don't understand why Seam is trying to flush. Do you?
Please, someone can explain this behavior? Is the expected?
Hi again! Anyone could help me with this question?
Please refer to the following documentation, I think that it explains why flush is being called.
3.9. Flush the persistence context 3.9.1. In a transaction From time to time the entity manager will execute the SQL DML statements needed to synchronize the data store with the state of objects held in memory. This process, flush, occurs by default (this is Hibernate specific and not defined by the specification) at the following points: * before query execution* * from javax.persistence.EntityTransaction.commit()* * when EntityManager.flush() is called* (*) if a transaction is active
yeah!!! Thanks very much for the perfect answer. I didn't know that hibernate
flushs the entity manager before any query!
I know this is a JPA/Hibernate issue, but i think this should be explained on seam reference doc (chapter 9.2. Seam managed transactions).
I created a new jira JBSEAM-3857