-->
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.  [ 6 posts ] 
Author Message
 Post subject: Update being fired on fetch
PostPosted: Wed Dec 28, 2005 12:27 pm 
Newbie

Joined: Wed Dec 28, 2005 12:06 pm
Posts: 3
Hi ,
I have a many-to-one mapping in my facilityContact.xml which maps to contactBean.xml . One fetching the records from the facilityContact (FAC_CONT) table an update is being fired on the contact (CONT) table. I really dont see why an update should be fired on the contact table since i have not created a new contact in my facilityContact pojo. This update stops the operation and locks the contact table. Does anyone have ne idea why an update is also being fired on a simple select ? The contactId is a foreign key from the contact table.

Hibernate version: 3.0

[b]Mapping documents: FacilityContactAssoc.hbm.xml
hibernate-mapping>

<class name="com.phcs.first.business.association.facilitycontact.data.FacilityContactAssocBean" table="FAC_CONT">
<id name="facilityContactId" column="FAC_CONT_ID">
<generator class="increment"/>
</id>
<property name="facilityId" column="FAC_ID" update="true" insert="true" />
<property name="contactId" column="CONT_ID" update="true" insert="true" /> <property name="contactTypeId" column="CONT_TYP_ID" update="true" insert="true" />
<property name="contactRoleId" column="CONT_ROLE_ID" update="true" insert="true" />
<property name="facilityContactOtherRole" not-null="false" column="OTHER_ROLE_NAME" update="true" insert="true" />
<property name="statusId" column="STATUS_ID" update="true" insert="true" />
<property name="effectiveDate" column="EFF_DT" update="true" insert="true" />
<property name="terminationDate" column="TERM_DT" update="true" insert="true" />
<property name="terminationReason" column="TERM_REASON" not-null="true" update="true" insert="true" />
<property name="createdOnDate" column="CREATE_ON_DT" update="false" insert="true" />
<property name="createdByUser" column="CREATE_BY_USER" update="false" insert="true" />
<property name="modifiedOnDate" column="LAST_MOD_ON_DT" update="true" insert="true" />
<property name="modifiedByUser" column="LAST_MOD_BY_USER" update="true" insert="true" />

<many-to-one name="contactBean" class="com.phcs.first.business.contact.data.ContactBean"
fetch="join" column="CONT_ID" unique="true" update="false" insert="false" />




</class>

</hibernate-mapping>

[b]Code between sessionFactory.openSession() and session.close():


Full stack trace of any exception that occurs:

Name and version of the database you are using: oracle10g

[b]The generated SQL (show_sql=true):
[12/28/05 21:54:50:665 IST] 0000003e Environment I Hibernate 3.0
[12/28/05 21:54:50:681 IST] 0000003e Environment I hibernate.properties not found
[12/28/05 21:54:50:681 IST] 0000003e Environment I using CGLIB reflection optimizer
[12/28/05 21:54:50:697 IST] 0000003e Environment I using JDK 1.4 java.sql.Timestamp handling
[12/28/05 21:54:51:056 IST] 0000003e Configuration I configuring from resource: /hibernate.cfg.xml
[12/28/05 21:54:51:056 IST] 0000003e Configuration I Configuration resource: /hibernate.cfg.xml
[12/28/05 21:54:51:384 IST] 0000003e Configuration I Mapping resource: ContactBean.hbm.xml
[12/28/05 21:54:51:556 IST] 0000003e HbmBinder I Mapping class: com.phcs.first.business.contact.data.ContactBean -> CONT
[12/28/05 21:54:51:665 IST] 0000003e Configuration I Mapping resource: EmailBean.hbm.xml
[12/28/05 21:54:51:665 IST] 0000003e HbmBinder I Mapping class: com.phcs.first.common.email.data.EmailBean -> MAIL_MASTER
[12/28/05 21:54:51:681 IST] 0000003e Configuration I Mapping resource: FacilityContactAssocBean.hbm.xml
[12/28/05 21:54:51:696 IST] 0000003e HbmBinder I Mapping class: com.phcs.first.business.association.facilitycontact.data.FacilityContactAssocBean -> FAC_CONT
[12/28/05 21:54:51:884 IST] 0000003e Configuration I Configured SessionFactory: null
[12/28/05 21:54:51:884 IST] 0000003e Configuration I processing extends queue
[12/28/05 21:54:51:884 IST] 0000003e Configuration I processing collection mappings
[12/28/05 21:54:51:900 IST] 0000003e Configuration I processing association property references
[12/28/05 21:54:51:900 IST] 0000003e Configuration I processing foreign key constraints
[12/28/05 21:54:51:993 IST] 0000003e Dialect I Using dialect: org.hibernate.dialect.OracleDialect
[12/28/05 21:54:52:040 IST] 0000003e SettingsFacto I Maximum outer join fetch depth: 1
[12/28/05 21:54:52:040 IST] 0000003e SettingsFacto I Default batch fetch size: 1
[12/28/05 21:54:52:040 IST] 0000003e SettingsFacto I Generate SQL with comments: disabled
[12/28/05 21:54:52:040 IST] 0000003e SettingsFacto I Order SQL updates by primary key: disabled
[12/28/05 21:54:52:056 IST] 0000003e SettingsFacto I Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[12/28/05 21:54:52:071 IST] 0000003e ASTQueryTrans I Using ASTQueryTranslatorFactory
[12/28/05 21:54:52:087 IST] 0000003e SettingsFacto I Query language substitutions: {}
[12/28/05 21:54:52:103 IST] 0000003e DriverManager I Using Hibernate built-in connection pool (not for production use!)
[12/28/05 21:54:52:103 IST] 0000003e DriverManager I Hibernate connection pool size: 1
[12/28/05 21:54:52:118 IST] 0000003e DriverManager I autocommit mode: false
[12/28/05 21:54:52:134 IST] 0000003e DriverManager I using driver: oracle.jdbc.driver.OracleDriver at URL:
[12/28/05 21:54:52:134 IST] 0000003e DriverManager I connection properties:
[12/28/05 21:54:52:478 IST] 0000003e SettingsFacto I JDBC batch size: 15
[12/28/05 21:54:52:509 IST] 0000003e SettingsFacto I JDBC batch updates for versioned data: disabled
[12/28/05 21:54:52:556 IST] 0000003e SettingsFacto I Scrollable result sets: enabled
[12/28/05 21:54:52:556 IST] 0000003e SettingsFacto I JDBC3 getGeneratedKeys(): disabled
[12/28/05 21:54:52:571 IST] 0000003e TransactionFa I Using default transaction strategy (direct JDBC transactions)
[12/28/05 21:54:52:587 IST] 0000003e TransactionMa I No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[12/28/05 21:54:52:587 IST] 0000003e SettingsFacto I Automatic flush during beforeCompletion(): disabled
[12/28/05 21:54:52:603 IST] 0000003e SettingsFacto I Automatic session close at end of transaction: disabled
[12/28/05 21:54:52:603 IST] 0000003e SettingsFacto I Cache provider: org.hibernate.cache.EhCacheProvider
[12/28/05 21:54:52:618 IST] 0000003e SettingsFacto I Second-level cache: enabled
[12/28/05 21:54:52:634 IST] 0000003e SettingsFacto I Optimize cache for minimal puts: disabled
[12/28/05 21:54:52:634 IST] 0000003e SettingsFacto I Structured second-level cache entries: enabled
[12/28/05 21:54:52:634 IST] 0000003e SettingsFacto I Query cache: disabled
[12/28/05 21:54:52:649 IST] 0000003e SettingsFacto I Echoing all SQL to stdout
[12/28/05 21:54:52:649 IST] 0000003e SettingsFacto I Statistics: disabled
[12/28/05 21:54:52:649 IST] 0000003e SettingsFacto I Deleted entity synthetic identifier rollback: disabled
[12/28/05 21:54:52:665 IST] 0000003e SettingsFacto I Default entity-mode: pojo
[12/28/05 21:54:52:962 IST] 0000003e SessionFactor I building session factory
[12/28/05 21:54:52:993 IST] 0000003e Configurator W No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: wsjar:file:/D:/PHCS/FIRST/code/FIRST/WebContent/WEB-INF/lib/ehcache-0.6.jar!/ehcache-failsafe.xml
[12/28/05 21:54:54:431 IST] 0000003e SessionFactor I Not binding factory to JNDI, no JNDI name configured
[12/28/05 21:54:54:446 IST] 0000003e SessionFactor I Checking 0 named queries
[12/28/05 21:54:54:555 IST] 0000003e SystemOut O got the dao 3
[12/28/05 21:54:54:587 IST] 0000003e SystemOut O Hibernate: select facilityco0_.FAC_CONT_ID as FAC1_1_, facilityco0_.FAC_ID as FAC2_2_1_, facilityco0_.CONT_ID as CONT3_2_1_, facilityco0_.CONT_TYP_ID as CONT4_2_1_, facilityco0_.CONT_ROLE_ID as CONT5_2_1_, facilityco0_.OTHER_ROLE_NAME as OTHER6_2_1_, facilityco0_.STATUS_ID as STATUS7_2_1_, facilityco0_.EFF_DT as EFF8_2_1_, facilityco0_.TERM_DT as TERM9_2_1_, facilityco0_.TERM_REASON as TERM10_2_1_, facilityco0_.CREATE_ON_DT as CREATE11_2_1_, facilityco0_.CREATE_BY_USER as CREATE12_2_1_, facilityco0_.LAST_MOD_ON_DT as LAST13_2_1_, facilityco0_.LAST_MOD_BY_USER as LAST14_2_1_, contactbea1_.CONT_ID as CONT1_0_, contactbea1_.CONT_FIRST_NAME as CONT2_0_0_, contactbea1_.CONT_LAST_NAME as CONT3_0_0_, contactbea1_.CONT_INTERNAL_EXTERNAL_FLG as CONT4_0_0_, contactbea1_.STATUS_ID as STATUS5_0_0_, contactbea1_.PHCS_TERR_ID as PHCS6_0_0_, contactbea1_.PHCS_LOC as PHCS7_0_0_, contactbea1_.CONT_TITLE as CONT8_0_0_, contactbea1_.CONT_LOC_ADDR_LINE_1 as CONT9_0_0_, contactbea1_.CONT_LOC_ADDR_LINE_2 as CONT10_0_0_, contactbea1_.CONT_LOC_ADDR_CITY as CONT11_0_0_, contactbea1_.CONT_LOC_ADDR_STATE as CONT12_0_0_, contactbea1_.CONT_LOC_ADDR_ZIP_CD as CONT13_0_0_, contactbea1_.CONT_LOC_ADDR_ZIP_CD_4 as CONT14_0_0_, contactbea1_.CONT_LOC_ADDR_COUNTRY as CONT15_0_0_, contactbea1_.CONT_MAIL_ADDR_LINE_1 as CONT16_0_0_, contactbea1_.CONT_MAIL_ADDR_LINE_2 as CONT17_0_0_, contactbea1_.CONT_MAIL_ADDR_CITY as CONT18_0_0_, contactbea1_.CONT_MAIL_ADDR_STATE as CONT19_0_0_, contactbea1_.CONT_MAIL_ADDR_ZIP_CD as CONT20_0_0_, contactbea1_.CONT_MAIL_ADDR_ZIP_CD_4 as CONT21_0_0_, contactbea1_.CONT_MAIL_ADDR_COUNTRY as CONT22_0_0_, contactbea1_.CONT_BUSINESS_TEL_NO as CONT23_0_0_, contactbea1_.CONT_BUSINESS_TEL_EXT as CONT24_0_0_, contactbea1_.CONT_MOBILE_TEL_NO as CONT25_0_0_, contactbea1_.CONT_TOLL_FREE_TEL_NO as CONT26_0_0_, contactbea1_.CONT_TOLL_FREE_TEL_EXT as CONT27_0_0_, contactbea1_.CONT_FAX_NO as CONT28_0_0_, contactbea1_.CONT_EMAIL_ADDR as CONT29_0_0_, contactbea1_.EFF_DT as EFF30_0_0_, contactbea1_.TERM_DT as TERM31_0_0_, contactbea1_.TERM_REASON as TERM32_0_0_, contactbea1_.CREATE_ON_DT as CREATE33_0_0_, contactbea1_.CREATE_BY_USER as CREATE34_0_0_, contactbea1_.LAST_MOD_ON_DT as LAST35_0_0_, contactbea1_.LAST_MOD_BY_USER as LAST36_0_0_ from FAC_CONT facilityco0_, CONT contactbea1_ where facilityco0_.CONT_ID=contactbea1_.CONT_ID(+) and facilityco0_.FAC_CONT_ID=?
[12/28/05 21:54:54:712 IST] 0000003e SystemOut O Hibernate: update CONT set CONT_FIRST_NAME=?, CONT_LAST_NAME=?, CONT_INTERNAL_EXTERNAL_FLG=?, STATUS_ID=?, PHCS_TERR_ID=?, PHCS_LOC=?, CONT_TITLE=?, CONT_LOC_ADDR_LINE_1=?, CONT_LOC_ADDR_LINE_2=?, CONT_LOC_ADDR_CITY=?, CONT_LOC_ADDR_STATE=?, CONT_LOC_ADDR_ZIP_CD=?, CONT_LOC_ADDR_ZIP_CD_4=?, CONT_LOC_ADDR_COUNTRY=?, CONT_MAIL_ADDR_LINE_1=?, CONT_MAIL_ADDR_LINE_2=?, CONT_MAIL_ADDR_CITY=?, CONT_MAIL_ADDR_STATE=?, CONT_MAIL_ADDR_ZIP_CD=?, CONT_MAIL_ADDR_ZIP_CD_4=?, CONT_MAIL_ADDR_COUNTRY=?, CONT_BUSINESS_TEL_NO=?, CONT_BUSINESS_TEL_EXT=?, CONT_MOBILE_TEL_NO=?, CONT_TOLL_FREE_TEL_NO=?, CONT_TOLL_FREE_TEL_EXT=?, CONT_FAX_NO=?, CONT_EMAIL_ADDR=?, EFF_DT=?, TERM_DT=?, TERM_REASON=?, LAST_MOD_ON_DT=?, LAST_MOD_BY_USER=? where CONT_ID=?

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: more info please
PostPosted: Wed Dec 28, 2005 2:08 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Since update was fired for that CONT table I suspect some problems in that mapping. Please post all the relevant mappings and code snippets.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 1:14 am 
Newbie

Joined: Wed Dec 28, 2005 12:06 pm
Posts: 3
Hi Konstantin,
Mapping for ContactBean is in ContactBean.hbm.xml :

<hibernate-mapping>
<class name="com.phcs.first.business.contact.data.ContactBean" table="CONT" >
<id name="contactID" column="CONT_ID">
<generator class="increment"/>
</id>
<property name="contactFirstName" column="CONT_FIRST_NAME"/>
<property name="contactLastName" column="CONT_LAST_NAME"/>
<property name="contactCategory" column="CONT_INTERNAL_EXTERNAL_FLG"/>
<property name="statusId" column="STATUS_ID"/>
<property name="phcsTerritoryId" column="PHCS_TERR_ID"/>
<property name="phcsLocation" column="PHCS_LOC"/>
<property name="contactTitle" column="CONT_TITLE"/>
<property name="contactLocAddLin1" column="CONT_LOC_ADDR_LINE_1"/>
<property name="contactLocAddLin2" column="CONT_LOC_ADDR_LINE_2"/>
<property name="contactLocAddCity" column="CONT_LOC_ADDR_CITY"/>
<property name="contactLocAddState" column="CONT_LOC_ADDR_STATE"/>
<property name="contactLocAddZip" column="CONT_LOC_ADDR_ZIP_CD"/>
<property name="contactLocAddZip4" column="CONT_LOC_ADDR_ZIP_CD_4"/>
<property name="contactLocAddCountry" column="CONT_LOC_ADDR_COUNTRY"/>
<property name="contactMailAddLin1" column="CONT_MAIL_ADDR_LINE_1"/>
<property name="contactMailAddLin2" column="CONT_MAIL_ADDR_LINE_2"/>
<property name="contactMailAddCity" column="CONT_MAIL_ADDR_CITY"/>
<property name="contactMailAddState" column="CONT_MAIL_ADDR_STATE"/>
<property name="contactMailAddZip" column="CONT_MAIL_ADDR_ZIP_CD"/>
<property name="contactMailAddZip4" column="CONT_MAIL_ADDR_ZIP_CD_4"/>
<property name="contactMailAddCountry" column="CONT_MAIL_ADDR_COUNTRY"/>
<property name="contactBusTelNo" column="CONT_BUSINESS_TEL_NO"/>
<property name="contactBusTelNoExt" column="CONT_BUSINESS_TEL_EXT"/>
<property name="contactMobileTelNo" column="CONT_MOBILE_TEL_NO"/>
<property name="contactTollFreeTelNo" column="CONT_TOLL_FREE_TEL_NO"/>
<property name="contactTollFreeTelNoExt" column="CONT_TOLL_FREE_TEL_EXT"/>
<property name="contactFaxlNo" column="CONT_FAX_NO"/>
<property name="contactEMailAddress" column="CONT_EMAIL_ADDR"/>
<property name="effectiveDate" column="EFF_DT"/>
<property name="terminationDate" column="TERM_DT"/>
<property name="terminationReasonID" column="TERM_REASON"/>
<property name="createdOnDate" column="CREATE_ON_DT" update="false" insert="true"/>
<property name="createdByUser" column="CREATE_BY_USER" update="false" insert="true"/>
<property name="lastModifiedDate" column="LAST_MOD_ON_DT"/>
<property name="lastModifiedByUser" column="LAST_MOD_BY_USER"/>
</class>
</hibernate-mapping>


The contactId of contactBean is the primary key of contact and it is the foreign key of the facilityContactAssoc (FAC_CONT) table. So wen i try to fetch a record from the FAC_CONT table i also want to fetch a record from the contact table which corresponds to the contactID. This is wen an update is bieng fired. The hibernate method i am using is session.load(facilityContactBean). facilityContactBean is a pojo with only one ID set in it.


Top
 Profile  
 
 Post subject: please try this
PostPosted: Thu Dec 29, 2005 2:22 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I suggest trying a bit different method:
ContactBean cb = (ContactBean) session.load( ContactBean.class, id);
Ant see if that will make that update go away.

I do not see any problems in mappings.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 2:47 am 
Newbie

Joined: Wed Dec 28, 2005 12:06 pm
Posts: 3
Hi Konstantin,
But why should i do that.
ContactBean cb = (ContactBean) session.load( ContactBean.class, id);
will retrieve the details of the contactBean, but i want the details of facilityContactAssocBean.

So currently i am doing

FacilityContactAssocBean fcb = session.load( facilityContactAssocBean.class, id);

Shouldnt this also give me the details of the contact record associated with my facilityContactAssocBean ?, since my facilityContactAssoc bean stores the foriegn key of contact bean. Each record of faciliytContactBean table will contain a single foreign key of contactBean. So according to me hibernate should fire a select query joining both the tables and get me the details of one record the facilityContactAssoc table and the details from the contact table associated with this facilityContactAssoc record.

But along with the select query it is also firing an update query on the contact table. And i dont understand why this is happening.


Top
 Profile  
 
 Post subject: code
PostPosted: Thu Dec 29, 2005 3:03 am 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
You are correct in your assumptions, it should work as you have described.
in your previous message you mentioned different method:
Quote:
The hibernate method i am using is session.load(facilityContactBean). facilityContactBean is a pojo with only one ID set in it


I still suggest trying my code snipped to check if there are any problems with H, mapping or code related to ContactBean itself.

And please check that code of FacilityContactAssocBean does NOT have something like

private ContactBean contactBean = new ContactBean();

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.