-->
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: Generics and PersistentSet
PostPosted: Tue Jul 12, 2005 12:33 pm 
Newbie

Joined: Thu Dec 16, 2004 7:50 am
Posts: 11
Hibernate version:
Hibernate 3.1 alpha 1
Annotations 3.1 beta 3

Hello, I have tried using java generics with annotations together, but Hibernate is replacing the collections like

Set<MyClass> mySet;

with its own PersistentSet. When ut as I would like to do something with reflection later using

myClass.getMySet().getClass().getTypeParameters();

basicaly I would like to get the Type Parameter ("MyClass") on runtime. It looks like it is not possible to get this information. Does anyone have any idea. I have been trying to find something like getOriginalDeclaredClass() method in class org.hibernate.collection.AbstractPersistentCollection, but I have not found such method. Or maybe there is a plan to make PersistentSet using generics too so I would get something like PersistentSet<MyClass> but if PersistentSet is never used before compilation it seems quite unnecessary to put generics at this point.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 12:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Well I don't think this is something we'll add.
You can workaround that using reflection on the getter instead of the returned object. thus PersistentSet will not be involved.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 1:24 am 
Newbie

Joined: Thu Dec 16, 2004 7:50 am
Posts: 11
thank you for answer but unfortunately I have got only the reference to the Set and not to the originating class of this collection, so getter is unaccessible. the only possibility for workaround is to have the TypeParameter somewhere in the configuration which is quite cumbersome.

Do you think if I would code something like getOriginalDeclaredClass() for org.hibernate.collection.AbstractPersistentCollection on my own it has a chance to be added to the hibernate code ? (maybe I am wrong but it seems quite easy, unfortunately this would include overloading this method in all subclasses like PersistentSet or some other modifications to them)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 2:04 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You can implement a UserCollectionType, I imagine.

_________________
Emmanuel


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.