Search code examples
sqloraclespring-bootspring-data-jpaeclipselink

Spring Data JPA + EclipseLink in Oracle


I have this repository:

@Repository
public interface EnvaRepository extends JpaRepository<Enva, Long> {
}

and this query:

 envaRepository.findAllById(lopn.getEnvans());

but on console I have this error:

SELECT t0.PERSONNE_ID, t0.DT_NAISSANCE, t1.PERSONNE_ID FROM PERSONNE t0, ENVA t1
WHERE ((t0.PERSONNE_ID IN ((777,777))) AND (t1.PERSONNE_ID = t0.PERSONNE_ID));

[42000][907] ORA-00907: parenthèse de droite absente

My config class:

@Configuration
public class JpaConfiguration extends JpaBaseConfiguration {

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

    @Override
    protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
        log.debug("Using EclipseLinkJpaVendorAdapter");
        return new EclipseLinkJpaVendorAdapter();
    }

    @Bean
    @Primary
    public static JpaProperties properties() {
        final JpaProperties jpaProperties = new JpaProperties();
        jpaProperties.setShowSql(true);
        jpaProperties.setDatabasePlatform("org.eclipse.persistence.platform.database.OraclePlatform");
        return jpaProperties;
    }

    @Override
    protected Map<String, Object> getVendorProperties() {
        HashMap<String, Object> map = new HashMap<>();
        map.put(PersistenceUnitProperties.WEAVING, detectWeavingMode());
        return map;
    }

    private String detectWeavingMode() {
        return InstrumentationLoadTimeWeaver.isInstrumentationAvailable() ? "true" : "static";
    }
}

Solution

  • @Query("SELECT e FROM Enva e where e.personneId IN :envantIds")
        List<Enva> findAllById(Iterable<Long> envantIds);