Search in sources :

Example 1 with JpaRepositoryOperations

use of io.micronaut.data.jpa.operations.JpaRepositoryOperations in project micronaut-data by micronaut-projects.

the class LoadInterceptor method intercept.

@Override
public T intercept(RepositoryMethodKey methodKey, MethodInvocationContext<T, T> context) {
    Serializable id = (Serializable) Arrays.stream(context.getParameterValues()).findFirst().orElseThrow(() -> new IllegalArgumentException("id argument cannot be null"));
    Class<T> returnType = context.getReturnType().getType();
    return ((JpaRepositoryOperations) operations).load(returnType, id);
}
Also used : JpaRepositoryOperations(io.micronaut.data.jpa.operations.JpaRepositoryOperations) Serializable(java.io.Serializable)

Aggregations

JpaRepositoryOperations (io.micronaut.data.jpa.operations.JpaRepositoryOperations)1 Serializable (java.io.Serializable)1