0

Which values exist for the eclipselink.weaving property and what is their meaning?

In Spring we can create the entityManager using Java configuration or XML configuration, the following example is for XML:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="jpaProperties">
        <props>
            <prop key="eclipselink.weaving">false</prop>
            ...
        </props>
    </property>
   ...
</bean>

We have the following option:

  • static - to static weaving to weave all applicable class files at build time so that you can deliver pre-woven class files.

What does the false means? And which options can we pass to eclipselink.weaving property?

EDIT: I want to configure the weaving during compile time. I am using this maven plugin

<groupId>com.ethlo.persistence.tools</groupId>
<artifactId>eclipselink-maven-plugin</artifactId>

What value should I use false or static ?

rMonteiro
  • 1,371
  • 1
  • 14
  • 37

1 Answers1

2

Javadoc for the eclipselink.weaving property state 3 values:

  • "true" - requires that weaving is done. Will throw an exception if entities are not woven
  • "false" - forces weaving not to be done
  • "static" - requires that the static weaving utility was used to weave the entities

True aka Dynamic implies there is an agent that will weave the entities in the JVM. See the doc for setting it up outside of a container. Static tells EclipseLink you've done the weaving yourself on the java classes within the class loader (see the wiki for how to set it up), while false turns off any options that require woven classes (change tracking, lazy one to ones and more).

Chris
  • 20,138
  • 2
  • 29
  • 43
  • So if I put `false` the weaving is not done, what does that exactly mean? The app will not use weaving? Or it uses if it is done during build ? Should I use `static` when the weaving is configured during build? – rMonteiro Nov 26 '21 at 09:58
  • 1
    false just tells EclipseLink weaving wasn't done beforehand and there is no agent, so it can't be done - this prevents EclipseLink from trying to access interfaces and other methods on entities that aren't going to be there. Both of the other values tell eclipseLink that the classes have been woven - Use static if you want EclipseLink to use these interfaces on the entity classes, and you've used static weaving (or added them yourself) on them. The value of true tells the agent to weave the classes when they are first loaded by the class loader. – Chris Nov 26 '21 at 18:41