-->
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.  [ 2 posts ] 
Author Message
 Post subject: Null values in many-to-many list
PostPosted: Mon Apr 05, 2004 2:53 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
I am using Hibernate 2.1.2 with SAPDB 7.4.

The following is the mapping in use for this question

Code:
<list name="assignedFunctionList" table="USERGROUPFUNCTIONS"
    lazy="true" inverse="false" cascade="all">

  <key column="USERGROUPID" />
  <index column="USERGROUPFUNCTIONID" />
  <many-to-many
      class="com.foo.bar.beans.site.access.Function"
      column="FUNCTIONID"
      outer-join="false"
  />
</list>


The relationship is used to get a list of assigned Function objects for a UserGroup.

Here is the code to get the many-to-many populated.

Code:
hibernateSession = HibernateManager.currentSession();
userGroup = (UserGroup) hibernateSession.load(UserGroup.class, userGroupId);

/**  load lazy objects */
logger.debug("preparing to get functionList: " + userGroup.getAssignedFunctionList());
List functionList = userGroup.getAssignedFunctionList();
logger.debug("functionList has size: " + functionList.size());


There are two relationships in the database for this mapping. However, the following are the log results I get for the two debug messages.

    DEBUG [com.foo.bar.dao.site.access.UserGroupDAO] - preparing to get functionList: [null, null, null, null, com.foo.bar.beans.site.access.Function@eb840f, com.foo.bar.beans.site.access.Function@16602cb]
    DEBUG [com.foo.bar.dao.site.access.UserGroupDAO] - functionList has size: 6
The table structure is as follows

    TABLE USERGROUPS
    USERGROUPID INTEGER PK

    TABLE FUNCTIONS
    FUNCTIONID INTEGER PK

    TABLE USERGROUPFUNCTIONS
    USERGROUPFUNCTIONID INTEGER PK
    USERGROUPID INTEGER FK
    FUNCTIONID INTEGER FK
I am curious as to why it returned 6 objects, 4 of which were null. I executed the query used by hibernate (from stdout.log) in the database client and got 2 rows back. I went ahead and used an Iterator to clean out the null objects but I was wondering if there was something I might be doing wrong that could cause this.

    1. Am I doing the right thing in doing the lazy load with the following: List functionList = userGroup.getAssignedFunctionList();
    2. Shouldn't the outer-join="false" ensure that I get back only those columns that are complete matches?


This is a really strange question and I don't know how else to explain it. Please let me know if I can give additional information.

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 6:00 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Please refer the doc and FAQ on List. Hibernate strictly obey the List semantic.

_________________
Emmanuel


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