I am having problems mapping a legacy database schema using JPA annotations.
The schema uses a table to generate unique IDs for most of the tables in the db – it has a structure of:
table_name
column_name
next_id
block_size
To get new unique ID for a record insert, you run a select like:
SELECT next_id FROM tbl_next_id WHERE table_name = 'tbl_pets' and column_name = 'pet_id'
urrgh. I know I could do this in pure hibernate by using a ‘select’ id generator (unless I just dreamt that up) – can anyone recommend the best way of handling this with JPA annotations?
Thanks
There is nothing better than this:
Will of course not support combination of table name + column name, but should work as long as there is only one generator for table.