我在休眠取特定属性处于休眠一一对多的关系
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对象在一个时间 –