-->
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: mappings from db with many-to-many with association tables
PostPosted: Tue Aug 16, 2005 3:36 pm 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:10 pm
Posts: 22
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate Tools v3.0.0 alpha4a

Mapping documents:
<?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-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="dao.hibernate.mysql.Term" table="term" >
<id name="termid" type="integer">
<column name="termid" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="name" length="50" not-null="true" />
</property>
<set name="conceptterms" inverse="true">
<key>
<column name="termid" not-null="true" />
</key>
<one-to-many class="dao.hibernate.mysql.Conceptterm" />
</set>
</class>
</hibernate-mapping>

<?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-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="dao.hibernate.mysql.Concept" table="concept" >
<id name="conceptid" type="integer">
<column name="conceptid" />
<generator class="assigned" />
</id>
<property name="name" type="string">
<column name="name" length="50" not-null="true" />
</property>
<property name="description" type="binary">
<column name="description" />
</property>
<property name="externalid" type="string">
<column name="externalid" length="50" not-null="true" />
</property>
<set name="conceptterms" inverse="true">
<key>
<column name="conceptid" not-null="true" />
</key>
<one-to-many class="dao.hibernate.mysql.Conceptterm" />
</set>
</class>
</hibernate-mapping>

<?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-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="dao.hibernate.mysql.Conceptterm" table="conceptterm" >
<id name="concepttermid" type="integer">
<column name="concepttermid" />
<generator class="assigned" />
</id>
<many-to-one name="term" class="dao.hibernate.mysql.Term">
<column name="termid" not-null="true" />
</many-to-one>
<many-to-one name="concept" class="dao.hibernate.mysql.Concept">
<column name="conceptid" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>

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

Hi,

I have a many-to-many association for the tables "concept" and "term" with a association table called "conceptterm".

When using the tool to generate hibernate mappings, it generates POJOs for each table including the association table and treats the associations between tables conceptterm and concept as many-to-one and between conceptterm and term as many-to-one. I understand that this is the default behavior.

Is there a way to tell the tool upfront that about association tables (such as table "conceptterm" above) so that the mappings are generated with fetch="join" and so that the association table does not get its own POJO?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 3:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not at the moment

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