-
Notifications
You must be signed in to change notification settings - Fork 682
Unknown column 'new' in 'field list' when implementing Persistable in a class with @AccessType(Type.PROPERTY) #2338
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
Comments
Moved to Spring Data Commons as the functionality is originating from Commons. |
That is actually intended behavior. Implementing |
Hmmm... how can this be the intended behaviour? If the purpose of Any valid and reasonable use case in which the user would like to persist the "being new" status of an entity implementing |
The use of |
The reason we decided to go this way is exactly to make it least surprising. This way the rules are actually fairly simple: Attributes are determined by fields. You can change that to properties by setting the access type It would be much weirder if either |
I still believe this is an unfortunate decision, although I respect it. Regarding the use of
Yes, but... you still didn't mention any reasonable use case in which storing the result of Anyway, I acknowledge your decision. |
|
Oh, well, and where the Indeed, this is what I'm doing in my UPDATE: oh, well, I see it's mentioned at https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.entity-persistence.optimistic-locking, however it's like a treasure hunt! :-D I would suggest you to add the information written in the second place to the table at the first link... |
The use of a version property to determine the state of an entity wasn't properly documented so far. Related tickets spring-projects/spring-data-commons#2338
My Spring Data JDBC entity is implementing
Persistable
and is annotated with@AccessType(Type.PROPERTY)
at the class level.When I invoke
save
on my repository, I get the following exception from the underlying JDBC implementation:java.sql.SQLException: Unknown column 'new' in 'field list'
Indeed, looking at the executed query, Spring Data JDBC is also specifying the column
new
in the insert statement. I think it comes from the implementation oforg.springframework.data.domain.Persistable.isNew()
.I take the opportunity to ask a question: is it true that implementing
Persistable
allows me to avoid to mark the primary key field with@Id
, being the implementation oforg.springframework.data.domain.Persistable.getId()
enough for the framework to detect the primary key? It's not very clear from the documentation.The text was updated successfully, but these errors were encountered: