-->
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.  [ 3 posts ] 
Author Message
 Post subject: avoiding import to base class
PostPosted: Fri Feb 27, 2004 6:22 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 12:53 pm
Posts: 23
Hi,

I'm using hbm2java with a base class.

Code:
    <class name="com.wgh.Tenant" table="tenant" >
            <meta attribute="generated-class">com.wgh.base.Tenant</meta>
            <id name="tenant_id" column="tenant_id" type="long" unsaved-value="null">
                    <generator class="identity"/>
            </id>

            <many-to-one name="original_tenant_record" column="original_tenant_id" class="com.wgh.Tenant"/>

</class>


My problem is that since there is a relationship to itself, when hbm2java is run an illegal import is generated. Any suggestions how to eliminate this import?

My class:

Code:
package com.wgh.om;

public class Tenant extends com.wgh.base.Tenant {
}


Generated class:

Code:
package com.wgh.base;

import com.wgh.Tenant;
import java.io.Serializable;
import java.util.Date;
import java.util.SortedSet;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/** @author Hibernate CodeGenerator */
abstract public class Tenant implements Serializable {
...
}


The line "import com.wgh.Tenant" causes cyclical inheritance. Appreciate any tips.

WILL


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 28, 2004 5:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
That is not cyclic inheritance!?

It is your baseclass that now refers to a subclass....that is normally messy - but legal java code?!

Remember you need to actually write the com.wgh.Tenant class before you can compile this!

If you don't want your base.Tenant refer the real Tenant then you can just use <meta attribute="property-type">com.wgh.base.Tenant</meta> for the original_tenant_record...but then you will probably get some weird problems with hibernate expecting it to be a Tenant and not a base.Tenant!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 8:24 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 12:53 pm
Posts: 23
Hi,

You're right, the problem is different than I first thought.

The issue is actually that the generated class tries to import "com.wgh.Tenant" but there is a name conflict with the class itself. I'll change the name and see if this helps.

WILL


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