-->
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.  [ 6 posts ] 
Author Message
 Post subject: inverse attribute in hibernate.set is not generated in hbm
PostPosted: Mon Apr 11, 2005 4:18 pm 
Newbie

Joined: Mon Apr 11, 2005 3:41 pm
Posts: 7
Location: Florianopolis, Brasil
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]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 11, 2005 4:32 pm 
Newbie

Joined: Mon Apr 11, 2005 3:41 pm
Posts: 7
Location: Florianopolis, Brasil
I using jdk 1.4.2


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 11, 2005 8:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Works fine for me. I know that does not help at all. Maybe (I did not try) it is an issue with spaces in your attributes, eg, cascase = "all" I would dump the spaces between the '=' and the attribute name and value. No idea if that would help but it was the one thing that stood out for me.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 8:29 am 
Newbie

Joined: Mon Apr 11, 2005 3:41 pm
Posts: 7
Location: Florianopolis, Brasil
I've tried with and without spaces and the inverse attribute never appears.

Now I'm trying verify a jar conflict, because in the most simple example don't works. He doesn't generated in hbm files.

By my experience, this crazy bugs occurs when jar conflicts exists.

Thanks in advance,

Murilo Henrique Marecki Foltran

ps.: losing my hair because this bug!!!! Going to the third day!!!!! :P


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 3:48 pm 
Newbie

Joined: Mon Apr 11, 2005 3:41 pm
Posts: 7
Location: Florianopolis, Brasil
The inverse attribute appears after change the "hibernate version" property in a build.xml from "2.1" to "2.0".
The tag <hibernate version="2.1"/> changed to <hibernate version="2.0"/> and works!!!!!!

Now the question is... this change cause some problem? Or not?

Regards,

Murilo Henrique Marecki Foltran


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 12, 2005 7:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
OK - I only ever have it set to 2.0 I am not sure why 2.1 version was introduced. Should create an XDoclet JIRA entry (if one does not exist) as I am aware of other options not showing up when using version 2.1 tag.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.