Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented Jun 23, 2025

Fix parameter and return type checks for DAO methods with update annotations:

  • When returning = @returning is specified, allow return types of Optional as long as T matches the entity type of the method parameter (avoid false error highlights).

  • For update and batch annotations with SQL templates, if the method parameter is an immutable Entity class, enforce that the return type must be Result or BatchResult instead of int or int[].

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the type-checking for DAO methods by allowing Optional returns with @returning and enforcing stricter return types for update and batch operations on immutable entities.

  • Enabled Optional return types for delete methods annotated with @returning.
  • Enforced Result or BatchResult return types for update and batch operations on immutable entities.
  • Updated processor implementations to validate entity and Optional types accordingly.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/test/testData/src/main/java/doma/example/dao/inspection/returntype/UpdateReturnTypeTestDao.java Added Optional-based method and error highlighting for incorrect return types in delete and update operations.
src/test/testData/src/main/java/doma/example/dao/inspection/returntype/BatchReturnTypeTestDao.java Updated error messages for batch update/delete methods with immutable entities and incorrect return types.
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/returntype/UpdateAnnotationReturnTypeCheckProcessor.kt Updated the return type checking logic to properly differentiate Optional and non-Optional entity types.
src/main/kotlin/org/domaframework/doma/intellij/inspection/dao/processor/returntype/BatchAnnotationReturnTypeCheckProcessor.kt Modified the control flow to correctly handle immutable entities when SQL file options are enabled.

@xterao xterao merged commit f349fdf into main Jun 23, 2025
5 checks passed
@xterao xterao deleted the fix/update-annotation-return-typpe-check branch June 23, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correction of Return Type Check Fix return value check for methods with returning option

2 participants