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.  [ 8 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: unmapped class
PostPosted: Mon Aug 14, 2006 8:54 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
hello all

I'm using hbm2java task (hibernate tools 3.2 beta 6a) task generate my java pojos from the hibernate mapping files.

I have 2 directories with hibernate mapping files, because i have two projects which are connected in Eclipse IDE.

Some hibernate mapping files in my Project refer to classes from the other project. In the file below the mapping file for class najsre7.model.Angebot refers for example to najs.model.Verband from the other project.

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  auto-import="false" >
    <class name="najsre7.model.Angebot" table="TANGEBOT">
        <id name="id" type="java.lang.Integer">
            <meta attribute="use-in-tostring">true</meta>
            <meta attribute="use-in-equals">true</meta>
            <column name="ILAUFNUMMER" precision="9" scale="0" />
            <generator class="sequence">
                <param name="sequence">SEQ_TANGEBOT</param>
            </generator>
        </id>
        <timestamp name="mutDatum" column="DMUTDAT" />
        <many-to-one name="organisation" class="najs.model.Organisation" lazy="false" fetch="join" >
            <column name="FK_TORG_ILAUFNR" precision="9" scale="0" not-null="true" />
        </many-to-one>
        <many-to-one name="verband" class="najs.model.Verband" lazy="false" fetch="join" >
            <column name="FK_TVRB_ILAUFNR" precision="9" scale="0" />
        </many-to-one>
        <many-to-one name="angebotsArt" class="najsre7.model.AngebotArt" fetch="join" >
            <column name="FK_TAART_ILAUFNR" precision="9" scale="0"  />
        </many-to-one>
    </class>
</hibernate-mapping>


How can i start the task, without getting errors?!

Code:
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: An association from the table TANGEBOT refers to an unmapped class: najs.model.Verband


Is there a way to refer the classpath to the other project as well?

kind regards
Angela


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 9:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
May I suggest adding the other projects classpath to the classpath you pass into the hibernatetool ? :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 9:34 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
May I suggest adding the other projects classpath to the classpath you pass into the hibernatetool ? :)


yes :-) i already tried that:

Code:

<target name="init" description="Initialize">
................................

<property name="bin.dir" value="WebContent/WEB-INF/classes" />
   <property name="bin.dir.business" value="C:/ndbjs/NDBJS Business Layer/bin" />

<path id="classpath" >   
      <fileset dir="${eclipseTools.dir}">
         <include name="**/*.jar"/>
      </fileset>
         
      <fileset dir="${eclipseHibernate.dir}">
         <include name="**/*.jar"/>
      </fileset>

      <pathelement location="${lib.dir.web}/ojdbc14_g.jar" />      
      <pathelement location="${lib.dir.web}/duke_2.0.jar" />   
      <pathelement location="${bin.dir}" />   
      <pathelement location="${bin.dir.business}" />
   </path>
   
   <taskdef
        name="hibernatetool"
        classname="org.hibernate.tool.ant.HibernateToolTask">
      <classpath refid="classpath" />
   </taskdef>
</target>   

<target name="generatePOJOS" depends="init" description="Generates model classes">
   <hibernatetool destdir="${dest.dir.pojo}">
               <classpath refid="classpath" />
           <configuration >
                <fileset dir="${dest.dir.hbm}">
                       <include name="*.hbm.xml"/>
                 </fileset>
           </configuration>

          <hbm2java jdk5="false" ejb3="false" />
             
   </hibernatetool>
</target>


what did i forget?

regards Angela


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 9:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
maybe the mapping files from the other project.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 9:41 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
max wrote:
maybe the mapping files from the other project.


hmmm they're in the following path as well:

<property name="bin.dir.business" value="C:/ndbjs/NDBJS Business Layer/bin" />


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 9:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well they are not being loaded by your cfg.xml or filepattern

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 16, 2006 3:33 am 
Regular
Regular

Joined: Mon Mar 06, 2006 6:18 am
Posts: 95
Location: Bern, Switzerland
I can't get it working. I added a jar file which contains all other hibernate mapping files and classes to the classpath:

<pathelement location="${lib.dir.web}/ndbjsBussinessLayer.jar" />

But it isn't working....any ideas?

angela


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 16, 2006 3:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
How are you adding those hbm.xml ?

via <mapping resource="xxx"/> in cfg.xml or just via the fileset ?

The resource mapping will look up in the classpath (and should thus work), a fileset is done via the filesystem where hbm.xml in a jar is not visible.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.