com.enterprisemath.dao.relational.MyBatisRelationMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of em-dao Show documentation
Show all versions of em-dao Show documentation
Simple and powerful data access layer.
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.enterprisemath.dao.relational.MyBatisRelationMapper"> <insert id="insertRelation"> insert into relations (code, subject_code, object_code, type) values (#{code}, #{subject_code}, #{object_code}, #{type}) </insert> <delete id="deleteRelation"> delete from relations where code = #{code} </delete> <select id="selectRelations" resultType="map"> select s.code as subject_code, s.name as subject_name, s.created_timestamp as subject_created_timestamp, s.parent_code as subject_parent_code, s.type as subject_type, o.code as object_code, o.name as object_name, o.created_timestamp as object_created_timestamp, o.parent_code as object_parent_code, o.type as object_type, r.type as type, r.code as code <if test="subjectJoins.size() > 0"> <foreach index="table" item="columns" collection="subjectJoins" open="" separator="" close=""> <foreach item="column" collection="columns" open="," separator="," close=""> subject_${table}.${column} as subject_${table}_${column} </foreach> </foreach> </if> <if test="objectJoins.size() > 0"> <foreach index="table" item="columns" collection="objectJoins" open="" separator="" close=""> <foreach item="column" collection="columns" open="," separator="," close=""> object_${table}.${column} as object_${table}_${column} </foreach> </foreach> </if> from relations r inner join entities s on r.subject_code = s.code inner join entities o on r.object_code = o.code <if test="subjectJoins.size() > 0"> <foreach index="table" item="columns" collection="subjectJoins" open="" separator="" close=""> inner join ${table} subject_${table} on subject_${table}.code = s.code </foreach> </if> <if test="objectJoins.size() > 0"> <foreach index="table" item="columns" collection="objectJoins" open="" separator="" close=""> inner join ${table} object_${table} on object_${table}.code = o.code </foreach> </if> <if test="filter.criteria.size() > 0"> where <foreach item="criterium" collection="filter.criteria" open="" separator=" and " close=""> ${criterium.column} <if test="criterium.operator.toString() == 'EQUAL'"> <if test="criterium.value == null"> is null </if> <if test="criterium.value != null"> = #{criterium.value} </if> </if> <if test="criterium.operator.toString() == 'NOT_EQUAL'"> <if test="criterium.value == null"> is not null </if> <if test="criterium.value != null"> != #{criterium.value} </if> </if> <if test="criterium.operator.toString() == 'LIKE'"> like #{criterium.value}</if> <if test="criterium.operator.toString() == 'IN'"> in ( <foreach item="value" collection="criterium.value" open="" separator=", " close=""> #{value} </foreach> ) </if> <if test="criterium.operator.toString() == 'LESS'"> < #{criterium.value}</if> <if test="criterium.operator.toString() == 'LESS_OR_EQUAL'"> <= #{criterium.value}</if> <if test="criterium.operator.toString() == 'GREATER'"> > #{criterium.value}</if> <if test="criterium.operator.toString() == 'GREATER_OR_EQUAL'"> >= #{criterium.value}</if> </foreach> </if> <if test="filter.orders.size() > 0"> order by <foreach item="order" collection="filter.orders" open="" separator="," close=""> ${order.column} <if test="order.direction.toString() == 'ASCENDANT'"> asc</if> <if test="order.direction.toString() == 'DESCENDANT'"> desc</if> </foreach> </if> offset #{filter.from} <if test="filter.limit != null"> limit #{filter.limit} </if> </select> <select id="countRelations" resultType="long"> select count(*) from relations r inner join entities s on r.subject_code = s.code inner join entities o on r.object_code = o.code <if test="subjectTables.size() > 0"> <foreach item="table" collection="subjectTables" open="" separator="" close=""> inner join ${table} subject_${table} on subject_${table}.code = s.code </foreach> </if> <if test="objectTables.size() > 0"> <foreach item="table" collection="objectTables" open="" separator="" close=""> inner join ${table} object_${table} on object_${table}.code = o.code </foreach> </if> <if test="criteria.size() > 0"> where <foreach item="criterium" collection="criteria" open="" separator=" and " close=""> ${criterium.column} <if test="criterium.operator.toString() == 'EQUAL'"> <if test="criterium.value == null"> is null </if> <if test="criterium.value != null"> = #{criterium.value} </if> </if> <if test="criterium.operator.toString() == 'NOT_EQUAL'"> <if test="criterium.value == null"> is not null </if> <if test="criterium.value != null"> != #{criterium.value} </if> </if> <if test="criterium.operator.toString() == 'LIKE'"> like #{criterium.value}</if> <if test="criterium.operator.toString() == 'IN'"> in ( <foreach item="value" collection="criterium.value" open="" separator=", " close=""> #{value} </foreach> ) </if> <if test="criterium.operator.toString() == 'LESS'"> < #{criterium.value}</if> <if test="criterium.operator.toString() == 'LESS_OR_EQUAL'"> <= #{criterium.value}</if> <if test="criterium.operator.toString() == 'GREATER'"> > #{criterium.value}</if> <if test="criterium.operator.toString() == 'GREATER_OR_EQUAL'"> >= #{criterium.value}</if> </foreach> </if> </select> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy