I'm working on a Java project where I've been tasked to write a few database mappings against a legacy database.
While doing this, I started to question how I was supposed to test if my mappings were valid or not. Most likely I've done a couple of mistakes in my mappings as I'm not a seasoned JPA annotations user.
So what is the general opinion/best-practice regarding testing manually written JPA mappings though annotations?
If you're using Hibernate, you can set the following in your persistence.xml file:
<property name="hibernate.hbm2ddl.auto" value="validate" />
to get Hibernate to validate the existing schema but NOT make any changes to the schema. It's a quick way to see if your mappings are valid or not against your DB.
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