Skip to content
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
Closed

Improved type-mapping for numbers #273

ssaarela opened this issue Nov 8, 2012 · 4 comments

Comments

@ssaarela
Copy link
Contributor

@ssaarela 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
Copy link
Member

@timowest 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
Copy link
Contributor Author

@ssaarela 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
Copy link
Member

@timowest timowest commented Nov 13, 2012

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

@timowest
Copy link
Member

@timowest 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants