분명, JDBC를 사용할 때에는, TinyInt를 Integer로 매핑을 했던 기억이 있는데, 에러가 발생하여 찾아보니
TinyInt(1)의 경우에만 Boolean으로 매핑이 되는 걸 알 수 있었다.(당연하겠지만...)
R2dbc에서는 다른 매핑으로 작동될 까 걱정했지만, 우선 tinyInt를 boolean으로 매핑하는 점은 jdbc와 동일 한 것 같다.
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html
MySQL Type NameReturn value of GetColumnTypeNameReturn value of GetColumnClassName
BIT(1) | BIT | java.lang.Boolean |
BIT( > 1) | BIT | byte[] |
TINYINT(1) SIGNED, BOOLEAN | If tinyInt1isBit=true and transformedBitIsBoolean=false: BIT If tinyInt1isBit=true and transformedBitIsBoolean=true: BOOLEAN If tinyInt1isBit=false: TINYINT |
If tinyInt1isBit=true and transformedBitIsBoolean=false: java.lang.Boolean If tinyInt1isBit=true and transformedBitIsBoolean=true: java.lang.Boolean If tinyInt1isBit=false: java.lang.Integer |
TINYINT( > 1) SIGNED | TINYINT | java.lang.Integer |
TINYINT( any ) UNSIGNED | TINYINT UNSIGNED | java.lang.Integer |
SMALLINT[(M)] [UNSIGNED] | SMALLINT [UNSIGNED] | java.lang.Integer (regardless of whether it is UNSIGNED or not) |
MEDIUMINT[(M)] [UNSIGNED] | MEDIUMINT [UNSIGNED] | java.lang.Integer (regardless of whether it is UNSIGNED or not) |
INT,INTEGER[(M)] | INTEGER | java.lang.Integer |
INT,INTEGER[(M)] UNSIGNED | INTEGER UNSIGNED | java.lang.Long |
BIGINT[(M)] | BIGINT | java.lang.Long |
BIGINT[(M)] UNSIGNED | BIGINT UNSIGNED | java.math.BigInteger |
FLOAT[(M,D)] | FLOAT | java.lang.Float |
DOUBLE[(M,B)] [UNSIGNED] | DOUBLE | java.lang.Double (regardless of whether it is UNSIGNED or not) |
DECIMAL[(M[,D])] [UNSIGNED] | DECIMAL | java.math.BigDecimal (regardless of whether it is UNSIGNED or not) |
DATE | DATE | java.sql.Date |
DATETIME | DATETIME | java.time.LocalDateTime |
TIMESTAMP[(M)] | TIMESTAMP | java.sql.Timestamp |
TIME | TIME | java.sql.Time |
YEAR[(2|4)] | YEAR | If yearIsDateType configuration property is set to false, then the returned object type is java.sql.Short. If set to true (the default), then the returned object is of type java.sql.Date. |
CHAR(M) | CHAR | java.lang.String |
VARCHAR(M) | VARCHAR | java.lang.String |
BINARY(M), CHAR(M) BINARY | BINARY | byte[] |
VARBINARY(M), VARCHAR(M) BINARY | VARBINARY | byte[] |
BLOB | BLOB | byte[] |
TINYBLOB | TINYBLOB | byte[] |
MEDIUMBLOB | MEDIUMBLOB | byte[] |
LONGBLOB | LONGBLOB | byte[] |
TEXT | TEXT | java.lang.String |
TINYTEXT | TINYTEXT | java.lang.String |
MEDIUMTEXT | MEDIUMTEXT | java.lang.String |
LONGTEXT | LONGTEXT | java.lang.String |
JSON | JSON | java.lang.String |
GEOMETRY | GEOMETRY | byte[] |
ENUM('value1','value2',...) | CHAR | java.lang.String |
SET('value1','value2',...) | CHAR | java.lang.String |
Table 6.19 Possible Conversions Between MySQL and Java Data Types
These MySQL Data TypesCan always be converted to these Java types
CHAR, VARCHAR, BLOB, TEXT, ENUM, and SET | java.lang.String, java.io.InputStream, java.io.Reader, java.sql.Blob, java.sql.Clob |
FLOAT, REAL, DOUBLE PRECISION, NUMERIC, DECIMAL, TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT | java.lang.String, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Double, java.math.BigDecimal |
DATE, TIME, DATETIME, TIMESTAMP | java.lang.String, java.sql.Date, java.sql.Timestamp |
'java,springboot' 카테고리의 다른 글
[Spring] mapstruct 사용법 (with custom method로 매핑) (0) | 2023.05.09 |
---|---|
[Springboot] Error:IllegalStateException: Required property b not found for class (0) | 2023.04.21 |
Spring - DI 세가지 방법 (생성자 방식이 좋은 이유 with code) (0) | 2023.04.19 |
[springboot] 부모 클래스 생성자 에러 해결 - 생성자 주입 방식 (0) | 2023.04.18 |
Spring - Bean으로 등록하는 2가지 방법(컴포넌트 스캔, 자바 코드) (0) | 2023.04.07 |