According to the
Compatibility Matrix the Hibernate Validator 3.1.0 CR1 should be compatible with Core 3.3.x, but it seems that some class incompatibility exists between Hibernate Validator 3.1.0 CR1 and Hibernate 3.3.0.GA.
org.hibernate.validator.event.ValidateEventListener uses
org.hibernate.event.PreInsertEvent.getSource() absent in the Hibernate 3.3.0.GA, as a result:
java.lang.NoSuchMethodError: org.hibernate.event.PreInsertEvent.getSource()Lorg/hibernate/engine/SessionImplementor
Details:
Hibernate 3.3.0.GA
Hibernate Commons Annotations 3.1.0.CR2
Hibernate Annotations 3.4.0.CR2
Hibernate EntityManager 3.4.0.CR2
Hibernate Validator 3.1.0.CR1
Debug level Hibernate log excerpt:
Code:
INFO o.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.CR2
INFO org.hibernate.cfg.Environment - Hibernate 3.3.0.GA
INFO org.hibernate.cfg.Environment - hibernate.properties not found
INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
INFO o.h.annotations.common.Version - Hibernate Commons Annotations 3.1.0.CR2
INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.CR2
...
INFO org.hibernate.validator.Version - Hibernate Validator 3.1.0.CR1
...
INFO o.h.c.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
INFO o.h.c.DriverManagerConnectionProvider - Hibernate connection pool size: 20
INFO o.h.c.DriverManagerConnectionProvider - autocommit mode: true
INFO o.h.c.DriverManagerConnectionProvider - using driver: org.apache.derby.jdbc.ClientDriver at URL: jdbc:derby://localhost:1527/database;create=true
INFO o.h.c.DriverManagerConnectionProvider - connection properties: {user=app, password=app, autocommit=true, release_mode=auto}
DEBUG o.h.c.DriverManagerConnectionProvider - opening new JDBC connection
DEBUG o.h.c.DriverManagerConnectionProvider - created connection to: jdbc:derby://localhost:1527/database;create=true, Isolation Level: 2
INFO org.hibernate.cfg.SettingsFactory - RDBMS: Apache Derby, version: 10.3.2.1 - (599110)
INFO org.hibernate.cfg.SettingsFactory - JDBC driver: Apache Derby Network Client JDBC Driver, version: 10.3.1.4 - (561794)
INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.DerbyDialect
INFO o.h.t.TransactionFactoryFactory - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
INFO o.h.t.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
DEBUG org.hibernate.cfg.SettingsFactory - Wrap result sets: disabled
INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO o.h.h.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: enabled
...
DEBUG o.h.p.entity.AbstractEntityPersister - Static SQL for entity: jpatest.Customer
DEBUG o.h.p.entity.AbstractEntityPersister - Version select: select LAST_UPDATED_TIME from CUSTOMER where CUST_ID =?
...
DEBUG o.h.p.entity.AbstractEntityPersister - Insert 0: insert into CUSTOMER (APPT, city, CUST_TYPE, FIRST_NAME, LAST_NAME, street, LAST_UPDATED_TIME, ZIP_CODE, CUST_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
...
DEBUG o.h.p.entity.AbstractEntityPersister - Identity insert: insert into CUSTOMER (CUST_ID, APPT, city, CUST_TYPE, FIRST_NAME, LAST_NAME, street, LAST_UPDATED_TIME, ZIP_CODE) values (default, ?, ?, ?, ?, ?, ?, ?, ?)
...
DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 12190674797
DEBUG o.h.transaction.JDBCTransaction - begin
DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
DEBUG o.h.transaction.JDBCTransaction - current autocommit status: true
DEBUG o.h.transaction.JDBCTransaction - disabling autocommit
DEBUG o.h.e.def.AbstractSaveEventListener - executing identity-insert immediately
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.event.PreInsertEvent.getSource()Lorg/hibernate/engine/SessionImplementor;
at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:172)
at org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:142)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:65)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:645)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:619)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:623)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
at jpatest.Main.main(Main.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)