Dali Java Persistence Tools - Database datatype to Java datatype mapping

166 views Asked by At

I am using Dali Java Persistence tool to create entities for an existing database with over 300 database tables. If I run the tool, it converts

  • database xml type to java Object
  • database timestamp to java timestamp
  • database integer to java int

and so on.

When I put my entities in the Spring project, lots of these datatype mappings (for example the 3 mentioned above) cause errors in the server startup, and some mappings cause failure during the CRUD operations.

I have the correct datatypes mappings that are working for me.

I can see that the Dali tool gives me an option to set the datatype mappings for each table.

The problem is I have over 300 tables and these same mappings repeat in all these tables.

I want to change the behavior of the tool to map database XML to java String, database integer to java Integer, database timestamp to java java.sql.Date etc.

I don't want to go to each and every one of these 300 tables and make the same changes in the datatype mappings.

Is it possible to specify the behavior of the Dali Java Persistence Tool to perform the mappings the way I want rather than the way it does the mapping, without going to each and every table and change it individually.

Thanks in advance.

1

There are 1 answers

2
Brian Vosburgh On

I have not tried this in years, but it might still work:

Dali (the part of Eclipse that generates JPA entities) uses DTP (another part of Eclipse) to determine the Java attribute type for a particular data type. These mappings are database platform-specific and are specified in .xmi files in various DTP plug-ins.

For example, in Eclipse JEE 2021-03, for PostgreSQL, the data type ABSTIME is mapped to the Java type java.lang.Object in the file /runtime/vendors/postgresql/postgresql_8.x.xmi in the plug-in jar ./plugins/org.eclipse.datatools.enablement.postgresql.dbdefinition_1.2.101.201811012051.jar.

Depending on your database platform and what other plug-ins you have installed, these settings could different. You can extract the appropriate .xmi file, edit it, and return it to its jar and this should alter how entities are generated.