hi,
i'm trying to use hibernate for a web application. i used hibernate tools and eclipse for reverse engineering all the code from an existing mysql 5 database.
the exporters i used are
- dao code
- hibernate xml mappings
- domain code
all the generated files are stored in the same directory. when i want to run a small test app, just to have a look if hibernate works correctly, it quits with the exception message
Initial SessionFactory creation failed. org.hibernate.MappingException: entity class not found: Relation
Relation is a table in my database. i've got an Relation.hbm.xml, Relation.java and RelationHome.java
everything is located in the same dir.
the mapping is, of course, done in the hibernate.cfg.xml
<mapping resource="fried/hibernate/src/Atribute.hbm.xml"/>
<mapping resource="fried/hibernate/src/AtttribValues.hbm.xml"/>
<mapping resource="fried/hibernate/src/Ci.hbm.xml"/>
<mapping resource="fried/hibernate/src/CiAttribute.hbm.xml"/>
<mapping resource="fried/hibernate/src/CiChange.hbm.xml"/>
<mapping resource="fried/hibernate/src/CiRelation.hbm.xml"/>
<mapping resource="fried/hibernate/src/CiType.hbm.xml"/>
<mapping resource="fried/hibernate/src/Datatype.hbm.xml"/>
<mapping resource="fried/hibernate/src/Event.hbm.xml"/>
<mapping resource="fried/hibernate/src/EventHistory.hbm.xml"/>
<mapping resource="fried/hibernate/src/GroupStandardAttributes.hbm.xml"/>
<mapping resource="fried/hibernate/src/Project.hbm.xml"/>
<mapping resource="fried/hibernate/src/Relation.hbm.xml"/>
<mapping resource="fried/hibernate/src/UserGroup.hbm.xml"/>
<mapping resource="fried/hibernate/src/UserProject.hbm.xml"/>
<mapping resource="fried/hibernate/src/UserTable.hbm.xml"/>
why does hibernate not find the class "Relation.java"? All other classes before "Relation" are seemingly found.
do you have any hints, what could be wrong? i guess, it's a newbie mistake but i don't have any clue.
is there the possibility, that this message could result out of an buggy "many-to-one" or "one-to-many" mapping?
i would be very pleased, if you could help me out, i've already spent so much time on this error.
thnx in advance, reverend
Hibernate version: Hibernate3
Code between sessionFactory.openSession() and session.close():
i use the "hinbernateutil" as described in the hibernate reference
Session sess = HibernateUtil.getSessionFactory().getCurrentSession(); sess.beginTransaction(); AtributeHome atHo = new AtributeHome(); List<Atribute> attList = atHo.findByExample(new Atribute()); for( int i = 0; i < attList.size(); i++){ System.out.println(attList.get(i).getAttributeType()); } sess.close();
Full stack trace of any exception that occurs:
Name and version of the database: MySQL 5.x.x
Debug level Hibernate log excerpt:
09:56:50,992 INFO SessionFactoryImpl:161 - building session factory
09:56:51,007 DEBUG SessionFactoryImpl:173 - Session factory constructed with filter configurations : {}
09:56:51,007 DEBUG SessionFactoryImpl:177 - instantiating session factory with properties:
...
hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=G:\Program Files\Java\jre1.6.0_01, hibernate.connection.url=jdbc:mysql://localhost/cmdb, hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect, java.specification.vendor=Sun Microsystems Inc., user.language=de, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode,
...
Initial SessionFactory creation failed. org.hibernate.MappingException: entity class not found: Relation
Exception in thread "main" java.lang.ExceptionInInitializerError
at friedl.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:30)
at friedl.hibernate.test.HibernateTest.main(HibernateTest.java:19)
Caused by: org.hibernate.MappingException: entity class not found: Relation
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:123)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at friedl.hibernate.util.HibernateUtil.<clinit>(HibernateUtil.java:22)
Last edited by reverend on Mon Jul 16, 2007 5:26 am, edited 1 time in total.
|