Skip to content

Commit

Permalink
fix update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojiebao committed Feb 4, 2024
1 parent 92ca94b commit 1c7021a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ public <E extends Entity & HasIdentifier> E update(
try {
switch (entityType) {
case METALAKE:
BaseMetalake oldMetalakeEntity =
POConverters.fromMetalakePO(
((MetalakeMetaMapper) SqlSessions.getMapper(MetalakeMetaMapper.class))
.selectMetalakeMetaByName(ident.name()));
MetalakePO oldMetalakePO =
((MetalakeMetaMapper) SqlSessions.getMapper(MetalakeMetaMapper.class))
.selectMetalakeMetaByName(ident.name());
BaseMetalake oldMetalakeEntity = POConverters.fromMetalakePO(oldMetalakePO);
BaseMetalake newMetalakeEntity = (BaseMetalake) updater.apply((E) oldMetalakeEntity);
Preconditions.checkArgument(
Objects.equals(oldMetalakeEntity.id(), newMetalakeEntity.id()),
String.format(
"The updated metalake entity id: %s is not same with the metalake entity id before: %s",
newMetalakeEntity.id(), oldMetalakeEntity.id()));
((MetalakeMetaMapper) SqlSessions.getMapper(MetalakeMetaMapper.class))
.updateMetalakeMeta(POConverters.toMetalakePO(newMetalakeEntity));
.updateMetalakeMeta(POConverters.toMetalakePO(newMetalakeEntity), oldMetalakePO);
SqlSessions.commitAndCloseSqlSession();
return (E) newMetalakeEntity;
case CATALOG:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,20 @@ public interface MetalakeMetaMapper {
@Update(
"UPDATE "
+ TABLE_NAME
+ " SET metalake_name = #{metalakeMeta.metalakeName},"
+ " metalake_comment = #{metalakeMeta.metalakeComment},"
+ " properties = #{metalakeMeta.properties},"
+ " audit_info = #{metalakeMeta.auditInfo},"
+ " schema_version = #{metalakeMeta.schemaVersion}"
+ " WHERE id = #{metalakeMeta.id}")
void updateMetalakeMeta(@Param("metalakeMeta") MetalakePO metalakePO);
+ " SET metalake_name = #{newMetalakeMeta.metalakeName},"
+ " metalake_comment = #{newMetalakeMeta.metalakeComment},"
+ " properties = #{newMetalakeMeta.properties},"
+ " audit_info = #{newMetalakeMeta.auditInfo},"
+ " schema_version = #{newMetalakeMeta.schemaVersion}"
+ " WHERE id = #{oldMetalakeMeta.id}"
+ " and metalake_name = #{oldMetalakeMeta.metalakeComment}"
+ " and metalake_comment = #{oldMetalakeMeta.metalakeComment}"
+ " and properties = #{oldMetalakeMeta.properties}"
+ " and audit_info = #{oldMetalakeMeta.auditInfo}"
+ " and schema_version = #{oldMetalakeMeta.schemaVersion}")
void updateMetalakeMeta(
@Param("newMetalakeMeta") MetalakePO newMetalakePO,
@Param("oldMetalakeMeta") MetalakePO oldMetalakePO);

@Delete("DELETE FROM " + TABLE_NAME + " WHERE id = #{id}")
Integer deleteMetalakeMetaById(@Param("id") Long id);
Expand Down

0 comments on commit 1c7021a

Please sign in to comment.