-->
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: No link table in reverse engineered many-to-many mapping
PostPosted: Mon Sep 04, 2006 10:15 pm 
Newbie

Joined: Mon Sep 04, 2006 9:53 pm
Posts: 4
Hi all,

I don't know if this is a problem as a result of something I did incorrectly or if this is an actual problem with the Hibernate Code Generation (Exporter : .hbm.xml) because I am relatively new to using Hibernate.

The problem appears to be that the hbm.xml file generated for two classes that have a Many-To-Many relationship does not include the attribute for the link (aka association) table name.

Hibernate version:3.2.0.cr4

Full stack trace of any exception that occurs:
WARNING: SQL Error: 1146, SQLState: 42S02
5/09/2006 14:00:24 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Table 'blah.enginemodels' doesn't exist
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.acme.model.ChassisModel.engineModels#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)


Name and version of the database you are using:MySQL 5.0

When I tried to navigate across the association while using the generated hbm.xml file I got the above stack trace.

Code:
        <set name="engineModels" inverse="true">
            <key>
                <column name="chassis_model_pkid" not-null="true">
                    <comment></comment>
                </column>
            </key>
            <many-to-many entity-name="nz.co.krazykarts.model.EngineModel">
                <column name="engine_model_pkid" not-null="true">
                    <comment></comment>
                </column>
            </many-to-many>
        </set>

When I added the table="lt_engine_model_chassis_model" attribute to the "set" element the navigation succeeded.

Code:
        <set name="engineModels" inverse="true" table="lt_engine_model_chassis_model">
            <key>
                <column name="chassis_model_pkid" not-null="true">
                    <comment></comment>
                </column>
            </key>
            <many-to-many entity-name="nz.co.krazykarts.model.EngineModel">
                <column name="engine_model_pkid" not-null="true">
                    <comment></comment>
                </column>
            </many-to-many>
        </set>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 05, 2006 2:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
looks like a bug.

put it in jra so I remember to fix it.

_________________
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.  [ 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.