spring-projects / spring-projects/spring-data-relational

Supporting SQL Function around inserting value [DATAJDBC-468]

Open
#694 7 comments 0 reactions 1 assignee View on GitHub

@schauder is already working on this.

Since Dec 31, 2020.

type: enhancement
Dominant language
Java
Stars
827
Forks
394
PR merge metrics
No merged PRs in 30d

Description

LaoTsing opened DATAJDBC-468 and commented

We can use annotations to insert value as any SQL function:

@UpdateStrategy(JdbcStrategy.UpdateIsNotNull)

public class DocEntity {

   @Id private Long id;

   private String english;

   @Fun("translate('french', english)") private String french;

}

 

in annotation Fun("translate('french', ?)") we can select character "?" and get value from any primitive type of "french" field

then repository.save(doc) with english == null generate:

update doc set ``french=translate('french', ``english``) where id=?

this will greatly simplify the logic and source code.

In SELECT case, the annotated functions can reveal their full potential


Issue Links:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.