-->
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: How to implement lazy classes in Nhibernate 1.2.0?
PostPosted: Sun Oct 29, 2006 4:52 am 
Newbie

Joined: Thu Oct 26, 2006 4:49 pm
Posts: 8
For NHibernate 1.0.2 I implemented several classes. I need lazy load to decrease amount of SQL queries.
Code:
    [Class(Table = "DOCUMENT_DEFINITION", Lazy = true)]
    public class DocumentDefinition
    { ... }

   [Class(Table = "DOCUMENT")]
    public class Document
    {
        ....
        [ManyToOne(Column = "DOCDEF_ID")]
        public DocumentDefinition DocumentDefinition
        {
            get ... set ...
        }
        ...
     }


In 1.0.2 all worked OK, and loading was lazy as required. Then I switched to ver 1.2.0, and got exception

Code:
[InvalidProxyTypeException: Type 'DocumentDefinition' cannot be specified as proxy: method get_Id should be virtual]


Is it possible to use lazy load support without implementing each my class as interface first? [/url]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 29, 2006 5:47 pm 
Newbie

Joined: Sun Oct 29, 2006 5:44 pm
Posts: 10
Location: New Zealand
You don't need to implement an interface, just specify all your non-overriding methods & properties in those classes as virtual
eg:
Code:
public virtual string Designation
        {
            get { return _designation; }
            set { _designation = value; }
        }


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 2:49 am 
Newbie

Joined: Thu Oct 26, 2006 4:49 pm
Posts: 8
Great thanks, it works.


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.