Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Mapping documents:
<hibernate-mapping>
<class name="ae.gov.dm.services.inspection.dto.PremiseDTO" table="DM_PREMISES" schema="DM_EINSPECTION">
<id name="premiseID" type="long">
<column name="PRM_ID" precision="10" scale="0" />
<generator class="sequence">
<param name="sequence">SEQ_PRM_ID</param>
</generator>
</id>
<property name="premiseLicenseSource" type="string">
<column name="PRM_LICENSE_SOURCE" length="160" />
</property>
<property name="premiseTradeLicense" type="string">
<column name="PRM_TRADE_LICENSE" length="160" />
</property>
<property name="premiseEnglishName" type="string">
<column name="PRM_ENGLISH_NAME" length="160" />
</property>
<property name="premiseArabicName" type="string">
<column name="PRM_ARABIC_NAME" length="160" />
</property>
<property name="premisePostalAddress" type="string">
<column name="PRM_POSTAL_ADDRESS" length="160" />
</property>
<property name="premiseCreatedDate" type="date">
<column name="PRM_DATE_CREATED" length="7" />
</property>
<property name="premiseInActive" type="long">
<column name="PRM_INACTIVE" precision="1" scale="0" />
</property>
<property name="premiseState" type="long">
<column name="PRM_STATE" precision="1" scale="0" />
</property>
<property name="premisePosted" type="long">
<column name="PRM_POSTED" precision="1" scale="0" />
</property>
<property name="premiseContactName" type="string">
<column name="PRM_CONTACT_NAME" length="160" />
</property>
<property name="premiseContactNameArabic" type="string">
<column name="PRM_CONTACT_NAME_ARABIC" length="160" />
</property>
<property name="premiseContactEmailID" type="string">
<column name="PRM_CONTACT_EMAIL_ID" length="80" />
</property>
<property name="premiseContactMobile" type="string">
<column name="PRM_CONTACT_MOBILE" length="80" />
</property>
<property name="premiseContactTelephone" type="string">
<column name="PRM_CONTACT_TELEPHONE" length="80" />
</property>
<set name="dmUserses" inverse="true">
<key>
<column name="PRM_ID" precision="10" scale="0" not-null="true" />
</key>
<one-to-many class="ae.gov.dm.services.inspection.dto.UserDTO" />
</set>
<set name="dmInspectionses" inverse="true">
<key>
<column name="PRM_ID" precision="10" scale="0" not-null="true" />
</key>
<one-to-many class="ae.gov.dm.services.inspection.dto.InspectionDTO" />
</set>
<set name="dmInspHistories" inverse="true">
<key>
<column name="PRM_ID" precision="10" scale="0" not-null="true" />
</key>
<one-to-many class="ae.gov.dm.services.inspection.dto.HistoryDTO" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
l_tempUsdPremiseDTO = (PremiseDTO)b_lstPremiseObj.get(0);
l_tempUsdPremiseDTO.setPremiseLicenseSource(b_strLicenseSource);
l_tempUsdPremiseDTO.setPremiseTradeLicense(b_strLicenseNo);
l_tempUsdPremiseDTO.setPremiseEnglishName(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getCompanyName());
l_tempUsdPremiseDTO.setPremiseArabicName(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getCompanyNameArabic());
l_tempUsdPremiseDTO.setPremiseContactEmailID(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getEmailID());
l_tempUsdPremiseDTO.setPremisePostalAddress(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getPostalAddress());
l_tempUsdPremiseDTO.setPremiseCreatedDate(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getDateCreated());
l_tempUsdPremiseDTO.setPremiseInActive(new Long(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getInActive()));
l_tempUsdPremiseDTO.setPremiseContactTelephone(((GIFSCompanyDTOId) l_lstGIFSCompanyVector.get(b_intCounter)).getTelephone());
l_tempUsdPremiseDTO.setPremiseState(new Long((State.UPDATED).id()));
l_tempUsdPremiseDTO.setPremisePosted(new Long(0));
//Try the flush part here ********** /////
PremiseDTO b_localPremiseDTO = (PremiseDTO)HibernateSessionFactory.currentSession().merge( l_tempUsdPremiseDTO );
HibernateDAO.beginTransaction();
HibernateDAO.update(l_tempUsdPremiseDTO);
HibernateDAO.commitTransaction();
l_usdPremiseDTO = null;
HibernateSessionFactory.currentSession().flush();
Name and version of the database you are using:
Oracle 8.1.7
I am currently reading some values from a View and then updating an already existing object of Premises in my database and then flushing the session. Instead of updating the Premise Object , hibernate tries to update the view. I found this error by trying to run my code in debug mode and looking at the exception that was raised. Can any one help me with this..