Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JOOQ concatenation

I have a query like this:

Result<?> result = create.select(CONSUMER.CONS_ID_NO,
                                             CONSUMER.CONS_NAME,
                                             concat(CONSUMER.AREA_CODE, "/", CONSUMER.CONS_NO, "/", CONSUMER.CAT_CODE).as("ConsNo"),
                                             CONSUMER.ARREARS)
                                            .from(CONSUMER)
                                            .fetch();

I wrote this according to the JOOQ Manual, but I am getting an error that says:

The method concat(String...) in the type Factory is not applicable for the arguments (TableField, String, TableField, String, TableField)

I am using JOOQ-3.

like image 522
kaushik Avatar asked Mar 13 '13 03:03

kaushik


1 Answers

It seems that the sample in the manual doesn't work. However, you can convert a string to Filed via org.jooq.impl.Factory.val.

    Record result = create.select(
            concat(AUTHOR.FIRST_NAME, val(" "), AUTHOR.LAST_NAME).as("Full Name")
    ).from(AUTHOR).fetchAny();

Please refer to this email from Lukas Eder for details

like image 83
longhua Avatar answered Oct 16 '22 20:10

longhua