Skip to content

Commit

Permalink
[jpa] Fetch <class> from Index when available
Browse files Browse the repository at this point in the history
And thus enlist the class hierarchy
  • Loading branch information
emmanuelbernard committed Sep 19, 2018
1 parent 9157ab7 commit b30209a
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public KnownDomainObjects discoverModelAndRegisterForReflection() throws IOExcep

List<PersistenceUnitDescriptor> persistenceUnitDescriptors = PersistenceUnitsHolder.getPersistenceUnitDescriptors();
for (PersistenceUnitDescriptor pud : persistenceUnitDescriptors) {
enlistExplicitClasses(pud.getManagedClassNames(), collector);
enlistExplicitClasses(pud.getManagedClassNames(), collector, index);
}

collector.registerAllForReflection(processorContext);
Expand All @@ -79,10 +79,18 @@ public KnownDomainObjects discoverModelAndRegisterForReflection() throws IOExcep
return collector;
}

private void enlistExplicitClasses(List<String> managedClassNames, DomainObjectSet collector) {
private static void enlistExplicitClasses(List<String> managedClassNames, DomainObjectSet collector, IndexView index) {
for (String className : managedClassNames) {
// TODO add superclass for reflection
collector.addEntity(className);
DotName dotName = DotName.createSimple(className);
boolean isInIndex = index.getClassByName(dotName) != null;
if (isInIndex) {
addClassHierarchyToReflectiveList(collector, index, dotName);
}
else {
// We do lipstick service by manually adding explicitly the <class> reference but not navigating the hierarchy
System.out.println("[WARNING] Did not find `" + className + "` in the indexed jars. You likely forgot to add shamrock-build.yaml in your dependency jar. See https://github.com/protean-project/shamrock/#indexing-and-application-classes for more info.");
collector.addEntity(className);
}
}
}

Expand Down

0 comments on commit b30209a

Please sign in to comment.