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

<!--
      metadataKey         integer not null,
      id                  integer generated always as identity ( start with 1 ) primary key,
      latest              varchar(100) not null,
      release             varchar(100) not null,
      lastUpdated         integer not null,
      snapshotTimestamp   integer not null,
      snapshotBuildNumber integer not null,
      snapshotLocalCopy   char(1) not null,
      foreign key( metadataKey ) references MetadataKeys( metadataKey )
-->

<sqlMap namespace="RepositoryMetadata">

<select id="getRepositoryMetadata" 
	parameterClass="org.apache.maven.archiva.database.key.MetadataKey"
	resultClass="org.apache.maven.artifact.repository.metadata.Metadata">
  SELECT 
    mk.groupId AS groupId,
    mk.artifactId AS artifactId,
    mk.version AS baseVersion,
 	rm.latest AS latest,
 	rm.release AS release,
 	rm.lastUpdated AS lastUpdated	
  FROM RepositoryMetadata rm, MetadataKeys mk
  WHERE 
    mk.metadataKey = rm.metadataKey
    AND mk.metadataKey = #metadataKey# 
</select> 

<!--
<insert id="addRepositoryMetadata" parameterClass="org.apache.maven.artifact.repository.metadata.Metadata"> 
  INSERT INTO 
  RepositoryMetadata  ( latest, release, lastUpdated ) 
  VALUES ( #latest#, #release#, #lastUpdated# ) 
</insert> 
-->

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

</sqlMap>