-->
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: Can't map generic Types? Please tell me there is a way!
PostPosted: Fri Jul 27, 2007 2:50 am 
Newbie

Joined: Wed Apr 11, 2007 2:39 pm
Posts: 6
Hibernate version:
1.2

Mapping documents:

[Class]
public class MyClass<T>
{
private int _id;
#region Hibernate
[Id(Name = "Id")]
[Generator(1, Class = "native")]
#endregion
public virtual int Id
{
get { return _id; }
set { _id = value; }
}
}


Debug level Hibernate log excerpt:

"Cannot create an instance of MyClass because Type.ContainsGenericParameters is true."

Please tell me that it's somehow possible to map a generic class. I understand that Hibernate is likely instantiating this under the hood, but it should be able to instantiate a generic type. Does anyone have a solution or workaround? Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 27, 2007 4:13 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No, it isn't possible. NHibernate internals cannot accomodate generic entities.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 4:03 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 2:55 am
Posts: 21
Can I ask whether this is going to be added in the near future as it would be very useful on the project I am working on.


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.