时间:2021-07-01 10:21:17 帮助过:42人阅读
@Entity
@Table(name = "app",schema = "", catalog = "game")
public class AppEntity {
@Id
@Column(name = "appId")
private String appId;
@Basic
@Column(name = "appName")
private String appName;
@Basic
@Column(name = "appdesc")
private String appdesc;
@Basic
@Column(name = "provider")
private String provider;
@Basic
@Column(name = "version")
private String version;
@Basic
@Column(name="postTime")
private Long postTime;
@Basic
@Column(name = "updateTime")
private Long updateTime;
@OneToMany(mappedBy = "appEntity",fetch = FetchType.EAGER)
private Set<ProductEntity> productEntities;
@OneToMany(mappedBy = "appEntity",fetch = FetchType.LAZY)
private Set<OrdersEntity> ordersEntities;
多的一方
@Entity
@Table(name = "product", schema = "" , catalog = "game")
@IdClass(ProductEntityPK.class)
public class ProductEntity {
@Id
@Column(name = "appId")
private String appId;
@Id
@GeneratedValue
@Column(name = "productId")
private long productId;
@Basic
@Column(name = "productName")
private String productName;
@Basic
@Column(name = "productDesc")
private String productDesc;
@Basic
@Column(name = "price")
private long price;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="appId",insertable = false, updatable = false)
private AppEntity appEntity;
@Override
public String toString() {
return "ProductEntity{" +
"appId=‘" + appId + ‘\‘‘ +
", productId=" + productId +
", productName=‘" + productName + ‘\‘‘ +
", productDesc=‘" + productDesc + ‘\‘‘ +
", price=" + price
", appEntity=" + appEntity +
‘}‘;
}
解决办法:将productEntity的toString方法中去掉 ", appEntity=" + appEntity +
hibernate+mysql关联映射师遇到java.lang.StackOverflowError异常
标签:pen sql post 解决办法 return upd etc pid str