diff --git a/src/main/java/net/helenus/core/AbstractUnitOfWork.java b/src/main/java/net/helenus/core/AbstractUnitOfWork.java index fe3ccdf..9a345bc 100644 --- a/src/main/java/net/helenus/core/AbstractUnitOfWork.java +++ b/src/main/java/net/helenus/core/AbstractUnitOfWork.java @@ -86,6 +86,12 @@ public abstract class AbstractUnitOfWork implements UnitOfW } public void logTimers(String what) { + + cache hit, miss; + multiple calls, sometimes to db, sometimes to cache, sometimes both... + uow.setPurpose(getClass().getSimpleName() + "::" + Thread.currentThread().getStackTrace()[1].getMethodName()); + + double e = (double) elapsedTime_.elapsed(TimeUnit.MICROSECONDS) / 1000.0; double d = (double) databaseTime_.elapsed(TimeUnit.MICROSECONDS) / 1000.0; double c = (double) cacheLookupTime_.elapsed(TimeUnit.MICROSECONDS) / 1000.0; diff --git a/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java b/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java index c46a0f0..dbe8b08 100644 --- a/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java +++ b/src/main/java/net/helenus/core/operation/AbstractStatementOperation.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; +import net.helenus.mapping.HelenusProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,9 +47,7 @@ import net.helenus.mapping.value.BeanColumnValueProvider; import net.helenus.support.HelenusException; public abstract class AbstractStatementOperation> extends Operation { - - private static final Logger LOG = LoggerFactory.getLogger(AbstractStatementOperation.class); - + protected boolean enableCache = true; protected boolean showValues = true; protected TraceContext traceContext; @@ -327,14 +326,14 @@ public abstract class AbstractStatementOperation { - if (valueMap == null) { - Object value = BeanColumnValueProvider.INSTANCE.getColumnValue(pojo, -1, prop, false); - binder.setValueForProperty(prop, value.toString()); - } else { - binder.setValueForProperty(prop, valueMap.get(prop.getPropertyName()).toString()); - } - facets.add(binder.bind()); - }); + List properties = unboundFacet.getProperties(); + if (properties != null) { + properties.forEach(prop -> { + if (valueMap == null) { + Object value = BeanColumnValueProvider.INSTANCE.getColumnValue(pojo, -1, prop, false); + binder.setValueForProperty(prop, value.toString()); + } else { + binder.setValueForProperty(prop, valueMap.get(prop.getPropertyName()).toString()); + } + facets.add(binder.bind()); + }); + } } else { facets.add(facet); } diff --git a/src/main/java/net/helenus/mapping/HelenusMappingEntity.java b/src/main/java/net/helenus/mapping/HelenusMappingEntity.java index 11f9790..77cd60e 100644 --- a/src/main/java/net/helenus/mapping/HelenusMappingEntity.java +++ b/src/main/java/net/helenus/mapping/HelenusMappingEntity.java @@ -125,8 +125,8 @@ public final class HelenusMappingEntity implements HelenusEntity { facetsBuilder.add(new UnboundFacet(primaryKeyProperties)); primaryKeyProperties = null; } - Optional optionalIndexName = prop.getIndexName(); - if (optionalIndexName.isPresent()) { + Index idx = prop.getGetterMethod().getAnnotation(Index.class); + if (idx.distinct()) { UnboundFacet facet = new UnboundFacet(prop); facetsBuilder.add(facet); } diff --git a/src/main/java/net/helenus/mapping/annotation/Index.java b/src/main/java/net/helenus/mapping/annotation/Index.java index 5222824..6e341c9 100644 --- a/src/main/java/net/helenus/mapping/annotation/Index.java +++ b/src/main/java/net/helenus/mapping/annotation/Index.java @@ -65,4 +65,10 @@ public @interface Index { * @return true if the index should ignore case when comparing */ boolean caseSensitive() default true; + + /** + * + * @return + */ + boolean distinct() default false; }