-->
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: Using TypeFactory inside a UserType
PostPosted: Fri Apr 29, 2011 8:00 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
Hi,

before Hibernate 3.6.0, I was defining the following UserTypes (simplified to illustrate):
Code:
public class JodaDateTimeType implements UserType { ... }

public class JodaIntervalType implements CompositeUserType {
    ...
    public String[] getPropertyNames() {
        return new String[] {"start", "end"};
    }

    public Type[] getPropertyTypes() {
        return new Type[] {Hibernate.custom(JodaDateTimeType.class), Hibernate.custom(JodaDateTimeType.class)};
    }
}

Now that Hibernate.custom() is deprecated, what is the correct way to obtain an instance of Type for a particular UserType class inside another (Composite)UserType?

I should use a TypeFactory but how do I get such a reference inside a UserType? I've been looking for some interface like TypeFactoryAware/SessionFactoryAware that my UserType could implement but I didn't find any.

Thanks,

Xavier


Top
 Profile  
 
 Post subject: Re: Using TypeFactory inside a UserType
PostPosted: Sat Jun 04, 2011 1:07 am 
Newbie

Joined: Tue May 31, 2011 8:25 am
Posts: 2
Hello everyone,

I'm trying to basically do the same thing as Xavier: creating a CompositeUserType with an association in it. All the examples I've seen (online and in Gavin King's Java Persistence with Hibernate) have only the rather naive case of simple members.

Prior to Hibernate 3.6.0.Final, I used Hibernate.entity() to return column types in getPropertyTypes, which seemed to work.
In Hibernate 3.6.0.Final that use is deprecated, and the only way to receive TypeHelper is from a SessionImplementor, inaccessible in getPropertyTypes.

I've followed Eyal Lupu's message (http://www.jroller.com/eyallupu/entry/h ... nnotations), as well as the examples from Hibernate's website / Gavin King's book when creating these custom user types.

I'm asking because one of the exceptions I get (inconsistently I might add) is "Wrong number of columns" for entities which have my custom type as an association.

My question is: Can someone from the Hibernate team please post a Hibernate 3.6.0.Final-compatible coded example of a case where a userType has an association?

The examples on the websites and Hibernate-maintained sources are not up to date on this point.

Thanks in advance,

Gil.


Last edited by Gil Shidlansik on Sat Jun 04, 2011 6:37 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Using TypeFactory inside a UserType
PostPosted: Mon Jul 18, 2011 4:26 pm 
Newbie

Joined: Wed Aug 24, 2005 3:16 pm
Posts: 7
Location: Minneapolis, MN
I have the same question as Xavier. Does anyone have an answer as to how a call to Hibernate.custom() can be changed for code using v3.6.5 now that that method has been deprecated?

Or is the answer that there won't be a way until v4.0?

It appears that the relevant JIRAs have been closed (HHH-5138 & HHH-5182) as of v3.6.0.

Thanks,
John


Last edited by john_yeager on Wed Mar 14, 2012 9:20 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Using TypeFactory inside a UserType
PostPosted: Wed Mar 14, 2012 6:47 am 
Beginner
Beginner

Joined: Mon Jul 05, 2004 9:29 am
Posts: 38
with Hibernate 4+,

I'm now able to do the following:
Code:
public Type[] getPropertyTypes() {
    return new Type[] {new CustomType(new JodaDateTimeType()), new CustomType(new JodaDateTimeType())};
}
hope it will help others.

Xavier


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.