How to check instance level model in Play 2?

I need a sophisticated validation logic that will go through several fields. Is there a way to do this every time the save () or update () function is called for the model? I am currently using Ebean as my ORM. The only way I can think of now is to override save () as:

public class User extends Model { @Override public void save(){ if(this.validate()){ super.save(); } } .. } 

Is there a more standardized way to do this?

+4
source share
1 answer

you can see the BeanPersistAdapter in ebean.

you can override methods like preUpdate.

0
source

All Articles