I have a table that does not have a Primary Key. It does not have to contain unique data either in any of the fields or in any combination of them, i.e. I can't even do Composite Primary Key. I need to read lines from it one at a time, 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 Entity based, 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 by writing a direct SQL query)?

Why do you need a table in which there is no binding to unique values, the same row can be repeated? flour-flour-flour, the second entry is flour-flour-flour. And how do you choose the second entry? Is there a rationale for such a structure?

wigravy2021-11-26 07:32:52

The table is given to me as a given, which I cannot influence, so the question "why" is not worth it :) "Events" arrive in this table, which I process. Lines with the same data are events of the same type, each subsequent one is guaranteed to "overlap" the previous one. Means from a bunch of identical events it is enough for me to process one. After processing, the event is deleted from this table (i.e., all identical rows will be killed).

user2021-11-26 07:56:34