Hi,I usually don't use Pojos but while preparing for a talk I used this feature.pojosAsJavaRecordClassesWhat's the reason for generating equals/hashCode and toString? Those are part of the Record spec anyway and are superfluous.
POJOsequals/hashCode use all attributes. Why?If the underlaying database table has a Primary or a Unique key only those attributes should be used.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5dKcLvkr9JTbgQiD5qU%2BkhzvM%2B4U-eik8s6yf4C%2BZ5Wg%40mail.gmail.com.
POJOsequals/hashCode use all attributes. Why?If the underlaying database table has a Primary or a Unique key only those attributes should be used.See:
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO7J6VXBSVfq4ObiAc%2BLVA6o0JdFaBZteqQTdU_yQ%2BHJbA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/C9399175-44C2-4440-A2EF-5DC46AB0FF2E%40gmail.com.
23. okt. 2024 kl. 09:10 skrev Lukas Eder <lukas...@gmail.com>:
I've thought about this again. All 3 options (I'm not seeing others, at them moment) come with their own tradeoff. In terms of what jOOQ did historically, I think option 1 is the soundest. The rationale is that POJOs have always been value types in jOOQ, not entities. Their identity is irrelevant, only their contents count. Making the code generator ignore non-PK columns in equals() and hashCode() is simply a special case of making the code generator ignore *some* columns in equals() and hashCode(), as per this related feature request:
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/3e95c18d-3a38-495d-8e55-2af93e23cc8bn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/D2D734AE-32D4-4E89-9C55-CD7E4FC7D1E3%40lervag.net.
IMO, that’s the important message: “what jOOQ thinks a POJO is. It's a bag of values, not an entity”As I said, I use DAOs and POJOs only for a demo because I have never found a real-life use case.
One of the issues with equals/hashCode is that if I use the POJOs together with some frameworks that use those methods, the current implementation is incorrect in the context of those frameworks.For example, if I use a POJO in a Vaadin Grid and try to refresh the item in the Grid, this will not work because equals will return false after editing the POJO.I had the same issue with the jOOQ Records and therefore created this https://github.com/72services/jooq-utilities
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO79J0vPQFJqg-bpKtF0oQhgnaZF5c%3DwK%2BFnay3Spfwiig%40mail.gmail.com.
IMO, that’s the important message: “what jOOQ thinks a POJO is. It's a bag of values, not an entity”