Friday, September 16, 2016

Java 8 equals helper using lambda expression

public class Equals {
 private Equals() {}

 public static  boolean of(Class type, Object obj, Predicate pred) {
  if (obj == null) {
   return false;
  if (!type.isInstance(obj)) {
   return false;
  T other = type.cast(obj);
  return pred.test(other);
Usage example:
public boolean equals(Object obj) {
 return Equals.of(ClassKey.class, obj, other -> 
   Objects.equals(this.kind, other.kind) &&
   Objects.equals(this.obj, other.obj)

Monday, November 30, 2015

Activiti: how to enable MyBatis SQL logging

We use SLF4J as the logging API, and Logback as the implementation for testing. Fortunately MyBatis supports multiple logging frameworks, SLF4J included, based on runtime auto-detection. See for more details.

Enabling SQL logging turned out the be quite easy, but it took a while to figure out, because the current top search results are out of date: they work with older versions of MyBatis (or iBatis).

To cut to the chase, the solution is simply to set the logger "org.activiti.engine.impl.persistence.entity" to level DEBUG:
<logger name="org.activiti.engine.impl.persistence.entity" level="DEBUG" />
In our case we are only interested in SQL statements for the ExecutionEntity, so our configuration can be more specific:
<logger name="org.activiti.engine.impl.persistence.entity.ExecutionEntity" level="DEBUG" />
For process/task variables:
<logger name="org.activiti.engine.impl.persistence.entity.VariableInstanceEntity" level="DEBUG" />