Search code examples
javajpaeclipselink

Verify JPA column mappings at load time


Current project recently had a mess of changes to the DB schema. These were largely style cleanups, such as ensuring that all columns followed a consistent naming pattern and were all_in_snake_case .

I believe we got all of the column references in our DB as well as in our Entities, is it possible to have JPA, EclipseLink, or GlassFish do some sort of "verify all" operation to ensure that each entities columns exist and match??


Solution

  • My two cents:

    • write unit test for each of your entity to test the mapping and the queries in the DAO. That's an asset for the future which is worth it.
    • you can create the database schema out of the mapping or annotation (turn automatic generation of tables on with eclipselink.ddl-generation), and then compare the two database schemas using some database tool (that will depend on your database. Maybe your DBA, if you have one, can help).