Skip to content

Custom Repository returns Optional as return type for T #3125

Closed
@jschmied

Description

@jschmied

For migrating existing code I have:

@NoRepositoryBean
public interface MyJpaDao<T, ID> extends Repository<T, ID>, QueryByExampleExecutor<T> {
	T findById(ID id);
}

with DAO:

public interface UserDAO extends MyJpaDao<User, Long> {
      
}

i would expect:
User findById(Long id);

but generated is
Optional<User> findById(Long id);

if I duplicate
User findById(Long id);
in UserDAO, it works as expected. Why?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions