I discovered the BeanPersistListener that I'd like to register to some of my models, but I didn't find any documentation, from Ebean nor PlayFramework on how to integrate it.
From the documentation :
A BeanPersistListener is either found automatically via class path search or can be added programmatically via ServerConfiguration.addEntity().
Apparently, it isn't found automatically (I added some Logger.info
in the implemented methods, and nothing was shown), so I'd like to add it via ServerConfiguration, but how? where?
I'm also suspecting it's a version problem. From what I've seen, BeanPersistListener is from Ebean 2.6.0, but I can't find which version of Ebean PlayFramework is running (I'm using 2.0.4).
First Play 2.0.4 uses Ebean version 2.7.3 [1]
And for registering your listener, you could try to use a ServerConfigStartup as shown in this documentation:
I never tested it, I think it is worth a try :-)
Update from comments:
You'll need to put these classes under the
models
package or a child of themodels
package so that Ebean can find them.I see a two problems with BeanPersistListener in PLay Framework:
I must create for every entity own BeanPersistListener. Not nice when I have 100 enities.
BeanPersistListener is fired in background thread. I have no information who was user.