-->
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: Null value matters ?
PostPosted: Thu Sep 04, 2003 9:01 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
I have one Catalog class which has the following mapping file.
For example, the catalog table has such record:

id | name | iconurl | pid
1 AAA NULL NULL
2 BBB NULL 1
3 CCC NULL 2

I want to get certain catalog's path up to top most parent with the following code piece:
while (true) {
parentCatalog = catalog.getCatalog();
if (parentCatalog == null) {
break;
}
System.err.println("@ converted path is "+ convertedPath);
convertedPath = parentCatalog.getName() + convertedPath;
};

But the loop never exits. It seems catalog.getCatalog() always returns the valid top most catalog object (id = 1) along the path even when its pid is NULL.
What's wrong here ?

Any help is appreciated !


Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class
        name="hibernate.Catalog"
        table="catalog"
        proxy="hibernate.Catalog"
        dynamic-update="false"
        dynamic-insert="false"
        mutable="true"
    >

        <id
            name="id"
            column="id"
            type="long"
            unsaved-value="null"
        >
            <generator class="native">
            </generator>
        </id>

        <property
            name="name"
            type="java.lang.String"
            update="true"
            insert="true"
            column="name"
            not-null="false"
            unique="false"
        />

        <property
            name="iconUrl"
            type="java.lang.String"
            update="true"
            insert="true"
            column="iconurl"
            not-null="false"
            unique="false"
        />

        <many-to-one
            name="catalog"
            class="hibernate.Catalog"
            cascade="none"
            outer-join="false"
            update="true"
            insert="true"
            column="pid"
            unique="false"
        />

        <set
            name="subCatalogs"
            table="Catalog"
            lazy="true"
            inverse="false"
            cascade="delete"
            sort="unsorted"
        >

              <key
                  column="pid"
              />

              <one-to-many
                  class="hibernate.Catalog"
              />
        </set>

        <set
            name="objectiveQuestions"
            table="objectiveQuestion"
            lazy="true"
            inverse="false"
            cascade="delete"
            sort="unsorted"
        >

              <key
                  column="cid"
              />

              <one-to-many
                  class="hibernate.QuestionObjective"
              />
        </set>

        <set
            name="subjectiveQuestions"
            table="subjectiveQuestion"
            lazy="true"
            inverse="true"
            cascade="delete"
            sort="unsorted"
        >

              <key
                  column="cid"
              />

              <one-to-many
                  class="hibernate.QuestionSubjective"
              />
        </set>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Catalog.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject: Ah! It's my fault :(
PostPosted: Thu Sep 04, 2003 9:09 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 11:33 pm
Posts: 38
dumb coder :(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 04, 2003 10:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Bet you wish you could delete this one :)


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.