title: Hibernate load UserType object from repository
body: <p>Setting: I have an object (AProduct) persisted by hibernate in my database. This object references another object (AComponent) stored in a repository. In the database table of the product only the ID of the component should be stored. By loading the product, I want to load the correct component from my repository.</p>
  
  <p>My solution so far is to create a UserType for the component to save only its ID. So far it's easy. Loading the component is also not the big deal because I have the ID. </p>
  
  <p>My problem is how to get a link to the repository in ComponentUserType.</p>
  
  <p>I am using java and Hibernate/Annotations but the solution might be independent.</p>