Hi,
I am not aware due to waht reason I am not able to insert any value for oen of my table. The mapping file is as follows:
Code:
<hibernate-mapping>
<class name="com.dc.teldirectory.trans.TransRequestBean" table="TBL_TRANS_REQUEST">
<composite-id>
<key-property column="LANG_ID" length="2" name="langId" type="string"/>
<key-property column="LANG_STRING" length="100" name="langString" type="string"/>
</composite-id>
<property column="REQ_DATE" length="7" name="reqDate" type="date"/>
</class>
</hibernate-mapping>
The code that I am running is as follows:
Code:
Session session = null ;
TransRequestBean trBean = new TransRequestBean();
try{
session = sFactory.openSession();
trBean.setLangId(langId);
trBean.setLangString(langString);
trBean.setReqDate(new java.util.Date());
session.saveOrUpdate(trBean);
System.out.println("Object TransRequestBean saved");
}
catch(HibernateException he){
}
catch(Exception e){
}
finally{
session.close();
session = null;
trBean = null;
}
Problem is the statements till the SOP "Object TransRequestBean saved" are executed but the data is not inserted in the database. The output from the log is as follows:
Code:
20 Nov 2003 13:16:42 DEBUG [Servlet.Engine.Transports:39] impl.SessionImpl - opened session
20 Nov 2003 13:16:42 DEBUG [Servlet.Engine.Transports:39] engine.Cascades - unsaved-value strategy NONE
20 Nov 2003 13:16:42 DEBUG [Servlet.Engine.Transports:39] impl.SessionImpl - saveOrUpdate() previously saved instance with id: com.dc.teldirectory.trans.TransRequestBean@881e0c6[langId=HI,langString=Agyat]
20 Nov 2003 13:16:42 DEBUG [Servlet.Engine.Transports:39] impl.SessionImpl - updating [com.dc.teldirectory.trans.TransRequestBean#com.dc.teldirectory.trans.TransRequestBean@881e0c6[langId=HI,langString=Agyat]]
20 Nov 2003 13:16:42 DEBUG [Servlet.Engine.Transports:39] impl.SessionImpl - closing session
The problems I guess are:
1. Why the log says: previously saved instance with id: com.dc.teldirectory.trans.TransRequestBean@881e0c6[langId=HI,langString=Agyat] hence updating while the table is absolutely empty?
2. The ReqDate column in my table is of type Date, the bean class has a corresponding Date attribute. Is the problem due to isertion of the date returned by the Date returned by the new Date()?
3. I tried not inserting the Date (null is allowed) and only the langid/text the combination of both is proimary key, but still data was not inserted. I am not getting any error out of the catch blocks.