#set( $refClass = ${reference.getParent()} )
#set( $refPropName = ${reference.getPropertyNameInReferred()} )
#set( $refPropNameCapitalized = ${stringUtils.capitalize( $refPropName )} )

    private Set $refPropName = null;
    
	protected void set${refPropNameCapitalized}Internal(Set $refPropName) {
		this.$refPropName = $refPropName;
	}
	
	/**
#if( ${reference.size()} == 1 )
#set( $localColumn = ${reference.getEntry(0).getLocal().getOriginal()} )
	 * @hibernate.set lazy="true"
	 * @hibernate.collection-key column="${localColumn.getName()}"
	 * @hibernate.collection-one-to-many
#end
	 */
	protected Set get${refPropNameCapitalized}Internal() {
		if (this.$refPropName == null) {
			this.$refPropName = new HashSet();
		}
		return this.$refPropName;
	}

	public List get${refPropNameCapitalized}() {
		//final List sorted${refPropNameCapitalized} = new ArrayList(get${refPropNameCapitalized}Internal());
		//PropertyComparator.sort(sorted${refPropNameCapitalized}, new MutableSortDefinition("name", true, true));
		//return Collections.unmodifiableList(sorted${refPropNameCapitalized});
		return Collections.unmodifiableList( new ArrayList(get${refPropNameCapitalized}Internal()) );
	}

#set( $paramName = ${reference.getPropertyNameInReferred( false )} )
#set( $paramNameCapitalized = ${stringUtils.capitalize( $paramName )} )
	
	/**
	 * Add a ${refClass.getName()} to the List of ${refPropName}.
	 * @param $paramName New ${refClass.getName()} to be added to the List of ${paramName}
	 */
	public void add${paramNameCapitalized}(${refClass.getName()} $paramName) {
		get${refPropNameCapitalized}Internal().add($paramName);
#*
		if (this instanceof ${entity.getName()}) {
			if ( ${paramName}.get${stringUtils.capitalize($reference.getPropertyNameInLocal())}() != this)
				${paramName}.set${stringUtils.capitalize($reference.getPropertyNameInLocal())}((${entity.getName()}) this);
		}
*#
	}

	/**
	 * remove a ${refClass.getName()} to the List of ${refPropName}.
	 * @param $paramName ${refClass.getName()} to be removed to the List of ${refPropName}
	 */
	public void remove${paramNameCapitalized}(${refClass.getName()} $paramName) {
		get${refPropNameCapitalized}Internal().remove($paramName);
#*
		if ( ${paramName}.get${stringUtils.capitalize($reference.getPropertyNameInLocal())}() == this)
			${paramName}.set${stringUtils.capitalize($reference.getPropertyNameInLocal())}(null);
*#
	}

	/**
	 * contains a ${refClass.getName()} in the List of ${refPropName}.
	 * @param $paramName 
	 */
	public boolean contains${paramNameCapitalized}(${refClass.getName()} $paramName) {
		return (${refPropName} == null) ? false : ${refPropName}.contains($paramName);
	}
