-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with Base Class Generics
PostPosted: Wed Mar 28, 2007 5:38 am 
Newbie

Joined: Wed Mar 28, 2007 5:27 am
Posts: 2
Hibernate version: 1.2.0.2001

Hi,
I have a problem ...
I have one base class and 2 classes who inherit from this class.
Now this base class is this:
Code:
public class Category<ParentType>
        where ParentType : Category<ParentType>
       
    {
        private Guid m_id;
        private ParentType m_parentCategory;
        private string m_name;
        private string m_description;

        #region Category Properties
        #region Category Constructors
    }
}


My other 2 classes:
public class UnitCategory : Category<UnitCategory>
public class StockItemCategory : Category<StockItemCategory>

As you can see there is a generic type that has to be given when creating it.
Now there is a problem when mapping this file..
Now I have this:
<class name="Category'1[???]" table="Categories">

What do I have to insert in place of the question marks?? Otherwise it can not map the file, which is logic.
Can anyone help me??
Thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 7:07 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
I don't believe you need to specify the bracketed part '[???]'. I don't usually this but try this and see how it works for you
Code:
<class name="Category'1" table="Categories">


Hope this helps
MIKE

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 10:52 am 
Newbie

Joined: Wed Mar 28, 2007 5:27 am
Posts: 2
it seems that hibernate doesn't support yet generics in the way i used them.
my solution was that i didnt map the base class, but only the subclasses.
with a small change in de database and putting virtual before every properitie and method, everything worked perfect.

greetzz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 30, 2007 2:27 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
Ah...sounds like you are dealing with limitations of the version of Dynamic Proxy that NHibernate uses in regard to generics.

_________________
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.  [ 4 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.