-->
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: Overriding onLoad for Embedded objects
PostPosted: Wed Jan 30, 2013 10:13 am 
Newbie

Joined: Wed Jan 30, 2013 9:57 am
Posts: 2
I want to override the onLoad() method in the org.hibernate.Interceptor interface, and use it for custom security checks of my own. This is working fine for normal objects in my application (which have @Entity annotation on them), but it is not working for any objects which are embedded (having @Embedded annotation ). It seems onLoad method is not called separately for Embedded objects.

Is there any workaround for this?
If not, is it possible to call a method of the containing class (object which contains the embedded object, i.e. the parent object) from within the embedded object. That will also solve my problem.

Thanks
Anuj


Top
 Profile  
 
 Post subject: Re: Overriding onLoad for Embedded objects
PostPosted: Thu Jan 31, 2013 6:07 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Embedded objects are loaded (hydrated) together with their parent object,
therefore it does not exist separate a load-event for them.

Quote:
If not, is it possible to call a method of the containing class (object which contains the embedded object, i.e. the parent object) from within the embedded object.


I fear not. What you can do is,
override the onLoad() method on the parent entity class and there do the security check for all it's embedded objects


Top
 Profile  
 
 Post subject: Re: Overriding onLoad for Embedded objects
PostPosted: Thu Jan 31, 2013 9:36 am 
Newbie

Joined: Wed Jan 30, 2013 9:57 am
Posts: 2
Thanks, I got the solution. I was able to fetch the embedded objects using the Types array and state array which are passed in as parameters to the onLoad method.

Thanks
Anuj


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.