title: java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files - due to Serializable
body: <p>I am practicing a simple Hibernate program and ran into the strange issue.</p>
  
  <p>My Model : </p>
  
  <pre><code>public class Employee implements java.io.Serializable {
  
  // Fields
  
  private Integer empId;
  private String empName;
  private BigDecimal empSal;
  
  //setters and getters
  </code></pre>
  
  <p>My Test class :</p>
  
  <pre><code>   public static void main(String[] args) {
  
      Configuration config =  new Configuration();
      config.configure("hibernate.cfg.xml");
  
      SessionFactory factory = config.buildSessionFactory();
  
      Session session = factory.openSession();
  
      Employee emp = new Employee();
      emp.setEmpName("abc");
      emp.setEmpSal(new BigDecimal("100000"));
  
      Transaction t = session.beginTransaction();
      session.save(emp);
      t.commit();
      System.out.println("Object Saved Succesfully!!");
  
      session.close();
      factory.close();
  
  }
  </code></pre>
  
  <p>exception I am getting :</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>Exception in thread "main" org.hibernate.InstantiationException: could not instantiate test objectcom.gbn.model.Employee
      at org.hibernate.engine.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:25)
      at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)
      at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
      at org.hibernate.tuple.entity.EntityMetamodel.&lt;init&gt;(EntityMetamodel.java:123)
      at org.hibernate.persister.entity.AbstractEntityPersister.&lt;init&gt;(AbstractEntityPersister.java:434)
      at org.hibernate.persister.entity.SingleTableEntityPersister.&lt;init&gt;(SingleTableEntityPersister.java:109)
      at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
      at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:226)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
      at com.gbn.test.Test.main(Test.java:19)
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.hibernate.engine.UnsavedValueFactory.instantiate(UnsavedValueFactory.java:22)
      ... 9 more
  Caused by: java.lang.Error: Unresolved compilation problem: 
      The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
  
      at com.gbn.model.Employee.&lt;init&gt;(Employee.java:1)
      ... 14 more
  </code></pre>
  
  <p><strong>If I don't implement Serializable in Employee model, I am able to save data without issue. the issue only when my pojo implements Serializable.</strong></p>
  
  <p>What causing the issue?</p>
  
  <p><strong>I have tried  solutions as suggested <a href="https://stackoverflow.com/questions/18075343/java-project-in-eclipse-the-type-java-lang-object-cannot-be-resolved-it-is-ind/26119203">here</a> and <a href="http://dev-answers.blogspot.in/2009/06/eclipse-build-errors-javalangobject.html" rel="nofollow noreferrer">here</a>, but unable to resolve my issue.</strong></p>
  
  <p>hbm file :</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
  &lt;class name="com.gbn.model.Employee" table="EMPLOYEE"&gt;
      &lt;id name="empId" type="java.lang.Integer"&gt;
          &lt;column name="EMP_ID" precision="22" scale="0" /&gt;
          &lt;generator class="increment" /&gt;
      &lt;/id&gt;
      &lt;property name="empName" type="java.lang.String"&gt;
          &lt;column name="EMP_NAME" length="20" /&gt;
      &lt;/property&gt;
      &lt;property name="empSal" type="java.math.BigDecimal"&gt;
          &lt;column name="EMP_SAL" precision="22" scale="0" /&gt;
      &lt;/property&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p></p>