-->
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: need to run a native SQL Insert as a named query
PostPosted: Tue Feb 20, 2007 8:07 pm 
Newbie

Joined: Tue Feb 20, 2007 7:57 pm
Posts: 1
I made my “Insert” query (which is native SQL) as a named sql query <sql-query> and when I ran it using

int records = SQLQuery .executeUpdate();

I got a following Exception

java.lang.UnsupportedOperationException: Update queries only supported through HQL
at org.hibernate.impl.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:753)
at com.fanniemae.fapt.mtm.domain.ref.common.TopMoversMappingLoader.main(TopMoversMappingLoader.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


Also if I try to put the query in <sql-insert> tag , than how will I invoke it , since this doesn’t allows “name” attribute to name this query ??

Do you know a work around for doing this ??

My insert query is very complicated and cannot be converted in to HQL

<sql-query name = "findTOP">
<![CDATA[
Insert into PREV_MARK_MAPG(FA_MTM_ID,FA_MTM_EFF_DT,FA_PREV_MTM_ID)
(
select * from (
select FA_MTM_ID,
FA_MTM_EFF_DT,
LAG(FA_MTM_ID) OVER (PARTITION BY SECU_CUSIP_ID ORDER BY FA_MTM_EFF_DT ASC) AS PREV_MTM_ID
FROM FA_MARK
WHERE FA_MTM_EFF_DT <= :effDate
and trd_stat_cd = :assetState
and SECU_CUSIP_ID in (
select SECU_CUSIP_ID from fa_mark
where fa_mtm_id in (
select FA_MTM_ID from FA_MARK where TRD_STAT_CD = :assetState and FA_MTM_EFF_DT between TRUNC(:effDate) AND LAST_DAY(:effDate)
minus
select FA_MTM_ID from PREV_MARK_MAPG where FA_MTM_EFF_DT between TRUNC(:effDate) AND LAST_DAY(:effDate)
)
)
) where FA_MTM_EFF_DT between TRUNC(:effDate) AND LAST_DAY(:effDate)
)
]]>
</sql-query>


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.