title: How to map a class attribute using hibernate?
body: <p>When I try to map the Phone on a Phone in the Contact class it gives the following error: </p>
  
  <blockquote>
    <p>Initial creation of the SessionFactory object failed. Error: org.hibernate.MappingException: Could not determine type for: com.livro.capitulo3.crudannotations.Telephone, at table: contact, for columns: [org.hibernate.mapping.Column (numPhone)]
    Error closing insert operation. Message: null
    java.lang.ExceptionInInitializerError
    The mapping class is as follows:</p>
  </blockquote>
  
  <p>//Class Contato</p>
  
  <pre><code>package com.livro.capitulo3.crudannotations;
  
  import java.sql.Date;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.ManyToOne;
  import javax.persistence.OneToMany;
  import javax.persistence.Table;
  
  import org.hibernate.annotations.ManyToAny;
  
  @Entity
  @Table(name = "contato")
  public class ContatoAnnotations {
  
      @Id
      @GeneratedValue
      @Column(name = "codigo")
      private Integer codigo;
  
      @Column(name = "nome", length = 50, nullable = true)
      private String  nome;
  
      @Column(name = "telefone", length = 50, nullable = true)
      private String  telefone;
  
      @Column(name = "email", length = 50, nullable = true)
      private String  email;
  
      @Column(name = "dt_cad", nullable = true)
      private Date        dataCadastro;
  
      @Column(name = "obs", nullable = true)
      private String  observacao;
  
  
      //Como ficaria a annotation aqui???? Só vou persistir esta tabela
      @OneToMany
      private Telefone numTelefone;
      ...
      //Getters e Setters
  
  }
  </code></pre>
  
  <p>//Class Telefone:</p>
  
  <pre><code>package com.livro.capitulo3.crudannotations;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.ManyToOne;
  import javax.persistence.OneToMany;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "contato")
  public class Telefone {
      @Id
      @GeneratedValue
      @Column(name = "numero")
      private String numero;
      @Column(name = "tipo")
      private String tipo;
  
      public String getNumero() {
          return numero;
      }
  
      public void setNumero(String numero) {
          this.numero = numero;
      }
  
      public String getTipo() {
          return tipo;
      }
  
      public void setTipo(String tipo) {
          this.tipo = tipo;
      }
  
  }
  </code></pre>
  
  <p>I do not know how to do this mapping. Help! Thanks!!!</p>