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]