-->
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.  [ 1 post ] 
Author Message
 Post subject: Look Up Of Objects That Got Attributes Of Type "Class&q
PostPosted: Tue Jul 18, 2006 5:54 am 
Newbie

Joined: Thu Dec 01, 2005 12:23 pm
Posts: 19
Hi folks,

I got a domain object mapped to a database table that got an attribute of type "Class". So far so good. Now Hibernate 3.2.x stores the value of this attribute as a string containing the full qualified class name (e.g. "mypackage.MyClass").

Now when I try to look up such a domain object via the Hibernate criteria API, this fails as the parameter is bound wrong. I get following log output:

Quote:
DEBUG [StringType] binding ''MYCLASS'' to parameter: 1
[/quote]

And here is a short example:

Code:
package mypackage;

@Entity
@Table(name = "mytable")
public class MyObject {

    @Column(name = "class")
    private Class<? extends Serializable> classinfo;
}


Now the code for look up looks like this:

Code:
session.createCriteria(MyObject.class)
    .add(Restrictions.eq("classinfo", MyOtherObject.class) )
    .list();


Is there anything wrong that I do? Do I need a special type of criterion for attributes of type "Class"?

Regards,
bitbyter


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.