title: Hibernate insert foreign key
body: <p>I'm using hibernate to insert some rows but I don't know if I'm doing well...</p>
  
  <p>My enity has a foreign key and i know its id, I can't understand if I need the referenced object or just the id.
  I how there is a way to do this because it is not useful getting the referenced object just for insert.</p>
  
  <p>I want to do this:</p>
  
  <pre><code>en=new MyEntity();
  en.setForeignVal("1");
  </code></pre>
  
  <p>Seems i have to do this:</p>
  
  <pre><code>en=new MyEntity();
  refObj=getSession().get(RefObject.class, "1"); //unuseful
  en.setForeignVal(refObj);
  </code></pre>