We have some code that adds row_number expressions like in the table based insert handler, which should rather use dense_rank or wrap a query in certain circumstances. See https://hibernate.atlassian.net/browse/HHH-15517 for an example.