Answer the question
In order to leave comments, you need to log in
spring data. Can an object not be an Entity?
I have a table that does not have a Primary Key. It is not required to contain unique data in any of the fields, or in any combination of them, i.e. I can't even make a Composite Primary Key. I need to subtract lines from it one by one, preferably in the order they were added (but not necessarily, you can also in any order).
All the Spring Data JPA examples I've seen are based on Entity, i.e. must have a unique ID, which is not applicable in this case.
Question: is it possible to work with such a table using Spring Data (except for writing a direct SQL query)?
Answer the question
In order to leave comments, you need to log in
https://en.wikibooks.org/wiki/Java_Persistence/Ide...
If your table truly has no unique columns, then use all of the columns as the id. Typically when this occurs the data is read-only, so even if the table allows duplicate rows with the same values, the objects will be the same anyway, so it does not matter that JPA thinks they are the same object. The issue with allowing updates and deletes is that there is no way to uniquely identify the object's row, so all of the matching rows will be updated or deleted.
Rows with the same data are the same type of events, each subsequent one is guaranteed to "overlap" the previous one.just what you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question