I have configured my project to support static weaving but it's not working for lazy loading @ManyToOne.
version of freamwork used:
my configuration :
- 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;
...
- Log :
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
when i load the user in the log always i see the request to get partner is requested !! ?
I think i have found the problem: first i have used the last version of plugin 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>
in eclipse if I run a clean install, then publish and run the project, weaving work perfectly. but if I clean install and then clean automatically with eclipse (Maven->update project) eclipse clear the .classes created with our maven plugin and create others with not weaving optimized.