java - hibernate insert three tables at once -


i have customer class, orders class , payment class. customer , orders have one-to-many relationship. orders , payment have one-to-many relationship.

i think there problem in orders.java (model) can 1 tell me how solve this?

this erd:

enter image description here

i think class not mapped

this orders java class(model)

@entity public class orders implements serializable { private integer orderid; private customer customer; private string orderdate;  private list<payment> payments;   /**  * @return orderid  */ @id @generatedvalue(strategy = generationtype.auto) public integer getorderid() {     return orderid; }  /**  * @param orderid orderid set  */ public void setorderid(integer orderid) {     this.orderid = orderid; }  /**  * @return customer  */ @manytoone @joincolumn(name = "cust_id") public customer getcustomer() {     return customer; }  /**  * @param customer customer set  */ public void setcustomer(customer customer) {     this.customer = customer; }  /**  * @return orderdate  */ public string getorderdate() {     return orderdate; }  /**  * @param orderdate orderdate set  */ public void setorderdate(string orderdate) {     this.orderdate = orderdate; }  /**  * @return payments  */ @onetomany(targetentity = payment.class, mappedby = "orders", cascade = cascadetype.all,fetch = fetchtype.eager) public list<payment> getpayments() {     return payments; }  /**  * @param payments payments set  */ public void setpayments(list<payment> payments) {     this.payments = payments; }   } 

error

run: hibernate many many (annotation) slf4j: failed load class "org.slf4j.impl.staticloggerbinder". slf4j: defaulting no-operation (nop) logger implementation slf4j: see http://www.slf4j.org/codes.html#staticloggerbinder further details. sep 10, 2017 3:25:20 pm org.hibernate.validator.internal.util.version <clinit> info: hv000001: hibernate validator 5.0.0.final initial sessionfactory creation failed.org.hibernate.loader.multiplebagfetchexception: cannot simultaneously fetch multiple bags exception in thread "main" java.lang.exceptionininitializererror     @ util.hibernateutil.buildsessionfactory(hibernateutil.java:17)     @ util.hibernateutil.<clinit>(hibernateutil.java:8)     @ main.demo.main(demo.java:49) caused by: org.hibernate.loader.multiplebagfetchexception: cannot simultaneously fetch multiple bags     @ org.hibernate.loader.basicloader.postinstantiate(basicloader.java:94)     @ org.hibernate.loader.entity.entityloader.<init>(entityloader.java:119)     @ org.hibernate.loader.entity.entityloader.<init>(entityloader.java:71)     @ org.hibernate.loader.entity.entityloader.<init>(entityloader.java:54)     @ org.hibernate.loader.entity.batchingentityloader.createbatchingentityloader(batchingentityloader.java:133)     @ org.hibernate.persister.entity.abstractentitypersister.createentityloader(abstractentitypersister.java:1914)     @ org.hibernate.persister.entity.abstractentitypersister.createentityloader(abstractentitypersister.java:1937)     @ org.hibernate.persister.entity.abstractentitypersister.createloaders(abstractentitypersister.java:3205)     @ org.hibernate.persister.entity.abstractentitypersister.postinstantiate(abstractentitypersister.java:3191)     @ org.hibernate.persister.entity.singletableentitypersister.postinstantiate(singletableentitypersister.java:728)     @ org.hibernate.impl.sessionfactoryimpl.<init>(sessionfactoryimpl.java:348)     @ org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1845)     @ util.hibernateutil.buildsessionfactory(hibernateutil.java:13)     ... 2 more java result: 1 

here can find answer.

hibernate doesn't 2 collections fetchtype.eager.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -