-->
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.  [ 1 post ] 
Author Message
 Post subject: Many-to-Many with Component (unmapped class error)
PostPosted: Fri Mar 31, 2006 4:12 pm 
Newbie

Joined: Mon Nov 21, 2005 1:48 pm
Posts: 17
Hibernate version: 3.0.5

Mapping documents:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
    <class
        name="com.manytomany.Preferences"
        table="test_preferences"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Preferences.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <component
            name="warningPreferences"
            class="com.manytomany.WarningPreferences"
        >
            <property
                name="enabled"
                type="java.lang.Boolean"
                    update="true"
                    insert="true"
            column="warningprefs_enabled"
        />

        <set
            name="warnedUsers"
            table="test_warned_users"
            lazy="true"
            inverse="true"
            cascade="save-update"
            sort="unsorted"
        >

            <key
                column="warningpreferences_id"
            >
            </key>

            <many-to-many
                class="com.manytomany.TestUser"
                column="user_id"
                outer-join="auto"
             />

        </set>

        </component>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Preferences.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
    <class
        name="com.manytomany.TestUser"
        table="test_user"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-TestUser.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

            <property
                name="name"
                type="java.lang.String"
                    update="true"
                    insert="true"
            column="name"
            unique="true"
        />

        <set
            name="warningPreferences"
            table="test_warned_users"
            lazy="true"
            inverse="false"
            cascade="save-update"
            sort="unsorted"
        >

            <key
                column="user_id"
            >
            </key>

            <many-to-many
                class="com.manytomany.WarningPreferences"
                column="warningpreferences_id"
                outer-join="auto"
             />

        </set>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-TestUser.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Code:
org.hibernate.MappingException: An association from the table test_warned_users refers to an unmapped class: com.manytomany.WarningPreferences
   at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:968)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:921)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
[snip]
Caused by: org.hibernate.MappingException: An association from the table test_warned_users refers to an unmapped class: com.manytomany.WarningPreferences
   at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:968)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:921)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
   at com.ims.wintox.model.persistence.HibernateUtil.init(HibernateUtil.java:120)
   ... 2 more

   at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:968)
   at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:921)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
   ... 3 more


Name and version of the database you are using: PostgreSQL 8.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Referencing the following figure, I'm trying to associate a hibernate component with another table in a many-to-many relationship. I get an error about WarningPreferences being unmapped when attemping to build my database. What's wrong?

http://www.dafunks.com/hibernate/ManyTo ... ponent.jpg

According to this link (http://www.hibernate.org/hib_docs/refer ... nents.html), this should be possible:

The properties of a component may be of any Hibernate type (collections, many-to-one associations, other components, etc). Nested components should not be considered an exotic usage. Hibernate is intended to support a very fine-grained object model.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.