• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

update query fired by hibernate!!!!

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
I'm novice to the hibernate world...i've a simple application wherein i've <many-to-one relation between two valueobject.
Below is my .hbm.xml file.

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="com.manheim.cis.business.contact.beans.EntityAddressVO"
table="ENTADDR">
<composite-id >
<key-property name="entityId" column="ENT_ID" />
<key-property name="addrId" column="ADDR_ID" />
</composite-id>
<property name="addrType" column="ADDR_TYPE" />
<property name="effectiveDate" column="EFFECTIVE_DATE" />
<property name="businessUse" column="BUSINESS_USE" />
<property name="instruction" column="DELIVERY_INSTRUCTION" />
<property name="defaultAddr" column="DEFAULT_ADDR" />
<property name="optOutDate" column="OPT_OUT_DATE" />
<property name="optOutMethod" column="OPT_OUT_METHOD" />
<property name="optOutRequester" column="OPT_OUT_REQUESTER" />
<property name="expireDate" column="EXPIRE_DATE" />
<property name="createdDate" column="CREATE_DATE" />
<property name="createdBy" column="CREATE_BY" />
<property name="updatedTime" column="UPDATE_TIME" />
<property name="updatedBy" column="UPDATE_BY" />
<many-to-one name="addressVO" column="ADDR_ID"
class="com.manheim.cis.business.contact.beans.AddressVO"
insert="false" update="false" cascade="all">
</many-to-one>
</class>
<class name="com.manheim.cis.business.contact.beans.AddressVO"
table="ADDR">
<id name="addrId" column="ADDR_ID" unsaved-value="null" >
<generator class="increment"></generator>
</id>
<property name="addr1" column="ADDR1" />
<property name="addr2" column="ADDR2" />
<property name="city" column="CITY" />
<property name="county" column="COUNTY" />
<property name="state" column="STATE" />
<property name="zip" column="ZIP_CODE" />
<property name="countryName" column="COUNTRY_NAME" />
<property name="countryCode" column="COUNTRY_CODE" />
<property name="latitude" column="LATITUDE" />
<property name="longtitude" column="LONGITUDE" />
<property name="timeZone" column="TIMEZONE" />
<property name="createdDate" column="CREATE_DATE" />
<property name="createdBy" column="CREATE_BY" />
</class>
</hibernate-mapping>


This is the hibernate generated query:
insert into ADDR (ADDR1, ADDR2, CITY, COUNTY, STATE, ZIP_CODE, COUNTRY_NAME, COUNTRY_CODE, LATITUDE, LONGITUDE, TIMEZONE, CREATE_DATE, CREATE_BY, ADDR_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

insert into ENTADDR (ADDR_TYPE, EFFECTIVE_DATE, BUSINESS_USE, DELIVERY_INSTRUCTION, DEFAULT_ADDR, OPT_OUT_DATE, OPT_OUT_METHOD, OPT_OUT_REQUESTER, EXPIRE_DATE, CREATE_DATE, CREATE_BY, UPDATE_TIME,

UPDATE_BY, ENT_ID, ADDR_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
update ADDR set ADDR1=?, ADDR2=?, CITY=?, COUNTY=?, STATE=?, ZIP_CODE=?, COUNTRY_NAME=?, COUNTRY_CODE=?, LATITUDE=?, LONGITUDE=?, TIMEZONE=?, CREATE_DATE=?, CREATE_BY=? where ADDR_ID=?


My doubt is why hibernate is going for an update operation in to ADDR table after doing a insert in ADDR table and how to prevent it.
I've tried with all the possible combination of unsaved-value attributes in both the valueobjects/tables.

Also please can any one cleary explain the meaning of unsaved-value attributes and its possible values and how it is realted to the object beign persisted.

Thanx in advance for any kind of help!!!

Regards
Ved
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Set Not-null to True in Many-to-one tag first....
id field and column name in many-to-one should be different.
then only u can avoid update query
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem , this is my code , hibernate is performing an unnecessary update , an giving me this error message.

Hibernate operation: Could not execute JDBC batch update; bad SQL grammar [/* update ec.gov.iess.modelo.fondoreserva.Calificacion */ update FRAFITACTCES set CREMORHPHL=? where CEDULA=?]; nested exception is java.sql.BatchUpdateException: ORA-01031: insufficient privileges ".


this is my the entity code:


I started getting this error after adding a new private member and its setter and getter




I will greatly appreciate your help
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than tack your question onto an old post, it'd be better in the future if you start a new post. Please read this for more information.
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic