#if( ${entity.getSuperClass()} )	
##継承している場合 ##
#set( $superClass = ${entity.getSuperClass()} )
#set( $superClassPk = ${superClass.getPrimaryKey()} )
#if( ${superClassPk.size()} == 1 )
	<key column="${superClassPk.getEntry(0).getProperty().getOriginal().getName()}" />
#end
#else
## 継承してない場合 ##
#if ( ${entity.getPrimaryKey().size()} < 1  )
###### 継承してなくて主キーがない ######
#elseif ( ${entity.getPrimaryKey().size()} == 1  )
###### 継承してなくて主キーのカラムがひとつ ######
#set( $keyEntry = ${entity.getPrimaryKey().getEntry(0)} )
#set( $keyEntryProp = ${keyEntry.getProperty()} )
#set( $keyEntryColumn = ${keyEntryProp.getOriginal()} )
#set( $dummy = $usedSet.add( $keyEntryProp ) )
#set( $hibernateColumnType = ${hibernateUtils.getHibernateType($keyEntryColumn.getJdbcType(), $keyEntryColumn.getSizeAsInt(), $keyEntryColumn.getDeciamlSizeAsInt() )} )
		<!-- $keyEntry.getName() -->
#set( $unsavedValueAttr = '' )
#if( ${keyEntryProp.getType().isNumber()} )
#set( $unsavedValueAttr = 'unsaved-value="0"' )
#end
	<id name="${keyEntryProp.getName()}" column="${keyEntryColumn.getName()}" type="${hibernateColumnType.getName()}" $unsavedValueAttr >
		<generator class="native" />
	</id>
#else
###### 継承してなくて主キーのカラムが複数 ######
	    <composite-id>
#foreach( $keyEntry in ${entity.getPrimaryKey().toList()} )
#set( $keyEntryProp = ${keyEntry.getProperty()} )
#set( $keyEntryColumn = ${java2rdb.get($keyEntryProp)} )
#set( $hibernateColumnType = ${hibernateUtils.getHibernateType( $keyEntryColumn.getJdbcType() )} )
#set( $dummy = ${usedSet.add( $keyEntryProp )} )
#set( $refList = ${keyEntryProp.getReferencesContainedAsLocal()} )
		<!-- $keyEntry.getName() -->
	#if( ${refList.size()} < 1 )
	        <key-property name="${keyEntryProp.getName()}" column="${keyEntryColumn.getName()}" type="${hibernateColumnType.getName()}"/>
	#else
		#foreach( $ref in $refList )
			#set( $dummy = $usedSet.add( $ref ) )
			#foreach( $refEntry in ${ref.toList()} )
				#set( $dummy = $usedSet.add( ${refEntry.getLocal()} ) )
			#end
	        <key-many-to-one name="${keyEntryProp.getName()}"
			#foreach( $refEntry in ${ref.toList()} ) #set($localCol = ${java2rdb.get($refEntry.getLocal())}) #end column="${localCol.getName()}"
			#set( $foreignClass = ${ref.getForeign()} )
				class="${foreignClass.getFqn()}" />
		#end
	#end
#end
	    </composite-id>    
#end
#end
