Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] howto refresh objects
[Teneo] howto refresh objects [message #87673] Thu, 28 June 2007 18:19 Go to next message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
I am working on implementing client notifications to support updates other
clients when a specific client modifies a hibernate object.

I have extended the EMFInterceptor so that I can see when hibernate is
marking objects dirty, etc. I then grab the EntityName and ID from the
arguments to onFlushDirty() and broadcast this information to all
connected/interested clients...

This all works.

However, in the receiving clients I am having trouble refresing the
objects. I can retreieve the object with session.get(EntityName, ID), but
a call to session.refresh(object) seems to load the entire hibernate
persistent database.

I would appreciate any help in this.

Mark.
Re: [Teneo] howto refresh objects [message #87764 is a reply to message #87673] Fri, 29 June 2007 04:37 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I think the main reason for this happening are the cascade settings on associations. Teneo sets full
cascade on almost all relations as a default (see the generated hbm and then look for the cascade
attribute). The advantage of this approach is that saving an object will ensure that its related
objects are also always persisted. The disadvantage is that in update (and refresh) scenarios all
related objects will also be read/persisted.
I have changed this behavior (in my development code) as I found this last behavior to be too much
of a disadvantage (the changed behavior is controlled by an option to retain backward
compatibility). In general the better (new) approach is:
- For containment relations always cascade (cascade="all" or cascade="all, delete-orphans") (this is
the current behavior)
- For all other relations do not cascade at all

Especially non-containment many-to-one do most of the time not require a cascade.

As I am still working on this new release of Teneo as a workaround the thing you can do now is
remove the cascade attribute manually in the hbm file or set cascade annotations on all associations
in ecore (or a separate xml). When you remove the cascade attribute from the hbm mapping the rule
is that if cascade="all" or cascade="all, delete-orphan" then it is a containment relation (for
which cascade is logical) and if cascade="refresh, persist, save-update etc. then it is a
non-containment relation which would not require cascade.

There is also a special association which is not visible in the hbm file (Teneo adds it dynamically
to the hibernate mapping): the econtainer handling. A contained object has a pointer to its
container (see the econtainer fields in the db table). When an object is loaded also its container
is loaded automatically. Normally this should not result in a full db load as only the containment
path is loaded.

gr. Martin

Mark wrote:
> I am working on implementing client notifications to support updates
> other clients when a specific client modifies a hibernate object.
>
> I have extended the EMFInterceptor so that I can see when hibernate is
> marking objects dirty, etc. I then grab the EntityName and ID from the
> arguments to onFlushDirty() and broadcast this information to all
> connected/interested clients...
>
> This all works.
>
> However, in the receiving clients I am having trouble refresing the
> objects. I can retreieve the object with session.get(EntityName, ID),
> but a call to session.refresh(object) seems to load the entire hibernate
> persistent database.
>
> I would appreciate any help in this.
>
> Mark.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] howto refresh objects [message #87862 is a reply to message #87764] Mon, 02 July 2007 22:06 Go to previous messageGo to next message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
Martin,

I will give this a try.

After I edit the hbm file, do I need to start with an empt db.??

I will remove all cascade entries that are not "all...".

Mark.
Re: [Teneo] howto refresh objects [message #87939 is a reply to message #87862] Tue, 03 July 2007 07:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
No you do not need to start with an empty db afiacs.

gr. Martin

Mark wrote:
> Martin,
>
> I will give this a try.
>
> After I edit the hbm file, do I need to start with an empt db.??
>
> I will remove all cascade entries that are not "all...".
>
> Mark.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] howto refresh objects [message #608615 is a reply to message #87673] Fri, 29 June 2007 04:37 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I think the main reason for this happening are the cascade settings on associations. Teneo sets full
cascade on almost all relations as a default (see the generated hbm and then look for the cascade
attribute). The advantage of this approach is that saving an object will ensure that its related
objects are also always persisted. The disadvantage is that in update (and refresh) scenarios all
related objects will also be read/persisted.
I have changed this behavior (in my development code) as I found this last behavior to be too much
of a disadvantage (the changed behavior is controlled by an option to retain backward
compatibility). In general the better (new) approach is:
- For containment relations always cascade (cascade="all" or cascade="all, delete-orphans") (this is
the current behavior)
- For all other relations do not cascade at all

Especially non-containment many-to-one do most of the time not require a cascade.

As I am still working on this new release of Teneo as a workaround the thing you can do now is
remove the cascade attribute manually in the hbm file or set cascade annotations on all associations
in ecore (or a separate xml). When you remove the cascade attribute from the hbm mapping the rule
is that if cascade="all" or cascade="all, delete-orphan" then it is a containment relation (for
which cascade is logical) and if cascade="refresh, persist, save-update etc. then it is a
non-containment relation which would not require cascade.

There is also a special association which is not visible in the hbm file (Teneo adds it dynamically
to the hibernate mapping): the econtainer handling. A contained object has a pointer to its
container (see the econtainer fields in the db table). When an object is loaded also its container
is loaded automatically. Normally this should not result in a full db load as only the containment
path is loaded.

gr. Martin

Mark wrote:
> I am working on implementing client notifications to support updates
> other clients when a specific client modifies a hibernate object.
>
> I have extended the EMFInterceptor so that I can see when hibernate is
> marking objects dirty, etc. I then grab the EntityName and ID from the
> arguments to onFlushDirty() and broadcast this information to all
> connected/interested clients...
>
> This all works.
>
> However, in the receiving clients I am having trouble refresing the
> objects. I can retreieve the object with session.get(EntityName, ID),
> but a call to session.refresh(object) seems to load the entire hibernate
> persistent database.
>
> I would appreciate any help in this.
>
> Mark.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] howto refresh objects [message #608622 is a reply to message #87764] Mon, 02 July 2007 22:06 Go to previous message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
Martin,

I will give this a try.

After I edit the hbm file, do I need to start with an empt db.??

I will remove all cascade entries that are not "all...".

Mark.
Re: [Teneo] howto refresh objects [message #608627 is a reply to message #87862] Tue, 03 July 2007 07:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
No you do not need to start with an empty db afiacs.

gr. Martin

Mark wrote:
> Martin,
>
> I will give this a try.
>
> After I edit the hbm file, do I need to start with an empt db.??
>
> I will remove all cascade entries that are not "all...".
>
> Mark.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:hibernate and collection setters
Next Topic:Handling of very large model instances using Teneo
Goto Forum:
  


Current Time: Thu Apr 25 01:07:10 GMT 2024

Powered by FUDForum. Page generated in 0.03267 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top