Comments (6)
This is a duplicate of:
https://sourceforge.net/apps/trac/jooq/ticket/519
See the discussion here:
https://groups.google.com/forum/#!topic/jooq-user/p_G7Cg8V8Xc
With UNSIGNED BIGINT, the probem is not very relevant. As you say, extreme values are needed. But with UNSIGNED TINYINT there could be trouble.
The best workaround I've found so far is something like this:
http://mindprod.com/jgloss/unsigned.html
Maybe, unsigned numbers could be wrapped in some library:
http://stackoverflow.com/questions/8193031/is-there-a-java-library-for-unsigned-number-types
I also like your idea of storing unsigned values as String and only convert them to Byte / Short / Integer / Long when needed. I'd personally prefer the next larger number type, rather than String, though:
UNSIGNED TINYINT
-> contains Short
-> declares Field
UNSIGNED SMALLINT
-> contains Integer
-> declares Field
UNSIGNED INT
-> contains Long
-> declares Field
UNSIGNED BIGINT
-> contains BigInteger
-> declares Field
However, while the user could decide to convert those values to String when reading them, writing them leaves open questions again. Simply declaring Field or Field for SMALLINT can lead to other problems, considering that you can use numbers that are too large for SMALLINT...
What database are you using, by the way?
from jooq.
We're on MySQL, and we use the unsigned bigint to store hash codes from CityHash, so almost every value tends to be up there at the top of the range. Hibernate treats them as Strings without a problem, and luckily we don't need to read them from the new jOOQ code.., yet. =)
from jooq.
I thought so. With enum types, it can almost only be MySQL...
I see, I hadn't thought of hash codes, only generated ID's. So I realise that I should make this a high priority for 2.0.0 or 2.0.1...
On a side-note: How is migration from Hibernate to jOOQ working out for you? I'd be very interested in a success-story. If this is a success-story for you, after all :-)
from jooq.
We're just using jOOQ in some areas where we need lower level access. I think Hibernate serves our other use cases pretty well, though.
from jooq.
I see. That, too might make for an even better success story :)
Tell me if you see room for improvement in the interaction between jOOQ and Hibernate/JPA, e.g. with ResultQuery.fetchInto(Class<?>)
I think I'm going to implement the wrapper solution and open-source those wrappers in an independent module:
http://code.google.com/p/joou/
With the wrappers, everyone's needs are covered. The needs of those that need Number types, of those that need Strings, and of those that don't care (they can call .longValue() etc, on the wrappers)
By default, jooq-codegen will use the wrappers for unsigned types. There will be a configuration flag, to avoid using those wrappers, like today:
https://sourceforge.net/apps/trac/jooq/ticket/960
Also, in jOOQ 2.0.1, I'll be implementing custom type mapping for more fine-grained usage of unsigned data types:
https://sourceforge.net/apps/trac/jooq/ticket/947
I'm closing this issue as it will be implemented with
https://sourceforge.net/apps/trac/jooq/ticket/519
from jooq.
More information on this topic at: http://www.jooq.org/doc/3.0/manual/reference/reference-data-types/data-types-unsigned/ in relation to how JOOQ deals with this topic.
from jooq.
Related Issues (20)
- Memory leak in DefaultCacheProvider when large amounts of arbitrary projections are mapped with DefaultRecordMapper - Merge [#16315]
- Memory leak in DefaultCacheProvider when large amounts of arbitrary projections are mapped with DefaultRecordMapper - Merge [#16315]
- Kotlin 2.0.0 warns about Kotlin Record class annotation on "is" property HOT 4
- Settings.transformPatternsUnnecessaryScalarSubquery produces wrong SQL when subquery column is aliased HOT 1
- Settings.transformPatternsUnnecessaryScalarSubquery produces wrong SQL when subquery column is aliased - Merge [#16702]
- Settings.transformPatternsUnnecessaryScalarSubquery produces wrong SQL when subquery column is aliased - Merge [#16702]
- Pattern replacement activates RETURNING clause of DELETE / UPDATE statements HOT 3
- Pattern replacement activates RETURNING clause of DELETE / UPDATE statements - Merge [#16705]
- Pattern replacement activates RETURNING clause of DELETE / UPDATE statements - Merge [#16705]
- Settings.transformPatternsUnnecessaryScalarSubquery produces wrong SQL when subquery column is an embeddable HOT 2
- Settings.transformPatternsUnnecessaryScalarSubquery produces wrong SQL when subquery column is an embeddable - Merge [#16708]
- Settings.transformPatternsUnnecessaryScalarSubquery produces wrong SQL when subquery column is an embeddable - Merge [#16708]
- Wrong SQL generated when projecting inline derived table based on to-one implicit join path
- Inline derived tables have no effect when used as explicit join paths
- Error related to unsupported implicit to-many join caused by internal hash function
- Add Kotlin and Scala code generator support for synonyms via type aliases
- Add Functions.let(T1, T2, ..., TN, Function[N]<? super T1, ? super T2, ..., ? super TN, ? extends R>) utilities HOT 2
- Generate MyTable.let(Function<? super MyTable, ? extends R>) utilities on generated tables HOT 5
- Jooq codegen doesnt generate POJO for one table HOT 1
- Compilation error in user code when trying to infer type of select(SelectField<T>) call from higher order function argument
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jooq.