我对 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)