-->
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: resource not found
PostPosted: Fri May 25, 2007 9:38 pm 
Newbie

Joined: Fri May 25, 2007 9:24 pm
Posts: 2
I am new to Hibernate and I am having a problem with the generator tools.

Here is my hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory >

      <!-- local connection properties -->
      <property name="hibernate.connection.url">jdbc:mysql://192.168.1.1/PulseCRM</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.username">admin</property>
      <property name="hibernate.connection.password">******</property>
      <!-- property name="hibernate.connection.pool_size"></property -->

      <!-- dialect for MySQL -->
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
              
              
           <mapping resource="com/johnjake/pulseCRM/controler/da/User.hbm.xml" />
         <mapping resource="com/johnjake/pulseCRM/controler/da/Note.hbm.xml" />
       
    </session-factory>
</hibernate-configuration>


and I have two mapping files:
com/johnjake/pulseCRM/controler/da/User.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.johnjake.pulseCRM.controler.da">
   <class
      name="User"
      table="users"
   >
        <meta attribute="sync-DAO">false</meta>
       <id
         name="Id"
         type="integer"
         column="id"
      >
          <generator class="native"/>
      </id>

      <property
         name="Name"
         column="name"
         type="string"
         not-null="true"
         length="255"
         unique="true"
      />
      <property
         name="Password"
         column="password"
         type="string"
         not-null="true"
         length="255"
      />
      <property
         name="Level"
         column="level"
         type="integer"
         not-null="true"
         length="10"
      />
   </class>   
</hibernate-mapping>


and com/johnjake/pulseCRM/controler/da/Note.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.johnjake.pulseCRM.controler.da" auto-import="true" >

   <class
      name="Note"
      table="notes"
   >
      <meta attribute="sync-DAO">false</meta>
      <id
         name="Id"
         type="integer"
         column="id"
      >
         <generator class="native"/>
      </id>

      <property
         name="Note"
         column="note"
         type="string"
         not-null="true"
      />
      <property
         name="CreateDate"
         column="create_date"
         type="timestamp"
         not-null="true"
      />
      <many-to-one
         name="CreateUserId"
         column="create_user_id"
         class="User"
         cascade="none"
      />
      <property
         name="UpdateDate"
         column="update_date"
         type="timestamp"
         not-null="false"
      />
   </class>   
   
</hibernate-mapping>


When I run any of the commands (hbm2java, schemaexport) I get the following error: resource: com/johnjake/pulseCRM/controler/da/User.hbm.xml not found

I even tried the third party tool hibernate synchronizer and it worked fine for User, but when I ran it against Note, I got the error: an association from the table notes refers to an unmapped class User, but if I paste the <class> section from user into note, hibernate synchronizer handles it fine.

Am i not defining something correct in my hibernatecfg.xml?

Any help would be most appreciated!

Thanks,
Jake
Hibernate version: 3.2


Top
 Profile  
 
 Post subject: Found the problem
PostPosted: Sat May 26, 2007 12:11 pm 
Newbie

Joined: Fri May 25, 2007 9:24 pm
Posts: 2
I found the problem, here is the solution if anyone else has similar issues.

1. Hibernate synchronizer seems to have issues resolving paths - so be warned.

2. The directory root containing the *.hbm.xml files needs to be in the classpath of the the schemaExport tool. Even though you are explicitly giving it the path of the hibernate.cfg.xml schemaExport looks up the *.hbm.xml files in the classpath, not relative to the hibernate.cfg.xml.

My personal solution - add a copy task to my build.xml's compile target that copy's my hibernate.cfg.xml and *.hbm.xml files to the compiler output directory and add the classes directory to schemaExport's taskdef classpath.

Not sure if its the best solution, but it is working well for me. Anyone who has a better way, let me know.

Hope this helps someone.


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.