我有一個使用GORM的grails項目。HibernateEventListeners沒有捕獲事件
我需要使用hibernates事件監聽器後插入事件。這裏是我
類class PersistenceListener implements PostInsertEventListener {
@Override
void onPostInsert(PostInsertEvent postInsertEvent) {
println("postInsert")
println(postInsertEvent)
println(postInsertEvent.entity)
}
這裏是我的resources.xml中: 豆= {
persistenceListener(PersistenceListener)
hibernateEventListeners(HibernateEventListeners) {
listenerMap = ['post-insert': persistenceListener]
}
}
我有兩個數據存儲。一個是使用mysql,另一個是使用mongodb。奇怪的是,監聽器正在捕獲去往mysql的事件,但沒有捕獲到mongodb事件。我不知道爲什麼。任何人都可以解釋這個問題?也許是因爲我有兩個數據存儲?
我可能會誤解,但我相當肯定GORM不使用hibernate作爲mongodb – rcgeorge23
真的嗎?在調用Domain.save()時,兩者之間必須有什麼東西? – Travis
嗯,我想當你調用Domain.save()時,它是mongo插件,它將數據保存到mongodb中。 [docs](http://springsource.github.io/grails-data-mapping/mongo/manual/guide/1.%20Introduction.html#1.1%20Compatibility%20with%20GORM%20for%20Hibernate)似乎表明:他們試圖提供一個與gorm/hibernate api一致的API,但實際上並沒有進行休眠。 – rcgeorge23