A
A
Alexander Wolf2020-06-24 12:14:42
Java
Alexander Wolf, 2020-06-24 12:14:42

Why does hibernate cut window functions like row_number in @Formula?

Hey!

Tell me, did anyone make a formula with row_number () in hibernate (java) in Entity? At me something window functions are not got at all. Hibernate turns them into something unreadable and crashes itself.

Maybe there are better ways?

I need to get the index of a post within the same user_id sorted by date. The problem is that there are places where my entity is requested in a single instance. And I need to know what it is in a row :(

Well, I don’t want to make a view at all. I have more than one such entity :(

An example of a formula:

@Formula(value = "(select row_number () over (order by created_at) from table where user_id=5)")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question