title: org.hibernate.MappingException: Could not determine typ
body: <p>I'm getting this error.</p>
  
  <pre><code>org.hibernate.MappingException: Could not determine type for: dom.Whore, at table:        Message, for columns: [org.hibernate.mapping.Column(receiver)]
  </code></pre>
  
  <p>This is the class that is being mapped into the table.</p>
  
  <pre><code>package dom;
  
  import java.util.Date;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  
  import org.hibernate.annotations.GenericGenerator;
  import org.springframework.stereotype.Component;
  
  @Component
  @Entity
  public class Message {
  
  private Whore sender;
  private Whore receiver;
  private Date date = new Date();
  private String messageText;
  private Boolean read;
  private long id;
  
  public Message(){}
  
  public Message(Whore sender, Whore receiver) {
      this.sender = sender;
      this.receiver = receiver;
  }
  
  public Whore getSender() {
      return sender;
  }
  
  public void setSender(Whore sender) {
      this.sender = sender;
  }
  public Whore getReceiver() {
      return receiver;
  }
  
  public void setReceiver(Whore receiver) {
      this.receiver = receiver;
  }
  
  public Date getDate() {
      return date;
  }
  
  public void setDate(Date date) {
      this.date = date;
  }
  public String getMessageText() {
      return messageText;
  }
  
  public void setMessageText(String messageText) {
      this.messageText = messageText;
  }
  
  public Boolean getRead() {
      return read;
  }
  
  public void setRead(Boolean read) {
      this.read = read;
  }
  
  @Id
  @GeneratedValue(generator="increment")
  @GenericGenerator(name="increment", strategy="increment")
  public long getId() {
      return id;
  }
  
  public void setId(long id) {
      this.id = id;
  }
  }
  </code></pre>
  
  <p>This is the class that the type can't be determined for.</p>
  
  <pre><code>package dom;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.ManyToMany;
  import javax.persistence.OneToMany;
  
  
  import org.hibernate.annotations.GenericGenerator;
  import org.springframework.stereotype.Component;
  
  
  @Component
  @Entity
  public class Whore {
  
  
  
      private String username;
      private String password;
      private String  email;
      private List&lt;Whore&gt; friends = new ArrayList&lt;Whore&gt;();
      private int reputation;
      private long id;
      private List&lt;Message&gt; messages = new ArrayList&lt;Message&gt;();
  
  
  
      public String getUsername() {
          return username;
      }
      public void setUsername(String username) {
          this.username = username;
      }
  
      public int getReputation() {
          return reputation;
      }
  
      public void setReputation(int reputation) {
          System.out.println("in set reputation : " + reputation);
          this.reputation = this.reputation + reputation;
          System.out.println("new repuration : " + this.reputation);
      }
  
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
  
      @Id
      @GeneratedValue(generator="increment")
      @GenericGenerator(name="increment", strategy="increment")
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
      public String getEmail() {
          return email;
      }
      public void setEmail(String email) {
          this.email = email;
      }
  
      @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      public List&lt;Whore&gt; getFriends() {
          return friends;
      }
      public void setFriends(List&lt;Whore&gt; friends) {
          this.friends = friends;
      }
  
      public void addFriend(Whore friend) {
          getFriends().add(friend);
      }
  
      public void removeFriend(Whore friend) {
          getFriends().remove(friend);
      }
  
      @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      public List&lt;Message&gt; getMessages() {
          return messages;
      }
  
      public void setMessages(List&lt;Message&gt; messages) {
          this.messages = messages;
      }
  
      public void addMessage(Message message) {
          getMessages().add(message);
      }
  }
  </code></pre>
  
  <p>I've read in a lot of posts that it's to do with not setting annotations on fields and getters at the same time. But as you can see that's not the cause here. I'm stumped.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"&gt;
  
          &lt;context:component-scan base-package="/dom" /&gt;
          &lt;context:component-scan base-package="/dao" /&gt;
          &lt;context:component-scan base-package="/controllers" /&gt;
          &lt;context:component-scan base-package="/services" /&gt;
          &lt;context:component-scan base-package="/security" /&gt;
          &lt;tx:annotation-driven /&gt; 
          &lt;mvc:annotation-driven /&gt;
  
          &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/culturewhore" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt; 
          &lt;property name="packagesToScan" value="/" /&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt; 
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;create&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"&gt;
          &lt;property name="messageConverters"&gt;
                  &lt;util:list id="beanList"&gt;
                      &lt;ref bean="mappingJacksonHttpMessageConverter" /&gt;
                  &lt;/util:list&gt;    
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" /&gt;
  
      &lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" p:maxUploadSize="1000000" /&gt;
  
      &lt;bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Also I've just tried using @ManyToOne on the sender and receiver getters. But this didn't make any difference.</p>