Spring Data JDBC: DataRetrievalFailureException : Unable to cast [oracle.sql.ROWID] to [java.lang.Number]

前端 未结 3 1516
悲哀的现实
悲哀的现实 2021-01-22 14:10

I am new to Spring Data JDBC, and I am struggling to create a simple Dto and get it persisted on the DB.

I am using Spring-Boot 2.1.1.RELEASE and and Oracle 12 Database.

3条回答
  •  别那么骄傲
    2021-01-22 14:35

    I suffered the same problem, while the PR is being included in the next Spring Data JDBC release we can use the following workaround with Spring AOP, It's not "perfect" but enough for us until the underlying problem is solved:

    @Around("execution(public * my-app-pacakage.repository.*.save(..))")
    public Object aspectController(ProceedingJoinPoint jp) throws Throwable {
        try {
            return jp.proceed();
        } catch (DbActionExecutionException e) {
            if (e.getCause() instanceof DataRetrievalFailureException) {
                return jp.getArgs()[0];
            }
            return e;
        } catch(Throwable e) {
            throw e;        
        }       
    }
    

提交回复
热议问题