I am using HashMaps instead of POJO's (not my choice, cant change it). I have a lazy loaded collection, using a <filter>, which is enabled and set up fine. The problem is, it refers to a field in a base class, and there is no way (that I can see) to point the filter condition to the parent attribute. It seems you can only filter on attributes in the table itself.
Very desperate - need help!
Hibernate version: 3.1rc1
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="BaseFulfillmentAccount" table="Phoenix.BaseFulfillmentAccount">
<id name="oid" column="oid" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.ComponentIdType">
<generator class="assigned" />
</id>
<property name="updatedThroughToDate" column="updatedThroughToDate" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.DateValueType" />
<property name="effectiveDate" column="effectiveDate" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.DateValueType" />
<property name="instructionOid" column="instructionOid" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.ComponentIdType" insert="false" update="false" />
<property name="postedDate" column="postedDate" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.DateValueType" />
<property name="systemDate" column="systemDate" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.TimestampValueType" />
<property name="userId" column="userId" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.StringValueType" />
<set name="PartyFulfillmentAccountRoles" lazy="true" cascade="all">
<key column="baseFulfillmentAccountOid" />
<one-to-many class="CoreFulfillmentAccountRole" />
<filter name="effectiveDateFilter" />
</set>
<set name="CoreShadowAccounts" lazy="true" cascade="all">
<key column="baseFulfillmentAccountOid" />
<one-to-many class="CoreShadowAccount" />
<filter name="effectiveDateFilter" />
</set>
<set name="AccountAllocationDetails" lazy="true" cascade="all">
<key column="baseFulfillmentAccountOid" />
<one-to-many class="AccountAllocationDetail" />
<filter name="effectiveDateFilter" />
</set>
<set name="ProductComponentLink" lazy="true" cascade="all">
<key column="baseFulfillmentAccountOid" />
<one-to-many class="CoreProductComponentLink" />
<filter name="effectiveDateFilter" />
</set>
<filter name="effectiveDateFilter" />
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<joined-subclass entity-name="CoreOverallFulfillmentAccount" table="Phoenix.CoreOverallFulfillmentAccount" extends="BaseFulfillmentAccount">
<key>
<column name="oid" sql-type="com.solcorp.phoenix.runtime.pl.hibernatetypes.ComponentIdType" />
</key>
<set name="CoreFulfillmentAccount" lazy="true" cascade="all">
<key column="coreOverallFulfillmentAccouOid" />
<one-to-many class="CoreFulfillmentAccount" />
<!--filter name="effectiveDateFilter" condition="corefulfil0_1_.effectiveDate <= :effectiveDate"/-->
<filter name="effectiveDateFilter" condition="effectiveDate <= :effectiveDate"/>
</set>
<set name="CoreCompositeAccounts" lazy="true" cascade="all">
<key column="coreOverallFulfillmentAccouOid" />
<one-to-many class="CoreCompositeAccount" />
<filter name="effectiveDateFilter" />
</set>
<many-to-one name="OverallDeployedAccountType" entity-name="DeployedAccountType" lazy="proxy" unique="true" column="deployedAccountTypeOid" />
</joined-subclass>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<joined-subclass entity-name="CoreFulfillmentAccount" table="Phoenix.CoreFulfillmentAccount" extends="BaseFulfillmentAccount">
<key>
<column name="oid" sql-type="com.solcorp.phoenix.runtime.pl.hibernatetypes.ComponentIdType" />
</key>
<property name="coreFulfillmentAccountOid" column="coreFulfillmentAccountOid" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.ComponentIdType" insert="false" update="false" />
<property name="coreOverallFulfillmentAccouOid" column="coreOverallFulfillmentAccouOid" type="com.solcorp.phoenix.runtime.pl.hibernatetypes.ComponentIdType" insert="false" update="false" />
<set name="ParentCoreFulfillmentAccount" lazy="true" cascade="all">
<key column="coreFulfillmentAccountOid" />
<one-to-many class="CoreFulfillmentAccount" />
<filter name="effectiveDateFilter" condition="effectiveDate <= :effectiveDate" />
</set>
</joined-subclass>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- All filters should be defined in this file. For now, we have only the effective date filter, used for financial history collections -->
<filter-def name="effectiveDateFilter" condition=":effectiveDate >= effectiveDate">
<filter-param name="effectiveDate" type="date"/>
</filter-def>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
19:41:53.204 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: -206, SQLState: 42S22
19:41:53.204 ERROR org.hibernate.util.JDBCExceptionReporter - [IBM][CLI Driver][DB2/NT] SQL0206N "COREFULFIL0_.EFFECTIVEDATE" is not valid in the context where it is used. SQLSTATE=42703
Name and version of the database you are using:
DB2
The generated SQL (show_sql=true):
Hibernate: select overallful0_.overallFulfillmentAccountOid as overallF9_1_, overallful0_.oid as oid1_, overallful0_.oid as oid101_0_, overallful0_.state as state101_0_, overallful0_.stateReason as stateRea3_101_0_, overallful0_.effectiveDate as effectiv4_101_0_, overallful0_.instructionOid as instruct5_101_0_, overallful0_.postedDate as postedDate101_0_, overallful0_.systemDate as systemDate101_0_, overallful0_.userId as userId101_0_, overallful0_.overallFulfillmentAccountOid as overallF9_101_0_ from Phoenix.OverallFulfillmentAccountStatus overallful0_ where ? >= overallful0_.effectiveDate and overallful0_.overallFulfillmentAccountOid=?
Hibernate: select corefulfil0_.coreOverallFulfillmentAccouOid as coreOver3_1_, corefulfil0_.oid as oid1_, corefulfil0_.oid as oid8_0_, corefulfil0_1_.updatedThroughToDate as updatedT2_8_0_, corefulfil0_1_.effectiveDate as effectiv3_8_0_, corefulfil0_1_.instructionOid as instruct4_8_0_, corefulfil0_1_.postedDate as postedDate8_0_, corefulfil0_1_.systemDate as systemDate8_0_, corefulfil0_1_.userId as userId8_0_, corefulfil0_.coreFulfillmentAccountOid as coreFulf2_25_0_, corefulfil0_.coreOverallFulfillmentAccouOid as coreOver3_25_0_, corefulfil0_2_.fullfilmentAccountKey as fullfilm2_55_0_, corefulfil0_2_.assetClassAllocationModelKey as assetCla3_55_0_, corefulfil0_2_.fulfillmentAccountID as fulfillm4_55_0_, corefulfil0_2_.terminationDate as terminat5_55_0_, corefulfil0_2_.terminationReason as terminat6_55_0_, corefulfil0_2_.nextSchedDateforAutoProcessing as nextSche7_55_0_, corefulfil0_2_.nextSchedAutoProcessingType as nextSche8_55_0_, corefulfil0_2_.taxCategoryType as taxCateg9_55_0_, corefulfil0_2_.agentRepresentativeEffDate as agentRe10_55_0_, corefulfil0_2_.settlementOptionType as settlem11_55_0_, corefulfil0_2_.settlementOptionTerm as settlem12_55_0_, corefulfil0_2_.applicationSignedDate as applica13_55_0_, corefulfil0_2_.applicationReceivedDate as applica14_55_0_, corefulfil0_2_.issueDate as issueDate55_0_, corefulfil0_2_.lastCapitalizationDate as lastCap16_55_0_, corefulfil0_5_.maturityRule as maturity2_84_0_, corefulfil0_5_.maturityDate as maturity3_84_0_, corefulfil0_5_.term as term84_0_, corefulfil0_10_.rateType as rateType94_0_, corefulfil0_10_.overrideRate as override3_94_0_, corefulfil0_10_.overrideRateFactor as override4_94_0_, corefulfil0_16_.accumulationEndDate as accumula2_207_0_, case when corefulfil0_15_.oid is not null then 20 when corefulfil0_7_.oid is not null then 8 when corefulfil0_8_.oid is not null then 9 when corefulfil0_14_.oid is not null then 16 when corefulfil0_28_.oid is not null then 35 when corefulfil0_25_.oid is not null then 30 when corefulfil0_26_.oid is not null then 31 when corefulfil0_27_.oid is not null then 32 when corefulfil0_21_.oid is not null then 26 when corefulfil0_11_.oid is not null then 12 when corefulfil0_19_.oid is not null then 24 when corefulfil0_20_.oid is not null then 25 when corefulfil0_13_.oid is not null then 15 when corefulfil0_24_.oid is not null then 29 when corefulfil0_22_.oid is not null then 27 when corefulfil0_23_.oid is not null then 28 when corefulfil0_18_.oid is not null then 23 when corefulfil0_3_.oid is not null then 4 when corefulfil0_4_.oid is not null then 5 when corefulfil0_5_.oid is not null then 6 when corefulfil0_6_.oid is not null then 7 when corefulfil0_9_.oid is not null then 10 when corefulfil0_10_.oid is not null then 11 when corefulfil0_12_.oid is not null then 14 when corefulfil0_16_.oid is not null then 21 when corefulfil0_17_.oid is not null then 22 when corefulfil0_2_.oid is not null then 3 when corefulfil0_.oid is not null then 1 end as clazz_0_ from Phoenix.CoreFulfillmentAccount corefulfil0_ inner join Phoenix.BaseFulfillmentAccount corefulfil0_1_ on corefulfil0_.oid=corefulfil0_1_.oid left outer join Phoenix.FulfillmentAccount corefulfil0_2_ on corefulfil0_.oid=corefulfil0_2_.oid left outer join Phoenix.LoanFulfillmentAccount corefulfil0_3_ on corefulfil0_.oid=corefulfil0_3_.oid left outer join Phoenix.MarketBasedFulfillmentAccount corefulfil0_4_ on corefulfil0_.oid=corefulfil0_4_.oid left outer join Phoenix.MaturingInterestBasedFulfillmentAccount corefulfil0_5_ on corefulfil0_.oid=corefulfil0_5_.oid left outer join Phoenix.MortalityBasedFulfillmentAccount corefulfil0_6_ on corefulfil0_.oid=corefulfil0_6_.oid left outer join Phoenix.NiftyLoanOptionCollateral corefulfil0_7_ on corefulfil0_.oid=corefulfil0_7_.oid left outer join Phoenix.NiftyLoanOptionImpairment corefulfil0_8_ on corefulfil0_.oid=corefulfil0_8_.oid left outer join Phoenix.NiftyMemberFixedAnnuity corefulfil0_9_ on corefulfil0_.oid=corefulfil0_9_.oid left outer join Phoenix.NonMaturingInterestBasedFulfillmentAccount corefulfil0_10_ on corefulfil0_.oid=corefulfil0_10_.oid left outer join Phoenix.NonMaturingInterestBasedLoanCollateralFulfillmentAccount corefulfil0_11_ on corefulfil0_.oid=corefulfil0_11_.oid left outer join Phoenix.UnitBasedFulfillmentAccount corefulfil0_12_ on corefulfil0_.oid=corefulfil0_12_.oid left outer join Phoenix.UnitBasedLoanCollateralFulfillmentAccount corefulfil0_13_ on corefulfil0_.oid=corefulfil0_13_.oid left outer join Phoenix.FixedAnnuityLoan corefulfil0_14_ on corefulfil0_.oid=corefulfil0_14_.oid left outer join Phoenix.SimpleLoan corefulfil0_15_ on corefulfil0_.oid=corefulfil0_15_.oid left outer join Phoenix.AnnuityAccumulationBasedFulfillmentAccount corefulfil0_16_ on corefulfil0_.oid=corefulfil0_16_.oid left outer join Phoenix.FixedAnnuity corefulfil0_17_ on corefulfil0_.oid=corefulfil0_17_.oid left outer join Phoenix.SimpleFixedAnnuity corefulfil0_18_ on corefulfil0_.oid=corefulfil0_18_.oid left outer join Phoenix.DailyInterestAccount corefulfil0_19_ on corefulfil0_.oid=corefulfil0_19_.oid left outer join Phoenix.FixedAnnuityDIA corefulfil0_20_ on corefulfil0_.oid=corefulfil0_20_.oid left outer join Phoenix.SimpleDIA corefulfil0_21_ on corefulfil0_.oid=corefulfil0_21_.oid left outer join Phoenix.AccumulationAnnuity corefulfil0_22_ on corefulfil0_.oid=corefulfil0_22_.oid left outer join Phoenix.NiftyAccumulationAnnuity corefulfil0_23_ on corefulfil0_.oid=corefulfil0_23_.oid left outer join Phoenix.SimpleAccumulationAnnuity corefulfil0_24_ on corefulfil0_.oid=corefulfil0_24_.oid left outer join Phoenix.FixedAnnuityGIA corefulfil0_25_ on corefulfil0_.oid=corefulfil0_25_.oid left outer join Phoenix.GuaranteedInterest1YrCompound corefulfil0_26_ on corefulfil0_.oid=corefulfil0_26_.oid left outer join Phoenix.GuaranteedInterest3YrCompound corefulfil0_27_ on corefulfil0_.oid=corefulfil0_27_.oid left outer join Phoenix.SimpleGIA corefulfil0_28_ on corefulfil0_.oid=corefulfil0_28_.oid where corefulfil0_.effectiveDate <= ? and corefulfil0_.coreOverallFulfillmentAccouOid=?
Debug level Hibernate log excerpt:
|