Hi, i am a newbie to Hibernate and face a problem which i am sure must be quite trivial to others out here but please do help me out. when i do a insert using session.save(), my app returns a success message with an id generated. However, the DB doesnt reflect the inserted record. I am able to see the inserted record on my app ( on a view screen). However when i restart my server, the app doesnt contain the record either.
this is my code snippet
Code:
Transaction tx = hibSession.beginTransaction();
tx.begin();
PlannedCrewMove plannedCrewMove = new PlannedCrewMove();
plannedCrewMove
.setCrewMoveName(crewMoveDetailsTO.getCrewMoveName());
CrewMoveType crewMoveType = new CrewMoveType();
crewMoveType = (CrewMoveType) hibSession.load(CrewMoveType.class,
crewMoveDetailsTO.getCrewMoveType());
plannedCrewMove.setCrewMoveType(crewMoveType);
plannedCrewMove.setFromBrqId(crewMoveDetailsTO.getFromBrqId());
plannedCrewMove.setToBrqId(crewMoveDetailsTO.getToBrqId());
Plan plan = new Plan();
plan = (Plan) hibSession.load(Plan.class, crewMoveDetailsTO
.getPssId());
plannedCrewMove.setPlan(plan);
plannedCrewMove.setNumToMove(new Long(crewMoveDetailsTO
.getCrewMoved()));
plannedCrewMove.setMoveDate(crewMoveDetailsTO.getFromDate());
Initiative initiative = new Initiative();
initiative = (Initiative) hibSession.load(Initiative.class, "XXX");
plannedCrewMove.setInitiative(initiative);
Long msgId = (Long) hibSession.save(plannedCrewMove);
hibSession.flush();
tx.commit();
this is the hbm.xml fileCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 22-Nov-2007 09:01:25 by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.baplc.ccmpp.services.dao.beans.PlannedCrewMove" table="PLANNED_CREW_MOVE">
<id name="crewMoveId" type="long">
<column name="CREW_MOVE_ID" precision="10" scale="0" />
<generator class="seqhilo" >
<param name="sequence">PLAN_CM_SEQ</param>
<param name="max_lo">0</param>
</generator>
</id>
<many-to-one name="crewMoveType" class="com.baplc.ccmpp.services.dao.beans.CrewMoveType" fetch="select">
<column name="CREW_MOVE_TYPE" length="3" not-null="true" />
</many-to-one>
<many-to-one name="plan" class="com.baplc.ccmpp.services.dao.beans.Plan" fetch="select">
<column name="PLAN_ID" precision="10" scale="0" not-null="true" />
</many-to-one>
<many-to-one name="ccCmStatus" class="com.baplc.ccmpp.services.dao.beans.CcCmStatus" fetch="select">
<column name="CM_STATUS_CODE" length="3" not-null="true" />
</many-to-one>
<many-to-one name="initiative" class="com.baplc.ccmpp.services.dao.beans.Initiative" fetch="select">
<column name="INITIATIVE_CODE" length="10" />
</many-to-one>
<property name="crewMoveName" type="string">
<column name="CREW_MOVE_NAME" length="50" />
</property>
<property name="fromBrqId" type="java.lang.Long">
<column name="FROM_BRQ_ID" precision="10" scale="0" />
</property>
<property name="toBrqId" type="java.lang.Long">
<column name="TO_BRQ_ID" precision="10" scale="0" />
</property>
<property name="moveDate" type="date">
<column name="MOVE_DATE" length="7" not-null="true" />
</property>
<property name="tempPermInd" type="char">
<column name="TEMP_PERM_IND" length="1" not-null="true" />
</property>
<property name="numToMove" type="java.lang.Long">
<column name="NUM_TO_MOVE" precision="10" not-null="true" />
</property>
<property name="femaleCrewToMove" type="java.lang.Short">
<column name="FEMALE_CREW_TO_MOVE" precision="3" scale="0" />
</property>
<property name="hce" type="big_decimal">
<column name="HCE" precision="10" />
</property>
<property name="updateDatetime" type="timestamp">
<column name="UPDATE_DATETIME" length="11" not-null="true" />
</property>
<set name="cmTrainingCourseDateds" inverse="true">
<key>
<column name="CM_COURSE_ID" precision="10" scale="0" not-null="true" unique="true" />
</key>
<one-to-many class="com.baplc.ccmpp.services.dao.beans.CmTrainingCourseDated" />
</set>
<set name="plannedContractChanges" inverse="true">
<key>
<column name="CREW_MOVE_ID" precision="10" scale="0" />
</key>
<one-to-many class="com.baplc.ccmpp.services.dao.beans.PlannedContractChange" />
</set>
</class>
</hibernate-mapping>