<?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 package="org.sakaiproject.metaobj.shared.model">

   <class name="StructuredArtifactDefinitionBean" table="metaobj_form_def">
      <id name="id" length="36" type="org.sakaiproject.metaobj.shared.IdType" column="id">
         <generator class="org.sakaiproject.metaobj.shared.IdentifiableIdGenerator"/>
      </id>
      <property name="description" type="string" column="description"/>
      <property name="documentRoot" type="string" column="documentRoot" not-null="true"/>
      <property name="owner" column="owner" not-null="true" type="org.sakaiproject.metaobj.shared.mgt.AgentUserType"/>
      <property name="created" type="java.util.Date" update="false" not-null="true"/>
      <property name="modified" type="java.util.Date" update="true" not-null="true"/>
      <property name="systemOnly" column="systemOnly" type="boolean" not-null="true"/>
      <property name="externalType" column="externalType" type="string" not-null="true"/>
      <property name="siteId" type="string" not-null="false"/>
      <property name="siteState" type="int" not-null="true"/>
      <property name="globalState" type="int" not-null="true"/>
      <property name="schema" column="schemaData" type="binary" not-null="true" length="2147483647"/>
      <property name="instruction" type="text"/>
      <property name="schemaHash" column="schema_hash" type="string"/>
   </class>
   
   
   <query name="findGlobalHomes">
      from StructuredArtifactDefinitionBean where ((siteId is null and (globalState = ? or owner = ?)) or globalState = 1)
   </query>
   
   <query name="findHomes">   
   	from StructuredArtifactDefinitionBean where globalState = ? or (siteId = ? and (owner = ? or siteState = ? )) 
	</query>
	
   <query name="loadHomeByExternalType">   	
		from StructuredArtifactDefinitionBean a where externalType=? AND (globalState=? OR siteId=?)
	</query>

   <query name="findByNullSchemaHash">   	
		from StructuredArtifactDefinitionBean a where schemaHash is null
	</query>

   <query name="findBean">   	
		from StructuredArtifactDefinitionBean where (globalState = ? or (siteState = ?  and siteId = ?)) and schema_hash = ?
	</query>

	
</hibernate-mapping>
