I am always looking for ways to eliminate redundant code from my project.
I am using Hibernate with Spring. I set up Spring JPA LocalContainerEntityManagerFactoryBean, which allows you to pass a bunch of properties to the JPA provider (Hibernate), which means I don't need to set these properties in the persistence.xml file.
In addition, Hibernate can find my constant classes without actually defining them in the persistence.xml file, so those <class> lines also go away.
I am left with one line in my persistence.xml:
<persistence-unit name="bigDatabase" transaction-type="RESOURCE_LOCAL"/>
Does anyone know a way to completely eliminate persistence.xml and transfer the definition of the unit of duration to the Spring configuration file? Of course, I tried Google, but could not find the answer.
Thanks!
source share