Pardon if this is a bit sparse on details. I am still trying to determine in exactly what cases this occurs.
This pertains to Hibernate, Annotations, and EM packaged with JBoss 4.0.4RC1 (I think 3.1.2, 3.1b8, and 3.1b6 respectively).
I have an @Entity which contains an @CollectionOfElements which is a Set of @Embeddable objects. I am manipulating the Entity detached from the Hibernate session within an active UserTransaction.
When items are added/removed from this set and the Entity is subsequently merged via the EntityManager, no changes are immediately written to the DB (as would be expected with FlushMode.AUTO).
Explicitly calling EntityManager.flush() also does not cause the changes to be written to the DB (unexpected). Only upon commit of the UserTransaction do the changes get written.
For remote invocations where a detached entity is returned it is important for the detached entity to reflect the current state of the object. Hence remote calls like this invoke flush before returning a detached entity.
Is this expected behavior? My understanding is that flush fully synchronizes persistent state with the DB (as well as updating object versions, generated ids, etc).
My classes and annotations look something like this:
@Entity MyEntity {
@CollectionOfElements
@JoinTable(
name="TBL_MY_EMBEDDEDS",
joinColumns= { @JoinColumn(name="COL_MY_ENTITY") }
)
private Set<MyEmbedded> visitedPages = new HashSet<MyEmbedded>();
}
@Embeddable MyEmbeddable {
}
-- A.J.
|