How to apply a to a stored function in jOOQ?

后端 未结 1 824
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 18:14

A common question among jOOQ users is how a can be applied to a stored function return type in the code generator. The manual specifies that

相关标签:
1条回答
  • 2021-01-24 18:32

    There is a synthetic parameter name that can be used. It's called return_value, which is also the name of the generated Parameter literal.

    The following specification will apply the same converter to both the P_I parameter and RETURN_VALUE:

    <forcedType>
      <userType>java.lang.String</userType>
      <converter>
        org.jooq.Converter.ofNullable(Integer.class, String.class, Object::toString, Integer::valueOf)
      </converter>
      <includeExpression>(?i:f_1\.p_i|return_value)</includeExpression>
    </forcedType>
    

    This produces the following Parameter specifications:

    /**
     * The parameter <code>STORED_FUNCTIONS.F_1.RETURN_VALUE</code>.
     */
    public static final Parameter<String> RETURN_VALUE = Internal.createParameter(
      "RETURN_VALUE", org.jooq.impl.SQLDataType.INTEGER, false, false, 
      org.jooq.Converter.ofNullable(Integer.class, String.class, Object::toString, Integer::valueOf)
    );
    
    /**
     * The parameter <code>STORED_FUNCTIONS.F_1.P_I</code>.
     */
    public static final Parameter<String> P_I = Internal.createParameter(
      "P_I", org.jooq.impl.SQLDataType.INTEGER, false, false, 
      org.jooq.Converter.ofNullable(Integer.class, String.class, Object::toString, Integer::valueOf)
    );
    
    0 讨论(0)
提交回复
热议问题