Skip to content

proxyentity

jwpttcg66 edited this page Apr 18, 2017 · 4 revisions

代理实体

注解

  • MethodSaveProxy 类需要使用代理 会通过此注解,注入到代理对象的变化集合里

生成代理

EntityProxyFactory entityProxyFactory = (EntityProxyFactory) classPathXmlApplicationContext.getBean("entityProxyFactory");
MoreOrder moreOrder = new MoreOrder();
MoreOrder proxyOrder = entityProxyFactory.createProxyEntity(moreOrder);

注解实例

@EntitySave
@DbMapper(mapper = OrderMapper.class)
public class Order extends BaseLongIDEntity implements RedisInterface, AsyncSave {

    @FieldSave
    private String status;

    /**
     * @return status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status
     */
    @MethodSaveProxy(proxy="status")
    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderId=" + getId() +
                ", userId=" + getUserId() +
                ", status='" + status + '\'' +
                '}';
    }

    @Override
    public String getUnionKey() {
        return String.valueOf(getUserId()+ EntityUtils.ENTITY_SPLIT_STRING + getId());
    }

    @Override
    public String getRedisKeyEnumString() {
        return RedisKeyEnum.PLAYER.getKey();
    }

}
Clone this wiki locally