Reputation: 18347
How can I generate insert statements like insert into table (sequence.nextval, 'b0)
using hibernate?
Hibernate currently selects the sequence.nextval
value and only then it uses the value to insert the entry in the table.
Note: I'm not very fond of custom id generators.
Upvotes: 0
Views: 2866
Reputation: 100706
Hibernate selects sequence.nextval
because it has to return that value back to you (e.g. set ID on your entity). Unless you're doing something very esoteric I strongly doubt this has a big impact on performance (e.g. it's nothing compared to the actual insert). That said, you can look at Hibernate's sequence hi-lo generator - it would only access the sequence once in a while instead of every insert.
Upvotes: 1
Reputation: 322
If you're using Oracle 10 client or above, check out sequence-identity in the most recent Hibernate versions to do what you're asking for.
Upvotes: 0