小编max*_*pro的帖子

spring 数据和 ORA-00942: 表或视图不存在

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

我有

java.sql.SQLSyntaxErrorException:
ORA-00942 :表或视图不 存在

但当我使用 JdbcTemplate 时它可以工作!Spring data和JdbcTemplate使用相同的dataSource。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> {

}
Run Code Online (Sandbox Code Playgroud)

但正如我所说,它适用于 JdbcTemplate

@Repository
public class CustomerAccountDao {

    @Autowired
    private DataSource dataSource;

    private JdbcTemplate jdbcTemplate;

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

    public List<CustomerAccount> findAll() { …
Run Code Online (Sandbox Code Playgroud)

oracle spring spring-data

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

oracle ×1

spring ×1

spring-data ×1