Objects are many-to-many relationships,
The error entity code is as follows:
Java code:
- @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
- @JoinTable(name = "product_packagetype:packageTypes:products")
- private java.util.Listimplambition.forxxx.model.PackageType> packageTypes;
- /**
- * @generated
- */
- @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
- @JoinTable(name = "product_productcolor:productColors:products")
- private java.util.Listimplambition.forxxx.model.ProductColor> productColors;
- /**
- * @generated
- */
- @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
- @JoinTable(name = "product_attach:attachs:products")
- private java.util.Listimplambition.forxxx.model.Attach> attachs;
-
-
The Code itself cannot run normally, and the error cannot simultaneously fetch multiple bags is reported.
After fetchtype. Lazy is changed, the following error occurs: Warn [main] 16:46:18, 655-SQL error: 1064, sqlstate: 42000
Error
[Main] 16:46:18, 655-you have an error in your SQL syntax;
Check the manual that corresponds to your MySQL Server version for
Right syntax to use near ': packagetypes: Products packagetyp0 _ left
Outer Join packagetype packagetyp1 _ on 'at line 1
The last modification can only be:
Product entity
Java code:
- /**
- * @generated
- */
- @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
- //@JoinTable(name = "product_packagetype:packageTypes:products")
- @JoinTable(name = "product_packagetype", joinColumns = { @JoinColumn(name = "packageTypes") }, inverseJoinColumns = { @JoinColumn(name = "products") })
- private java.util.Listimplambition.forxxx.model.PackageType> packageTypes;
- /**
- * @generated
- */
- @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
- //@JoinTable(name = "product_productcolor:productColors:products")
- @JoinTable(name = "product_productcolor", joinColumns = { @JoinColumn(name = "productColors") }, inverseJoinColumns = { @JoinColumn(name = "products") })
- private java.util.Listimplambition.forxxx.model.ProductColor> productColors;
- /**
- * @generated
- */
- @ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
- //@JoinTable(name = "product_attach:attachs:products")
- @JoinTable(name = "product_attach", joinColumns = { @JoinColumn(name = "attachs") }, inverseJoinColumns = { @JoinColumn(name = "products") })
- private java.util.Listimplambition.forxxx.model.Attach> attachs;
Only one example of other associated entities is listed. The Code is as follows (the code generated by studio is commented out)
Java code:
- /**
- * @generated
- */
- //@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
- @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy="attachs")
- private java.util.Listimplambition.forxxx.model.Product> products;