Spring 数据和 ORA-00942 : table or view does not exist

标签 spring oracle spring-data

我有 Spring Data 和 Oracle 12 数据库的有趣问题

我有

java.sql.SQLSyntaxErrorException:
ORA-00942: table or view does not exist



但是当我使用 JdbcTemplate 时它有效! Spring 数据和 JdbcTemplate 使用相同的数据源。 Liquibase 迁移也没有问题

我尝试将模式用于模型,但没有运气。
@Getter
@Setter
@Entity
@Table(name = "tb_accounts", schema = "rx")
public class CustomerAccount {

   @Id
   @Column(name = "id")
   private String id;

   private String accountNo;
}

@Repository
public interface CustomerAccountRepository extends JpaRepository<CustomerAccount, String> {

}

但正如我所说,它适用于 JdbcTemplate
@Repository
public class CustomerAccountDao {

    @Autowired
    private DataSource dataSource;

    private JdbcTemplate jdbcTemplate;

    @PostConstruct
    private void postConstruct() {
        jdbcTemplate = new JdbcTemplate(dataSource);
    }

    public List<CustomerAccount> findAll() {
    return jdbcTemplate.query("select * from tb_accounts", (rs, i) -> {

        CustomerAccount account = new CustomerAccount();
        account.setId(rs.getString("id"));

        return account;
    });
}

迁移文件
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">

    <changeSet id="1" author="user1">
        <createTable tableName="tb_accounts">
            <column name="id" type="VARCHAR(256)">
                <constraints primaryKey="true"/>
            </column>
            <column name="accountNo" type="VARCHAR(256)"/>

        </createTable>

    </changeSet>

</databaseChangeLog>

有任何想法吗?我应该检查什么?我花了几个小时找到原因,但没有任何帮助:(

最佳答案

它需要使用 TB_ACCOUNTS 而不是 tb_accounts ...

关于 Spring 数据和 ORA-00942 : table or view does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52348230/

相关文章:

java - Spring 表达式语言 (SpEL) : check empty string?

oracle - 使用 DATE 和 VARCHAR2 重载 oracle 过程

java - 在不向数据库插入任何内容的情况下初始化 OrdImage 对象

spring - @JsonIgnore 和 @JsonIgnoreProperties 有什么区别

java - 如何合并 springframework.beans.factory.UnsatisfiedDependencyException 堆栈跟踪?

java - 为 spring-data-neo4j-4 中的继承节点添加第二个标签

java - Spring代理不包含被代理类的注解

java - 使用注释和@Valid的Spring表单验证

java - 是否可以在一个 spring 容器中运行带有 spring security 的 spring webmvc webapp?

oracle - oracle中为什么要按顺序使用缓存和顺序?