Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

java - JOOQ Vs Hibernate behavior

As we know Hibernate have a a very good feature SaveOrUpdate when we pass any object to this method it know data would be update or new record will be added in database. Is this feature also available in JOOQ Or in my code i have to handle this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

jOOQ does the same. If you change the primary key of a record, then it will use INSERT, otherwise, it will use UPDATE.

As it is, when you read a record from the database, then calling store() will trigger an UPDATE as you'd expect. If you create a new record, then it will be INSERTed.

With 2.6, it's a bit hard to clone a record and then ask jOOQ to update it (since cloning will set the primary key in a new instance, hence marking it as "new" -> insert).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...