We're updating the issue view to help you get more done. 

Hibernate will crash with (custom) enum types when running with a logback.xml in debug mode

Description

hibernate crashes when there is a logback.xml which is defined to set all logger levels to debug and when there are own enum types defined.
enumValueMapper will be null but the LOG.debug will be used which calls enumValueMapper.toXmlString() which fails with a NPE. It should instead call one of the safeNotNull methods which check that the mapper is not null.

stack:
org.hibernate.type.EnumType.toXMLString(EnumType.java:308)
org.hibernate.type.CustomType.toString(CustomType.java:256)
org.hibernate.type.CustomType.toXMLString(CustomType.java:169)
org.hibernate.type.CustomType.toLoggableString(CustomType.java:228)
org.hibernate.internal.util.EntityPrinter.toString(EntityPrinter.java:79)
org.hibernate.internal.util.EntityPrinter.toString(EntityPrinter.java:121)
org.hibernate.event.internal.AbstractFlushingEventListener.logFlushResults(A
bstractFlushingEventListener.java:131)
org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingTo
Executions(AbstractFlushingEventListener.java:107)
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushE
ventListener.java:51)
org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:402)
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransac
tionCommit(JdbcTransaction.java:101)
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(Abstract
TransactionImpl.java:175)
org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75)

i removed the logback.xml and it worked. also i used info instead of debug which worked too. imo this is a blocker as its impossible to use hibernate with debugging enabled and own enum types.

Environment

win7, x64, jdk7

Status

Assignee

Strong Liu

Reporter

oliverz

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.1.9

Priority

Major