简体   繁体   English

jOOQ-dao-插入对象的主键

[英]jOOQ - dao - primary key of inserted object

I am using the DAO's as generated by jOOQ: 我正在使用jOOQ生成的DAO:

<generate>
    <relations>true</relations>
    <records>true</records>
    <pojos>true</pojos>
    <daos>true</daos>
    <interfaces>true</interfaces>
    <globalObjectReferences>true</globalObjectReferences>
    <jpaAnnotations>true</jpaAnnotations>
    <validationAnnotations>true</validationAnnotations>
    <fluentSetters>true</fluentSetters>
</generate>

After inserting a POJO to the database, how do I get the created identifier/primary key? 将POJO插入数据库后,如何获取创建的标识符/主键? The insertion succeeds, but calling getIdentifier() on the POJO still returns null . 插入成功,但是在POJO上调用getIdentifier()仍返回null

This is a missing feature in jOOQ 3.5 and is tracked as two independent feature requests: jOOQ 3.5中缺少此功能,并作为两个独立的功能请求进行跟踪:

Right now, you cannot fetch generated keys on insert unless you implement your own insert() method, or extend the code generator to generate that method for you. 现在,除非实现自己的insert()方法或扩展代码生成器为您生成该方法,否则您无法在insert上获取生成的键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM