Example i have this table
table transaction
- id int (PK)
- unit varchar(10)
- journal_number
journal number is combination of unit and a sequence. so example data could be like this
id | unit | journal_number
------------------------------
1 | 'unit1' | 1
2 | 'unit1' | 2
3 | 'unit2' | 1
4 | 'unit2' | 2
...
i how to create the journal_number automatically ?
is there any solution for this in hibernate without doing this manually ?
like using a Generator
If i have to do this manually, for example if there is a new row for the ‘unit1’. then i have to to this
select max(journal_number) where unit = 'unit1'
then asign the result to the new row
I don’t Know if I got your point.But it seems that yo want a composite Key.
if yes then there is way that you can do in your mapping file.