In my table I have a column that acts like a sequence, only it's not auto incremented, the incrementation is done in code.
A crude representation of the table would be like this:
id | fruit | sequence |
---|---|---|
1 | apple | 1 |
2 | apple | 2 |
3 | apple | 3 |
4 | apple | 10 |
5 | orange | 1 |
6 | orange | 2 |
As you can see I have gaps in my sequence column and I want to find that gap, where it starts and where it ends. For example, make a query that finds the start of the gap with fruit = apple and then the end of the gap, like so: "4-9"
Right now I use this solution with native query in JPA: which works great but is only usable for mysql, can this be done with entitymanager and JPQL? The reason behind this is to be able to switch from one type of database to another.