Hi all,
Sorry, but my english is a "little" poor. :P
I have a relation Parent/Child between two tables.
Parent -> Child
Haha -> Hehe
When I run the hibernatedoclet task in ant (under Eclipse), a sucessuful generation occurs.
But in hahaPojo.hbm.xml is missing the inverse property in set named "hehe".
I tried by two days find a solution, so a create this simple example and the hibernatedoclet don´t generate the inverse attribute.
I'm using a xdoclet.1.2.2 version, ant is a 1.6.2, eclipse 3.0, windows 2000, hibernate 2.1.8.
I thinking the problaly cause of this problem is a jar conflict, but i try isolate the jars used in generation, and the problem continues.
I can zip my project folder and send for anyone.
Help me please, because I'm staying crazy with this bug.
Thanks in advance,
Murilo Henrique Marecki Foltran
[b]Mapping documents:[/b]
[b]HahaPojo.java[/b]
/**
* @hibernate.class table = "haha"
*/
public class HahaPojo {
/**
* @return Retorna desc.
* @hibernate.property column = "desc"
*/
public String getDesc() {
return desc;
}
/**
* @return Retorna hehe.
* @hibernate.set inverse="true" cascade = "all-delete-orphan"
* @hibernate.collection-key column = "haha"
* @hibernate.collection-one-to-many class = "HehePojo"
*/
public Set getHehe() {
return hehe;
}
/**
* @return Retorna id.
* @hibernate.id column = "id"
*/
public Long getId() {
return id;
}
/**
* @param desc desc é setado.
*/
public void setDesc(String desc) {
this.desc = desc;
}
/**
* @param hehe hehe é setado.
*/
public void setHehe(Set hehe) {
this.hehe = hehe;
}
/**
* @param id id é setado.
*/
public void setId(Long id) {
this.id = id;
}
public HahaPojo() {
super();
}
private Long id;
private String desc;
private Set hehe;
}
[b]HehePojo.java[\b]
* @hibernate.class table = "hehe"
*/
public class HehePojo {
/**
* @return Retorna desc.
* @hibernate.property column = "desc"
*/
public String getDesc() {
return desc;
}
/**
* @return Retorna hehePojo.
* @hibernate.many-to-one class = "HahaPojo" column = "haha" not-null = "true"
*/
public HahaPojo getHahaPojo() {
return hahaPojo;
}
/**
* @return Retorna id.
* @hibernate.id column = "id"
*/
public Long getId() {
return id;
}
/**
* @param desc desc é setado.
*/
public void setDesc(String desc) {
this.desc = desc;
}
/**
* @param hahaPojo hehePojo é setado.
*/
public void setHahaPojo(HahaPojo hahaPojo) {
this.hahaPojo = hahaPojo;
}
/**
* @param id id é setado.
*/
public void setId(Long id) {
this.id = id;
}
public HehePojo() {
super();
}
private Long id;
private String desc;
private HahaPojo hahaPojo;
}
The generated hbm.xml files:
[b]HehePojo.hbm.xml[\b]
<hibernate-mapping>
<class name="HehePojo" table="hehe" >
<id name="id" column="id" type="java.lang.Long">
<generator class="">
</generator>
</id>
<property name="desc" type="java.lang.String"
column="desc" />
<many-to-one name="hahaPojo" class="HahaPojo"
cascade="none" outer-join="auto" column="haha"
not-null="true" />
</class>
</hibernate-mapping>
[b]HahaPojo.hbm.xml[\b]
<hibernate-mapping>
<class name="HahaPojo" table="haha" >
<id name="id" column="id" type="java.lang.Long" >
<generator class="">
</generator>
</id>
<property name="desc" type="java.lang.String"
column="desc" />
<set name="hehe" lazy="false" cascade="all-delete-orphan"
sort="unsorted" >
<key column="haha" >
</key>
<one-to-many class="HehePojo" />
</set>
</class>
</hibernate-mapping>
[b]The build.xml is here:[\b]
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="haha" default="clean" basedir=".">
<property environment="env" />
<property file="build.properties" />
<property name="project.hierarchy" value="0250"/>
<path id="classpath">
<pathelement location="${src.dir}" />
<pathelement location="${bin.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="classpath.hibernate">
<pathelement location="${src.dir}" />
<pathelement location="${bin.dir}" />
<fileset dir="${base.dir}/libant">
<include name="**/*.jar" />
</fileset>
<fileset dir="${lib.dir}">
<include name="**/hibernate2.jar" />
<include name="**/dom4j-1.4.jar" />
<include name="**/odmg-3.0.jar" />
</fileset>
</path>
<target name="clean" description="limpa o projeto">
<delete>
<fileset dir="${src.dir}">
<include name="**/*.hbm.xml" />
<include name="hibernate.properties" /> </fileset>
<fileset dir="${bin.dir}">
<include name="**/*.*" />
</fileset>
<fileset dir="${base.dir}">
<include name="*.sql" />
</fileset>
</delete>
</target>
<target name="prepare" description="prepara o projeto">
<tstamp>
<format property="data.atual" pattern="yyyyMMdd" />
</tstamp>
<property name="tag.atual" value="-v${data.atual}" />
<copy todir="${bin.dir}" overwrite="true">
<fileset dir="${src.dir}" includes="**/*.properties" />
</copy>
<propertyfile file="${bin.dir}/hibernate.properties">
<entry key="hibernate.connection.driver_class" value="${connection.driver_class}"/>
<entry key="hibernate.connection.url" value="${connection.url}"/>
<entry key="hibernate.connection.username" value="${connection.username}"/>
<entry key="hibernate.connection.password" value="${connection.password}"/>
<entry key="hibernate.dialect" value="${connection.dialect}"/>
</propertyfile>
</target>
<target name="compile" depends="clean,prepare" description="compila">
<javac debug="true" classpath="classpath" srcdir="${src.dir}" destdir="${bin.dir}">
<classpath>
<path refid="classpath"/>
</classpath>
</javac>
</target>
<target name="generate-hbm" depends="compile">
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask"
classpathref="classpath.hibernate" />
<hibernatedoclet destdir="${src.dir}" >
<fileset dir="${src.dir}">
<include name="**/*Pojo.java"/>
</fileset>
<hibernate version="2.1"/>
</hibernatedoclet>
<copy todir="${bin.dir}" overwrite="true">
<fileset dir="${src.dir}" includes="**/*Pojo.hbm.xml" />
</copy>
</target>
</project>[/code]
|