As far as i Understand, when 'Native' class is used for auto id generation in Oracle, a single hibernate sequence is created, from where all the IDs are supplied to whichever table needed.
But i dont see this happen with MySQL. Instead, id's for each table start with 1.
Please correct me if am wrong.
Also, if i want the same tu happen on MySQL, what should be done.
Thanks All.
Raj.
As far as I Understand, when 'Native' class is used for auto id generation in Oracle, a single hibernate sequence is created, from where all the IDs are supplied to whichever table needed.
This occurs if you don't specify any sequence name, unlike this:
<generator class="sequence">
<param name="sequence">employer_id_seq</param>
</generator>
And actually most of time, people do NOT want a unique sequence, they prefer one sequence per table.
But I don't see this happen with MySQL. Instead, id's for each table start with 1.
With MySQL, the native
generator will default to an identity
strategy i.e. will use identity columns, which are per table.
Also, if I want the same to happen on MySQL, what should be done.
By same, I guess you mean using sequential IDs for all your entities. Give the table
generator a try :
<generator class="table">
</generator>
But this won't perform as well as sequence or identity columns. Also, people usually tend to prefer not sharing IDs between entities as I already wrote. I would think about this again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With