spring-data-relational icon indicating copy to clipboard operation
spring-data-relational copied to clipboard

How to skip mybatis method lookup when extends MybatisMapper

Open tianyu94 opened this issue 3 years ago • 1 comments

Mybatis mapper:

@Mapper
public interface SysUserMapper {
    @Transactional(readOnly = true)
    List<SysUserFullNamePj> selectFullName();

    @Transactional(readOnly = true)
    List<SysUser> selectAll();
}

Spring Data JDBC:

@Repository
public interface SysUserRepo extends PagingAndSortingRepository<SysUser, Long>, SysUserMapper {
    Optional<SysUser> findFirstByUsernameEqualsIgnoreCase(String username);
}
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 'selectAll' found for type 'SysUser'

Example:

@EnableJdbcRepositories(excludeNamedQueriesStartWith = "select")
@EnableJdbcRepositories(mybatisMethodPrefix = "select")

tianyu94 avatar Aug 20 '22 07:08 tianyu94

This could be handled similar to named queries where we try to look up the query in MyBatis before trying to resolve it with query derivation inside Spring Data.

schauder avatar Aug 29 '22 14:08 schauder