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

querydsl-sql generation of Boolean from Oracle DB #513

Closed
dmiorandi opened this Issue Sep 27, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@dmiorandi

This is the method inside com.mysema.query.sql.JDBCTypeMapping.
I've defined a numeric(1,0) type to rapresent a Boolean value but this code
map it as a Byte. Boolean is never generated (unreachable code)

Locally I've made a patch to this code to have this behavior
NUMERIC(2,0) ==> Byte
NUMERIC(1,0) ==> Boolean

....
            } else if (size > 2) {
                return Short.class;
            } else if (size > 1) {
                return Byte.class;
            } else {
                return Boolean.class;
            }
....

but this not allow to rapresent 1 digit Bytes. Another trick should be to
rapresent Boolean with NUMERIC(1,-1) with this other patch

            } else {
                return Boolean.class;
            }
        } else {
            if (size == -1 && digits==1) {
                return Boolean.class;
            }
            else if (size > 16) {
                return BigDecimal.class;
            } else {
                return Double.class;
            }
        }

Maybe 2nd one is better: What do you think about? Is applicable to distribution?
What's your opinion about generation of Boolean in Oracle?

   private Class<?> getNumericClass(int size, int digits) {
        Pair<Integer,Integer> key = Pair.of(size, digits);
        if (numericTypes.containsKey(key)) {
            return numericTypes.get(key);
        } else if (digits == 0) {
            if (size > 18) {
                return Long.class;
            } else if (size > 5) {
                return Integer.class;
            } else if (size > 2) {
                return Short.class;
            } else if (size > 0 ) {
                return Byte.class;
            } else {
                return Boolean.class;
            }
        } else {
            if (size > 16) {
                return BigDecimal.class;
            } else {
                return Double.class;
            }
        }
    }
@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 29, 2013

Member

Boolean is represented as numeric(1,0) in Hibernate, so maybe that could be used in Querydsl as well?

Member

timowest commented Sep 29, 2013

Boolean is represented as numeric(1,0) in Hibernate, so maybe that could be used in Querydsl as well?

@dmiorandi

This comment has been minimized.

Show comment
Hide comment
@dmiorandi

dmiorandi Sep 29, 2013

Yes! I think numeric (1,0) is the beast approach, because (1,-1) have some issue in old oracle, so first patch that I proposed should be ok.

Yes! I think numeric (1,0) is the beast approach, because (1,-1) have some issue in old oracle, so first patch that I proposed should be ok.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 20, 2013

Member

Released in 3.2.4

Member

timowest commented Oct 20, 2013

Released in 3.2.4

@timowest timowest closed this Oct 20, 2013

@timowest timowest added this to the 3.2.4 milestone Apr 13, 2014

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