-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hibernate trying to update View? when updating other
PostPosted: Tue Jun 27, 2006 3:03 pm 
Newbie

Joined: Tue Jun 27, 2006 2:20 pm
Posts: 2
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..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 10:09 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You've mapped a class to a view? Then every time you flush a session in which a modified persistent instance of that class exists, you will write to that view. To avoid this, don't map to a view.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.