Eclipselink静态编织不起作用

时间:2016-04-24 12:36:31

标签: eclipselink many-to-one wildfly-10 compile-time-weaving

我已将我的项目配置为支持静态编织,但它不适用于延迟加载 @ManyToOne

使用的freamwork版本:

  • 的EclipseLink-2.6.3-M1.jar
  • wildfly 10.0.0
  • JPA 2.0
  • 的EclipseLink-staticweave-行家-插件:1.0.4

我的配置:

- pom.xml:

                            ...
             <plugin>
            <artifactId>eclipselink-staticweave-maven-plugin</artifactId>
            <groupId>au.com.alderaan</groupId>
            <version>1.0.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>weave</goal>
                    </goals>
                    <phase>process-classes</phase>
                    <configuration>
                        <logLevel>ALL</logLevel>
                <includeProjectClasspath>true</includeProjectClasspath>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>eclipselink</artifactId>
                    <version>${eclipslink-version}</version>
                </dependency>
            </dependencies>
            </plugin>
            ...

- persistence.xml:

    ...
    <validation-mode>NONE</validation-mode>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <shared-cache-mode>NONE</shared-cache-mode>
    <properties>
        <property name="eclipselink.target-database" value="MySQL" />
        <property name="eclipselink.target-server" value="JBoss" />
        <property name="eclipselink.weaving" value="static" />
        <!-- LOG DEBUG -->
        <property name="eclipselink.logging.level.sql" value="FINEST" />
        <property name="eclipselink.logging.parameters" value="true" />
        <property name="eclipselink.logging.level.transaction"
            value="FINEST" />
        <property name="eclipselink.logging.level" value="FINEST" />
        <property name="eclipselink.logging.level.cache" value="FINEST" />
    </properties>
    ...

- User.java:

            ...
            @JoinColumn(name = "PARTNER_ID", referencedColumnName = PARTNER_ID", nullable = false)
            @ManyToOne(optional = false, fetch = FetchType.LAZY)
            private Partner partnerId;
            ...

- 记录:

                            14:14:00,696 INFO  [stdout] (default task-14) [EL Fine]: 2016-04-24 14:14:00.696--ServerSession(2107137839)--Connection(1003936572)--Thread(Thread[default task-14,5,main])--SELECT USER_ID, USER_LOGIN, USER_MAIL, USER_PWD, PARTNER_ID FROM user WHERE (USER_LOGIN = ?)
                14:14:00,696 INFO  [stdout] (default task-14)   bind => [admin]
                14:14:00,703 INFO  [stdout] (default task-14) [EL Finest]: 2016-04-24 14:14:00.703--ServerSession(2107137839)--Connection(453922073)--Thread(Thread[default task-14,5,main])--Connection released to connection pool [read].
                14:14:00,705 INFO  [stdout] (default task-14) [EL Finest]: 2016-04-24 14:14:00.705--UnitOfWork(889591992)--Thread(Thread[default task-14,5,main])--Execute query ReadObjectQuery(name="partnerId" referenceClass=Partner )
                14:14:00,706 INFO  [stdout] (default task-14) [EL Finest]: 2016-04-24 14:14:00.706--ServerSession(2107137839)--Connection(1634321100)--Thread(Thread[default task-14,5,main])--Connection acquired from connection pool [read].
                14:14:00,706 INFO  [stdout] (default task-14) [EL Finest]: 2016-04-24 14:14:00.706--ServerSession(2107137839)--Thread(Thread[default task-14,5,main])--reconnecting to external connection pool
                14:14:00,706 INFO  [stdout] (default task-14) [EL Fine]: 2016-04-24 14:14:00.706--ServerSession(2107137839)--Connection(415563557)--Thread(Thread[default task-14,5,main])--SELECT PARTNER_ID, DISABLED FROM partner WHERE (PARTNER_ID = ?)
                14:14:00,706 INFO  [stdout] (default task-14)   bind => [1]
                14:14:00,852 INFO  [stdout] (default task-14) [EL Finest]: 2016-04-24 14:14:00.852--ServerSession(2107137839)--Connection(1992473777)--Thread(Thread[default task-14,5,main])--Connection released to connection pool [read].
                14:14:00,853 INFO  [stdout] (default task-14) [EL Finer]: 2016-04-24 14:14:00.853--UnitOfWork(889591992)--Thread(Thread[default task-14,5,main])--TX beforeCompletion callback, status=STATUS_ACTIVE
                14:14:00,853 INFO  [stdout] (default task-14) [EL Finer]: 2016-04-24 14:14:00.853--UnitOfWork(889591992)--Thread(Thread[default task-14,5,main])--begin unit of work commit
                14:14:00,859 INFO  [stdout] (default task-14) [EL Finer]: 2016-04-24 14:14:00.859--UnitOfWork(889591992)--Thread(Thread[default task-14,5,main])--TX afterCompletion callback, status=COMMITTED
                14:14:00,860 INFO  [stdout] (default task-14) [EL Finer]: 2016-04-24 14:14:00.86--UnitOfWork(889591992)--Thread(Thread[default task-14,5,main])--end unit of work commit
                14:14:00,860 INFO  [stdout] (default task-14) [EL Finer]: 2016-04-24 14:14:00.86--UnitOfWork(889591992)--Thread(Thread[default task-14,5,main])--release unit of work
                14:14:00,861 INFO  [stdout] (default task-14) [EL Finer]: 2016-04-24 14:14:00.861--ClientSession(1390020981)--Thread(Thread[default task-14,5,main])--client released

当我在日志中加载用户时总是看到要求获得合作伙伴的请求!! ?

1 个答案:

答案 0 :(得分:0)

我想我发现了这个问题: 首先我使用了最新版本的插件1.0.4:

            <!-- This plugin ensures the EclipseLink static weaving -->
            <plugin>
                <artifactId>eclipselink-staticweave-maven-plugin</artifactId>
                <groupId>au.com.alderaan</groupId>
                <version>1.0.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>weave</goal>
                        </goals>
                        <phase>process-classes</phase>
                        <configuration>
                            <logLevel>ALL</logLevel>
                            <includeProjectClasspath>true</includeProjectClasspath>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>eclipselink</artifactId>
                        <version>${eclipslink-version}</version>
                    </dependency>
                </dependencies>
            </plugin>
如果我运行一个干净的安装,那么在eclipse中,然后发布并运行项目,完美地编织工作。但是如果我清理安装然后使用eclipse自动清理(Maven-&gt;更新项目)eclipse清除使用我们的maven插件创建的.classes并创建其他没有编织优化的。