I have a database on Oracle 11 XE and all my tables have primary keys that are NUMERIC(22,0)
. I have generated model classes with Hibernate tools
in Eclipse. Unfortunately, all NUMERIC
fields have been implemented as BigDecimal
s. Even fields representing INT
columns are changed too. I tried some reverse engineering, but it seems not to work in my case.
How can I fix it?
You better use BIGINT
instead of NUMERIC(22,0)
for your IDs. Then re-generate the entities. The Java-IDs should be of type Long
. If not you have to change the type manually. In general you should see generated entities more then a template which needs some modifications.
Reference: Mapping SQL and Java Types
You can customize the type mapping in Hibernate tools. Specify the mappings in the reveng.xml. Translate every JDBC type to a Hibernate type and run your generator again. E.g.
<sql-type>jdbc-type="NUMERIC" precision="22" hibernate-type="Long"</sql-type>
see also: http://omtlab.com/java-hibernate-reverse-engineering-eclipse-tutorial/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With