-->
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.  [ 3 posts ] 
Author Message
 Post subject: Single inheritance table doesn't work with annotations
PostPosted: Tue Oct 19, 2010 9:29 am 
Newbie

Joined: Mon Dec 25, 2006 4:59 am
Posts: 15
Hi guys
I am migrating my project from xml mapping to annotations, I am stuck on Table per class hierarchy inheritance.

In xml mapping i was doing this

Code:
<hibernate-mapping package="com.company.common.web.preferences" default-access="field">
   <class name="Element" table="ELEMENT"   discriminator-value="0" >

      <composite-id name="id" class="ElementId">
         <key-property name="elementId" column="ELEMENT_ID" type="long"/>
         <key-property name="userId" column="USR_ID" type="string"/>
      </composite-id>

      <discriminator column="TYPE" type="integer" insert="true" />

      <subclass name="com.company.center.web.preferences.A
         discriminator-value="4">
         ...
      </subclass>
  </class>
</hibernate-mapping>


with annotations i am doing this

Code:
@Entity
@Table(name = "ELEMENT")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@org.hibernate.annotations.ForceDiscriminator
@DiscriminatorColumn(name = "TYPE", discriminatorType = DiscriminatorType.INTEGER)
public abstract class Element implements Serializable

@Id
private ElementId id;


Code:
@Entity
@DiscriminatorValue("4")
public class A extends Element


I am getting the following exception

Code:
Caused by: org.hibernate.MappingException: Unknown entity: com.company.common.web.preferences.Element
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:597)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:879)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:816)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:809)
   at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:531)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
   ... 27 more


please help !


Last edited by dandan on Tue Oct 19, 2010 9:42 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Single inheritance table doesn't work with annotations
PostPosted: Tue Oct 19, 2010 9:37 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Did you add Element entity into hibernate context?


Top
 Profile  
 
 Post subject: Re: Single inheritance table doesn't work with annotations
PostPosted: Tue Oct 19, 2010 9:41 am 
Newbie

Joined: Mon Dec 25, 2006 4:59 am
Posts: 15
Sweet ! Thanks !
it was under another packages root :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.