-->
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: Named query for a Composite key problem
PostPosted: Thu Jul 14, 2011 5:01 am 
Newbie

Joined: Thu Jul 14, 2011 4:44 am
Posts: 1
Hi folks, would massively appreciate some guidance on the below prob. Have trawled the documentation, other posts, sites etc until my eyes have begun to mist :(
Anyway, trying to introduce Hibernate at my current client's site, against a rather poor legacy SqlServer database and (as luck would have it) my first table is one as defined below:
Code:
CREATE TABLE "dbo"."cla_appvl_calc_log"(
cla_appvl_id_c numeric not null,
cla_proc_nm_c varchar not null,
cla_prty_ord_n smallint not null,
cla_disp_cmt_c char not null,
cla_debug_cmt_c varchar,
cla_cmt_pt_c varchar not null,
stamp_add_dz datetime not null,
user_phr_em_add_c char)

The above table does not have any primary key defined against it and I'm not able to change it's definition (long story)

I've installed HibernateTools on my Eclipse (Helios) and persuaded it to generate the below mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 12-Jul-2011 11:44:16 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
    <class name="com.somewhere.ClaAppvlCalcLog" table="cla_appvl_calc_log" schema="dbo" catalog="p_dbcla001">

        <composite-id name="id" class="com.somewhere.ClaAppvlCalcLogId">
            <key-property name="claAppvlIdC" type="long">
                <column name="cla_appvl_id_c" precision="10" scale="0" />
            </key-property>
            <key-property name="claProcNmC" type="string">
                <column name="cla_proc_nm_c" length="100" />
            </key-property>
            <key-property name="claPrtyOrdN" type="short">
                <column name="cla_prty_ord_n" />
            </key-property>
            <key-property name="claDispCmtC" type="char">
                <column name="cla_disp_cmt_c" length="1" />
            </key-property>
            <key-property name="claDebugCmtC" type="string">
                <column name="cla_debug_cmt_c" />
            </key-property>
            <key-property name="claCmtPtC" type="string">
                <column name="cla_cmt_pt_c" />
            </key-property>
            <key-property name="stampAddDz" type="timestamp">
                <column name="stamp_add_dz" length="23" />
            </key-property>
            <key-property name="userPhrEmAddC" type="string">
                <column name="user_phr_em_add_c" length="10" />
            </key-property>
        </composite-id>

    </class>

   <query name="findLogsById">
      <![CDATA[ from ClaAppvlCalcLog c where c.ClaAppvlCalcLogId.claAppvlIdC = :claAppvlIdC ]]>
   </query>
</hibernate-mapping>


I have then added a named query (findLogsById) but it fails at app startup time. It's deployed to a Weblogic10.4 app server and responds with the below error:
<14-Jul-2011 09:00:48 o'clock BST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID
'1310630441428' for task '107'. Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1373)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
Truncated. see log file for complete stacktrace
org.hibernate.HibernateException: Errors in named queries: findLogsById
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:426)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
Truncated. see log file for complete stacktrace
>


Anyone suggest how I may fix my named query at all? In the last chance saloon with this one at the moment. Appreciate any help.


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.