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.  [ 7 posts ] 
Author Message
 Post subject: Hiding non-Virtual properties for lazy loading
PostPosted: Wed Nov 01, 2006 5:44 pm 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 1.2.0

Hi,

Quick question - I realise to use lazy loading you need to declare properties as "virtual". However, if I am trying to map to a class which inherits from a class which has at least one property which is not marked virtual is there any way I can ignore it. I have tried declaring a property of the same name as virtual and used the "new" keyword to hide it but I am getting the same error as if I hadn't declare this.

Any help would be greatly appreciated.

Stuart Jones


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 2:51 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You will have to disable the proxy validator, I guess... Set hibernate.use_proxy_validator to false.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 11:06 am 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
sergey wrote:
You will have to disable the proxy validator, I guess... Set hibernate.use_proxy_validator to false.


Thanks. Is this set in the web.config or can it be set on a per class basis?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 11:24 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, it's a configuration option (settable in either web.config or hibernate.cfg.xml). It's not possible to set it on per-class basis.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 11:37 am 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
sergey wrote:
Yes, it's a configuration option (settable in either web.config or hibernate.cfg.xml). It's not possible to set it on per-class basis.


Thanks. What is the downside of implementing this? It sounds as if it might be safer to simply turn off lazy loading for the class in question.

Is this a bug however, as perhaps it shouldn't be checking properties that can't be mapped to as they are hidden?


Last edited by tunic on Thu Nov 02, 2006 11:43 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 11:38 am 
Beginner
Beginner

Joined: Wed Nov 01, 2006 5:33 pm
Posts: 22
(deleted - duplicate post)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 12:43 pm 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
tunic wrote:
Is this a bug however, as perhaps it shouldn't be checking properties that can't be mapped to as they are hidden?


In reality, You can not actually "hide" the property - it will remain accessible from code.

And from lazy loading point of view, the fact wether proeprty is mapped or not is unimportant. Code behind public instance method/property might (and propably does) access the persitent state of object, directly or indirectly. So the object should be initialized before any public method is executed. And for that, the member must be virtual.

Gert

_________________
If a reply helps You, rate it!


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