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

<hibernate-mapping default-cascade="all">
    <class entity-name="censusMasterIngest" name="gov.va.med.cds.scheduler.persistence.CensusMasterIngest" table="CENSUS_MASTER_INGEST" lazy="false"  >

        <id name="censusMasterId" type="java.lang.Long">
            <column name="CENSUS_MASTER_ID" />
            <generator class="assigned" />
        </id>
        
		<property name="reportStartDt" column="REPORT_START_DT" type="date" />
		<property name="vendorName" column="VENDOR_NAME" type="java.lang.String" />
		<property name="vendorFacility" column="VENDOR_FACILITY" type="java.lang.String" />
		<property name="segmentsExpectedCount" column="SEGMENTS_EXPECTED_CNT" type="java.lang.Long" />
		<property name="segmentsReceivedCount" column="SEGMENTS_RECEIVED_CNT" type="java.lang.Long" />
		<property name="segmentDateTime" column="SEGMENT_DATETIME" type="java.lang.String" />
		<property name="ingestStatus" column="INGEST_STATUS" type="java.lang.String" />
		<property name="ingestStatusDt" column="INGEST_STATUS_DT" type="date" />
		<property name="transformStatus" column="TRANSFORM_STATUS" type="java.lang.String" />
		<property name="transformStatusDt" column="TRANSFORM_STATUS_DT" type="date" />
		<property name="messageInsertionTime" column="MESSAGE_INSERTION_TIME" type="timestamp" />
		<property name="senderAddress" column="SENDER_ADDRESS" type="java.lang.String" />
		<property name="ingestExpireTime" column="INGEST_EXPIRE_TIME" type="timestamp" />
		<property name="ingestExpiredStatusTime" column="INGEST_EXPIRED_STATUS_TIME" type="timestamp" />
		
    </class>
    
	<query name="censusMasterIngest.list.expiredReports">
		<![CDATA[ from censusMasterIngest c where c.ingestStatus = 'PENDING' and c.ingestExpireTime < sysdate ]]>
	</query>
	
	<query name="censusMasterIngest.update.ingestStatus">
		<![CDATA[ update censusMasterIngest c set c.ingestStatus = 'EXPIRED' where c.censusMasterId = :censusMasterId ]]>
	</query>
	
</hibernate-mapping>
