I'm using jOOQ to get id which in MySQL is smallint unsigned primary key auto_increment
public List<Integer> getID() {
Factory sql = new Factory(Database.getInstance().connect(), SQLDialect.MYSQL);
return (List<Integer>) sql.select().from("users").fetch().getValues("id_users");
}
And go error
org.jooq.tools.unsigned.UShort cannot be cast to java.lang.Integer
Here they wrote that smallint unsigned should be cast to int.
Edit Method should be
public List<UShort> getID() {
Factory sql = new Factory(Database.getInstance().connect(), SQLDialect.MYSQL);
return (List<UShort>) sql.select().from("users").fetch().getValues("id_users");
}
And in loop result should be cast to int.
You cannot cast UShort into Integer as it does not inherit that class. I guess you should use UShort.intValue()
to retrieve the Integer.
The java lang cannot cast that directly. You need am intermediate step.
Something like UShortval.intValue()
Iterate the result of the query, and build up a new List where you add the result of ushortval.intValue()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With