-->
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.  [ 4 posts ] 
Author Message
 Post subject: Lazy collections are loaded during commit
PostPosted: Wed Dec 17, 2003 10:14 pm 
Newbie

Joined: Wed Dec 17, 2003 9:24 pm
Posts: 2
In my application I am loading some of the objects that are needed in that session and creating new object. During save we haven't seen insert statement. Finally during the transaction commit, I noticed that lazy collections of the retrieved objects are loaded though they were not accessed. What could be wrong?

Note: I am using 2.1 final and show_SQL is true.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 5:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The database operations are sent during the flush call (or commit as flush is implied). Not sure about your loading issue - it will depend on the mappings, what collection type you have mapped etc. No enough information.


Top
 Profile  
 
 Post subject: Lazy collections are loaded during commit
PostPosted: Fri Dec 19, 2003 2:14 pm 
Newbie

Joined: Wed Dec 17, 2003 9:24 pm
Posts: 2
Here is my Mapping & Class

=============
<!-- Folder Model definition -->
<class name="xxxx.bizcomponent.dms.model.Folder" table="folder" dynamic-update="true">
<id name="ObjectId" type="string" column="FolderId">

<generator class="assigned"/>
</id>
<property name="Name"/>
<property name="Title"/>
<property name="LockStatus" type="boolean"/>
<!-- Documents to Folder -->
<set name="ChildDocuments" table="Document" inverse="true" lazy="true">
<key column="FolderId"/>
<one-to-many class="xxxx.bizcomponent.dms.model.Document"/>
</set>
<!-- Folder Folder Relation -->
<set name="ChildFolders" table="folder" inverse="true" lazy="true">
<key column="ParentId"/>
<one-to-many class="xxxx.bizcomponent.dms.model.Folder"/>
</set>

<many-to-one name="ParentFolder" column="ParentId" class="xxxx.bizcomponent.dms.model.Folder" not-null="true"/ -->
</class>

===========


package xxxx.xxxx.dms.model;

import java.lang.*;
import java.util.*;
import java.sql.Date;
import zzz.bizcomponent.admin.model.* ;


/**
* @author
* @see
* @since
* @version
*/
public class Folder extends BaseModel
{
// variables for holding the Folder properties.



private static String NAME = "Name";
private static String TITLE = "Title" ;
private static String LOCKSTATUS = "LockStatus" ;
private static String CHILDDOCUMENTS = "childDocuments";
private static String CHILDFOLDERS = "childFolders";
private static String PARENT_FOLDER = "parentFolder";



/**
* Sets the name of the Folder
* @param title
* @return void
* @exception
* @author
*/
public void setName(String name)
{
setProperty(NAME, (Object)name);
}

/**
* Returns the Name of the Folder
* @return String
* @exception
* @author
*/
public String getName()
{
return (String)getProperty(NAME);
}



/**
* Sets the title of the Folder
* @param title
* @return void
* @exception
* @author
*/
public void setTitle(String title)
{
setProperty(TITLE, (Object)title);
}

/**
* Returns the Title of the Folder
* @return String
* @exception
* @author
*/
public String getTitle()
{
return (String)getProperty(TITLE);
}


/**
This method thes the Lock status of the folder
*/
public void setLockStatus(boolean status)
{
setProperty(LOCK_STATUS, status);

}

/**
This method returns the Lock Status of the Folder
*/
public boolean getLockStatus()
{
return getPropertyAsBoolean(LOCK_STATUS);
}




/**
Sets the document Objects
*/

public void setChildDocuments(Set childDocs)
{
if ( childDocs != null )
{
setProperty(CHILDDOCUMENTS, (Object)childDocs);
}
}

/**
Returns the document Objects
*/

public Set getChildDocuments()
{
Set dSet = (Set)getProperty((Object)CHILDDOCUMENTS);

return dSet;
}

/**
Sets the folder Objects
*/

public void setChildFolders(Set childFlds)
{
if ( childFlds != null )
{
setProperty(CHILDFOLDERS, (Object)childFlds);
}
}

/**
Returns the Folder Objects
*/

public Set getChildFolders()
{
Set fSet = (Set) getProperty((Object)CHILDFOLDERS);

return fSet;


}

/**
* Sets the Parent Folder of the Folder
* @param Folder folder
* @return void
*/
public void setParentFolder(Folder parentFolder)
{
setProperty(PARENT_FOLDER, parentFolder);
}

/**
* Returns the Parent Folder of the Folder
* @return Folder parent folder
* @exception
* @author
*/
public Folder getParentFolder()
{
return (Folder)getProperty(PARENT_FOLDER);
}



}
===========

During create new folder, parent folder is just loaded in the session and set as parent folder in child and not accessed any collection methods. But after commit, I noticed that lazy collection of parent Folder (Documents and ChildFolders) are initialized even though lazy is set to true.

(Note: All the Object properties are stored in Hashtable that is there in BaseModel)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Put the Hibernate src in your sourcepath, and use your debugger to find where your code causes the collections to be initialized.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.