0

I am trying to use the @Query to create a custom method in my jpa repository but I am getting the following error at runtime, please help me check it out. Thanks in advance

below is the code

public interface OrganizationRepository extends JpaRepository<Organization, Long> { List<Organization> findByDeleted(Boolean isDeleted); List<Organization> findAllByDeletedOrderById(Boolean isDeleted); @Query(value="SELECT * FROM ORGANIZATION WHERE id = :organizationId AND NAME LIKE %:organizationId% LIMIT 1 ", nativeQuery = true) Organization findFirstNameByNameLike(@Param("organizationId") Long organizationId, @Param("name") String name); } 

below is the runtime error

Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract com.oasis.firsbacklogbackend.entity.Organization com.oasis.firsbacklogbackend.repository.OrganizationRepository.findFirstNameByNameLike(java.lang.Long,java.lang.String) but parameter 'Optional[name]' not found in annotated query 'SELECT * FROM ORGANIZATION WHERE id = :organizationId AND NAME LIKE %:organizationId% LIMIT 1 '! 

I would appreciate any help

1 Answer 1

1

You used organizationId twice instead of name. Like this instead:

@Query(value="SELECT * FROM ORGANIZATION WHERE id = :organizationId AND NAME LIKE %:name% LIMIT 1 ", nativeQuery = true) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.