-->
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: Mapping non-generic subclasses of Generic Types
PostPosted: Thu Dec 09, 2010 11:00 am 
Newbie

Joined: Thu Dec 09, 2010 10:31 am
Posts: 1
I ran into a peculiarity when trying to use subclasses of a parameterized class, the mapper seems to interpret the subclass as typed with the same type parameter.
I'm use the following structure (class names are changed for clarity):

Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class ParentClass<U> {
   
   private U value;

   public void setValue(U value) {
      this.value = value;
   }

   public U getValue() {
      return value;
   }



Code:
@Entity
public class IntegerSubClass extends ParentClass<Integer>{

}


Code:
public class StringSubClass extends ParentClass<String>{

}


The subclasses don't do a lot, but it's enough to get a generated table for them in the database. The main issue is that both generated tables have
a column called value, and both have the type used by the IntegerSubClass. If I'd change Integer to String both are String, whatever type parameter StringSubClass
specifies. What could cause this behavior and is this behavior of hibernate correct? If so, what could I do to get the right data type for the column?


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.