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

<sqlMap namespace="MetadataKey">

<!-- 
this query can be improved by adding a lookup index based on these trinity of values
 -->
<select id="getMetadataKey" resultClass="org.apache.maven.archiva.database.key.MetadataKey">
  SELECT 
    metadataKey,
    groupId,
    artifactId,
    version
  FROM MetadataKeys 
  WHERE groupId = #groupId# and artifactId = #artifactId# and version = #version#
</select> 

<insert id="addMetadataKey" parameterClass="org.apache.maven.artifact.repository.metadata.Metadata"> 
  INSERT INTO 
  MetadataKeys  ( groupId, artifactId, version ) 
  VALUES ( #groupId#, #artifactId#, #version# ) 
</insert> 

<delete id="removeMetadataKey" parameterClass="org.apache.maven.archiva.database.key.MetadataKey">
	DELETE FROM
	MetadataKeys
	WHERE metadataKey=#metadataKey#
</delete>

</sqlMap>