我在休眠取特定屬性處於休眠一一對多的關係
CustomerAccountEnduserOrderDetails.class
@Entity @Table(name="customer_account_enduser_order_details")
public class CustomerAccountEnduserOrderDetails implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id")
private Long id;
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name = "product_id", insertable = false, updatable = false)
private CustomerCmsProduct customerCmsProduct;
}
其次有兩個pojo
班,one-to-many relationship
是CustomerCmsProduct.class
@Entity
@Table(name="customer_cms_product")
@JsonIgnoreProperties(ignoreUnknown = true)
public class CustomerCmsProduct {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private Long id;
@Column(name="name")
private String name;
@Column(name="offer_price")
private String offerPrice;
@Column(name="original_price")
private String originalPrice;
@Column(name="discount")
private String discount;
}
她e如果我取CustomerAccountEnduserOrderDetails
類的對象,那麼我會得到CustomerCmsProduct
類也,我的問題是,這裏我想CustomerCmsProduct
表的特定列(不是所有默認我收到全部)像只ID和originalPrice。
我怎麼能這樣做projection
在這裏?
爲什麼你需要複雜化hibernate的自動獲取策略?爲什麼不能將其更改爲另一個級別,將所有數據庫對象轉換爲UI中的Pojo級別? – VinayVeluri
我dint得到你想說的,你可以給一個例子或提示,如何轉換在另一個層面,我在手動想我可以爲不需要的字段設置空值,但它是非常昂貴的,如果我加載100對象在一個時間 –