-->
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: Unable to find entity...?
PostPosted: Thu Aug 04, 2005 10:01 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Hibernate version: 3.1 beta 1
Hibernate annotations version: 3.1 beta 4
Name and version of the database you are using: MySQL 4.1.13

I have an abstract class User which is extended by the three classes Student, Lecturer and Administrator using the strategy single table per class hierarchy.

When trying to get it started, I get the exception below. I could not figure out what I went wrong. Maybe it's just too late... 8)
I hope you can help me. Thanks in advance!

User:
@Entity()
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@Table(name = "users")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE, discriminatorType = DiscriminatorType.STRING)
@DiscriminatorColumn(name = "discriminator")
public abstract class User implements Comparable {
...
}

Student:
@Entity()
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@Inheritance(discriminatorValue = "student")
public class Student extends User {
...
}

Lecturer:
@Entity()
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@Inheritance(discriminatorValue = "lecturer")
public class Lecturer extends User {
...
}

Administrator:
@Entity()
@org.hibernate.annotations.Entity(dynamicUpdate = true)
@Inheritance(discriminatorValue = "administrator")
public class Administrator extends User {
...
}

Full stack trace of any exception that occurs:
Code:
Exception in thread "main" java.lang.ExceptionInInitializerError
   at de.w3s.tools.HibernateUtil.<clinit>(HibernateUtil.java:38)
   at de.w3s.tools.DDLManager.main(DDLManager.java:37)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: org.hibernate.AnnotationException: Unable to find entity de.w3s.persistence.Lecturer
   at org.hibernate.cfg.AnnotationBinder.bindFkSecondPass(AnnotationBinder.java:1480)
   at org.hibernate.cfg.FkSecondPass.secondPass(FkSecondPass.java:37)
   at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:31)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:215)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1026)
   at de.w3s.tools.HibernateUtil.<clinit>(HibernateUtil.java:34)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 4:36 pm 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Well, I think it was really to late. :)
I just forgot to map the derived classes in the hibernate.cfg.xml.

<mapping class="de.w3s.persistence.Student"/>
<mapping class="de.w3s.persistence.Lecturer"/>
<mapping class="de.w3s.persistence.Administrator"/>

Best regards
Sven


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 7:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You can use the .par feature of Hibernate entity Manager to avoid this kind of mistake in the future.
http://blog.hibernate.org/cgi-bin/blosxom.cgi/2005/08/04#par-archive

_________________
Emmanuel


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.