Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [Persistence, JBoss/CMP, Hibernate,
 Database] - Mapping exception

scott.stark@jboss.org

2007-03-27


I am using Hibernate Core 3.2.2 with Jboss Application Server 4.0.5GA. I managed to map my entities using myEntity.hbm.xml file for each. However, now I would like to use Hibernate Annotations to facilitate mapping especially when having attribute ovverrides in an embeddable class.

I have replaced the myEntity.hbm.xml files with hibernate.cfg.xml file which includes a list of mapping classes as follows. I have placed the config file in the root of my source code outside any package.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
jdbc:mysql://localhost/myDB

guest
password
com.mysql.jdbc.Driver
org.hibernate.dialect.MySQLDialect
org.hibernate.transaction.JTATransactionFactory
thread
true
create
<!-- mapping files -->

</session-factory>
</hibernate-configuration>

However when I run my application and arrive at the point of saving one of my entities, the following exception is thrown:

org.hibernate.MappingException: Unknown entity: com.company.test.ejb.entity.TestEntity
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister (SessionFactoryImpl.java:548)
at org.hibernate.impl.SessionImpl.getEntityPersister (SessionImpl.java:1338)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId (AbstractSaveEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId (DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId (DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient (DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate (DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate (DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave (SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save (SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save (SessionImpl.java:519)
at com.company.test.ejb.session.myTestApp.method1(TestThread.java:70)

So I'm assuming that during deployment the hibernate.cfg.xml is not being considered. Am I placing the file in the wrong place or do I have to add some configuration settings to Jboss?

Thanks
Gail

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031980#4031980

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031980
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.