-->
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: Accessing private fields using reflection
PostPosted: Mon Aug 06, 2007 9:46 am 
Newbie

Joined: Mon Aug 06, 2007 9:40 am
Posts: 2
I am using NHibernate to retrieve an object from the database. As part of a test, I want to check the private fields of the returned object are as expected.

The public properties responsible for accessing the fields return the correct values, however when the private fields are accessed directly using reflection, they are empty.

I have tried calling NHibernateUtil.Initialize on the object, but this doesn't seem to make any difference.

If I set lazy=”false” on the class that I am loading, this fixes the problem, but I would rather not do that.

Does anybody have any idea of how this might be done?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 3:28 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
You aren't going to be able to do this. Dynamic Proxy will delegate members declared as virtual which, obviously, are only your properties.
You'll have to declare lazy='false'.

_________________
If this helped...please remember to rate it!


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.