MySQL TINYINT(3) is mapped to Byte

238 views
Skip to first unread message

ariel...@gmail.com

unread,
Feb 27, 2014, 5:19:03 PM2/27/14
to jooq...@googlegroups.com
What's the corresponding Java type? Is the expectation that the user cast an int variable to a byte?

Thanks

Lukas Eder

unread,
Feb 28, 2014, 2:12:27 AM2/28/14
to jooq...@googlegroups.com
Hi,

A SQL TINYINT has 8 bits or 1 byte, so the closest match in the Java world is java.lang.Byte. We chose wrapper types over primitive types for two reasons:

1. They can be NULL
2. They work better with the all-present generics in jOOQ's API

If you're working with int variables in your user code, you will have to turn them into java.lang.Byte manually, through casting and (auto-)boxing.

If you prefer to work with java.lang.Integer instead (deferring the risk of overflow to the database), you can rewrite data types in the code generator:

Cheers
Lukas

Ariel Tal

unread,
Feb 28, 2014, 1:25:53 PM2/28/14
to jooq...@googlegroups.com
OK, thanks I'll give that a try. Data-type rewrites are a good workaround.

FYI, the link below points to a dead-end: 
This link works:

Lukas Eder

unread,
Mar 1, 2014, 4:06:34 AM3/1/14
to jooq...@googlegroups.com
Hi Ariel,

2014-02-28 19:25 GMT+01:00 Ariel Tal <ariel...@gmail.com>:
OK, thanks I'll give that a try. Data-type rewrites are a good workaround.

Great!
 
FYI, the link below points to a dead-end: 
This link works:

You're right, that was a typo. One of the "manual" path elements should've been "latest", as in:
Reply all
Reply to author
Forward
0 new messages