Skip to content

simpler result mappings for @StaticNativeQuery #961

@gavinking

Description

@gavinking

Currently, we say you can do this:

@StaticNativeQuery("select * from books where isbn = ?")
@SqlResultSetMapping(entities =
        @EntityResult(entityClass = Book.class,
                fields = {@FieldResult(name = "isbn", column = "isbn_13"),
                          @FieldResult(name = "title", column = "title_en")}))
Book getBookWithIsbn(String isbn);

I think that's just unnecessary ceremony, when we can easily just let you write this:

@StaticNativeQuery("select * from books where isbn = ?")
@EntityResult(entityClass = Book.class,
        fields = {@FieldResult(name = "isbn", column = "isbn_13"),
                  @FieldResult(name = "title", column = "title_en")})
Book getBookWithIsbn(String isbn);

All we need to do is promote the XxxResult annotations to METHOD and make them @Repeatable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions