This week I've continued converting classes/tables from XML to JPA
annotations, and making sure they work with Hibernate 5 / PostgreSQL in
the process. I've taken the approach of converting the most complicated
cases first, on the theory that once those are prototyped, similar cases
should be fairly mechanical. This results in less visible progress, but
it should (I hope) also take less time overall, and allow for
parallelization. Confounding that, however, is how closely everything is
tied together, and the difficulty in testing one thing when it's linked
to something else which is broken.
As I've been going through
the things that are persisted to the database, I've been renaming tables
and columns to follow the conventions I'm more familiar with and which I
find more readable. I understand that's subjective, but at the moment I
believe I'm the only one working on this with opinions on the subject,
and will be working with it most closely in the near future. Some
examples are: column `applicant_typ` -> `applicant_type`, column `id`
-> `audit_record_id`, table `lu_provider_type` ->
`provider_types`, and so on. Basically: try to have ID columns that
include the table name, use whole, correctly spelled words, avoid
Hungarian notation, use snake_case, and use plural table names. If you
have opinions on any of this, I would love to hear them!
There are a few bits of complexity I haven't worked through yet: polymorphism, bags, and outer joins.
The
former is implemented as a pair of columns to be an application-side
foreign key to several different tables; ie, ('AgreementDocument', '02')
-> agreement_documents(agreement_document_id=2). Aside from
giving up database integrity by using real foreign keys on a link table,
this is also breaking because PostgreSQL is reasonably saying "you
can't compare a string to a number, stop it". I need to study the two
instances of polymorphic tables to better understand what they're doing,
but broadly speaking, my plan is to try to better represent these
relationships in the database.
The latter two are less
complicated, and so far have not caused any errors; I think I just need
to study and understand what it's doing now and figure out how to do the
same thing with annotations.
Overall, I think I'm getting close; barring any surprises, I hope to finish the hibernate migration next week!
Thanks,
Jason