title: Hibernate unknown entity error when saving new object
body: <pre><code>    Student s = (Student) db.getByID(Student.class,1);
      s.setFirstName("Preston");
      db.saveOrUpdate(s); &lt;--Successful save
      s = new Student(){{setFirstName("asdf");setLastName("asdf1");}};
      s.setSchool((School) db.getByID(School.class, 1));
      db.saveOrUpdate(s); &lt;--Error occurs 
  </code></pre>
  
  <p>Exception in thread "main" org.hibernate.MappingException: Unknown entity: project.databaseio.TestClass$1</p>
  
  <pre><code>public void saveOrUpdate(Object object)
  {
      Transaction  tx = sessionFactory.getCurrentSession().beginTransaction();
      sessionFactory.getCurrentSession().saveOrUpdate(object);
      tx.commit();
  }
  </code></pre>
  
  <p>Stack Trace</p>
  
  <pre><code>Exception in thread "main" org.hibernate.MappingException: Unknown entity: project.databaseio.TestClass$1
  at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:548)
  at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
  at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
  at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:487)
  at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
  at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
  at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
  at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
  at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
  at com.sun.proxy.$Proxy0.saveOrUpdate(Unknown Source)
  at project.databaseio.DatabaseConnection.saveOrUpdate(DatabaseConnection.java:117)
  at project.databaseio.TestClass.main(TestClass.java:21)
  </code></pre>
  
  <p>Hibernate Config for Student</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
      &lt;class name="project.databaseio.Student" table="Student" catalog="fblaem"&gt;
          &lt;id name="id" type="java.lang.Integer"&gt;
              &lt;column name="id" /&gt;
              &lt;generator class="identity" /&gt;
          &lt;/id&gt;
          &lt;many-to-one name="school" class="project.databaseio.School" fetch="select"&gt;
              &lt;column name="SchoolID" not-null="true" /&gt;
          &lt;/many-to-one&gt;
          &lt;property name="firstName" type="string"&gt;
              &lt;column name="FirstName" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;property name="lastName" type="string"&gt;
              &lt;column name="LastName" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;property name="middleName" type="string"&gt;
              &lt;column name="MiddleName" /&gt;
          &lt;/property&gt;
          &lt;property name="createDate" type="timestamp"&gt;
              &lt;column name="CreateDate" length="0" /&gt;
          &lt;/property&gt;
          &lt;set name="studentEventTeams" table="StudentEventTeam" inverse="true" lazy="true" fetch="select"&gt;
              &lt;key&gt;
                  &lt;column name="StudentID" not-null="true" /&gt;
              &lt;/key&gt;
              &lt;one-to-many class="project.databaseio.StudentEventTeam" /&gt;
          &lt;/set&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>