自动附加新记录

发布于 2025-01-21 15:55:01 字数 473 浏览 4 评论 0原文

是否可以连接默认配置来创建新记录,而不是每次手动附加?我看到,在执行选择时,它会自动连接记录,如果我可以跳过此步骤,以获取创建的每个新记录。

var address = new AddressRecord();
address.attach(jooq().configuration());
address.setAddress(addressTemplate.getAddress());
address.setState(addressTemplate.getState());
address.setCity(addressTemplate.getCity());
address.setZipcode(addressTemplate.getZipcode());
address.setCountryId(addressTemplate.getCountryId());

Is it possible to attach a default configuration for creating new records instead of manually attaching each time? I saw that while performing a SELECT it automatically attaches the record, would be nice if I could skip this step for every new record created.

var address = new AddressRecord();
address.attach(jooq().configuration());
address.setAddress(addressTemplate.getAddress());
address.setState(addressTemplate.getState());
address.setCity(addressTemplate.getCity());
address.setZipcode(addressTemplate.getZipcode());
address.setCountryId(addressTemplate.getCountryId());

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不甘平庸 2025-01-28 15:55:01

由于Java构造函数调用的性质(new AddressRecord()),因此无法拦截此类调用,例如将结果对象连接到configuration

但是您可以使用jOOQ()。newRecord(address),它会产生附带的记录。您还可以使用jOOQ()。newRecord(address,addressTemplate)使用 defaultrecordunmapper

Due to the nature of a Java constructor call (new AddressRecord()), it is not possible to intercept such a call e.g. in order to attach the resulting object to a Configuration.

But you can use jooq().newRecord(ADDRESS) instead, which produces an attached record. You can also use jooq().newRecord(ADDRESS, addressTemplate) to copy values using the DefaultRecordUnmapper

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文