wood burning stoves 2.0*
The moose likes Spring and the fly likes Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml" Watch "Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml" New topic
Author

Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml

Ivy chen
Greenhorn

Joined: Aug 31, 2010
Posts: 16
In my practise,i want to persist some information about Hibernate Event into the dataBase by Spring.

And i configed the Hibernate Event Listener (Such as:PostInsertEventListener) in the ApplicationContext.

How ever problems occur.

Here are the Exceptions out print in MyEclipse:





Here are my beans and ApplicationContext.xml

HibernateEventListener( which is a table to save the information )


PostInsertEvent(get the information of the Insert Action )


HibernateEventListenerDaoImpl (save the event information into the dataBase)


ApplicationContext.xml,I thing the problems occur in the tag:<property name="eventListeners">( in line 30)




hunger for your answer,Thanks~







Ivy chen
Greenhorn

Joined: Aug 31, 2010
Posts: 16
If i just use Hibernate ( without Spring ) , i can define these listeners in the hibernate.cfg.xml, and every thing goes well.

i need your help~

IVY~
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

While I am not sure if LocalSessionFactoryBean has a property called eventListeners.

It looks to me like you have a circular reference going on here and Spring can't figure out which comes first, the Chicken or the Egg.

SessionFactory --- EventListeners -- EventListener -- EventListernerDAO -- SessionFactory

See how the references/dependencies work its way back to the SessionFactory.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ivy chen
Greenhorn

Joined: Aug 31, 2010
Posts: 16
Mark Spritzler wrote:While I am not sure if LocalSessionFactoryBean has a property called eventListeners.

It looks to me like you have a circular reference going on here and Spring can't figure out which comes first, the Chicken or the Egg.

SessionFactory --- EventListeners -- EventListener -- EventListernerDAO -- SessionFactory

See how the references/dependencies work its way back to the SessionFactory.

Mark


As you say,when i config the "Hibernate EventListener" in the Spring,i found there was a circular between the sessionFactory and the Listeners(obviously this configaration is unreasonable and make me confused).

Dear Mark:
Is there any way that i can config the "Hibernate EventListener" in the Spring?
1/use an MethodInterceptor in a aspect??
2/config the "Hibernate EventListener" in the "hibernate.cfg.xml"??
3/or any other better ways???

Waiting for your guidance.....thanks~
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

What about using annotations in your classes for @PreUpdate etc from Hibernate.

http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html_single/#listeners

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml
 
Similar Threads
SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException
spring 2.5.3 / hibernate 3 sessionFactory NullPointerException
My app works fine on weblogic 9.2 32 bits, but fails on 64 bits, any good ideas out there ?
Spring+Hibernate can't create SessionFactory bean
Caused by: org.hibernate.HibernateException: could not instantiate CacheProvider: ...please help me