Repository: tomee Updated Branches: refs/heads/master 26ac4e346 -> 85ead5e47
ensure ConfigurationDeployer auto jpa mode has a fallback when no jpa entities are in current module Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/85ead5e4 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/85ead5e4 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/85ead5e4 Branch: refs/heads/master Commit: 85ead5e4706c5493717c906a1f46b82b03a2f7d0 Parents: 26ac4e3 Author: Romain Manni-Bucau <rmannibu...@apache.org> Authored: Fri Apr 24 16:18:56 2015 +0200 Committer: Romain Manni-Bucau <rmannibu...@apache.org> Committed: Fri Apr 24 16:18:56 2015 +0200 ---------------------------------------------------------------------- .../openejb/config/ConfigurationDeployer.java | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/85ead5e4/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java ---------------------------------------------------------------------- diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java index dbe7b81..75f9d26 100644 --- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java +++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java @@ -26,10 +26,13 @@ import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; import org.apache.openejb.util.PropertyPlaceHolderHelper; +import java.util.ArrayList; +import javax.persistence.Entity; + public class ConfigurationDeployer implements DynamicDeployer { @Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { - for (final EjbModule module : appModule.getEjbModules()) { + for (final EjbModule module : new ArrayList<>(appModule.getEjbModules())) { if (module.getFinder() == null) { continue; } @@ -46,7 +49,27 @@ public class ConfigurationDeployer implements DynamicDeployer { } } if (scan) { - AnnotationDeployer.autoJpa(module); // we pass after annotation deployer so need to fill it ourself + EjbModule m = module; + if (m.getFinder().findAnnotatedClasses(Entity.class).isEmpty()) { + // switch to another module + for (final EjbModule other : appModule.getEjbModules()) { + if (other == module || other.getFinder() == null) { + continue; + } + m = other; + boolean done = false; + for (final WebModule web : appModule.getWebModules()) { + if (web.getModuleId().equals(other.getModuleId())) { // the biggest module is found, use it + done = true; + break; + } + } + if (done) { + break; + } + } + } + AnnotationDeployer.autoJpa(m); // we pass after annotation deployer so need to fill it ourself } } return appModule;