<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0"
           targetNamespace="urn:infinispan:config:store:jdbc:9.0"
           xmlns:tns="urn:infinispan:config:store:jdbc:9.0"
           xmlns:config="urn:infinispan:config:9.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import namespace="urn:infinispan:config:9.0"
             schemaLocation="http://www.infinispan.org/schemas/infinispan-config-9.0.xsd" />

  <xs:element name="string-keyed-jdbc-store" type="tns:string-keyed-jdbc-store"/>
  <xs:element name="binary-keyed-jdbc-store" type="tns:binary-keyed-jdbc-store"/>
  <xs:element name="mixed-keyed-jdbc-store" type="tns:mixed-keyed-jdbc-store"/>

  <xs:complexType name="jdbc-store" abstract="true">
    <xs:complexContent>
      <xs:extension base="config:store">
        <xs:sequence>
          <xs:choice minOccurs="1" maxOccurs="1">
            <xs:element name="connection-pool" type="tns:connection-pool" />
            <xs:element name="data-source" type="tns:data-source" />
            <xs:element name="simple-connection" type="tns:simple-connection" />
          </xs:choice>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="string-keyed-jdbc-store">
    <xs:complexContent>
      <xs:extension base="tns:jdbc-store">
        <xs:sequence>
          <xs:element name="string-keyed-table" type="tns:string-keyed-table" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Defines the table used to store cache entries.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="binary-keyed-jdbc-store">
    <xs:complexContent>
      <xs:extension base="tns:jdbc-store">
        <xs:sequence>
          <xs:element name="binary-keyed-table" type="tns:binary-keyed-table" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Defines the table used to store cache buckets.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="mixed-keyed-jdbc-store">
    <xs:complexContent>
      <xs:extension base="tns:jdbc-store">
        <xs:sequence>
          <xs:element name="binary-keyed-table" type="tns:binary-keyed-table" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Defines the table used to store cache buckets.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="string-keyed-table" type="tns:string-keyed-table" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Defines the table used to store cache entries.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="string-keyed-table">
    <xs:complexContent>
      <xs:extension base="tns:table">
        <xs:attribute name="prefix" type="xs:string" default="ispn_entry">
          <xs:annotation>
            <xs:documentation>Defines the prefix prepended to the cache name used when composing the name of the cache entry table.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="binary-keyed-table">
    <xs:complexContent>
      <xs:extension base="tns:table">
        <xs:attribute name="prefix" type="xs:string" default="ispn_bucket">
          <xs:annotation>
            <xs:documentation>Defines the prefix prepended to the cache name used when composing the name of the cache bucket table.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="table">
    <xs:sequence>
      <xs:element name="id-column" type="tns:id-column" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Defines the column in which to store the cache key or bucket id.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="data-column" type="tns:data-column" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Defines the column in which to store the cache entry or bucket.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="timestamp-column" type="tns:timestamp-column" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Defines the column in which to store the timestamp of the cache entry or bucket.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="fetch-size" type="xs:int" default="100">
      <xs:annotation>
        <xs:documentation>The fetch size used when querying from this table.  Used to avoid heap memory exhaustion when query is large.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="batch-size" type="xs:int" default="100">
      <xs:annotation>
        <xs:documentation>The statement batch size used when modifying this table.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="create-on-start" type="xs:boolean" default="true">
        <xs:annotation>
           <xs:documentation>Determines whether database tables should be created by the store on startup.</xs:documentation>
        </xs:annotation>
     </xs:attribute>
     <xs:attribute name="drop-on-exit" type="xs:boolean" default="false">
        <xs:annotation>
           <xs:documentation>Determines whether database tables should be dropped by the store on shutdown.</xs:documentation>
        </xs:annotation>
     </xs:attribute>
  </xs:complexType>

  <xs:complexType name="id-column">
    <xs:attribute name="name" type="xs:string" default="id">
      <xs:annotation>
        <xs:documentation>The name of the column used to store the cache key or bucket id.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="type" type="xs:string" default="VARCHAR">
      <xs:annotation>
        <xs:documentation>The type of the column used to store the cache key or bucket id.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="data-column">
    <xs:attribute name="name" type="xs:string" default="datum">
      <xs:annotation>
        <xs:documentation>The name of the column used to store the cache entry or bucket.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="type" type="xs:string" default="BINARY">
      <xs:annotation>
        <xs:documentation>The type of the column used to store the cache entry or bucket.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="timestamp-column">
    <xs:attribute name="name" type="xs:string" default="version">
      <xs:annotation>
        <xs:documentation>The name of the column used to store the cache entry or bucket timestamp.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="type" type="xs:string" default="BIGINT">
      <xs:annotation>
        <xs:documentation>The type of the column used to store the cache entry or bucket timestamp.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="connection-pool">
    <xs:attribute name="connection-url" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          A JDBC driver-specific connection URL
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="driver" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The class name of the driver used for connecting to the database.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="password" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The password to use when connecting via connectionUrl
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="username" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The username to use when connecting via connectionUrl
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="data-source">
    <xs:attribute name="jndi-url" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The address of a datasource to use when connecting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="simple-connection">
    <xs:attribute name="connection-url" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          A JDBC driver-specific connection URL
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="driver" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The class name of the driver used for connecting to the database.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="password" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The password to use when connecting via connectionUrl
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="username" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The username to use when connecting via connectionUrl
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

</xs:schema>
