I do NOT want to configure in my java source code which can be done like:
@org.hibernate.annotations.Entity(
dynamicUpdate = true)
because I want it to be configurable.
I am not using hibernate.properties, only persistence.xml as I am using JPA. How can I make dynamicUpdate
as true
for all entities using persistence.xml
only?
You are using the JPA standard with the Hibernate implementation. In this case, you are attempting to configure something that is specific to the Hibernate implementation and not a part of the JPA standard. If it's a property that helps configure the implementation, then many of those can be passed to the implementation through persistence.xml, but in this case where you are attempting to configure the property for each entity, you are going to have to do it the Hibernate way. You've probably seen this question with a very similar answer by Bozho.
With all that, if you decide to go ahead with org.hibernate.* annotations for configuration, you won't really be able to make it configurable because annotation values must be constant expressions.
One interesting solution would be something in a startup listener that would modify all the persistent classes and add the attribute. You could read the configured value and set it using the mechanism described in the answer to this question.
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