diff --git a/integration/deltaspike-data/impl-1.7/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java b/integration/deltaspike-data/impl-1.7/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java index d42aabb07e..d0dfcd1d35 100644 --- a/integration/deltaspike-data/impl-1.7/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java +++ b/integration/deltaspike-data/impl-1.7/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java @@ -94,7 +94,13 @@ protected String entityName() { @Override protected String idAttribute() { - Class entityClass = context.getEntityViewManager().getMetamodel().view(viewClass()).getEntityClass(); + Class viewClass = viewClass(); + Class entityClass; + if (viewClass == null) { + entityClass = entityClass(); + } else { + entityClass = context.getEntityViewManager().getMetamodel().view(viewClass).getEntityClass(); + } EntityType entityType = context.getEntityManager().getMetamodel().entity(entityClass); return JpaMetamodelUtils.getSingleIdAttribute(entityType).getName(); } diff --git a/integration/deltaspike-data/impl-1.8/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java b/integration/deltaspike-data/impl-1.8/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java index 4a777219ed..e20bde93b1 100644 --- a/integration/deltaspike-data/impl-1.8/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java +++ b/integration/deltaspike-data/impl-1.8/src/main/java/com/blazebit/persistence/deltaspike/data/impl/handler/EntityViewRepositoryHandler.java @@ -94,7 +94,13 @@ protected String entityName() { @Override protected String idAttribute() { - Class entityClass = context.getEntityViewManager().getMetamodel().view(viewClass()).getEntityClass(); + Class viewClass = viewClass(); + Class entityClass; + if (viewClass == null) { + entityClass = entityClass(); + } else { + entityClass = context.getEntityViewManager().getMetamodel().view(viewClass).getEntityClass(); + } EntityType entityType = context.getEntityManager().getMetamodel().entity(entityClass); return JpaMetamodelUtils.getSingleIdAttribute(entityType).getName(); }