title: @OneToOne annotoation problem (i think...)
body: <p>im new in hibernate and JPA and i have some problems with annotations.</p>
  
  <p>My target is to create this table in db (PERSON_TABLE with personal-details)</p>
  
  <pre><code>ID      ADDRESS     NAME    SURNAME     MUNICIPALITY_ID
  </code></pre>
  
  <p>First of all, i have a MUNICIPALITY table in db containing all municipality of my country.
  I mapped this table in this ENTITY:</p>
  
  <pre><code>@Entity
  public class Municipality implements Serializable {
  
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Long id;
  private String country;
  private String province;
  private String name;
  @Column(name="cod_catasto")
  private String codCatastale;
  private String cap;
  
  
  public Municipality() {
  }
  
  ...
  </code></pre>
  
  <p>Then i make an EMBEDDABLE class Address containing fields that realize a simple address...</p>
  
  <pre><code>@Embeddable
  public class Address implements Serializable {
  
  @OneToOne(cascade=CascadeType.ALL)
  @JoinColumn(name="id_municipality")
  private Municipality municipality;
  @Column(length=45)
  private String address;
  
  public Address() {
  }
  
  ...
  </code></pre>
  
  <p>Finally i embedded this class into Person ENTITY</p>
  
  <pre><code>@Entity
  public class Person implements Serializable {
  
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Long id;
  private String name;
  private String surname;
  @Embedded
  private Address address;
  
  public Person() {
  }
  
  ...
  </code></pre>
  
  <p>All works good when i have to save a new Person record, in fact hibernate creates a PERSON_TABLE as i want, but if i try to retrieve a Person record i have an exception.
  HQL is simply "from Person"
  The excpetion is (Entities is the package containing all classes above-mentioned):</p>
  
  <pre><code>org.hibernate.AnnotationException: @OneToOne or @ManyToOne on Entities.Person.address.municipality references an unknown entity: Entities.Municipality
  </code></pre>
  
  <p>Is the @OneToOne annotation the problem?</p>
  
  <p>My hibernate.cfg.xml is this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
   &lt;session-factory&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;org.h2.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:h2:tcp://localhost/DB_PATH&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.H2Dialect&lt;/property&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
          &lt;mapping class="Entities.Person"/&gt;
          &lt;mapping class="Entities.Municipality"/&gt;
          &lt;mapping class="Entities.Address"/&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Thanks.</p>