micronaut-data icon indicating copy to clipboard operation
micronaut-data copied to clipboard

Improve error message for invalid update method return

Open jameskleeh opened this issue 5 years ago • 1 comments

For example:

Todo update(@Id UUID id, String name, LocalDateTime createdAt);

where Todo is an entity

Results in

Unable to implement Repository method: TodoRepository.update(UUID id,String name,LocalDateTime createdAt). No possible implementations found. Todo update(@Id UUID id, String name, LocalDateTime createdAt);

It would be more helpful if the error said:

Unable to implement Repository method: TodoRepository.update(UUID id,String name,LocalDateTime createdAt). Invalid return type. Update methods must return void or a number type.

jameskleeh avatar May 29 '20 15:05 jameskleeh

I think this can be closed? It's happening in 2.4.7 at least

error: Unable to implement Repository method: TestRepository.updateByLocationId(long locationId). Update methods only support void or number based return types

Spotted this when I was trying to find an issue as to why I can't use RETURNING in an explicit Query when it worked in a previous version of micronaut data

micronaut: 2.4.4 Micronaut Data: 2.3.1

    @Query(
        """
        INSERT INTO locations (location_id, external_location_id, partner)
        VALUES( :locationId, :externalLocationId, :partner)
        ON CONFLICT (location_id) WHERE deleted_at IS NULL
        DO
        UPDATE SET external_location_id = EXCLUDED.external_location_id, partner = EXCLUDED.partner
        RETURNING id
    """)
    abstract fun upsert(locationModel: LocationModel): UUID
Unable to implement Repository method: TestRepository.upsert(LocationModel locationModel). Invalid result type: java.util.UUID for 'INSERT' operation

scprek avatar Feb 11 '22 21:02 scprek

This has been fixed and can be closed. Getting this compilation error

Unable to implement Repository method: TodoRepository.update(UUID id,String name,LocalDateTime createdAt). Update methods only support void or number based return types

radovanradic avatar Sep 13 '23 10:09 radovanradic