原因在进行关联映射时在多的一方的toString方法中有对属性对应的一的一方的输出
比如:
一的一方:
@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 +
时间: 2024-11-09 09:21:05