-->
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.  [ 2 posts ] 
Author Message
 Post subject: NamedQuery not known [BEGINNER]
PostPosted: Tue Mar 20, 2007 9:55 am 
Newbie

Joined: Tue Jul 26, 2005 10:25 am
Posts: 12
I'm attempting to move my embedded HQL code into named queries. Unfortunately, the query blows up on me, as shown below.

The application finds the "loadBySerialNumber" and "loadAll" queries fine, but "loadByLikeSerialNumber" blows up.

I ensure that the String passed to the method has "%" appended to front and back of the String, but I don't even think it's even getting that far.

Any help would be appreciated.

Jason

Hibernate version: 3.1.3

Mapping documents:
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">

<hibernate-mapping package="mil.af.amc.acap.model" default-lazy="true" default-access="field">

    <class name="Hardware" table="T_HARDWARE" batch-size="40">

        <cache usage="read-write" />
       
        <id name="id" column="HARDWAREID">
            <generator class="increment"/>
        </id>

        <property name="manufacturer" column="MANUFACTURER"/>
        <property name="modelNumber" column="MODELNUMBER"/>
        <property name="serialNumber" column="SERIALNUMBER"/>
        <property name="name" column="NAME"/>
        <property name="macAddress" column="MACADDRESS"/>
        <property name="building" column="BUILDING"/>
        <property name="room" column="ROOM"/>
        <property name="ipAddress" column="IPADDRESS"/>

        <many-to-one name="organization" column="ORGANIZATIONID" />


    </class>

    <query name="loadBySerialNumber">from Hardware as hardware where lower(hardware.serialNumber) = ?</query>
    <query name="loadAll">from Hardware</query>
    <query name="Hardware.loadByLikeSerialNumber">from Hardware where lower(serialNumber) like :serial</query>

</hibernate-mapping>



Full stack trace of any exception that occurs:
Code:

org.springframework.orm.hibernate3.HibernateSystemException: Named query not known: Hardware.loadByLikeSerialNumber; nested exception is org.hibernate.MappingException: Named query not known: Hardware.loadByLikeSerialNumber
org.hibernate.MappingException: Named query not known: Hardware.loadByLikeSerialNumber
   at org.hibernate.impl.AbstractSessionImpl.getNamedQuery(AbstractSessionImpl.java:70)
   at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.java:1224)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1205)
   at $Proxy2.getNamedQuery(Unknown Source)
   at mil.af.amc.acap.dao.hibernate.HibernateHardwareDao$4.doInHibernate(HibernateHardwareDao.java:138)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:334)
   at mil.af.amc.acap.dao.hibernate.HibernateHardwareDao.searchByLikeSerialNumber(HibernateHardwareDao.java:135)
   at mil.af.amc.acap.dao.NewHardwareDaoTest.testLoadByLikeSerialNumber(NewHardwareDaoTest.java:86)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


Process finished with exit code -1


[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 21, 2007 12:52 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If it's not being found then there must have been an error reported during startup, when hibernate was parsing the file. Find that, it should give you a hint.

The first thing I'd check is that "." is a legal character in a query name. It probably is, but I've never tried it: try deleting it, maybe the problem will go away.

_________________
Code tags are your friend. Know them and use them.


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

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.