Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell querydsl-maven-plugin to generate NumberPath with Long instead of BigDecimal?

I am using querydsl-maven-plugin in order to export Q paths from an Oracle 11g database. The problem I am facing is that Oracle NUMBER fields are mapped to NumberPath<java.math.BigDecimal> instead of NumberPath<Long>

Is there any way I can instruct querydsl-maven-plugin to translate BigDecimal to Long during code generation?

The approach I am taking right now is to use the plugin to generate the code and then translate types by hand.

Any hints would be appreciated.

like image 752
benishor Avatar asked Nov 03 '22 15:11

benishor


1 Answers

It is currently possible to declare custom user types in the configuration of the querydsl-maven-plugin like this

<configuration>
  <customTypes>
    <customType>com.example.NumericLongType</customType>
  </customTypes>
</configuration>

com.example.NumericLongType would need to implement the com.mysema.query.sql.types.Type interface

But ideally this should be something like this

<configuration>
  <overrides>
    <NUMERIC>java.lang.Long</NUMERIC>
  </overrides>
</configuration>

and Querydsl would handle the mapping from NUMERIC to Long internally.

Feel free to open a ticket for it.

Update

Numeric mappings are now customizable in Querydsl https://github.com/mysema/querydsl/issues/273

like image 145
Timo Westkämper Avatar answered Nov 15 '22 01:11

Timo Westkämper