-
Notifications
You must be signed in to change notification settings - Fork 356
@ReadOnlyProperty with child entity associated with a View possibly related to DATAJDBC-431 #1249
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
Labels
Comments
Please clarify which property is annotated with class A {
@ReadOnlyProperty // the complete reference is read only
B b;
} class B {
@ReadOnlyProperty // only one property of the referenced class is read only
String someProperty
} |
schauder
added a commit
that referenced
this issue
May 18, 2022
The `@ReadOnlyProperty` annotation is now honoured for references to entities or collections of entities. For tables mapped to such annotated references, no insert, delete or update statements will be created. The user has to maintain that data through some other means. These could be triggers or external process or `ON DELETE CASCADE` configuration in the database schema. See #1249
@schauder The complete reference is marked with @ReadOnlyProperty. @Table("parent")
class ParentEntity {
@Id
UUID id;
String timezone;
String starttime;
String endtime;
boolean enabled;
@ReadOnlyProperty
@Column("parent_id")
ChildViewEntity childViewEntity;
}
@Table("child_view")
class ChildViewEntity {
int calculatedField;
} |
schauder
added a commit
that referenced
this issue
May 19, 2022
The `@ReadOnlyProperty` annotation is now honoured for references to entities or collections of entities. For tables mapped to such annotated references, no insert, delete or update statements will be created. The user has to maintain that data through some other means. These could be triggers or external process or `ON DELETE CASCADE` configuration in the database schema. Closes #1249
Thanks. It would be great, if you could verify that it solves the problem for you. |
@schauder I've tested your change and verified it has solved our problem. Thank you very much for looking into this. When will this officially release? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I am using
spring-data-relational 2.2.11
with Postgres and I am having an issue where I have a child@Column
that maps to a different Java class that is annotated with@Table
and that table is a view.This works fine for retrieval, but for some reason when I attempt to modify the parent and use parentNameRepository.save(), it attempts to run a delete statement against the child. This then throws an error because it is attempting to delete from a view.
@ReadOnlyProperty
does not appear to prevent this delete statement and neither does annotation the child class with@Immutable
.For now the our work are either to create triggers at the DB level that ignores this delete generated delete statement, or just iterate over the parent and set a
@Transient
field with a repository call for the view. (not ideal).I found that there was an old ticket for ignored
@ReadOnlyProperty
DATAJDBC-431The text was updated successfully, but these errors were encountered: