Hibernate JPA how to configure dynamic-update in persistence.xml
Asked Answered
A

1

5

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?

Avisavitaminosis answered 31/5, 2012 at 16:28 Comment(2)
Please note that I know how to do in hibernate configuration. But here I want to do it in persitence.xmlAvisavitaminosis
What is the problem with hibernate configuration files?Surra
P
5

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.

Prohibit answered 26/10, 2012 at 23:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.