Announcement Announcement Module
Collapse
No announcement yet.
update using createSQLQuery problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • update using createSQLQuery problem

    hi everyone,

    is it possible to update db record using createSQLQuery method? i really need help from experts. my mapping looks like this:

    Code:
    <hibernate-mapping auto-import="true" default-lazy="true">
    
    	<class name="net.nationalpayment.pps.model.RecentItem" table="USR_MRU">
    		<composite-id name="id" class="net.nationalpayment.pps.model.RecentItemId" unsaved-value="undefined">
    			<key-property name="userId"  column="UMR_USRID" type="string" length="30"/>
    			<key-property name="itemDate" column="UMR_DT" type="timestamp" length="6"/>
    		</composite-id>				
    		<property name="itemValue" column="UMR_MRUVAL" type="string" length="30"/>
    		<property name="itemLink" column="UMR_MRULINK" type="string" length="255"/>
    		<property name="type" column="UMR_TYPE" type="string" length="255"/>
    		
    		<property name="auditInfo" type="net.nationalpayment.pps.model.AuditInfoUserType">
                <column name="LAST_UPDATED_ON"/>
                <column name="LAST_UPDATED_BY"/>
                <column name="CREATED_DATE"/>
                <column name="CREATED_BY"/>
            </property>
    	</class>
    
    </hibernate-mapping>
    and my java code is looks like this:
    Code:
    String queryStr = "update USR_MRU set UMR_DT=to_date('"+ this.convertDateToString(recentItem.getId().getItemDate()) +"', 'yyyy-mm-dd hh24:mi:ss'), UMR_TYPE='"+recentItem.getType()+"' where UMR_USRID='"+recentItem.getId().getUserId()+"' and UMR_MRUVAL='"+recentItem.getItemValue()+"'";
    try{
    	this.getSession().createSQLQuery(queryStr);
    }catch(Exception e){
    	e.printStackTrace();
    }finally{
            this.getSession().flush(); 
    }
    i believe the createSQLQuery doesn't update the record. does anyone has an idea on this? im not really good at it. any help and suggestions are greatly appreciated.

    Thanks,
    thinkspace

  • #2
    update using createSQLQuery problem

    can anyone give some ideas, tips or suggestions? help greatly appreciated.

    regards,
    thinkspace

    Comment


    • #3
      i wonder why you guys don't give any feedback coz the answer is so simple. i figure it out. tnx for your time viewing my thread.


      regards,
      thinkspace

      Comment


      • #4
        There is information on this in the reference manual so maybe people thought it was pretty simple.
        http://www.hibernate.org/hib_docs/v3.../#batch-direct
        http://www.hibernate.org/hib_docs/v3...ngle/#querysql
        Last edited by karldmoore; Aug 27th, 2007, 04:02 PM.

        Comment

        Working...
        X