Skip to content
Snippets Groups Projects
DbXRef.xml 2.39 KiB
Newer Older
tjc's avatar
tjc committed
<?xml version="1.0" encoding="UTF-8" ?> 
 
<!DOCTYPE sqlMap 
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" 
    "http://ibatis.apache.org/dtd/sql-map-2.dtd"> 
 

tjc's avatar
tjc committed
<sqlMap namespace="DbXRef"> 
tjc's avatar
tjc committed

tjc's avatar
tjc committed
  <typeAlias alias="DbXRef"
        type="org.gmod.schema.general.DbXRef"/>
tjc's avatar
tjc committed
        
  <resultMap id="select-dbxref-lazy" 
               class="DbXRef">
    <result property="dbXRefId"    column="dbxref_id"/>           
    <result property="db"          column="db_id" select="getDbByDbId"/>
    <result property="accession"   column="accession"/>
    <result property="version"     column="version"/>
    <result property="description" column="description"/>
  </resultMap>
	
tjc's avatar
tjc committed
  <resultMap id="select-dbxref" 
               class="DbXRef">
tjc's avatar
tjc committed
    <result property="dbXRefId"    column="dbxref_id"/>           
tjc's avatar
tjc committed
    <result property="accession"   column="accession"/>
    <result property="version"     column="version"/>
    <result property="description" column="description"/>
	<result property="db"   resultMap="Db.select-db"/>
tjc's avatar
tjc committed
  </resultMap>
tjc's avatar
tjc committed
  
tjc's avatar
tjc committed
  <select id="getDbXRefId" parameterClass="DbXRef"
tjc's avatar
tjc committed
                           resultClass="java.lang.Integer">
    SELECT dbxref_id FROM dbxref WHERE accession=#accession#
tjc's avatar
tjc committed
           AND db_id=$db.dbId$
tjc's avatar
tjc committed
  </select>
  
  <select id="getDbXRefByDbXRefIdLazy" resultMap="select-dbxref-lazy">
tjc's avatar
tjc committed
    SELECT * FROM dbxref WHERE dbxref_id=$dbXRefId$
tjc's avatar
tjc committed
  </select>
	
  <select id="getDbXRefByDbXRefId" resultMap="select-dbxref">
	SELECT * FROM dbxref LEFT JOIN db ON dbxref.db_id=db.db_id WHERE dbxref_id=$dbXRefId$
  </select>
tjc's avatar
tjc committed
  
tjc's avatar
tjc committed
  <select id="getDbXRef" parameterClass="DbXRef"
                         resultMap="select-dbxref">
    SELECT * FROM dbxref 
    <dynamic>
      <isNotNull property="db">
        LEFT JOIN db ON db.db_id=dbxref.db_id 
      </isNotNull>
      WHERE
      <isGreaterThan property="dbXRefId" compareValue="0">
        dbxref_id=$dbXRefId$
      </isGreaterThan>
      <isEqual property="dbXRefId" compareValue="0">
        accession=#accession#
      </isEqual>
      <isNotNull property="db">
        AND db.name=#db.name# 
      </isNotNull>
    </dynamic>
  </select>
  
tjc's avatar
tjc committed
  
tjc's avatar
tjc committed
  <!-- WRITE BACK -->
tjc's avatar
tjc committed
  <insert id="insertDbXRef" parameterClass="DbXRef">
tjc's avatar
tjc committed
    INSERT INTO dbxref ( db_id, accession <isNotNull property="version"> ,version   </isNotNull>) 
           VALUES ($db.dbId$, #accession# <isNotNull property="version"> ,#version# </isNotNull>)
tjc's avatar
tjc committed
  </insert>    
tjc's avatar
tjc committed

</sqlMap>