sql - Oracle 中的 Spring Data JPA + EclipseLink
问题描述
我有这个存储库:
@Repository
public interface EnvaRepository extends JpaRepository<Enva, Long> {
}
这个查询:
envaRepository.findAllById(lopn.getEnvans());
但在控制台上我有这个错误:
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
我的配置类:
@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";
}
}
解决方案
在你的 IN 语句中去掉额外的括号,如下所示:
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));
推荐阅读
- intellij-idea - IntelliJ Show Diff 包括未版本控制的文件
- azure-data-explorer - 如何根据 Kusto 中的条件计算列的累积总和
- java - 在 SharedPreferences 中保存 hashmap
- java - 如果父窗口不在焦点中,Java 11 上的 JComboBox 在第一次鼠标单击时不显示弹出菜单
- python - 将管理员创建的用户连接到 django 项目中的注册用户
- wordpress - 下载 Bitbucket 存储库,但保证文件名为 master.zip
- node.js - 如何在 Mocha 测试之前运行 Koa 服务器?
- reactjs - 如何使变量具有未知类型或分配“电影”?
- mysql - 如何返回每个日期的套数
- javascript - 使用 Redux 进行组件验证