0

In my project I have an entity with this property:

/**
 * @return the myObject
 */
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "T1_MYOBJECT")
public MyObject getMyObject()
{
    return myObject;
}

When I call method getMyObject() to assign that value to a new object, a query is made on the db to retrieve it. How can I avoid that query? I only want to assign its value to a new object.

xc93hil
  • 105
  • 1
  • 9
  • Without loading the object from the database how would Hibernate know its ID and be able to update/create the foreign key correctly at the new object you want to assign it to? – OH GOD SPIDERS Feb 17 '20 at 17:01
  • With a proxy? In that way I get the Id but not the entire object..Am I wrong? How can I get a proxy? – xc93hil Feb 17 '20 at 17:16

0 Answers0