gpt4 book ai didi

java - 升级到Spring boot 2.1.0 Data Jpa + Batch,遇到ORA-00942

转载 作者:太空宇宙 更新时间:2023-11-04 10:00:35 24 4
gpt4 key购买 nike

我在升级到 Spring Boot 2.1.0 时遇到了问题,我正在使用 jpa + hibernate & 我的实体和存储库都很简单。

基本上我的代码可以在 Spring Boot 2.0.4 上运行,但是当升级 2.1.0 时(没有完成任何代码更改),我的存储库抛出了 ORA-00942 错误。我检查了两个版本的 hibernate 查询,它们看起来都一样。

我已阅读 changelog我没有看到任何可能导致该问题的原因。

我对这个问题感到困惑,欢迎任何建议!

我遇到的错误和设置如下

存储库设置:

package com.my.sample.app.dao

@Repository
public interface MyRepository extends CrudRepository<MyEntity, String> {
MyEntity findTopByTypeOrderByStartTimeDesc(String type);
}

JPA相关配置:

package com.my.sample.app.configs

@Configuration
@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", basePackages = "com.my.sample.app.dao")
@EnableTransactionManagement
public class DatabaseConnectionConfig {

@Bean
@Primary
@ConfigurationProperties(prefix = "my-datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}

@Primary
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
DataSource dataSource) {
Map<String, String> properties = new HashMap<>();
properties.put("hibernate.dialect", "org.hibernate.dialect.OracleDialect");

return builder.dataSource(dataSource).packages("com.my.sample.app.entity").persistenceUnit("my-jpa").properties(properties)
.build();
}

@Primary
@Bean(name = "myJpaTransactionManager")
public PlatformTransactionManager transactionManager(
@Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}

实体:

package com.my.sample.app.entity

@Entity
@Table(name = "AUDIT_TABLE")
public class AuditLog implements Serializable{
private static final long serialVersionUID = 7862607645530582453L;
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy="uuid2")
@Column(name = "AUDIT_ID")
private String auditId;
@Column(name = "TYPE")
private String dataType;
@Column(name = "START_TIME")
private Date startTime;
@Column(name = "END_TIME")
private Date endTime;
@Column(name = "STATUS")
private String status;

//getters & setters
}

遇到的错误:

2018-11-30 14:37:04.539  WARN 21616 --- o.h.engine.jdbc.spi.SqlExceptionHelper  : SQL Error: 942, SQLState: 42000
2018-11-30 14:37:04.539 ERROR 21616 --- o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-00942: table or view does not exist

属性文件:

my-datasource.jdbcUrl = jdbc:oracle:thin:@hostname:1521/service
my-datasource.username = username
my-datasource.password = password
my-datasource.driverClassName = oracle.jdbc.driver.OracleDriver

PS:该表确实存在,并且我的代码可以在 Spring Boot 2.0.4 版本上运行。不确定升级到 2.1.0 时出现了什么问题

最佳答案

尝试将属性文件更改为:

my-datasource.jdbcUrl = jdbc:oracle:thin:@hostname:1521:service

关于java - 升级到Spring boot 2.1.0 Data Jpa + Batch,遇到ORA-00942,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53552808/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com