Hi, I am trying to insert a number into SQL DB.
I failed to insert values. I don't see any errors though
my Table:
columns:
TRIALID int type,NUMBER int type
TRIALID is autoincrement and identity
my code:
Trial trial = new Trial();
trial.setNumber(new Integer(1));
TrialDAO tDao = new TrialDAO();
Transaction trnx = HibernateSessionFactory.getSession().getTransaction();
try {
trnx.begin();
tDao.save(trial);
trnx.commit();
tDao.getSession().close();
} catch (HibernateException e) {
// TODO Auto-generated catch block
trnx.rollback();
e.printStackTrace();
}
and my hibernate mapping file:
<hibernate-mapping>
<class name="ourhome.persistence.persist.Trial" table="TRIAL" schema="dbo" catalog="ourhome">
<id name="trialid" type="java.lang.Integer">
<column name="TRIALID" />
<generator class="identity" />
</id>
<property name="number" type="java.lang.Integer">
<column name="number" />
</property>
</class>
</hibernate-mapping>
Pls help me in understanding the mistake
|