mysql - How to annotate ManyToMany relation Ebean in Play 2.6.x -


i trying implement manytomany relation histroy_user table bridge table between user , history table. attached screen shot of mysql rendered play

my user model

package models;   import java.util.*; import javax.persistence.*; import io.ebean.*; import io.ebean.annotation.enumvalue; import play.data.format.*; import play.data.validation.*; import io.ebean.model;  /**  * created shah on 7/20/17.  * above line 1 explits package name  * line 4 9 basic package importing required  */ @entity public class user extends model{ //start of user model class      @id //defines tables primanry key     @constraints.min(10) //apply limit 10 digits     @column(nullable=false)     @generatedvalue     public long id;      @constraints.required //apply constraint "not null"     @column(nullable = false)     public string name;      @constraints.required     @column(nullable = false)     public string email;      @constraints.required     @column(nullable = false)     public string password;      @onetomany(cascade = cascadetype.all)     public list<history_user> historyuser=new arraylist<history_user>();      @column(name="account_status", nullable = false) //apply column name account_status     @constraints.required     public string account_status_type;      @formats.datetime(pattern="dd/mm/yyyy") //defines date pattern     public date createddate = new date();      @formats.datetime(pattern="dd/mm/yyyy")     public date updateddate = new date();      public static final finder<long, user> find = new finder<>(user.class); // helper class ebean data extraction  } //end of user class 

and history model

package models;   import java.util.*; import javax.persistence.*; import io.ebean.*; import play.data.format.*; import play.data.validation.*; import io.ebean.model;  /**  * created shah on 7/25/17.  */  @entity public class history extends model { //start of history model class       @id //defines tables primanry key     @constraints.min(10) //apply limit 10 digits     @generatedvalue     @column(nullable = false)     public long id;       @onetomany(cascade = cascadetype.all)     public list<history_user> historyuser=new arraylist<history_user>();      @column(name="blood_exchange", nullable = false) //apply column name account_status     @constraints.required     public string blood_exchange_type;      @formats.datetime(pattern="dd/mm/yyyy") //defines date pattern     public date createddate = new date();      public static final finder<long, history> find = new finder<>(history.class); // helper class ebean data extraction  } //end of history table => model class 

my pivot history_user model class

package models;   import java.util.*; import javax.persistence.*; import javax.validation.constraint;  import io.ebean.*; import play.data.format.*; import play.data.validation.*; import io.ebean.model;  /**  * created shah on 7/25/17.  */  @entity public class history_user extends model { //start of pivot table      @id //defines tables primanry key     @constraints.min(10) //apply limit 10 digits     @generatedvalue     @column(nullable = false)     public long id;      @manytoone     public list<user> user=new arraylist<user>();      @manytoone     public list<history> history=new arraylist<history>();       @constraints.min(10)     @column(nullable = false)     public string key;      @formats.datetime(pattern="dd/mm/yyyy") //defines date pattern     public date createddate = new date();      public static final finder<long, history> find = new finder<>(history.class); // helper class ebean data extraction  } //end of pivot table 

i following link custom bridge table in playframework ebean


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -