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

Improved type-mapping for numbers #273

Closed
ssaarela opened this Issue Nov 8, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@ssaarela
Contributor

ssaarela commented Nov 8, 2012

Current Type contains only mapping from SQL type to Java class. SQL type number has many mapping alternatives depending on precision and scale. For example number(19) should be mapped to Long but number(19,4) to BigDecimal.

Would it be possible to extend Type interface and related metadata exporters/configurations to allow using precision and scale in mapping?

In DatabaseMetaData.getColumns ResultSet we have

7 COLUMN_SIZE int => column size. = precision
9 DECIMAL_DIGITS int => the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable.

Perhaps this extended type mapping interface could utilize all available column metadata for maximum expressivity?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 8, 2012

Member

Is there a standard mapping available? Based on Hibernate's OracleDialect and this I came up with this

19-...,0   -> Long
6-18,0     -> Integer
4-5,0      -> Short
2-3,0      -> Byte
1,0        -> Boolean

17-...,?   -> BigDecimal
0-16,?     -> Double

If the mapping interface would support all metadata then it would probably need to be a callback signature, which would be expressive, but would be a major refactoring.

I'd start with a mapping that can be tuned via the Configuration interface.

Member

timowest commented Nov 8, 2012

Is there a standard mapping available? Based on Hibernate's OracleDialect and this I came up with this

19-...,0   -> Long
6-18,0     -> Integer
4-5,0      -> Short
2-3,0      -> Byte
1,0        -> Boolean

17-...,?   -> BigDecimal
0-16,?     -> Double

If the mapping interface would support all metadata then it would probably need to be a callback signature, which would be expressive, but would be a major refactoring.

I'd start with a mapping that can be tuned via the Configuration interface.

timowest added a commit that referenced this issue Nov 12, 2012

@ssaarela

This comment has been minimized.

Show comment
Hide comment
@ssaarela

ssaarela Nov 12, 2012

Contributor

Wow! That was a big refactoring and much needed. Thanks (again) for quick response! When's the next release?

Contributor

ssaarela commented Nov 12, 2012

Wow! That was a big refactoring and much needed. Thanks (again) for quick response! When's the next release?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 13, 2012

Member

I will make a release at the end of this week.

Member

timowest commented Nov 13, 2012

I will make a release at the end of this week.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 19, 2012

Member

Released in 2.9.0

Member

timowest commented Nov 19, 2012

Released in 2.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment