Неизвестное исключение имени столбца после изменения пакета во время инициализации приложения базы данных с помощью Speedment - PullRequest
0 голосов
/ 01 декабря 2018

Я создал правила агрегации для объекта соединения.Все работает хорошо, пока я не попытался изменить настройку Bundle на .withBundle (InMemoryBundle.class), а затем внезапно возникла исключительная ситуация.

Вот часть кода, расположенная внутри одного из моих классов.

   private static class SalaryPerDepartment {
        private Double salary;
        private String departmentName;

        public Double getSalary() {
            return salary;
        }

        public void setSalary(Double salary) {
            this.salary = salary;
        }

        public String getDepartmentName() {
            return departmentName;
        }

        public void setDepartmentName(String departmentName) {
            this.departmentName = departmentName;
        }

        @Override
        public String toString() {
            return "Result{" +
                    "salary=" + salary +
                    ", departmentName='" + departmentName + '\'' +
                    '}';
        }
    }

    public void executeQuery(){
        JoinComponent joinComponent = employeesApplication.getOrThrow(JoinComponent.class);

        Join<Tuple2<Departments, Salaries>> join = employeesApplication.getOrThrow(JoinComponent.class)
                .from(EmployeesManager.IDENTIFIER)
                .innerJoinOn(DeptEmp.EMP_NO).equal(Employees.EMP_NO)
                    .where(DeptEmp.TO_DATE.equal(Date.valueOf("9999-01-01")))
                .innerJoinOn(Departments.DEPT_NO).equal(DeptEmp.DEPT_NO)
                .innerJoinOn(Salaries.EMP_NO).equal(Employees.EMP_NO)
                    .where(Salaries.TO_DATE.equal(Date.valueOf("9999-01-01")))
                .build((a,b,c,d) -> Tuples.of(c,d));

        AggregationCollector<Tuple2<Departments, Salaries>, ?, SalaryPerDepartment> aggregationCollector = Aggregator.builder(SalaryPerDepartment::new)
                            .firstOn(Tuple2.<Departments, Salaries>getter0())
                                .andThen(Departments.DEPT_NAME)
                                .key(SalaryPerDepartment::setDepartmentName)
                            .firstOn(Tuple2.getter1())
                                .andThen(Salaries.SALARY)
                                .average(SalaryPerDepartment::setSalary)
                            .build()
                            .createCollector();

        Aggregation<SalaryPerDepartment> aggregation= join.stream().collect(aggregationCollector);

    }

Журналы без какого-либо пакета приложения:

2018-12-01T12:30:43.349629Z DEBUG [main] (#JOIN) - Resolving join with 4 stages:
 # Table Identifier                 Join Type    R# Referenced Table Identifier      Field            Operation    Referenced Field
 0 Employees.employees.employees    null         -1 null                             null             null         null            
 1 Employees.employees.dept_emp     INNER_JOIN    0 Employees.employees.employees    emp_no           EQUAL        emp_no          
 2 Employees.employees.departments  INNER_JOIN    1 Employees.employees.dept_emp     dept_no          EQUAL        dept_no         
 3 Employees.employees.salaries     INNER_JOIN    0 Employees.employees.employees    emp_no           EQUAL        emp_no          
2018-12-01T12:30:43.353807Z DEBUG [main] (#STREAM) - SELECT A.`emp_no`,A.`birth_date`,A.`first_name`,A.`last_name`,A.`gender`,A.`hire_date`, B.`emp_no`,B.`dept_no`,B.`from_date`,B.`to_date`, C.`dept_no`,C.`dept_name`, D.`emp_no`,D.`salary`,D.`from_date`,D.`to_date` FROM `employees`.`employees` AS A INNER JOIN `employees`.`dept_emp` AS B ON (B.`emp_no` = A.`emp_no`) INNER JOIN `employees`.`departments` AS C ON (C.`dept_no` = B.`dept_no`) INNER JOIN `employees`.`salaries` AS D ON (D.`emp_no` = A.`emp_no`)  WHERE (B.`to_date` = ?) AND (D.`to_date` = ?), values:[9999-01-01, 9999-01-01]
2018-12-01T12:30:43.355190Z DEBUG [main] (#CONNECTION) - getConnection(jdbc:mysql://127.0.0.1:3306?useUnicode=true&characterEncoding=UTF-8&useServerPrepStmts=true&zeroDateTimeBehavior=convertToNull&nullNamePatternMatchesAll=true&useLegacyDatetimeCode=true&useSSL=false, root, *****)
2018-12-01T12:30:43.355555Z DEBUG [main] (#CONNECTION) - Reuse Connection: com.speedment.runtime.core.internal.pool.PoolableConnectionImpl@19976a65
2018-12-01T12:30:45.493046Z DEBUG [main] (#CONNECTION) - Discard: com.speedment.runtime.core.internal.pool.PoolableConnectionImpl@19976a65
2018-12-01T12:30:45.493162Z DEBUG [main] (#CONNECTION) - Closed external connection: com.mysql.jdbc.JDBC4Connection@6f8e8894

Журналы только для .withBundle (DataStoreBundle.class):

2018-12-01T12:39:47.269803Z DEBUG [main] (#JOIN) - Resolving join with 4 stages:
 # Table Identifier                 Join Type    R# Referenced Table Identifier      Field            Operation    Referenced Field
 0 Employees.employees.employees    null         -1 null                             null             null         null            
 1 Employees.employees.dept_emp     INNER_JOIN    0 Employees.employees.employees    emp_no           EQUAL        emp_no          
 2 Employees.employees.departments  INNER_JOIN    1 Employees.employees.dept_emp     dept_no          EQUAL        dept_no         
 3 Employees.employees.salaries     INNER_JOIN    0 Employees.employees.employees    emp_no           EQUAL        emp_no          
2018-12-01T12:39:47.272905Z DEBUG [main] (#STREAM) - SELECT A.`emp_no`,A.`birth_date`,A.`first_name`,A.`last_name`,A.`gender`,A.`hire_date`, B.`emp_no`,B.`dept_no`,B.`from_date`,B.`to_date`, C.`dept_no`,C.`dept_name`, D.`emp_no`,D.`salary`,D.`from_date`,D.`to_date` FROM `employees`.`employees` AS A INNER JOIN `employees`.`dept_emp` AS B ON (B.`emp_no` = A.`emp_no`) INNER JOIN `employees`.`departments` AS C ON (C.`dept_no` = B.`dept_no`) INNER JOIN `employees`.`salaries` AS D ON (D.`emp_no` = A.`emp_no`)  WHERE (B.`to_date` = ?) AND (D.`to_date` = ?), values:[9999-01-01, 9999-01-01]
2018-12-01T12:39:47.273516Z DEBUG [main] (#CONNECTION) - getConnection(jdbc:mysql://127.0.0.1:3306?useUnicode=true&characterEncoding=UTF-8&useServerPrepStmts=true&zeroDateTimeBehavior=convertToNull&nullNamePatternMatchesAll=true&useLegacyDatetimeCode=true&useSSL=false, root, *****)
2018-12-01T12:39:47.273823Z DEBUG [main] (#CONNECTION) - Reuse Connection: com.speedment.runtime.core.internal.pool.PoolableConnectionImpl@7e4204e2
2018-12-01T12:39:49.780182Z DEBUG [main] (#CONNECTION) - Recycled: com.speedment.runtime.core.internal.pool.PoolableConnectionImpl@7e4204e2

И, наконец, журналы для троянского коня .withBundle (DataStoreBundle.class)

2018-12-01T12:43:20.525722Z DEBUG [main] (#JOIN) - Resolving join with 4 stages:
 # Table Identifier                 Join Type    R# Referenced Table Identifier      Field            Operation    Referenced Field
 0 Employees.employees.employees    null         -1 null                             null             null         null            
 1 Employees.employees.dept_emp     INNER_JOIN    0 Employees.employees.employees    emp_no           EQUAL        emp_no          
 2 Employees.employees.departments  INNER_JOIN    1 Employees.employees.dept_emp     dept_no          EQUAL        dept_no         
 3 Employees.employees.salaries     INNER_JOIN    0 Employees.employees.employees    emp_no           EQUAL        emp_no          
2018-12-01T12:43:20.632068Z DEBUG [main] (#JOIN) - JoinSpliteratorBuilderImpl computed the following advancer types:
InnerJoinOneToMany
InnerJoinOneToOne
InnerJoinOneToMany
Exception in thread "main" java.lang.UnsupportedOperationException: Unknown column name 'dept_name'.
    at com.company.employees.employees.employees.employees.generated.GeneratedEmployeesEntityStoreSerializerImpl.isNull(GeneratedEmployeesEntityStoreSerializerImpl.java:205)
    at com.speedment.enterprise.datastore.runtime.internal.function.predicate.EntityIsNullPredicateImpl.asReferencePredicate(EntityIsNullPredicateImpl.java:54)
    at com.speedment.enterprise.datastore.runtime.internal.aggregator.AggregatorAdapterImpl.adaptIsNull(AggregatorAdapterImpl.java:104)
    at com.speedment.enterprise.datastore.runtime.internal.aggregator.TupleAggregatorAdapterImpl.internalAdaptIsNull(TupleAggregatorAdapterImpl.java:137)
    at com.speedment.enterprise.datastore.runtime.internal.aggregator.TupleAggregatorAdapterImpl.adaptIsNull(TupleAggregatorAdapterImpl.java:53)
    at com.speedment.enterprise.aggregator.internal.action.nullable.NullableKeyAction.tupleInitiator(NullableKeyAction.java:95)
    at com.speedment.enterprise.aggregator.internal.AggregationCollectorImpl.lambda$asTupleCollector$6(AggregationCollectorImpl.java:162)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1492)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
    at com.speedment.enterprise.aggregator.internal.AggregationCollectorImpl.asTupleCollector(AggregationCollectorImpl.java:163)
    at com.speedment.enterprise.datastore.runtime.internal.stream.TupleStream.collect(TupleStream.java:546)
    at TestCases.AverageSalaryPerDepartment.executeQuery(AverageSalaryPerDepartment.java:79)
    at TestCases.SpeedmentTestImpl.executeWarmUp(SpeedmentTestImpl.java:45)
    at TestCases.SpeedmentTestImpl.execute(SpeedmentTestImpl.java:23)
    at SpeedmentTestManager.executeTests(SpeedmentTestManager.java:24)
    at Main.main(Main.java:58)

Process finished with exit code 1

Схема БД, которую я использую Источник: https://github.com/datacharmer/test_db/tree/master/images

Знаете ли вы, почему возникает эта проблема?Заранее спасибо.

...