-->
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: Hibernate Query Help
PostPosted: Thu Jan 26, 2006 11:29 am 
Newbie

Joined: Mon Jul 26, 2004 11:35 am
Posts: 13
Hi,
I got into a habit of using custom objects to individual properties with column mappings. However, have not been able to figure out how to issue queries on individual columns. Looking at the mapping document I posted and within paymentInfo property I need to issue search query using like statement on BILLING_NAME column. Any help greatly appreciated.

Also, can hibernate Team add this method to their Query implementation in the next release:

public void setParameters(Map parameters){
String[] namedParameters = getNamedParameters();
for(String namedParameter:namedParameters)
setParameter(namedParameter,parameters.get(namedParameter));
}

setParameters(Object bean) does not seem to work with map properties.

Thank you
Roman

3.1 rc:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.app.beans.Transaction" table="PORTAL_TRANSACTION"
dynamic-insert="true" dynamic-update="true">
<id name="id" column="ID" unsaved-value="0">
<generator class="increment">
<param name="table">PORTAL_TRANSACTION</param>
<param name="column">ID</param>
</generator>
</id>
<many-to-one name="user"
column="USER_ID"
class="com.app.beans.User"
lazy="false"
cascade="refresh"
outer-join="true"
update="false"
insert="true"/>
<property name="addressInfo"
type="com.app.dao.hibernate.types.AddressInfoType">
<column name="ADDRESS1"/>
<column name="ADDRESS2"/>
<column name="CITY"/>
<column name="STATE"/>
<column name="ZIP"/>
<column name="COUNTRY"/>
</property>
<property name="paymentInfo"
type="com.app.dao.hibernate.types.PaymentInfoType">
<column name="BILLING_NAME"/>
<column name="CARD_NUMBER"/>
<column name="EXP_MONTH"/>
<column name="EXP_YEAR"/>
<column name="CARD_TYPE"/>
</property>
<property name="orderTotal" column="AMOUNT" type="double"/>
<property name="description" column="DESCRIPTION" type="string"/>
<property name="result" column="RESULT" type="string"/>
<property name="pnRef" column="PNREF" type="string"/>
<property name="message" column="RESPMSG" type="string"/>
<property name="authCode" column="AUTHCODE" type="string"/>
<property name="avsAddr" column="AVSADDR" type="character"/>
<property name="avsZip" column="AVSZIP" type="character"/>
<property name="trxType" column="TRXTYPE" type="character"/>
<property name="tender" column="TENDER" type="character"/>
<property name="created" column="DATE_CREATED" type="timestamp"
update="false" insert="false"/>
<property name="updated" column="DATE_UPDATED" type="timestamp"
update="false" insert="false"/>
<!-- order reference -->
<many-to-one name="order"
column="ORDER_ID"
class="com.app.beans.Order"
lazy="false"
cascade="refresh"
outer-join="true"
update="false"
insert="true"/>
</class>
</hibernate-mapping>:


Using spring HibernateTemplate with HibernateCallback implementation:

25 Jan 2006 16:05:54,751 ERROR [action].invoke:253 - Servlet.service() for servlet action threw exception
org.springframework.orm.hibernate3.HibernateQueryException: Invalid path: 'p.name' [select t,t.paymentInfo as p from com.bertl.beans.Transaction t where lower(p.name) like lower(:name) order by t.created desc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: Invalid path: 'p.name' [select t,t.paymentInfo as p from com.bertl.beans.Transaction t where lower(p.name) like lower(:name) order by t.created desc]
org.hibernate.hql.ast.QuerySyntaxException: Invalid path: 'p.name' [select t,t.paymentInfo as p from com.bertl.beans.Transaction t where lower(p.name) like lower(:name) order by t.created desc]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:223)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:103)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:72)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:52)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1133):


MySql 5:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 1:40 pm 
Newbie

Joined: Mon Jul 26, 2004 11:35 am
Posts: 13
Solved it by changing property mapping to component

<component name="paymentInfo" class="com.app.beans.info.PaymentInfo">
<property name="name" column="BILLING_NAME"/>
<property name="number" column="CARD_NUMBER"/>
<property name="expMonth" column="EXP_MONTH"/>
<property name="expYear" column="EXP_YEAR"/>
<property name="type" column="CARD_TYPE"/>
</component>

Roman


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.