2 Replies Latest reply on Jul 30, 2005 11:09 AM by neelixx

    hibernate class not found?

    qwidjibo

      Just a simple question, just starting out with jboss and hibernate so be gentle.

      I currently have two hibernate classes in my har file which share a <many-to-one> association, but hibernate doesn't seem to recognise the classes unless they are in the same package.

      When I try to deploy the two classes in separate packages in the same har file, I get a class not found exception even though the class has been mapped.

      Not a big problem but I really wanted to keep each class in a separate package for readabilty when the number of classes increases.

      here's the output

      12:41:47,171 INFO [Configuration] Searching for mapping documents in jar: user.har
      12:41:47,171 INFO [Configuration] Found mapping documents in jar: com/uni/address/Address.hbm.xml
      12:41:47,187 INFO [Binder] Mapping class: com.uni.address.Address -> Address
      12:41:47,187 INFO [Configuration] Found mapping documents in jar: com/uni/student/Student.hbm.xml
      12:41:47,187 INFO [Binder] Mapping class: com.uni.student.Student -> Student
      12:41:47,218 ERROR [Configuration] Could not compile the mapping document
      net.sf.hibernate.MappingException: Could not find class: Address

      and here's the association in the student.hbm.xml file

      <many-to-one name="address"
      class="Address"
      unique="true"
      cascade="all"/>


      cheers

        • 1. Re: hibernate class not found?
          neelixx

          qwidjibo,

          Can you post your hbm.xml files, as well as the structure of your har file?

          Normally, when you create your hbm.xml files, you must define the classes you are persisting. Since you have a many-to-one with another class, but that class is in a different package, you'll have to use the full package name. i.e. rather than just .

          • 2. Re: hibernate class not found?
            neelixx

            Ooops. Code got stripped out:
            For example:

            <class name="org.application.package.Class">
            


            Rather than:
            <class name="Class">