-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDBCType BIT for boolean classes #1800
Comments
Type mapping is a concern on its own as there is a common set that applies to most databases. However, things deviate in the details as some databases do not have boolean types or bit types, or these would simply suggest using a specific type to map a certain Java type.
Zooming out, we derive column types based either on their Java type or, as an alternative, on a registered custom converter that can return You could also register a converter for your Generally, we currently do not support type hints on a per-property level (something like
All boolean types will map into |
That sounds good, thanks! A converter definitely works for me. It would be nice at a property level, but I'm glad i had a solution outside of reflection! |
#746 is related. It asks for a way to control the JDBCType to be used for method parameters. |
Note in this use case because the mapping is BIT for boolean values, Spring JDBC Template for setting arguments on a PreparedStatement ends up falling back to I.e. in theory Spring JDBC template could do something like:
around here |
The mapping of Java classes to JDBCType is currently static.
We should provide a way to customize that mapping, possibly via the
@Column
annotation and allow for a customization by differentDialect
implementations.Original issue, as raised by @kurtymckurt
I'm bringing this as curiosity because i'm not entirely sure if its an issue. I was recently using a JDBC driver for a proprietary system and their driver does not support the BIT JDBC type. Therefore, when using boolean fields, it would fail. It made me look into it and noticed that your mappings of Java classes to JDBC Type had BIT for boolean/Boolean as you can see here:
spring-data-relational/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/support/JdbcUtil.java
Line 77 in 967f0f9
However, the Spring framework JDBC core library seems to map Boolean/boolean to Types.BOOLEAN. You can see here:
https://github.com/spring-projects/spring-framework/blob/main/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java#L92
One obvious solution is to ask the proprietary company to support BIT type. I am curious if the BIT for boolean/Boolean deviation was purposeful. As a work around, i'm currently using reflection to remap the types as its a small service and the impact of this change seems rather low. Am I missing any other impact from doing this?
The text was updated successfully, but these errors were encountered: