Package com.architecture.core.dao.entity

Examples of com.architecture.core.dao.entity.BaseEntity


    protected final Logger logger = Logger.getLogger(this.getClass());

    @Override
    public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
        if (entity instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) entity;
            Timestamp currentTime = new Timestamp(new Date().getTime());
            baseEntity.setCreateTime(currentTime);
            baseEntity.setUpdateTime(currentTime);
        }
        return true;
    }
View Full Code Here


    public void onCollectionUpdate(Object obj, Serializable key) throws CallbackException {

        Timestamp currentTime = new Timestamp(new Date().getTime());

        if (obj instanceof BaseEntity) {
            BaseEntity baseEntity = (BaseEntity) obj;

            //当做逻辑删除操作时,则只更新删除时间,其它情况则只是普通更新,只需修改更新时间
            if (true == baseEntity.isDeleted()) {
                baseEntity.setDeleteTime(currentTime);
            }else {
                baseEntity.setUpdateTime(currentTime);
            }
        } else if (obj instanceof Collection) {          //如果为批量更新,则批量修改更新时间
            Collection collection = (Collection) obj;
            for (Object cell : collection) {
                if (cell instanceof BaseEntity) {
                    BaseEntity baseEntity = (BaseEntity) cell;

                    //当做逻辑删除操作时,则只更新删除时间,其它情况则只是普通更新,只需修改更新时间
                    if (true == baseEntity.isDeleted()) {
                        baseEntity.setDeleteTime(currentTime);
                    }else {
                        baseEntity.setUpdateTime(currentTime);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.architecture.core.dao.entity.BaseEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.