1

In my bi-direction JPA association between my Parent-child; I am trying to Lazy load my Parent from my Child Entity through a ManyToOne association.
While I debug, I do get the javaassist Proxy object(something like Trade_$$_javaassist_41) which is always a blank object. When I click the Proxy object, JPA does execute the select Query also, but ultimately, no binding happens with the original Parent Object(tradeBean).
Lazy loading the child entity from Parent(OneToMany) doesn't have such issues and child loads without fail.

Parent Entity(Trade)

@OneToMany(mappedBy="tradeBean", fetch=FetchType.LAZY, cascade=CascadeType.ALL})
@Fetch(FetchMode.SELECT)
private Set<Product> products = new LinkedHashSet<Product>();

Child Entity(Product)

@ManyToOne(fetch=FetchType.LAZY, targetEntity=Trade.class)
@JoinColumn(name="Trade", referencedColumnName="TradeID", insertable=false, updatable=false)
@Fetch(FetchMode.SELECT)
private Trade tradeBean;

EntityManager Retrieval

EntityManager manager  = getEntityManager();
productObj = manager.find(Product.class, productPrimarykey);
if (productObj != null){
    productObj.getTradeBean().getTradeID();
}
manager.detach(productObj);         
return productObj;

Question JPA/Hibernate proxy not fetching real object data, sets all properties to null has the similar problem statement but there are no final members in my entities.

Community
  • 1
  • 1
DeludedPsyche
  • 131
  • 1
  • 1
  • 11

0 Answers0