It looks as though deserialized objects can
* incur unrequired trips to the db
* not honour updated properties sent from the client.
This needs investigation, as I don't know the deserializer code well enough ATM
to know for sure what the current / expected behaviour is.
Initial email conversation pasted below:
So, your method conceptually looks something like this?
public class SavePersonRequest()
{
var person:Person;
// Other stuff
}
This is not currently supported out-of-the-box, that I'm aware of. (I
haven't spent a great deal of time in the Deserializer, but I can take a
look).
I guess what the deserializer should do is grab the person instance out of
the hibernate cache (or, if it's been flushed, we'll need to re-load it),
and copy populated properties over from the instance received in the server
call.
I can see some challenges ahead in differentiating the meaning of null
values between that of a uninitialized proxy, and one where the value has
subsequently been set to null on the client.
I'll raise a ticket to track the discovery & dev of this feature.
Marty
--------------------------------------------------
From: "Lea, Isaac" <IsaacLea@SierraSystems.com>
Sent: Wednesday, July 28, 2010 2:44 PM
To: <dphibernate@googlegroups.com>
Subject: RE: Lazyload not working - problems in HibernateManaged.as
> Hi Marty, I need to be able to send back non entity objects which contain
> entities so I need to have custom save methods to pull out the various
> entities and save them. I've been able to hack the Deserializer to allow
> this (populates non initialized collections as empty collections rather
> than initialize all the children) but i'm not too fond of having to modify
> the code.
> Is there a way I can accomplish what i'm trying to do out of the box?
>
> ________________________________________
> From: dphibernate@googlegroups.com [dphibernate@googlegroups.com] On
> Behalf Of Marty Pitt [martypitt@me.com]
> Sent: July-28-10 11:39 AM
> To: dphibernate@googlegroups.com
> Subject: Re: Lazyload not working - problems in HibernateManaged.as
>
> Hi Lea
>
> For persistence, I would reccommend using the dpHibernate persistence
> methods, rather than just sending back your own object.
>
> Basically, the pattern goes like this:
> // During app intialization:
> // initialize service to something on the server that implements
> IProxyUpdateService.
> // eg, DataAccessService.java
> HibernateManaged.defaultHibernateService = this.dataAccessService;
>
> // Before making the first change - only needs to be called once per
> entity.
> if (!StateRepository.contains(entity))
> {
> StateRepository.store( entity );
> }
>
> // When you're ready to persist:
> HibernateUpdater.save(entity, responder); // responder is optional.
>
>
> This way, dpHibernate sends a list of changed properties only back to the
> server, and not the entire entity itself. Serialization of the entity can
> be expensive, especially on non-initalized objects.
>
> There's an example of this pattern on the LazyOverflow project.
>
> Marty
>
>
> --------------------------------------------------
> From: "Lea, Isaac" <IsaacLea@SierraSystems.com>
> Sent: Wednesday, July 28, 2010 2:11 PM
> To: <dphibernate@googlegroups.com>
> Subject: RE: Lazyload not working - problems in HibernateManaged.as
>
>> Looks like it's happening in HibernateDeserializer in the following code.
>> It is performing the load if it isn't initialized on the way back to the
>> server. Is there a reason for this?
>>
>> else if (obj != null && obj instanceof IHibernateProxy &&
>> !((IHibernateProxy) obj).getProxyInitialized())
>> {
>> Object hibResult = readHibernateProxy(obj);
>>
>> //replace cache with initialized item
>> cache.put(obj, hibResult);
>>
>> return hibResult;
>> }
>>
>>
>> ________________________________________
>> From: dphibernate@googlegroups.com [dphibernate@googlegroups.com] On
>> Behalf Of Lea, Isaac
>> Sent: July-28-10 10:45 AM
>> To: dphibernate@googlegroups.com
>> Subject: RE: Lazyload not working - problems in HibernateManaged.as
>>
>> I've run into a couple of problems so far around persisting data.
>>
>> I am getting the Person object back and not initializing the child
>> Address
>> in Flex. That all works fine but when I save it for some reason
>> dpHibernate is initializing the Address on the way back to the server. I
>> need to leave the Address not initialized because it just adds database
>> query calls. I'm not referencing the address anywhere.
>>
>> This is the output:
>>
>> INFO
>> net.digitalprimates.persistence.hibernate.utils.services.ProxyLoadService
>> - loadByClass : ca.pensionsbc.rms.model.domain.AddressVw::22290
>>
>> Then it spits out the HQL as it queries the database.
>>
>> Why would it be trying to initialize the address if i'm not referencing
>> it?
>>
>> ----Notice Regarding Confidentiality----
>>
>> This email, including any and all attachments, (this “Email”) is intended
>> only for the party to whom it is addressed and may contain information
>> that is confidential or privileged. Sierra Systems Group Inc. and its
>> affiliates accept no responsibility for any loss or damage suffered by
>> any
>> person resulting from any unauthorized use of or reliance upon this
>> Email.
>> If you are not the intended recipient, you are hereby notified that any
>> dissemination, copying or other use of this Email is prohibited. Please
>> notify us of the error in communication by return email and destroy all
>> copies of this Email. Thank you.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "dpHibernate" group.
>> To post to this group, send email to dphibernate@googlegroups.com.
>> To unsubscribe from this group, send email to
>> dphibernate+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/dphibernate?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "dpHibernate" group.
> To post to this group, send email to dphibernate@googlegroups.com.
> To unsubscribe from this group, send email to
> dphibernate+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/dphibernate?hl=en.
>
> ----Notice Regarding Confidentiality----
>
> This email, including any and all attachments, (this “Email”) is intended
> only for the party to whom it is addressed and may contain information
> that is confidential or privileged. Sierra Systems Group Inc. and its
> affiliates accept no responsibility for any loss or damage suffered by any
> person resulting from any unauthorized use of or reliance upon this Email.
> If you are not the intended recipient, you are hereby notified that any
> dissemination, copying or other use of this Email is prohibited. Please
> notify us of the error in communication by return email and destroy all
> copies of this Email. Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "dpHibernate" group.
> To post to this group, send email to dphibernate@googlegroups.com.
> To unsubscribe from this group, send email to
> dphibernate+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/dphibernate?hl=en.
>
>
Original issue reported on code.google.com by martypit...@gtempaccount.com on 28 Jul 2010 at 7:02
Original issue reported on code.google.com by
martypit...@gtempaccount.com
on 28 Jul 2010 at 7:02