I just upgraded my project's hibernate version to 5.0.0.FINAL. But than I realise that, I am getting this warning. And I want to get rid of it. I don't know if it will effect my application or not.
2015-08-24 14:29:22.235 WARN --- [ main] org.hibernate.orm.deprecation : HHH90000003: Use of DOM4J entity-mode is considered deprecated
Since I never used entity-mode explicitly, I searched online but there is almost no information about it. Here is the EntityMode enum. Since, there is no DOM4J
mode any more, I am suspecting that I might get an error in production if I continue to use hibernate in version 5.0.0.
I am also using envers with hibernate. If I disable envers the warning also disappears.I am using spring alongside with hibernate and envers. And here is the versions of them.
<spring.version>4.2.0.RELEASE</spring.version>
<hibernate.version>5.0.0.Final</hibernate.version>
<hibernate.envers.version>5.0.0.Final</hibernate.envers.version>
<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
<project.java.version>1.8</project.java.version>
And here is my hibernate-jpa configuration.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="commonsEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="commonDataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.ejb.interceptor">com.examples.dao.utils.AbstractEntityInterceptor</prop>
<!--<prop key="hibernate.listeners.envers.autoRegister">false</prop>-->
<prop key="hibernate.implicit_naming_strategy">org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl</prop>
<prop key="hibernate.physical_naming_strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.showSql">${hibernate.showSql}</prop>
<prop key="hibernate.formatSql">${hibernate.formatSql}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop>
<prop key="hibernate.default_batch_fetch_size">${hibernate.default_batch_fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
<prop key="org.hibernate.envers.audit_table_suffix">${org.hibernate.envers.audit_table_suffix}</prop>
<prop key="javax.persistence.sharedCache.mode">${javax.persistence.sharedCache.mode}</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.examples.entity</value>
</list>
</property>
</bean>
<bean id="commonsTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="commonsEntityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="commonsTransactionManager"/>
<context:component-scan base-package="com.examples.dao.*"/>
</beans>
And here is an example entity.
@Entity
@Table(name = "T_USER")
@Access(AccessType.FIELD)
@Audited
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "C_USERNAME", unique = true)
private String username;
@Column(name = "C_PASSWORD")
private String password;
@Column(name = "C_EMAIL")
private String email;
// Getters && Setters etc
}
I created a project on github that demonstrates this behaviour. After debugging a little, I found out that the warning message is created on ModelBinder#L2441.
Here is the sample code:
public class ModelBinder
...
private void bindProperty(
MappingDocument mappingDocument,
AttributeSource propertySource,
Property property) {
property.setName( propertySource.getName() );
if ( StringHelper.isNotEmpty( propertySource.getName() ) ) {
// Here is the line that print outs the log I was mentioned
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfDomEntityModeSupport();
}
...
}
}
And when I looked into the value of mappingDocument.getOrigin()
, It was Origin(name=envers,type=OTHER)
. So I still suspecting that envers is causing this warning.
By the way, If you remove @Audit
annotation, or use the property I was mentioned, this warning still disappears.
I think that those messages are cause by bug in ModelBinder. Instead of getName should be getXmlNodeName. I've reported that issue and I hope that this will be fixed in next release. Anyway, besides extra log lines, there are no any other consequences.