public static EntityType entityForPK(Class<? extends Serializable> pkClass, CacheConcurrencyStrategy cacheConcurrencyStrategy) { for (EntityType entityType : EntityType.values()) { if(entityType.getPrimaryKeyType().equals(pkClass) && entityType.getCacheConcurrencyStrategy().equals(cacheConcurrencyStrategy)) { return entityType; } } throw new RuntimeException("Couldn't find any EntityType with PK of class " + pkClass.getSimpleName() + " and CacheConcurrencyStrategy " + cacheConcurrencyStrategy); } }