JPA and support provider and database compatibility

JPA promises is provider neutral for persistence and database. But I already know that some persistence frameworks like hibernation are not ideal (character encoding, null comparison) and you need to adapt your schema for each database. Since there are two levels (persistence framework and database), I would guess that they are working on some JPA code ...

Does anyone have any experience with multiple support, and if so, what tricks and guidelines avoid this kind of incompatibility?

+2


a source to share


1 answer


At the JPA level, the only thing you can do is use the JPA API of the currently used persistence library (i.e. when using hibernate, don't use Hibernate.initialize ()).

At the DB level, it is best to keep things simple, as the chances of behavioral differences increase as you move away from the most commonly used use cases. In particular, it might mean not using composite primary keys, not storing binary data, and not doing SQL execution at all ... I'm sure others will have better examples of practices that will allow you to easily transition from one database to other.



The above allowed me to switch one application between PostgreSQL and Oracle and another between PostgreSQL and multiple "dialects" (in a dormant language) of MySQL.

+2


a source







All Articles