-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Description
Considering the following xml custom mapper for a Manager entity :
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.repository.userManagement.ManagerRepository">
<!--<cache />-->
<!-- Is it possible to reuse the spring-data-mybatis instead of writing this one -->
<resultMap id="managerResultMap" type="com.domain.userManagement.Manager">
<id property="id" column="id" />
<result property="login" column="login" jdbcType="VARCHAR" javaType="string" />
<result property="roleList" column="roleList" jdbcType="BLOB" typeHandler="com.typeHandler.RoleListTypeHandler" />
<result property="password" column="password" jdbcType="VARCHAR" javaType="string" />
<result property="version" column="version" jdbcType="BIGINT" javaType="long" />
<result property="active" column="active" jdbcType="BOOLEAN" javaType="boolean" />
<result property="creationDateTime" column="creationDateTime" jdbcType="DATE" typeHandler="com.typeHandler.DateTimeTypeHandler" />
<result property="modificationDateTime" column="modificationDateTime" jdbcType="DATE" typeHandler="com.typeHandler.DateTimeTypeHandler" />
</resultMap>
<!-- Is it possible to reuse the spring-data-mybatis instead of writing this one -->
<sql id="getManagerSelect">
SELECT
manager.`ID` as 'id',
manager.`LOGIN` as 'login',
manager.`ROLES` as 'roleList',
manager.`PASSWORD` as 'password',
manager.`VERSION` as 'version',
manager.`CREATION_DATETIME` as 'creationDateTime',
manager.`MODIFICATION_DATETIME` as 'modificationDateTime',
manager.`ACTIVE` as 'active'
</sql>
<!-- Is it possible to reuse the spring-data-mybatis instead of writing this one -->
<sql id="getManagerFrom">
FROM
`MANAGER` manager
</sql>
<!-- So it will be possible to write small queries like this -->
<select id="find" resultType="com.domain.userManagement.Manager" parameterType="Long">
<include refid="getManagerSelect" />
<include refid="getManagerFrom" />
<if test="pk">
WHERE manager.`ID` = #{pk.value}
</if>
</select>
<!-- This is a delete override only for that entity -->
<delete id="delete" parameterType="com.domain.userManagement.Manager">
UPDATE
`MANAGER`
SET
`ACTIVE` = 1
<if test="pk">
WHERE `ID` = #{pk.value}
</if>
</delete>
</mapper>I would like to know if it is possible to :
- override default
deletequery for a single entity like in this xml - how is it possible to change
repository.delete()andrepository.deleteAll()for doing it on all entities - reuse the
spring-data-mybatisgeneratedresultMapso I don't need to maintain my own (for example by knowing in advance the resultMap id.
Note:
I really wouldn't do that. That would radically change the contract of these two methods but I need to know if these extends can be set up.