Skip to content

enhancement miss properties, inherited from another module #2

Description

@npokr

There are multi-module gradle project, class hierarchy with @MappedSuperclass in parent module and class with @Entity in child module, that extends class from parent module.
When I run this construction from IDEA (15.0.5) with activated Ebean ORM Enhancer (4.9.2), all is fine.
But when I run gradle tasks, they fail with java.lang.IllegalStateException: Property id not found in [...] for type class X.Y.Z at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setBeanReflect(BeanDescriptorManager.java:1385).
As it turned out, this is because static field _ebean_props (of descripted bean) contains only properties defined in child module, but no properties inherited from parent module.
I build test case: module parent with classes Firstand Second that extends First. Module child with classes Fourthextends Thirdextends Second. Fourth is entity, other - mapped superclasses.
Test method:

@Test
    public static void testMeta() throws Exception {
        Class<?> clazz = Fourth.class;
        while (!clazz.equals(Object.class)) {
            Field field = clazz.getField("_ebean_props");
            String[] props = (String[]) field.get(null);
            StringBuilder sb = new StringBuilder(clazz.getName());
            sb.append(": ");
            for (int i = 0; i < props.length; i++) {
                sb.append(props[i]);
                if (i < props.length - 1)
                    sb.append(", ");
            }
            log.info(sb.toString());
            clazz = clazz.getSuperclass();
        }
    }

When test runs from IDEA output is

[TestNG] Running:
  C:\Users\N\.IntelliJIdea15\system\temp-testng-customsuite.xml
13:37:17.927 [main] INFO ru.pokr.FourthTest - ru.pokr.Fourth: id, code, second, third, fourth
13:37:17.929 [main] INFO ru.pokr.FourthTest - ru.pokr.Third: id, code, second, third
13:37:17.929 [main] INFO ru.pokr.FourthTest - ru.pokr.Second: id, code, second
13:37:17.929 [main] INFO ru.pokr.FourthTest - ru.pokr.First: id, code

When runs gradle task 🧒test output is

Testing started at 13:40 ...
13:40:43: Executing external task 'test'...
:parent:compileJava
:parent:enhanceEbeanMain
:parent:processResources UP-TO-DATE
:parent:classes
:parent:jar
:child:compileJava
:child:enhanceEbeanMain
:child:processResources UP-TO-DATE
:child:classes
:child:compileTestJava
:child:enhanceEbeanTest
:child:processTestResources UP-TO-DATE
:child:testClasses
:child:test
13:40:44.570 [Test worker] INFO ru.pokr.FourthTest - ru.pokr.Fourth: third, fourth
13:40:44.572 [Test worker] INFO ru.pokr.FourthTest - ru.pokr.Third: third
13:40:44.572 [Test worker] INFO ru.pokr.FourthTest - ru.pokr.Second: id, code, second
13:40:44.572 [Test worker] INFO ru.pokr.FourthTest - ru.pokr.First: id, code
BUILD SUCCESSFUL

Test project https://github.com/npokr/test-ebean-plugin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions