@Override public boolean mapToMapFromEntity( SessionImplementor session, Map<String, Object> data, Object newObj, Object oldObj) { data.put(propertyData.getName(), newObj); boolean dbLogicallyDifferent = true; if ((session.getFactory().getDialect() instanceof Oracle8iDialect) && (newObj instanceof String || oldObj instanceof String)) { // Don't generate new revision when database replaces empty string with NULL during INSERT or // UPDATE statements. dbLogicallyDifferent = !(StringTools.isEmpty(newObj) && StringTools.isEmpty(oldObj)); } return dbLogicallyDifferent && !Tools.objectsEqual(newObj, oldObj); }
/** * Recursively constructs sets of audited and not audited properties and classes which behavior * has been overridden using {@link AuditOverride} annotation. * * @param clazz Class that is being processed. Currently mapped entity shall be passed during * first invocation. */ private void readAuditOverrides(XClass clazz) { /* TODO: Code to remove with @Audited.auditParents - start. */ final Audited allClassAudited = clazz.getAnnotation(Audited.class); if (allClassAudited != null && allClassAudited.auditParents().length > 0) { for (Class c : allClassAudited.auditParents()) { final XClass parentClass = reflectionManager.toXClass(c); checkSuperclass(clazz, parentClass); if (!overriddenNotAuditedClasses.contains(parentClass)) { // If the class has not been marked as not audited by the subclass. overriddenAuditedClasses.add(parentClass); } } } /* TODO: Code to remove with @Audited.auditParents - finish. */ final List<AuditOverride> auditOverrides = computeAuditOverrides(clazz); for (AuditOverride auditOverride : auditOverrides) { if (auditOverride.forClass() != void.class) { final XClass overrideClass = reflectionManager.toXClass(auditOverride.forClass()); checkSuperclass(clazz, overrideClass); final String propertyName = auditOverride.name(); if (!StringTools.isEmpty(propertyName)) { // Override @Audited annotation on property level. final XProperty property = getProperty(overrideClass, propertyName); if (auditOverride.isAudited()) { if (!overriddenNotAuditedProperties.contains(property)) { // If the property has not been marked as not audited by the subclass. overriddenAuditedProperties.add(property); } } else { if (!overriddenAuditedProperties.contains(property)) { // If the property has not been marked as audited by the subclass. overriddenNotAuditedProperties.add(property); } } } else { // Override @Audited annotation on class level. if (auditOverride.isAudited()) { if (!overriddenNotAuditedClasses.contains(overrideClass)) { // If the class has not been marked as not audited by the subclass. overriddenAuditedClasses.add(overrideClass); } } else { if (!overriddenAuditedClasses.contains(overrideClass)) { // If the class has not been marked as audited by the subclass. overriddenNotAuditedClasses.add(overrideClass); } } } } } final XClass superclass = clazz.getSuperclass(); if (!clazz.isInterface() && !Object.class.getName().equals(superclass.getName())) { readAuditOverrides(superclass); } }