| 
					
						 I'm getting **IllegalArgumentException** while saving an dynamic entity,
  I have two classes as **SuperClassImpl** and **SubClassImpl**, which are mapped using table per class hierarchy. Also, I used the explicit polymorphism to use same POJO for two different tables.
      <class name="SuperclassImpl" polymorphism="explicit" table="super_class" mutable="true" discriminator-value="1000"> 	<id name='id' type='long'> 	<discriminator column="data" type="int"/> 	<version name='version'/> 	<property name="entry"/> 	<subclass name="SupclassImpl" discriminator-value="1"> 		<property name="subId" column="sub_id" type="long"/> 	</subclass> </class>
      <class name="SuperclassImpl" entity-name="SuperclassImplHist"  table="super_class_hist" mutable="true" discriminator-value="1000"> 	<composite-id> 	   <key-property name="id" type="long"/> 	   <key-property name="fromDate" type="imm_timestamp"/> 	</composite-id> 	<discriminator column="data" type="int"/> 	<property name="entry"/> 	<subclass name="SupclassImpl" entity-name="SupclassImplHist" discriminator-value="1"> 		<property name="subId" column="sub_id" type="long"/> 	</subclass> </class>
 
      public class SuperClassImpl implements Serializable { 	private Long id; 	private int version; 	private String entry; 	     public Long getId() {         return id;     }
      public void setId(Long id) {         this.id = id;     }
  	public String getEntry() {         return entry;     }
      public void setEntry(String entry) {         this.entry = entry;     }
  }
      public class SubClassImpl extends SuperClassImpl {
  	private Date fromDate; 	private Long subId; 	     public Date getFromDate() {         return fromDate;     }
      public void setFromDate(Date fromDate) {         this.fromDate = fromDate;     } 	 	public Long getSubId() {         return id;     }
      public void setSubId(Long subId) {         this.subId = subId;     } 	 }
      /*this below code works and saves the entity*/     SuperClassImpl sci = new SuperClassImpl();     pbe.setId(109305L);     pbe.setEntry("started");     pbe.setFromDate(new Date());     HibernateUtil.currentSession().save("SuperClassImplHist", sci);
 
      /*not working and throws exception      Caused by: java.lang.IllegalArgumentException: Can not set   java.lang.Long field      SubClassImpl.id to java.lang.Long*/     SubClassImpl sci = new SubClassImpl();     pbe.setId(109321L);     pbe.setSubId(2123L);     pbe.setEntry("started");     pbe.setFromDate(new Date());     HibernateUtil.currentSession().save("SubClassImplHist", sci);
 
  Do you see any issues with the code or mapping? While saving the **SubClassImplHist** I get this exception 
      "java.lang.IllegalArgumentException: Can not set   java.lang.Long field SubClassImpl.id to java.lang.Long"
 
  Many thanks for your answers. 
					
  
						
					 |