<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
    default-lazy="false"
    auto-import="true"
    default-access="property"
    default-cascade="all"
    package="gov.va.med.esr.common.model.comms">

	<class name="Directory" table="DIRECTORY">

        <id name="identifier" type="big_decimal" column="DIRECTORY_ID">
            <generator class="gov.va.med.fw.persistent.hibernate.BigSequenceGenerator">
                <param name="sequence">transaction_s</param>
            </generator>
        </id>
		<version name="version" type="java.lang.Integer" column="RECORD_MODIFIED_COUNT"/>
		
		<property name="inUseFlag" type="string" column="IN_USE_FLAG"/>
		<property name="name" type="string" column="NAME"/>
		
		<many-to-one
            name="applicationInfo"
            class="gov.va.med.esr.common.model.comms.ApplicationInfo"
            outer-join="false"
            cascade="none">
            <column name="APPLICATION_ID" />
        </many-to-one>		
		
		<many-to-one
            name="mountPoint"
            class="gov.va.med.esr.common.model.comms.MountPoint"
            outer-join="false"
            cascade="none">
            <column name="MOUNT_POINT_ID" />
        </many-to-one>

		<!-- ADR required attributes -->
        <property name="createdOn" column="RECORD_CREATED_DATE" type="timestamp" not-null="true" update="false"/>
        <property name="modifiedOn" column="RECORD_MODIFIED_DATE" type="timestamp" not-null="true"/>
		<property name="createdBy" column="RECORD_CREATED_BY" update="false" type="gov.va.med.fw.persistent.hibernate.AuditUserType"/> 
		<property name="modifiedBy" column="RECORD_MODIFIED_BY" type="gov.va.med.fw.persistent.hibernate.AuditUserType"/>		
	</class>
	
	<query name="findActiveVBADirectory">
        FROM   Directory dir
        WHERE  dir.inUseFlag = :inUseFlag
    </query>
</hibernate-mapping>
