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)
|