how to do static weaving if we use eclipselink jpa in the spring boot app
Asked Answered
R

1

0

how to do static weaving if we use eclipselink jpa in the spring boot app. There is a lack of enough articles on it in internet. The articles I saw used de.empulse.eclipselink staticweave-maven-plugin to weave but it is of 10 years old and do not know if it will support Jpa 3 and above. Another issue is its requirement of persistence.xml. How to do using annotation based approach in spring boot.I tried using "map.put(PersistenceUnitProperties.WEAVING, "static");" but it does not weave. Rest all works properly.

@Configuration
public class EclipsLinkJpaConfiguration extends JpaBaseConfiguration {

   protected EclipsLinkJpaConfiguration(DataSource dataSource, JpaProperties properties,
      ObjectProvider<JtaTransactionManager> jtaTransactionManager) {
      super(dataSource, properties, jtaTransactionManager);
   }

   @Override
   protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
      return new EclipseLinkJpaVendorAdapter();
   }

   @Override
   protected Map<String, Object> getVendorProperties() {
      Map<String, Object> map = new HashMap<>();
      map.put(PersistenceUnitProperties.WEAVING, "static");
      map.put(PersistenceUnitProperties.LOGGING_LEVEL, SessionLog.FINER_LABEL); 
      //map.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.CREATE_ONLY);
     // map.put(PersistenceUnitProperties.LOGGING_LEVEL, SessionLog.FINER_LABEL); 
      map.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");

      return map;
   }

   @Bean
   public static DataSource dataSource() {
      final DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
      dataSource.setUrl("jdbc:mysql://localhost:3306/studentcrudangular");
      dataSource.setUsername("root");
      dataSource.setPassword("root");
      return dataSource;
   }
}
Refection answered 22/4 at 7:20 Comment(0)
O
0

static weaving is something you do after compilation to give you a new set of class files. This setting/hint specifies that the jar files have already been woven, so that EclipseLink knows they should already be enhanced and be able to use advanced features like lazy loading of one to ones. See https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

Odontograph answered 25/4 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.