<?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="alfresco.propval">

    <insert id="insert_PropertyClass" parameterClass="PropertyClass" >
        
        <selectKey resultClass="long" keyProperty="id">
            select nextVal('alf_prop_class_seq')
        </selectKey>
        
        insert into alf_prop_class (id, java_class_name, java_class_name_short, java_class_name_crc) 
        values (#id#, #javaClassName#, #javaClassNameShort#, #javaClassNameCrc#)
    </insert>

    <insert id="insert_PropertyStringValue" parameterClass="PropertyStringValue" >
        
        <selectKey resultClass="long" keyProperty="id">
            select nextVal('alf_prop_string_value_seq')
        </selectKey>
        
        insert into alf_prop_string_value (id, string_value, string_end_lower, string_crc) 
        values (#id#, #stringValue#, #stringEndLower#, #stringCrc#)
        
    </insert>

    <insert id="insert_PropertyDoubleValue" parameterClass="PropertyDoubleValue" >
        
        <selectKey resultClass="long" keyProperty="id">
            select nextVal('alf_prop_double_value_seq')
        </selectKey>
        
        insert into alf_prop_double_value (id, double_value) 
        values (#id#, #doubleValue#)
        
    </insert>

    <insert id="insert_PropertySerializableValue" parameterMap="parameter_IdPropertySerializableValue" >
        
        <selectKey resultClass="long" keyProperty="id">
            select nextVal('alf_prop_serializable_value_seq')
        </selectKey>
        
        insert into alf_prop_serializable_value (id, serializable_value) 
        values (?, ?)
        
    </insert>

    <insert id="insert_PropertyValue" parameterClass="PropertyValue" >
        
        <selectKey resultClass="long" keyProperty="id">
            select nextVal('alf_prop_value_seq')
        </selectKey>
        
        insert into alf_prop_value (id, actual_type_id, persisted_type, long_value) 
        values (#id#, #actualTypeId#, #persistedType#, #longValue#)
        
    </insert>

    <insert id="insert_PropertyRoot" parameterMap="parameter_IdPropertyRoot" >
        <selectKey resultClass="long" keyProperty="id" type="pre">
            select nextVal('alf_prop_root_seq')
        </selectKey>
        <include refid="insert_PropertyValue_Sequence"/>
    </insert>

    <insert id="insert_PropertyUniqueContext" parameterClass="PropertyUniqueContext" >
        
        <selectKey resultClass="long" keyProperty="id">
            select nextVal('alf_prop_unique_ctx_seq')
        </selectKey>
        
        insert into alf_prop_unique_ctx (id, version, value1_prop_id, value2_prop_id, value3_prop_id) 
        values (#id#, #version#, #value1PropId#, #value2PropId#, #value3PropId#)
        
    </insert>

</sqlMap>