Re: hibernate-plugin: bi-directional one-to-many association with join table

Konstantin Priblouda <kpriblouda-/[email protected]> Fri, 18 Apr 2008 12:10:02 -0700 (PDT)
Newsgroups gmane.comp.java.xdoclet-plugins
Message-ID <[email protected]>
--- Robert Taylor <[email protected]>
wrote:

> Greetings, 
> 
>  
> 
> I've been using XDoclet2 and have come across a
> situation where I need to
> map a bi-directional one-to-many association using a
> join table.
> 
> Hibernate has a mapping example here:
> 
>  
> 
>
http://www.hibernate.org/hib_docs/v3/reference/en/html/associations.html#ass
> oc-bidirectional-join-12m
> 
>  
> 
> I found the @hibernate.join tag, however, it's a
> class-level tag. It appears
> I need a method level tag.

It's the correct tag. with it, you define joined table
( on a class level )  and properties which should go
inside, are tagged with join-name param
( mea culpa, I forgot to upload fresh docs on
confluence ) 

> Does XDoclet2 have a tag which supports the example
> in the above link?

It's all in out test cases:
------------%<----------


/**
 * @author Ryan Ye
 * @hibernate.class table="join_parent_table"
 * @hibernate.join name="testJoin" table="join_table"
 * @hibernate.join-key column="join_key_column"
 */
public class JoinMapping {
	/**
	 * @hibernate.id generator-class="assigned" 
access="property"
     *
	 *our test cases:/
	public Integer getId(){
		return null;
	}
	
	/**
	 * @hibernate.property column="join_property_column"
join-name="testJoin" 
	 */
	public String getJoinProperty(){
		return null;
	}
	
	/**
	 * @hibernate.many-to-one
column="join_foreign_key_column" join-name="testJoin" 
	 */
	public Simple getManyToOne() {
		return null;
	}
}
------------%<----------

will produce:
----------------%<-----------
<hibernate-mapping>
  <class table="join_parent_table"
name="org.xdoclet.plugin.hibernate.pojo.JoinMapping">
    <id access="property" name="id">
      <generator class="assigned"/>
    </id>
    <join table="join_table">
      <key column="join_key_column"/>
      <property name="joinProperty"
column="join_property_column"/>
      <many-to-one column="join_foreign_key_column"
name="manyToOne"/>
    </join>
  </class>
</hibernate-mapping>
----------------%<------------

regards,


----[ Konstantin Pribluda http://www.pribluda.de ]----------------
JTec quality components: http://www.pribluda.de/projects/


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone