}
private void batchInsert(Iterable<MeasureModel> values) {
- SqlSession session = mybatis.openBatchSession();
+ SqlSession session = mybatis.openSession();
try {
MeasureMapper mapper = session.getMapper(MeasureMapper.class);
for (MeasureModel value : values) {
- mapper.batchInsert(value);
+ mapper.insert(value);
}
session.commit();
MeasureMapper mapper = session.getMapper(MeasureMapper.class);
for (MeasureModel value : values) {
- mapper.batchInsert(value);
+ mapper.insert(value);
mapper.insertData(value);
}
public interface MeasureMapper {
void insert(MeasureModel measure);
- void batchInsert(MeasureModel measure);
-
void insertData(MeasureModel data);
void update(MeasureModel measure);
)
</insert>
- <insert id="batchInsert" parameterType="MeasureModel" useGeneratedKeys="false">
- INSERT INTO project_measures (
- id,
- value, metric_id, snapshot_id, rule_id, text_value, tendency, measure_date,
- project_id, alert_status, alert_text, url, description, rule_priority, characteristic_id, variation_value_1,
- variation_value_2, variation_value_3, variation_value_4, variation_value_5, person_id)
- VALUES (
- project_measures_seq.NEXTVAL,
- #{value}, #{metricId}, #{snapshotId}, #{ruleId}, #{textValue}, #{tendency},
- #{measureDate, jdbcType=TIMESTAMP}, #{projectId}, #{alertStatus}, #{alertText},
- #{url}, #{description}, #{rulePriority.ordinal}, #{characteristic.id}, #{variationValue1},
- #{variationValue2}, #{variationValue3}, #{variationValue4}, #{variationValue5}, #{personId}
- )
- </insert>
-
- <insert id="insertData" parameterType="MeasureModel" useGeneratedKeys="false">
+ <insert id="insertData" parameterType="MeasureModel" useGeneratedKeys="true" keyProperty="id">
INSERT INTO measure_data (id, measure_id, snapshot_id, data)
VALUES (measure_data_seq.NEXTVAL, #{id}, #{snapshotId}, #{measureData.data})
</insert>
)
</insert>
- <insert id="batchInsert" parameterType="MeasureModel" useGeneratedKeys="false">
- INSERT INTO project_measures (
- value, metric_id, snapshot_id, rule_id, text_value, tendency, measure_date,
- project_id, alert_status, alert_text, url, description, rule_priority, characteristic_id, variation_value_1,
- variation_value_2, variation_value_3, variation_value_4, variation_value_5, person_id)
- VALUES (
- #{value}, #{metricId}, #{snapshotId}, #{ruleId}, #{textValue}, #{tendency},
- #{measureDate}, #{projectId}, #{alertStatus}, #{alertText},
- #{url}, #{description}, #{rulePriority.ordinal}, #{characteristic.id}, #{variationValue1},
- #{variationValue2}, #{variationValue3}, #{variationValue4}, #{variationValue5}, #{personId}
- )
- </insert>
-
- <insert id="insertData" parameterType="MeasureModel" useGeneratedKeys="false">
+ <insert id="insertData" parameterType="MeasureModel" useGeneratedKeys="true" keyProperty="id">
INSERT INTO measure_data (measure_id, snapshot_id, data)
VALUES (#{id}, #{snapshotId}, #{measureData.data})
</insert>