Fixed entity manager leak
@@ -69,6 +69,7 @@ public class EntityMetamodelImpl implements EntityMetamodel {
Set<Class<?>> seenTypesForEnumResolving = new HashSet<>();
+ try {
for (ManagedType<?> t : managedTypes) {
if (t instanceof EntityType<?>) {
EntityType<?> e = (EntityType<?>) t;
@@ -118,6 +119,9 @@ public class EntityMetamodelImpl implements EntityMetamodel {
cteToType.put(t.getJavaType(), t);
}
}
+ } finally {
+ em.close();
+ }
this.entityNameMap = Collections.unmodifiableMap(nameToType);
this.entityTypes = Collections.unmodifiableMap(entityTypes);
