Eclipselink 静态编织不起作用
Eclipselink static weaving not work
我已将我的项目配置为支持静态编织,但它不适用于延迟加载 @ManyToOne。
使用的框架版本:
- eclipselink-2.6.3-M1.jar
- 野蝇 10.0.0
- JPA 2.0
- eclipselink-staticweave-maven-plugin: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.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-> 更新项目)自动清理 eclipse 清除使用我们的 maven 插件创建的 .类 并创建其他没有编织优化的。
我已将我的项目配置为支持静态编织,但它不适用于延迟加载 @ManyToOne。
使用的框架版本:
- eclipselink-2.6.3-M1.jar
- 野蝇 10.0.0
- JPA 2.0
- eclipselink-staticweave-maven-plugin: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.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-> 更新项目)自动清理 eclipse 清除使用我们的 maven 插件创建的 .类 并创建其他没有编织优化的。