com.enterprisemath.dao.relational.MyBatisEntityMapper.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.MyBatisEntityMapper"> <insert id="insertEntityCore"> insert into entities (code, name, created_timestamp, parent_code, type) values (#{code}, #{name}, #{createdTimestamp}, #{parent_code}, #{type}) </insert> <insert id="insertEntityJoins"> insert into ${table} (code, <foreach item="value" index="column" collection="join" open="" separator="," close="">${column}</foreach>) values (#{code}, <foreach item="value" index="column" collection="join" open="" separator="," close="">#{value}</foreach>) </insert> <select id="selectEntities" resultType="map"> select a.code as code, a.name as name, a.created_timestamp as created_timestamp, a.parent_code as parent_code, a.type as type <if test="joins.size() > 0"> <foreach index="table" item="columns" collection="joins" open="" separator="" close=""> <foreach item="column" collection="columns" open="," separator="," close=""> ${table}.${column} as ${table}_${column} </foreach> </foreach> </if> from entities a <if test="joins.size() > 0"> <foreach index="table" item="columns" collection="joins" open="" separator="" close=""> inner join ${table} ${table} on ${table}.code = a.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="countEntities" resultType="long"> select count(*) from entities a <if test="tables.size() > 0"> <foreach item="table" collection="tables" open="" separator="" close=""> inner join ${table} ${table} on ${table}.code = a.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'"> = #{criterium.value}</if> <if test="criterium.operator.toString() == 'NOT_EQUAL'"> != #{criterium.value}</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> <delete id="deleteEntity"> delete from entities where code = #{code} </delete> <update id="updateEntityName"> update entities set name = #{name} where code = #{code} </update> <update id="updateEntityJoin"> update ${table} set ${column} = #{value} where code = #{code} </update> <delete id="deleteEntityJoins"> delete from ${table} where code = #{code} </delete> <insert id="insertProfile"> insert into entity_profiles (code, entity_code, profile_key, profile_value) values (#{code}, #{entity_code}, #{profile_key}, #{profile_value}) </insert> <select id="selectProfiles" resultType="map"> select code, entity_code, profile_key, profile_value from entity_profiles <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'"> = #{criterium.value}</if> <if test="criterium.operator.toString() == 'NOT_EQUAL'"> != #{criterium.value}</if> <if test="criterium.operator.toString() == 'LIKE'"> like #{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> <delete id="deleteProfiles"> delete from entity_profiles <if test="criteria.size() > 0"> where <foreach item="criterium" collection="criteria" open="" separator=" and " close=""> ${criterium.column} <if test="criterium.operator.toString() == 'EQUAL'"> = #{criterium.value}</if> <if test="criterium.operator.toString() == 'NOT_EQUAL'"> != #{criterium.value}</if> <if test="criterium.operator.toString() == 'LIKE'"> like #{criterium.value}</if> </foreach> </if> </delete> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy