-->
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: Using Hbm Files from JAR
PostPosted: Thu Mar 06, 2008 7:27 am 
Newbie

Joined: Fri May 25, 2007 4:03 am
Posts: 15
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.2.5.ga

Mapping documents:
e.g.:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
   package="org.pcd.wam.gegenstandsbereich.tmcHibernate.model.web">
   <class name="PersonalName" table="PERSONAL_NAME">
      <!-- primary key -->
      <id name="id" type="integer" column="PN_ID">
         <generator class="increment" />
      </id>
      <property name="forename" type="string" column="PN_FORENAME" />
      <property name="surname" type="string" column="PN_SURNAME" />
   </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle XE

Hi!

I have 2 Projects (Project A and Project B).
Project A only contains hibernate hbm files and java classes for that hbm files.

Project B needs Project A to communicate with the database. For that, Project B contains a hibernate.cfg.xml which should include all hbm files from Project A.

Project A exist at the classpath from Project B

+) How I can do this?

-) Project A contains hibernate hbm and java classes for that on:
Code:
org.pcd.wam.gegenstandsbereich.tmcHibernate.model.event
org.pcd.wam.gegenstandsbereich.tmcHibernate.model.locating
org.pcd.wam.gegenstandsbereich.tmcHibernate.model.statistic
org.pcd.wam.gegenstandsbereich.tmcHibernate.model.web


I tried following:
Code:
<mapping jar="lib/ProjectA-1.0-SNAPSHOT.jar"
         resource="org.pcd.wam.gegenstandsbereich.tmcHibernate.model.web.PersonalName" />

Exception:
Code:
Exception in thread "main" org.hibernate.MappingNotFoundException: resource: org.pcd.wam.gegenstandsbereich.tmcHibernate.model.web.PersonalName not found
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:563)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
   at org.pcd.wam.gegenstandsbereich.tmcHibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:65)
   at org.pcd.wam.gegenstandsbereich.tmcHibernate.HibernateUtil.getCurrentSession(HibernateUtil.java:78)
   at at.pcd.wam.gegenstandsbereich.tmcWeb.common.FillTestDate.main(FillTestDate.java:16)


or:
Code:
<mapping jar="lib/ProjectA-1.0-SNAPSHOT.jar" />

Exception:
Code:
Exception in thread "main" org.pcd.wam.gegenstandsbereich.tmcHibernate.dao.exception.DAOException: exception occurred while loading driver:
   at at.pcd.wam.gegenstandsbereich.tmcWeb.common.FillTestDate.main(FillTestDate.java:33)
Caused by: org.hibernate.MappingException: Unknown entity: org.pcd.wam.gegenstandsbereich.tmcHibernate.model.web.PersonalName
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:68)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
   at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795)
   at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
   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:597)
   at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
   at $Proxy0.load(Unknown Source)
   at org.pcd.wam.gegenstandsbereich.tmcHibernate.dao.GenericHibernateDAO.findById(GenericHibernateDAO.java:71)
   at at.pcd.wam.gegenstandsbereich.tmcWeb.common.FillTestDate.main(FillTestDate.java:27)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 06, 2008 2:23 pm 
Newbie

Joined: Tue Apr 25, 2006 1:17 pm
Posts: 19
I had a similar problem and what I did to get it working was to have the hibernate.hbm.xml file in project A with the content of the file referring to the mappings listed in Project B as such:

<mapping resource="com/domain/project/mappings/Entity.hbm.xml"/>

Not as clean as since you're exposing the mapping details into Project A when A probably doesn't care or need to know -- so if there's a better way, I'd like to know about it and use 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.