-->
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: Problem with different aliases in select and where clauses
PostPosted: Mon Mar 24, 2008 10:54 am 
Newbie

Joined: Tue Jun 08, 2004 1:18 pm
Posts: 1
Our code is usually building the following query:

Code:
/* criteria query */ select
    this_.ID as ID2_0_,
    this_.rateDate as rateDate2_0_,
    this_.ticker as ticker2_0_,
    this_.currency as currency2_0_,
    this_.rate as rate2_0_
from
    BbgDailyRateData this_
where
    this_.rateDate between to_date('2008-03-24 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
    and to_date('2008-03-24 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
    and this_.currency='USD'


Everynight we bounce our 4 servers and once or twice a week a server will end up trying to run the query as:

Code:
    /* criteria query */ select
        dailybbgra0_.ID as ID2_0_,
        dailybbgra0_.rateDate as rateDate2_0_,
        dailybbgra0_.ticker as ticker2_0_,
        dailybbgra0_.currency as currency2_0_,
        dailybbgra0_.rate as rate2_0_
    from
        BbgDailyRateData dailybbgra0_
    where
        this_.rateDate between to_date('2008-03-23 00:00:00',
'YYYY-MM-DD HH24:MI:SS') and to_date('2008-03-23 23:59:59', 'YYYY-MM-DD
HH24:MI:SS')
        and this_.currency='USD'


without any changes to code or configuration. We quickly notice the problem and restart the server the and problem goes away.

The mapping is:

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>
   <class name="com.creditex.backoffice.defaultswap.BbgCdswData" table="TRADEBBGCDSW">

      <cache usage="nonstrict-read-write" />

      <id name="id">
         <column name="ID" precision="10" scale="0" />
         <generator class="assigned"/>
      </id>

      <property name="bbgTicker" column="bbgTicker" length="32" not-null="true" />

      <property name="settlementDate" column="settlementDate" />
      <property name="maturityDate" column="maturityDate" />
      <property name="effectiveDate" column="effectiveDate" />
      <property name="firstCouponDate" column="firstCouponDate" />
      <property name="nextToLastCouponDate" column="nextToLastCouponDate" />
      <property name="spread" column="spread" precision="8" scale="3" />
      <property name="curveDate" column="curveDate" />
      <property name="notional" column="notional" precision="12" scale="0" />
      <property name="currency" column="currency" length="3" not-null="true" />
      <property name="paymentFrequency" column="paymentFrequency" length="1" not-null="true" />
      <property name="recoveryRate" column="recoveryRate" precision="7" scale="6" />
      <property name="flatSpread" column="flatSpread" precision="8" scale="3" />
      <property name="cnvBpv" column="cnvBpv" precision="10" scale="2" />
      <property name="swapCurveBpv" column="swapCurveBpv" precision="10" scale="2" />
      <property name="marketValue" column="marketValue" precision="10" scale="2" />
      <property name="netAccruedInterest" column="netAccruedInterest" precision="10" scale="2" />
      <property name="daysAccrued" column="daysAccrued" precision="4" scale="0" />
      <property name="payCurveNumber" column="payCurveNumber" length="4" />
      <property name="payCurveMktSide" column="payCurveMktSide" length="20" not-null="true" />
      <property name="securityDescription" column="securityDescription" length="32" not-null="true" />
      <property name="replSpread" column="replSpread" precision="8" scale="3" />
      <property name="buySellFlag" column="buySellFlag" length="1" not-null="true">
         <type name="com.creditex.db.hibernate.StringLabeledEnumUserType">
            <param name="targetClass">com.creditex.trading.TradeDirection</param>
         </type>
      </property>
      <property name="busDays1" column="busDays1" length="3" />
      <property name="busDays2" column="busDays2" length="3" />
      <property name="busDays3" column="busDays3" length="3" />
      <property name="cashSettledOn" column="cashSettledOn" />
      <property name="quotedPrice" column="quotedPrice" precision="12" scale="8" />
      <property name="dealRecoveryRate" column="dealRecoveryRate" precision="7" scale="6" />
      <property name="priceToSpreadMode" column="priceToSpreadMode" precision="1" scale="0" />
      <property name="swapPremium" column="swapPremium" precision="12" scale="2" />
      <property name="dateGenMethod" column="dateGenMethod" length="20" not-null="true" />
      <property name="payAccrued" column="payAccrued" type="yes_no" length="1" />

   </class>
</hibernate-mapping>



and the Java we are running is:

Code:
   Date from = DateUtils.getStartOfDay(date);
   Date to = DateUtils.getEndOfDay(date);
   Criteria criteria = session.createCriteria(DailyBbgRateData.class);
   criteria.add(Expression.between("date", from, to));
   criteria.add(Expression.eq("currency", currency));


This problem has been persistent from Hibernate 3.2.5.ga and 3.2.6.ga. The Java is 1.5.0_11 and the database is Oracle 10G.

This is the first query that we run on startup that has the problem. Once we see this query failing, other queries for different classes fail with the same alias problem. Anyone have any ideas.

Thanks
Neil Hart


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.