Hibernate JPA如何在persistence.xml中配置动态更新
我不想在我的java源代码中进行如下配置:Hibernate JPA如何在persistence.xml中配置动态更新,hibernate,jpa,persistence.xml,Hibernate,Jpa,Persistence.xml,我不想在我的java源代码中进行如下配置: @org.hibernate.annotations.Entity( dynamicUpdate = true) 因为我希望它是可配置的 我使用的不是hibernate.properties,而是persistence.xml,因为我使用的是JPA。如何使仅使用persistence.xml的所有实体的dynamicUpdate成为true。在本例中,您试图配置特定于Hibernate实现的内容,而不是JPA标准的一部分。如果它是一
@org.hibernate.annotations.Entity(
dynamicUpdate = true)
因为我希望它是可配置的
我使用的不是hibernate.properties,而是persistence.xml,因为我使用的是JPA。如何使仅使用
persistence.xml
的所有实体的dynamicUpdate
成为true
。在本例中,您试图配置特定于Hibernate实现的内容,而不是JPA标准的一部分。如果它是一个有助于配置实现的属性,那么许多属性可以通过persistence.xml传递给实现,但是在本例中,如果您试图为每个实体配置属性,则必须使用Hibernate方法。你可能已经看到了波佐的一个非常相似的答案
尽管如此,如果您决定继续使用org.hibernate.*注释进行配置,您将无法真正使其可配置,因为注释值必须是常量表达式
一个有趣的解决方案是在启动侦听器中修改所有持久类并添加属性。您可以读取配置的值,并使用回答中描述的机制进行设置。请注意,我知道如何在hibernate配置中进行设置。但是在这里我想在persitence.xml中实现它hibernate配置文件有什么问题?