All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Well, you can write a SQL query (however that's done in Hibernate) and check for the existence to the key first. This is probably better than getting an exception.
No more Blub for me, thank you, Vicar.
You can either do this before the INSERT (resulting in 2 DB operations for the overall insert process), or you can let the SQL INSERT find the duplicate and then you either do an upsert or handle the exception.
Samar Land wrote:I Like to share with you what it comes to my mind this morning;
I can do a list in Java code with for loop to check through teams I have already in DB before adding the record.
No more Blub for me, thank you, Vicar.
Don't use Java to do things that can be done more efficiently in SQL
Don't get me started about those stupid light bulbs. |