<?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.ee">

    <class
        name="VoaFileAttachment"
        table="FILE_ATTACHMENT">

        <id
            name="identifier"
            type="big_decimal"
            column="FILE_ATTACHMENT_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">
        </version>

 <many-to-one name="voaApplication" class="gov.va.med.esr.common.model.person.VOAApplication" 
 			outer-join="false" cascade="none" update="false" column="VOA_ENROLLMENT_APP_ID" />

		<property
            name="personId"
            type="java.math.BigDecimal"
            column="PERSON_ID">
        </property>	
		

        <property
            name="fileName"
            type="java.lang.String"
            column="FILE_NAME">
        </property>
				
        <property
            name="fileMimeType"
            type="java.lang.String"
            update="true"
            column="FILE_MIME_TYPE">
        </property>
				
        <property
            name="attachmentReviewUserName"
            type="java.lang.String"
            update="true"
            column="ATTACHMENT_REVIEW_USERNAME">
        </property>
        <property
            name="attachmentReviewDate"
            type="java.util.Date"
            update="true"
            column="ATTACHMENT_REVIEW_DATE">
        </property>
  
       <set name="internalAttachmentDetails" lazy="false" inverse="true" cascade="all-delete-orphan">
            <key column="FILE_ATTACHMENT_ID" />
            <one-to-many class="gov.va.med.esr.common.model.ee.VoaFileAttachmentDetail" />
       </set>

<set name="internalAttachmentImages" lazy="false" inverse="true" cascade="all-delete-orphan">
            <key column="FILE_ATTACHMENT_ID" />
            <one-to-many class="gov.va.med.esr.common.model.ee.VoaFileAttachmentImage" />
       </set>
 		<property
            name="attchmentAcceptableInd"
            type="boolean"
            column="ATTACHMENT_ACCEPTABLE_IND">
        </property>
		
        <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="findAttachmentByPersonId">
        FROM   VoaFileAttachment attach
        WHERE  attach.personId = :personId
    </query>
 
</hibernate-mapping>
