protected WebDAVProps toUnwrappedModel(WebDAVProps webDAVProps) { if (webDAVProps instanceof WebDAVPropsImpl) { return webDAVProps; } WebDAVPropsImpl webDAVPropsImpl = new WebDAVPropsImpl(); webDAVPropsImpl.setNew(webDAVProps.isNew()); webDAVPropsImpl.setPrimaryKey(webDAVProps.getPrimaryKey()); webDAVPropsImpl.setMvccVersion(webDAVProps.getMvccVersion()); webDAVPropsImpl.setWebDavPropsId(webDAVProps.getWebDavPropsId()); webDAVPropsImpl.setCompanyId(webDAVProps.getCompanyId()); webDAVPropsImpl.setCreateDate(webDAVProps.getCreateDate()); webDAVPropsImpl.setModifiedDate(webDAVProps.getModifiedDate()); webDAVPropsImpl.setClassNameId(webDAVProps.getClassNameId()); webDAVPropsImpl.setClassPK(webDAVProps.getClassPK()); webDAVPropsImpl.setProps(webDAVProps.getProps()); return webDAVPropsImpl; }
@Override public WebDAVProps updateImpl(WebDAVProps webDAVProps) { webDAVProps = toUnwrappedModel(webDAVProps); boolean isNew = webDAVProps.isNew(); WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl) webDAVProps; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (webDAVProps.getCreateDate() == null)) { if (serviceContext == null) { webDAVProps.setCreateDate(now); } else { webDAVProps.setCreateDate(serviceContext.getCreateDate(now)); } } if (!webDAVPropsModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { webDAVProps.setModifiedDate(now); } else { webDAVProps.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (webDAVProps.isNew()) { session.save(webDAVProps); webDAVProps.setNew(false); } else { webDAVProps = (WebDAVProps) session.merge(webDAVProps); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } entityCache.putResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps, false); clearUniqueFindersCache(webDAVPropsModelImpl); cacheUniqueFindersCache(webDAVPropsModelImpl, isNew); webDAVProps.resetOriginalValues(); return webDAVProps; }