-->
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.  [ 4 posts ] 
Author Message
 Post subject: isUnsaved return FALSE... should my object be updated?
PostPosted: Wed Dec 17, 2003 7:54 pm 
Newbie

Joined: Sun Nov 30, 2003 4:11 pm
Posts: 11
Hi,

I'm trying to solve some of my problems when updating composite-id'ed objects... I've implemented my little interceptor (madmax), which just test a value to decide if the object isUnsaved or not.

I get to the isUnsaved, and it seems to work fine, returning false when the object has been saved before... but...seems like my saveOrUpdate is not doing anything with my object.

Hibernates log says:

Code:
  - saveOrUpdate() previously saved instance
  - updating [com.previsora.data.hibernate.Beneficiario#com.previsora.data.hibernate.BeneficiarioPK@5b46]
  - calling onUpdate()
  - flushing session
  - Flushing entities and processing referenced collections
  - Processing unreferenced collections
  - Scheduling collection removes/(re)creates/updates
  - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
  - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
  - listing entities:
  - com.previsora.data.hibernate.Beneficiario{idioma=null, apellidos=null, anyonac=null, estadoCivil=null, idProfesion=null, PKBeneficiario=BeneficiarioPK{numAsegurado=2, numSolicitud=19}, mesnac=null, telfMovilProfesional=null, sexo=null, mail=null, dianac=null, dni=null, permisoResidencia=null, nombre=null, telfMovil=699065269, falsa=19, nacionalidad=null}
  - executing flush
  - post flush


Is Hibernate really trying to update my object...? I think it should, because of the first lines of the log... but I get no exception, and I get no change in the data neither.
The phone above is the changed field, and it doesn't get updated in the database.

What am I doing soooo wrong?

TIA,

_
Jorge


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 7:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
What does Lifecycle.onUpdate() return?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 2:50 am 
Newbie

Joined: Sun Nov 30, 2003 4:11 pm
Posts: 11
it returns false, and id does return the value without throwing the exception.

Code:
  public boolean onUpdate(Session session) throws CallbackException {
    return false;
  }


_
Jorge


Top
 Profile  
 
 Post subject: why is findDirty's returned value an array?
PostPosted: Thu Dec 18, 2003 6:22 pm 
Newbie

Joined: Sun Nov 30, 2003 4:11 pm
Posts: 11
Hi,

seems like I finally got it... but this does not necessarily means I undestand it :-(

Debugging through Hibernate's code, seemd like my object would not be updated, because it was not considerated "dirty enough".

The test I was running is like:

Code:
    IBeneficiario b3 = mgr.newBeneficiario();
    b3.setSolicitud(sol);
    b3.setNumAsegurado(new Integer(3));
    b3.setTelfMovil(new Long(600066066));
    mgr.save(b3);
    mgr.close();

    IPersistenceManager mgr11=Previsora.getManager();
    b2.setTelfMovil(new Long(699065269));
    mgr11.save(b2);
    mgr11.close();


So the field setTelfMovil has been modified, so I would expect hibernate to automagically infere my object was dirty.

To force this, I'm now checking in the findDirty method if the passed object is one of my IBeneficiario implementation's and if so, I will always considere it "dirty".

This does not sound too performance aware to me, and neither too elegant, but it's the only workaround I found so far.
Has anybody else got any better solution?

Also... a doubt... why is Interceptor.findDirty returning an array of ints??
Is it supposed to be kind of a flag/mask to decide which property has been changed? Seems like it's not checked in the calling code, till now?

_
Jorge


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.