-->
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: @TypeDef, @Entity & @MappedSuperClass problem
PostPosted: Tue Jun 28, 2011 5:00 am 
Newbie

Joined: Tue Jun 28, 2011 4:24 am
Posts: 2
Hello,

I have a problem with using @TypeDef and @MappedSuperClass, @TypeDef does not seem to be seen from the child classes (the @Entity ones) here is an example:

Code:
@MappedSuperclass
@TypeDef(name="GUID",typeClass=GUIDAsString.class)
public abstract class MyEntity {

  @Id
  @Type(type="GUID")
  @Column(name="id", nullable=false)
  public GUID id = null;
}

@Entity()
@Table(name="COOL_ENTITY")
class CoolEntity extends MyEntity {}


and I get this when deploying it :

Code:
org.hibernate.MappingException: Could not determine type for: GUID, at table: COOL_ENTITY, for columns: [org.hibernate.mapping.Column(id)]


Why does this happen? I am using Hibernate 3.5.3-Final.

Thanks,
Gabriel


Top
 Profile  
 
 Post subject: Re: @TypeDef, @Entity & @MappedSuperClass problem
PostPosted: Tue Jun 28, 2011 9:23 am 
Newbie

Joined: Tue Jun 28, 2011 4:24 am
Posts: 2
I tried changing hibernate versions (now using 3.6.5.Final) to see if that changed anything, as I saw a post that said this was a bug in hibernate. I still got the error, but I noticed something, If I have the TypeDef annotation on only one of the MappedSuperclass' children (and not even on the MappedSuperclass itself) and it works :

Code:
@MappedSuperclass
public abstract class MyEntity {

  @Id
  @Type(type="GUID")
  @Column(name="id", nullable=false)
  public GUID id = null;
}

@Entity()
@TypeDef(name="GUID",typeClass=GUIDAsString.class)
@Table(name="COOL_ENTITY")
class CoolEntity extends MyEntity {}

@Entity()
@Table(name="OTHER_COOL_ENTITY")
class OtherCoolEntity extends MyEntity {}


This poses no problems...I would have thought that it would pose problems though, I don't get it....


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.