Play! framework 2. + using Ebean @ Constraints.Required on the @ManyToOne foreign key

Is it possible to easily determine the constraint on the external field?

example: I have Entity1 and Entity2. Entity1 has an entity2_id field, which is the foreign key that makes the connection. However, this does not work the same as the @Required restriction for a simple field, for example a String title:

This does not work:

@ManyToOne
@JoinColumn(name = "entity2_id")
@Required
public Entity2 entity2;

It works:

@Required
public String title;

I know about the shape of the form validate(). Is there an easier way? preferably a method that will cause an error in a specific field in the view without passing the message to the view as a parameter.

thanks

+4
source share
1

ManyToOne, .

- JoinColumn, .

formate(). ? , , .

, , - .

+1

All Articles