java - detached entity passed to persist error with liquibase -


i have 2 domains

@entity public class model extends baselongidmodel {      @notnull     @size(min = 2, max = 50)     @column(length = 50, nullable = false)     private string name;      @notnull     @column(nullable = false)     private long threshold;      @onetomany(mappedby = "model", cascade = cascadetype.all, orphanremoval = true)     @cache(usage = cacheconcurrencystrategy.nonstrict_read_write)     private set<modelweight> weights;      public string getname() {         return name;     }      public model setname(string name) {         this.name = name;         return this;     }      public long getthreshold() {         return threshold;     }      public model setthreshold(long threshold) {         this.threshold = threshold;         return this;     }      public set<modelweight> getweights() {         return weights;     }      public model setweights(set<modelweight> weights) {         this.weights = weights;         return this;     }      @override     public string tostring() {         return new tostringbuilder(this)             .append("name", name)             .append("threshold", threshold)             .append("weights", weights)             .tostring();     } }     @entity public class company extends baselongidmodel {     @notnull     @column(length = 64, nullable = false)     private string name;     @notnull     @column(length = 32, nullable = false)     private string merchantid;      @size(max = 255)     @notnull     @column(length = 255, nullable = false)     private string companyaddress;     @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string companydistrict;     @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string companycity;     @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string companyphone;     @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string companycontact;     @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string companycontactmobilephone;     @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string companycountry;      @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string taxpayertype;      @size(max = 64)     @notnull     @column(length = 32, nullable = false)     private string taxoridnumber;      @onetomany(mappedby = "company", cascade = cascadetype.all, orphanremoval = true)     @org.hibernate.annotations.cache(usage = cacheconcurrencystrategy.nonstrict_read_write)     private set<merchant> merchants;       public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public string getmerchantid() {         return merchantid;     }      public void setmerchantid(string merchantid) {         this.merchantid = merchantid;     }        public string getcompanyaddress() {         return companyaddress;     }      public void setcompanyaddress(string companyaddress) {         this.companyaddress = companyaddress;     }      public string getcompanydistrict() {         return companydistrict;     }      public void setcompanydistrict(string companydistrict) {         this.companydistrict = companydistrict;     }      public string getcompanycity() {         return companycity;     }      public void setcompanycity(string companycity) {         this.companycity = companycity;     }      public string getcompanyphone() {         return companyphone;     }      public void setcompanyphone(string companyphone) {         this.companyphone = companyphone;     }      public string getcompanycontact() {         return companycontact;     }      public void setcompanycontact(string companycontact) {         this.companycontact = companycontact;     }      public string getcompanycontactmobilephone() {         return companycontactmobilephone;     }      public void setcompanycontactmobilephone(string companycontactmobilephone) {         this.companycontactmobilephone = companycontactmobilephone;     }      public string getcompanycountry() {         return companycountry;     }      public void setcompanycountry(string companycountry) {         this.companycountry = companycountry;     }      public string gettaxpayertype() {         return taxpayertype;     }      public void settaxpayertype(string taxpayertype) {         this.taxpayertype = taxpayertype;     }      public string gettaxoridnumber() {         return taxoridnumber;     }      public void settaxoridnumber(string taxoridnumber) {         this.taxoridnumber = taxoridnumber;     }      public set<merchant> getmerchants() {         return merchants;     }      public company setmerchants(set<merchant> merchants) {         this.merchants = merchants;         return this;     }       @override     public boolean equals(object o) {         if (this == o) return true;          if (o == null || getclass() != o.getclass()) return false;          company company = (company) o;          return new equalsbuilder()             .append(name, company.name)             .append(merchantid, company.merchantid)              .append(companyaddress, company.companyaddress)             .append(companydistrict, company.companydistrict)             .append(companycity, company.companycity)             .append(companyphone, company.companyphone)             .append(companycontact, company.companycontact)             .append(companycontactmobilephone, company.companycontactmobilephone)             .append(companycountry, company.companycountry)             .append(taxpayertype, company.taxpayertype)             .append(taxoridnumber, company.taxoridnumber)             .isequals();     }      @override     public int hashcode() {         return new hashcodebuilder(17, 37)             .append(name)             .append(merchantid)              .append(companyaddress)             .append(companydistrict)             .append(companycity)             .append(companyphone)             .append(companycontact)             .append(companycontactmobilephone)             .append(companycountry)             .append(taxpayertype)             .append(taxoridnumber)             .tohashcode();     }      @override     public string tostring() {         return new tostringbuilder(this)             .append("name", name)             .append("merchantid", merchantid)             .append("companyaddress", companyaddress)             .append("companydistrict", companydistrict)             .append("companycity", companycity)             .append("companyphone", companyphone)             .append("companycontact", companycontact)             .append("companycontactmobilephone", companycontactmobilephone)             .append("companycountry", companycountry)             .append("taxpayertype", taxpayertype)             .append("taxoridnumber", taxoridnumber)             .append("merchants", merchants)//// todo: 06.08.2016 how             .tostring();     } } 

and error that

{"timestamp":"2016-08-08t13:53:31.966+0000","status":500,"error":"internal server error","exception":"org.springframework.dao.invaliddataaccessapiusageexception","message":"detached entity passed persist: net.infoowl.fraud.domain.merchant; nested exception org.hibernate.persistentobjectexception: detached entity passed persist: net.infoowl.fraud.domain.merchant","path":"/api/companies"}

while try

  <md-input-container flex-gt-xs>         <label translate>company.merchants.title</label>         <md-select ng-model="vm.model.merchants" md-on-close="vm.clearsearchterm()" multiple=""                    ng-model-options="{trackby: '$value.id'}">             <md-select-header>                 <input ng-model="vm.searchruleterm" type="text" placeholder="{{'company.merchants.search' | translate}}"                        class="_md-text">             </md-select-header>             <md-optgroup>                 <md-option ng-value="merchant" ng-repeat="merchant in vm.merchants |filter: vm.searchruleterm">{{merchant.name}}                 </md-option>             </md-optgroup>         </md-select>     </md-input-container> 


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -