-->
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.  [ 2 posts ] 
Author Message
 Post subject: IdentifierGenerationException when I use UserType in ID tag
PostPosted: Wed Jan 04, 2006 10:55 pm 
Newbie

Joined: Wed Jan 04, 2006 10:50 pm
Posts: 3
Location: Brazil
Hi...

- My database is MySQL e all the PK are 'autoincrement'

- I'm using the follow ID TAG:

<id name="id" type="package.IdToLongConverter" column="id">
<generator class="native" />
</id>


- The IdToLongConverter is a org.hibernate.usertype.UserType class

- When I put 'null' in a id value, occours this error:

org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string

- I looked at the source code Hib3 and I verified that it doesn't support UserType...

- In IdentifierGeneratorFactory.get(ResultSet, Type) display:

// unhappy about this being public ... is there a better way?
public static Serializable get(ResultSet rs, Type type)
throws SQLException, IdentifierGenerationException {

Class clazz = type.getReturnedClass();
if ( clazz==Long.class ) {
return new Long( rs.getLong(1) );
}
else if ( clazz==Integer.class ) {
return new Integer( rs.getInt(1) );
}
else if ( clazz==Short.class ) {
return new Short( rs.getShort(1) );
}
else if ( clazz==String.class ) {
return rs.getString(1);
}

// in this POINT I need support to UserType

else {
throw new IdentifierGenerationException("this id generator generates long, integer, short or string");
}

}

Are there a solution for this my problem? Thank's.

_________________
Leonardo Pereira
Rio de Janeiro, Brazil


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 5:40 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
<id name="id" type="package.IdToLongConverter" column="id">
<generator class="native" />
</id>

you may use
<generator class="my.userdefined.MyIdGeneratorClass" />

_________________
sHeRiN
thanks for your ratings ...... :)


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