title: Hibernate - Mapping: Could not determine type for #, at table: #, for columns: #
body: <p>I tried everything, but I'm stuck. 
  Can you help me please?</p>
  
  <p>The small project is just a preliminary test for a large database. I've only been using Hibernate for a week and I'm trying to connect it all with Srping MVC Tomcat later.</p>
  
  <p>But now I just want to be able to recognize the mistakes in the mapping.</p>
  
  <p><strong>Console:</strong></p>
  
  <pre><code>    `Initial SessionFactory creation failed.org.hibernate.MappingException: Could not determine type for: hiber.data_examplecompany.Address, at table: EMPLOYEE, for columns: [org.hibernate.mapping.Column(address)]
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at tools.hiber.HiberUtil.&lt;clinit&gt;(HiberUtil.java:19)
      at tools.hiber.HiberSave.main(HiberSave.java:15)
  Caused by: org.hibernate.MappingException: Could not determine type for: hiber.data_examplecompany.Address, at table: EMPLOYEE, for columns: [org.hibernate.mapping.Column(address)]
      at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:486)
      at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:453)
      at org.hibernate.mapping.Property.isValid(Property.java:226)
      at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:624)
      at org.hibernate.mapping.RootClass.validate(RootClass.java:267)
      at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:347)
      at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:466)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
      at tools.hiber.HiberUtil.&lt;clinit&gt;(HiberUtil.java:15)
      ... 1 more
  </code></pre>
  
  <p><strong>Employee.java:</strong></p>
  
  <pre><code>package hiber.data_examplecompany;
  
  import javax.persistence.Access;
  import javax.persistence.AccessType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.OneToOne;
  import javax.persistence.Table;
  
  import org.hibernate.annotations.Cascade;
  
  @Entity
  @Table(name = "EMPLOYEE")
  @Access(value=AccessType.FIELD)
  public class Employee {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "emp_id")
      private long id;
      @Column(name = "emp_name")
      private String name;
      @Column(name = "emp_salary")
      private double salary;
  
      private Address address;
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      @OneToOne(mappedBy = "employee")
      @Cascade(value = org.hibernate.annotations.CascadeType.ALL)
      public Address getAddress() {
          return address;
      }
  
      public void setAddress(Address address) {
          this.address = address;
      }
  
      @Column(name = "emp_name")
      public String getName() {
          System.out.println("Employee getName called");
          return name;
      }
  
      public void setName(String name) {
          System.out.println("Employee setName called");
          this.name = name;
      }
  
      @Column(name = "emp_salary")
      public double getSalary() {
          return salary;
      }
  
      public void setSalary(double salary) {
          this.salary = salary;
      }
  
      @Override
      public String toString() {
          return "Id= " + id + ", Name= " + name + ", Salary= " + salary
                  + ", {Address= " + address + "}";
      }
  
  }
  </code></pre>
  
  <p><strong>Address.java:</strong></p>
  
  <pre><code>package hiber.data_examplecompany;
  
  import javax.persistence.Access;
  import javax.persistence.AccessType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.OneToOne;
  import javax.persistence.PrimaryKeyJoinColumn;
  import javax.persistence.Table;
  
  import org.hibernate.annotations.GenericGenerator;
  import org.hibernate.annotations.Parameter;
  
  @Entity
  @Table(name = "ADDRESS")
  @Access(value=AccessType.FIELD)
  public class Address {
  
      @Id
      @Column(name = "emp_id", unique = true, nullable = false)
      @GeneratedValue(generator = "gen")
      @GenericGenerator(name = "gen", strategy = "foreign", parameters = { @Parameter(name = "property", value = "employee") })
      private long id;
  
      @Column(name = "address_line1")
      private String addressLine1;
  
      @Column(name = "zipcode")
      private String zipcode;
  
      @Column(name = "city")
      private String city;
  
      @OneToOne
      @PrimaryKeyJoinColumn
      private Employee employee;
  
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getAddressLine1() {
          return addressLine1;
      }
  
      public void setAddressLine1(String addressLine1) {
          this.addressLine1 = addressLine1;
      }
  
      public String getZipcode() {
          return zipcode;
      }
  
      public void setZipcode(String zipcode) {
          this.zipcode = zipcode;
      }
  
      public String getCity() {
          return city;
      }
  
      public void setCity(String city) {
          this.city = city;
      }
  
      public Employee getEmployee() {
          return employee;
      }
  
      public void setEmployee(Employee employee) {
          this.employee = employee;
      }
  
      @Override
      public String toString() {
          return "AddressLine1= " + addressLine1 + ", City=" + city
                  + ", Zipcode=" + zipcode;
      }
  }
  </code></pre>
  
  <p><strong>Thank you
  for the time invested! :)</strong></p>