Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support insert/update condition on ReadOnlyProperty. [DATACMNS-1737] #2158

Closed
spring-projects-issues opened this issue Jun 4, 2020 · 3 comments
Labels
status: duplicate

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jun 4, 2020

mxandeco opened DATACMNS-1737 and commented

JPA offers an updatable/insertable property on the @Column annotation to allow a property to be read only on the scope of that statement, spring-data core annotation does not offer that feature. but offer a ReadOnlyProperty that works almost in the same way.

 

The main different here is that I can't ignore only update statement if I want to, it can be situations when a read only behavior is desired only for updates and not for inserts, looks like would be more natural to include that filter on the @ReadOnlyProperty annotation instead of column?

 

eg.


@ReadOnlyProperty(updatable=true)
private Instant createdAt;

That's a realm example I have now, all our audit logic lives in the db, and is set as default or trigger values. but during some old data sync, we need to also set this value manually, what is then ignored by the db trigger, I am using r2dbc at the moment, and can't see a way to implement this with core mapping annotation without having to write code to deal with it


Affects: 2.3 GA (Neumann)

@spring-projects-issues spring-projects-issues added type: bug in: mapping labels Dec 30, 2020
@mp911de
Copy link
Member

mp911de commented Jan 26, 2021

That sounds like a UpdateOnly property. I think we have seen a similar request in Spring Data JDBC. Paging @schauder.

@mp911de mp911de added status: waiting-for-triage and removed in: mapping type: bug labels Jan 26, 2021
@schauder
Copy link
Contributor

schauder commented Jan 27, 2021

There is indeed a similar issue for Spring Data JDBC: spring-projects/spring-data-relational#637
It asks for insert only semantics.

Since we are at it, we might want to think about a read after write logic. It is a frequently asked question for JPA how to obtain values generated by the database after an insert/update.

@schauder
Copy link
Contributor

schauder commented Feb 8, 2021

We will implement this only for JDBC for which there is spring-projects/spring-data-relational#637

@schauder schauder closed this as completed Feb 8, 2021
@schauder schauder added status: duplicate and removed status: waiting-for-triage labels Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate
Projects
None yet
Development

No branches or pull requests

4 participants