From 77ba9c0ee865492cf335f5481d065b72d21a271a Mon Sep 17 00:00:00 2001 From: godotg Date: Tue, 23 Aug 2022 16:05:39 +0800 Subject: [PATCH] =?UTF-8?q?perf[orm]:=20=E5=8E=BB=E9=99=A4IEntity=E9=87=8C?= =?UTF-8?q?=E5=AE=B9=E6=98=93=E5=BC=95=E8=B5=B7=E8=AF=AF=E8=A7=A3=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BF=9D=E6=8C=81IEntity=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=AE=80=E6=B4=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zfoo/orm/model/entity/IEntity.java | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/orm/src/main/java/com/zfoo/orm/model/entity/IEntity.java b/orm/src/main/java/com/zfoo/orm/model/entity/IEntity.java index bf960963..9a3cb725 100644 --- a/orm/src/main/java/com/zfoo/orm/model/entity/IEntity.java +++ b/orm/src/main/java/com/zfoo/orm/model/entity/IEntity.java @@ -13,7 +13,6 @@ package com.zfoo.orm.model.entity; -import com.zfoo.orm.OrmContext; import com.zfoo.protocol.util.StringUtils; /** @@ -67,46 +66,4 @@ public interface IEntity> { } } - /** - * 增:插入数据库时使用 - */ - default void insert() { - OrmContext.getAccessor().insert(this); - invalidate(); - } - - /** - * 删:从数据库删除时使用 - */ - default void delete() { - OrmContext.getAccessor().delete(this); - invalidate(); - } - - /** - * 更新:保存到数据库时使用 - */ - default void save() { - if (empty()) { - // 未初始化的对象不允许保存 - return; - } - OrmContext.getOrmManager().getEntityCaches(this.getClass()).update(queryEntity()); - } - - private void invalidate() { - if (empty()) { - // 未初始化的对象不允许失效 - return; - } - OrmContext.getOrmManager().getEntityCaches(this.getClass()).invalidate(queryId()); - } - - private E queryEntity() { - return (E) this; - } - - private PK queryId() { - return (PK) id(); - } }