From be5720fbf778166dcf1d426ece53198b1d8a9409 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 23 Jan 2019 16:52:27 +0100 Subject: [PATCH] [#728] Fix NPE during entity type id resolving for deltaspike repository method using the plain entity type --- .../data/impl/handler/EntityViewRepositoryHandler.java | 8 +++++++- .../data/impl/handler/EntityViewRepositoryHandler.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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(); }