PersonRecord p = //... select ... assert p.getName() == "Otto"; p.setName("Max"); //ok changed is true p.setName("Max"); // ok changed is still true, change flag is not resetted p.setName("Otto"); //why changed flag remains true? p.store();
PersonRecord p = //... select ... assert p.getName() == "Otto";
p.setName("Otto"); //why changed flag remains true?
p.store();p.reset();
Hi,I'm playing a bit with UpdatableRecords, and I'm falling into this issue: primary key is marked as changed also when setted value is the same of prevoius one.I wirte a test to reproduced the issue:1) using set<columnName> of generated record2) using ModelMapper (corresponds to the previous case because it uses generated set)This test fails:@Test public void test() {AccountUserRecord r = ctx.fetchOne(ACCOUNT_USER, ACCOUNT_USER.ID.eq(1L));
r.setId(1L);assertFalse(r.changed(ACCOUNT_USER.ID));
}When I use setValue(Field, value) the behaviour is correct, as a matter of fact this test pass:@Test public void test() {AccountUserRecord r = ctx.fetchOne(ACCOUNT_USER, ACCOUNT_USER.ID.eq(1L));r.setValue(ACCOUNT_USER.ID, 1L);
assertFalse(r.changed(ACCOUNT_USER.ID));}
For completeness' sake I attached a full maven project to highlight the problem, the project require mysql.
Generated AccountUserRecord.setId is the following code:public void setId(java.lang.Long value) {setValue(0, value);}Why use setValue(int, value) instead of setValue(Field, value)?
Is this an issue of code generator?I read https://github.com/jOOQ/jOOQ/issues/945?source=c and https://github.com/jOOQ/jOOQ/issues/948 but I'm still puzzled:PersonRecord p = //... select ... assert p.getName() == "Otto"; p.setName("Max"); //ok changed is true p.setName("Max"); // ok changed is still true, change flag is not resetted p.setName("Otto"); //why changed flag remains true? p.store();Cheers--Daniele
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Daniele,The rationale behind this is easy to explain:PersonRecord p = //... select ... assert p.getName() == "Otto";p.setName("Otto"); //why changed flag remains true? p.store();Explicitly setting a value in a record means that you want this value to appear in an INSERT / UPDATE statement. This may have desired side-effects on triggers and other database objects. Note that there is alsop.reset();In order to reset the changed flags and the value.
Hope this helps
CheersLukasIs this an issue of code generator?I read https://github.com/jOOQ/jOOQ/issues/945?source=c and https://github.com/jOOQ/jOOQ/issues/948 but I'm still puzzled:PersonRecord p = //... select ... assert p.getName() == "Otto"; p.setName("Max"); //ok changed is true p.setName("Max"); // ok changed is still true, change flag is not resetted p.setName("Otto"); //why changed flag remains true? p.store();Cheers--Daniele
assertEquals("x", user.getEmail());
user.setEmail("x"); // This has no effect
user.setEmail("y"); // This sets email to "y"user.setEmail("x"); // This has no effect (!)
--
I agree that it might be nice to be able to influence whether assigning the same value again to a Record should set the changed flag to true. I think that this behaviour should be adaptable through a Setting, though. There is a feature request pending for jOOQ 3.3:
--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/gtMxNzg02NA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.