-->
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.  [ 5 posts ] 
Author Message
 Post subject: Custom types
PostPosted: Tue Jun 07, 2005 11:39 am 
Newbie

Joined: Wed Nov 12, 2003 3:49 pm
Posts: 19
Folks,

I am trying to map to my own classes instead of using the built in mapping classes:

<property name="exp" column="EXP" type="myclasses.Exp"/>

Are there any special requirements of the myclasses.Exp class? (I can make it work by mapping to a string.)

At run time, I get a desrialization error.

Thanks,
Dave


Top
 Profile  
 
 Post subject: one more note on this
PostPosted: Tue Jun 07, 2005 11:41 am 
Newbie

Joined: Wed Nov 12, 2003 3:49 pm
Posts: 19
My class does implement Serializable.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 2:08 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the documentation, you want a UserType.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 3:03 pm 
Newbie

Joined: Wed Nov 12, 2003 3:49 pm
Posts: 19
christian wrote:
Read the documentation, you want a UserType.


Thanks, Christian. I have been through Hibernate in Action, the java doc, and the documentation at:

http://www.hibernate.org/hib_docs/v3/re ... pes-custom

The documentation states:

To implement a custom type, implement either org.hibernate.UserType or org.hibernate.CompositeUserType and declare properties using the fully qualified classname of the type.

So, my question is this...

Before I embark on the effort to write 9 of the 11 methods (I already have hashcode and equals ) required by the UserType interface for my 100 or so custom classes, is there an easier way? This isn't insurmountable, but likewise it certainly isn't trivial, and I'm eager to start on the actual mapping activity.

Thanks again,
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 3:57 pm 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
Are you sure that you aren't really trying to map many-to-one (and related) associations?

100+ custom types seems excessive.


For example:

Code:
class Foo {
    long id;
    Bar bar;
    // ...
}

class Bar {
    long id;
    String someSting;
    // ... 
}


You don't need a custom UserType for any of that. I appologize if this isn't the case for you, but it seems like you might be headed down the wrong path here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.