If the condition is always routed to the hasError condition when submitting the form

I created a simple form for adding a store, each store has a multi- tone connection with a member of the Shop.java model

   package models;
   @Entity
   public class Shop extends Model {

    @Id@SequenceGenerator(name = "shop_gen", sequenceName = "shop_id_seq", allocationSize = 1)@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "shop_gen")@Column(name = "id")
    public Long id;

    @Required
    public String name;

    @Required
    public String addressLine1;

    public String addressLine2;

    public String addressLine3;

    @Required
    public String city;

    @Required
    public String town;

    @Required
    public String phoneNumber;

    @ManyToOne@JoinColumn(name = "email",
    insertable = false, updatable = false,
    nullable = false)@Required
    public Member email;

    public static Model.Finder < Long, Shop > find = new Model.Finder(Long.class, Shop.class);
    public static Shop create(Shop shop) {
        shop.save();
        return shop;
    }

  }

Member.java Model

@Entity
public class User extends Model {

    @Id
    @Email
    @OneToMany(cascade = {CascadeType.ALL})
    @JoinColumn(name = "email")
    public String email;

    @Required
    public String password;

    @Required
    public String firstName;

    @Required
    public String lastName;


}

ShopController.java

package controllers;


public class ShopController extends Controller {
    static Form<Shop> shopForm = Form.form(Shop.class);



    public static Result submit()
    {
        Form<Shop> filledForm = shopForm.bindFromRequest();
        if(filledForm.hasErrors()) {
            return badRequest(views.html.shop.create.render(filledForm, Member.names()));
        }
        else {
            Shop shop = filledForm.get();
            Shop.create(shop);

            return redirect(routes.ProductController.blank());

        }
    }
}

but when I submit a form to add a store, it loads the same page with a completed record, if the condition is always true, I use postgresql, and this problem did not occur in my previous mysql database.

Can someone help me?

+4
source share
1 answer

@Required Shop.email, , , HTTP 400 ( ) . , null bindFromRequest. .

HTTP POST , Play , (String) Member. , , , String to Member.

:

@Id
@Email
@OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="email")
public String email;

OneToMany , . (String) , . .

0

Source: https://habr.com/ru/post/1534502/