Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.3.6
-
Fix Version/s: 2.0-M2
-
Component/s: Persistence
-
Environment:Tried on both windows/Linux
Description
Registering an event listener for "save, update etc" (SaveOrUpdateEventListener) Will cause ArrayStoreException at runtime .
I just tried with "pre-insert" and it works without any issues. I don't know what all other event listeners will cause this issue.
In my sample plugin,
def doWithSpring = {
sampleListener(SampleListener)
hibernateEventListeners(HibernateEventListeners) {
listenerMap = ['save':sampleListener]
}
}
Both, sampleListenerand HibernateEventListeners classes are imported.
In integration test
Book b = new Book() b.name = "Sample book" b.save() println "Book ID :" + b.id b.name = "Name changed" b.save()
This will cause the exception
Error creating bean with name 'transactionManager': Cannot resolve reference to bean'sessionFactory' while setting
bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creat
ing bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.ArrayStoreExceptio.
For more details, Look at http://grails.1312388.n4.nabble.com/Hibernate-listeners-are-not-called-for-integration-tests-td3546387.html
I worked on a fix for this issue.
As I am working with version 1.3.7, I created a branch from the v1.3.7 tag of my clone at GitHub and then I fixed the problem, hoping that I could merge the changes in the master later.
Happens that the changed file (ConfigurableLocalSessionFactoryBean.java) was moved to other location in the master.
I am providing two patches, one for grails 1.3.7 and one for the master branch.
Also I made a pull request at GitHub.