-->
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.  [ 2 posts ] 
Author Message
 Post subject: cglib optimizer and direct reflective access of fields
PostPosted: Wed May 09, 2007 9:39 am 
Newbie

Joined: Sat Aug 12, 2006 1:20 am
Posts: 7
Hi,

We are using Hibernate 3.2.3 along with Hibernate annotations 3.3.0. All mapping configurations are specified through field level annotations. I understand that this would imply that access='field'.

It seems that if reflection optimizer is enabled then field values are only initialized when an attempt to access is made through a getter or a setter. If one tries to access the field value using reflection ( i.e java.lang.reflect.Field.get(Object) ) then the value returned is null if the fields are not initialized yet. However, if the same field value is obtained through the accessors then the persisted value is returned. We've some code that uses reflection to access field values directly. Is there any configuration option that would initialize field values even in case of a reflective access ?

Thanks in advance.
Radhakrishnan

_________________
Don't forget to rate if the reply helped.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 9:55 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Hibernate uses AOP which is done around your getters and setters, that's where the "magic" happens, if you bypass the magic, "getters and setters" then directly accessing your object with reflection is not gonig to do anything.
Why don't you just change your reflection class to call a specific getter or setter instead of accessing the feilds directly?

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


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