-->
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.  [ 1 post ] 
Author Message
 Post subject: Version and Snapshot Select - Stored Procs
PostPosted: Mon Apr 30, 2007 12:12 am 
Newbie

Joined: Wed Feb 21, 2007 12:45 pm
Posts: 3
Hi.

For version and snapshot select's, how do you make it work with SPs?

At the moment, the version and snapshot select's show a direct SQL in the logs. I need to get this replaced by SP calls instead. I have tried using, <loader query-ref/> in the mapping file for entity loading, but that doesnt help.

The problem is, in certain cases(save a 1-m, with cascading), Hibernate uses the direct SQL's to check(since the 'id' is assigned) wether the instance is transient/persistent instead of doing it via the SP calls.

The example is a Folder containing folder's.

Here is the output from the logs,

Code:
DEBUG - AbstractEntityPersister:2678:  Version select: select ID from FOLDER where ID =?
DEBUG - AbstractEntityPersister:2681:  Snapshot select: select folder_.ID, folder_.NAME as NAME0_, folder_.DISPLAY_ORDER as DISPLAY3_0_, folder_.POSTED_DATE as POSTED4_0_, folder_.POSTED_TIME as POSTED5_0_, folder_.CREATED_BY as CREATED6_0_, folder_.START_DATE as START7_0_, folder_.END_DATE as END8_0_, folder_.FOLDER_ID as FOLDER9_0_, folder_.USR_ID as USR10_0_ from FOLDER folder_ where folder_.ID=?
DEBUG - AbstractEntityPersister:2684:  Insert 0: { call CREATE_FOLDER(?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }
DEBUG - AbstractEntityPersister:2685:  Update 0: update FOLDER set NAME=?, DISPLAY_ORDER=?, POSTED_DATE=?, POSTED_TIME=?, CREATED_BY=?, START_DATE=?, END_DATE=?, FOLDER_ID=?, USR_ID=? where ID=?
DEBUG - AbstractEntityPersister:2686:  Delete 0: delete from FOLDER where ID=?


And here's a snippet of the mapping file -

Code:
<class
    name="example.domain.Folder"
    table="FOLDER"
>
    <id
        name="id"
        type="java.lang.Integer"
        column="ID"
    >
        <generator class="assigned" />
    </id>
    <property
        name="name"
        type="java.lang.String"
        column="NAME"
        not-null="true"
        unique="true"
        length="50"
    >
    <many-to-one
        name="folder"
        class="example.domain.Folder"
        not-null="true"
    >
        <meta attribute="use-in-equals">true</meta>
        <column name="FOLDER_ID" />
    </many-to-one>
    <!-- bi-directional many-to-one association to User -->
    <many-to-one
        name="user"
        class="example.domain.User"
        not-null="true"
    >
        <column name="USR_ID" />
    </many-to-one>
    <set
        name="folders"
        lazy="true"
        inverse="true"
      cascade="all,delete-orphan"
    >
        <key>
            <column name="FOLDER_ID" />
        </key>
        <one-to-many
            class="example.domain.Folder"
        />
    </set>

   <loader query-ref="folder"/>
   
   <sql-insert callable="true" check="none">
      { call CREATE_FOLDER(?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }
   </sql-insert>
   
    <sql-query name="folder">
     <return alias="f" class="example.domain.Folder" lock-mode="none"/>
     { call FIND_FOLDER(:id) }
    </sql-query>

</class>


I have tried, moving the sql-query out of the class.

Thanks.

Amit


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

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.