-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: CollectionOfElements not being flushed until TX commit
PostPosted: Sat Feb 11, 2006 12:23 am 
Newbie

Joined: Wed Dec 28, 2005 1:18 pm
Posts: 5
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 12:34 am 
Newbie

Joined: Wed Dec 28, 2005 1:18 pm
Posts: 5
Some additional info...

The flushing behavior works as I would expect (i.e. actually flushing when flush() is called) when the collection is an @OneToMany of entities (i.e. if I change my @Embeddable to @Entity).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 12, 2006 10:37 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I find it hard to believe, since the method called on commit is session.flush() nothing more.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.