Patrick,

Nice catch, that did the trick.  I guess Hiberntate must be more forgiving
:-)  And yes it is a crappy error for sure.

Ron

On Fri, Feb 29, 2008 at 1:50 PM, Patrick Linskey <[EMAIL PROTECTED]> wrote:

> >  SELECT tbl FROM CreditAccountDetailTbl tbl WHERE
> prodAcctTypTbl.prodTypCd in
> >  ('CPCC', 'CCC') and tbl.id.apcntId = :apcntId
>
> That's a really crappy error. I think you want that to read:
>
> SELECT tbl FROM CreditAccountDetailTbl tbl WHERE
> tbl.prodAcctTypTbl.prodTypCd in ('CPCC', 'CCC') and tbl.id.apcntId =
> :apcntId
>
> Notice that I added the 'tbl.' prefix in the first bit of the WHERE
> clause.
>
> -Patrick
>
> On Fri, Feb 29, 2008 at 10:44 AM, Ronald R. DiFrango
> <[EMAIL PROTECTED]> wrote:
> > All,
> >
> >  This is another snag I hit when moving over to OpenJPA, I have the
> following
> >  named query:
> >
> >  SELECT tbl FROM CreditAccountDetailTbl tbl WHERE
> prodAcctTypTbl.prodTypCd in
> >  ('CPCC', 'CCC') and tbl.id.apcntId = :apcntId
> >
> >  When I attempt to execute it I get the following error:
> >
> >  <openjpa-1.0.2-r420667:627158 nonfatal user error>
> >  org.apache.openjpa.persistence.ArgumentException: An error occurred
> while
> >  parsing the query filter "SELECT tbl FROM CreditAccountDetailTbl tbl
> WHERE
> >  prodAcctTypTbl.prodTypCd in ('CPCC', 'CCC') and tbl.id.apcntId =
> :apcntId".
> >  Error message: Attempt to query field "prodAcctTypTbl.prodTypCd" from
> >  non-entity class "null".
> >     at
> >  org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException
> (
> >  AbstractExpressionBuilder.java:118)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getPath(
> >  JPQLExpressionBuilder.java:1294)
> >     at
> >  org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getPathOrConstant(
> >  JPQLExpressionBuilder.java:1260)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.eval(
> >  JPQLExpressionBuilder.java:858)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getValue(
> >  JPQLExpressionBuilder.java:1354)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getValue(
> >  JPQLExpressionBuilder.java:1340)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.eval(
> >  JPQLExpressionBuilder.java:824)
> >     at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getExpression(
> >  JPQLExpressionBuilder.java:1331)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.eval(
> >  JPQLExpressionBuilder.java:747)
> >     at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getExpression(
> >  JPQLExpressionBuilder.java:1331)
> >     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.eval(
> >  JPQLExpressionBuilder.java:701)
> >     at
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.evalWhereClause(
> >  JPQLExpressionBuilder.java:476)
> >     at
> >
> org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getQueryExpressions(
> >  JPQLExpressionBuilder.java:264)
> >     at org.apache.openjpa.kernel.jpql.JPQLParser.eval(JPQLParser.java
> :61)
> >     at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor
> >  .<init>(ExpressionStoreQuery.java:656)
> >     at
> org.apache.openjpa.kernel.ExpressionStoreQuery.newDataStoreExecutor(
> >  ExpressionStoreQuery.java:165)
> >     at org.apache.openjpa.kernel.QueryImpl.createExecutor(QueryImpl.java
> >  :728)
> >     at org.apache.openjpa.kernel.QueryImpl.compileForDataStore(
> >  QueryImpl.java:686)
> >     at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(
> QueryImpl.java
> >  :668)
> >     at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:568)
> >     at org.apache.openjpa.persistence.EntityManagerImpl.createNamedQuery
> (
> >  EntityManagerImpl.java:788)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >     at java.lang.reflect.Method.invoke(Unknown Source)
> >     at
> >
> org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke
> >  (SharedEntityManagerCreator.java:180)
> >     at $Proxy32.createNamedQuery(Unknown Source)
> >     at
> >
> com.circuitcity.instantcredit.services.persistance.impl.GenericDAOImpl.findByParameters
> >  (GenericDAOImpl.java:201)
> >     at
> >
> com.circuitcity.instantcredit.services.persistance.impl.GenericDAOImpl$$FastClassByCGLIB$$aea3ab09.invoke
> >  (<generated>)
> >     at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
> >     at
> >
> org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint
> >  (Cglib2AopProxy.java:694)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:149)
> >     at
> >
> org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke
> >  (AfterReturningAdviceInterceptor.java:50)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:171)
> >     at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke
> (
> >  AspectJAfterThrowingAdvice.java:54)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:171)
> >     at
> >
> org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke
> >  (MethodBeforeAdviceInterceptor.java:50)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:171)
> >     at
> >  org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(
> >  ExposeInvocationInterceptor.java:89)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:171)
> >     at
> >
> org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept
> >  (Cglib2AopProxy.java:629)
> >     at
> >
> com.circuitcity.instantcredit.services.persistance.impl.GenericDAOImpl$$EnhancerByCGLIB$$d1947d1.findByParameters
> >  (<generated>)
> >     at
> >
> com.circuitcity.instantcredit.services.impl.CreditApplicationStatusImpl.setCreditInformation
> >  (CreditApplicationStatusImpl.java:143)
> >     at
> >
> com.circuitcity.instantcredit.services.impl.CreditApplicationStatusImpl.getApplicationsByLocationNumber
> >  (CreditApplicationStatusImpl.java:120)
> >     at
> >
> com.circuitcity.instantcredit.services.impl.CreditApplicationStatusImpl$$FastClassByCGLIB$$fb599bf0.invoke
> >  (<generated>)
> >     at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
> >     at
> >
> org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint
> >  (Cglib2AopProxy.java:694)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:149)
> >     at
> >
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
> >  TransactionInterceptor.java:106)
> >     at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> >  ReflectiveMethodInvocation.java:171)
> >     at
> >
> org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept
> >  (Cglib2AopProxy.java:629)
> >     at
> >
> com.circuitcity.instantcredit.services.impl.CreditApplicationStatusImpl$$EnhancerByCGLIB$$3724154a.getApplicationsByLocationNumber
> >  (<generated>)
> >     at
> >
> com.circuitcity.instantcredit.services.test.CreditStatusTest.testCreditStatusByLocation
> >  (CreditStatusTest.java:54)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >     at java.lang.reflect.Method.invoke(Unknown Source)
> >     at junit.framework.TestCase.runTest(TestCase.java:154)
> >     at junit.framework.TestCase.runBare(TestCase.java:127)
> >     at org.springframework.test.ConditionalTestCase.runBare(
> >  ConditionalTestCase.java:69)
> >     at
> >
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001
> >  (AbstractAnnotationAwareTransactionalTests.java:47)
> >     at
> >
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run
> >  (AbstractAnnotationAwareTransactionalTests.java:113)
> >     at
> >
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest
> >  (AbstractAnnotationAwareTransactionalTests.java:176)
> >     at
> >
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed
> >  (AbstractAnnotationAwareTransactionalTests.java:150)
> >     at
> >
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare
> >  (AbstractAnnotationAwareTransactionalTests.java:109)
> >     at org.springframework.test.jpa.AbstractJpaTests.runBare(
> >  AbstractJpaTests.java:174)
> >     at org.springframework.test.jpa.AbstractJpaTests.runBare(
> >  AbstractJpaTests.java:254)
> >     at junit.framework.TestResult$1.protect(TestResult.java:106)
> >     at junit.framework.TestResult.runProtected(TestResult.java:124)
> >     at junit.framework.TestResult.run(TestResult.java:109)
> >     at junit.framework.TestCase.run(TestCase.java:118)
> >     at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >     at junit.framework.TestSuite.run(TestSuite.java:203)
> >     at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(
> >  JUnit3TestReference.java:130)
> >     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(
> >  TestExecution.java:38)
> >     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> >  RemoteTestRunner.java:460)
> >     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
> >  RemoteTestRunner.java:673)
> >     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(
> >  RemoteTestRunner.java:386)
> >     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
> >  RemoteTestRunner.java:196)
> >
> >  The complete class is as follows:
> >
> >  package com.circuitcity.instantcredit.services.persistance.domain;
> >
> >  import java.sql.Timestamp;
> >  import java.util.Date;
> >
> >  import javax.persistence.AttributeOverride;
> >  import javax.persistence.AttributeOverrides;
> >  import javax.persistence.Column;
> >  import javax.persistence.EmbeddedId;
> >  import javax.persistence.Entity;
> >  import javax.persistence.EntityListeners;
> >  import javax.persistence.FetchType;
> >  import javax.persistence.JoinColumn;
> >  import javax.persistence.ManyToOne;
> >  import javax.persistence.NamedQuery;
> >  import javax.persistence.Table;
> >  import javax.persistence.Temporal;
> >  import javax.persistence.TemporalType;
> >  import javax.persistence.Version;
> >
> >  import
> >  com.circuitcity.instantcredit.services.persistance.audit.AuditListenter
> ;
> >  import
> com.circuitcity.instantcredit.services.persistance.audit.Auditable;
> >
> >  /**
> >   * CrAcctDtlTbl entity.
> >   *
> >   * @author MyEclipse Persistence Tools
> >   */
> >  @Entity
> >  @Table(name = "cr_acct_dtl_tbl", uniqueConstraints = {})
> >  @EntityListeners(AuditListenter.class)
> >  @NamedQuery(name="findApprovedCreditCards",
> >         query="SELECT tbl FROM CreditAccountDetailTbl tbl WHERE
> >  prodAcctTypTbl.prodTypCd in ('CPCC', 'CCC') and tbl.id.apcntId =
> :apcntId")
> >  @SuppressWarnings("serial")
> >  public class CreditAccountDetailTbl implements java.io.Serializable,
> >  Auditable {
> >
> >     // Fields
> >     private CreditAccountDetailTblId id;
> >     private ProdAcctTypTbl prodAcctTypTbl;
> >     private ApplicantTbl apcntTbl;
> >     private CreditAccountTypeTbl crAcctTypTbl;
> >     private Timestamp crtDttm;
> >     private Timestamp lstUpdDttm;
> >     private Date effBegDt;
> >     private String lstUpddByTxt;
> >     private Double locNbr;
> >     private Double crlmtNbr;
> >     private Double apr;
> >
> >     // Constructors
> >
> >     /** default constructor */
> >     public CreditAccountDetailTbl() {
> >     }
> >
> >     /** minimal constructor */
> >     public CreditAccountDetailTbl(CreditAccountDetailTblId id,
> ApplicantTbl
> >  apcntTbl,
> >             CreditAccountTypeTbl crAcctTypTbl, Double locNbr) {
> >         this.id = id;
> >         this.apcntTbl = apcntTbl;
> >         this.crAcctTypTbl = crAcctTypTbl;
> >         this.locNbr = locNbr;
> >     }
> >
> >     /** full constructor */
> >     public CreditAccountDetailTbl(CreditAccountDetailTblId id,
> >  ProdAcctTypTbl prodAcctTypTbl,
> >             ApplicantTbl apcntTbl, CreditAccountTypeTbl crAcctTypTbl,
> >  Timestamp crtDttm,
> >             Timestamp lstUpdDttm, Date effBegDt, String lstUpddByTxt,
> Double
> >  locNbr,
> >             Double crlmtNbr, Double apr) {
> >         this.id = id;
> >         this.prodAcctTypTbl = prodAcctTypTbl;
> >         this.apcntTbl = apcntTbl;
> >         this.crAcctTypTbl = crAcctTypTbl;
> >         this.crtDttm = crtDttm;
> >         this.lstUpdDttm = lstUpdDttm;
> >         this.effBegDt = effBegDt;
> >         this.lstUpddByTxt = lstUpddByTxt;
> >         this.locNbr = locNbr;
> >         this.crlmtNbr = crlmtNbr;
> >         this.apr = apr;
> >     }
> >
> >     // Property accessors
> >     @EmbeddedId
> >     @AttributeOverrides( {
> >             @AttributeOverride(name = "apcntId", column = @Column(name =
> >  "apcnt_id", unique = false, nullable = false, insertable = true,
> updatable =
> >  true)),
> >             @AttributeOverride(name = "crAcctTypCd", column =
> @Column(name =
> >  "cr_acct_typ_cd", unique = false, nullable = false, insertable = true,
> >  updatable = true, length = 25)) })
> >     public CreditAccountDetailTblId getId() {
> >         return this.id;
> >     }
> >
> >     public void setId(CreditAccountDetailTblId id) {
> >         this.id = id;
> >     }
> >
> >     @ManyToOne(cascade = {}, fetch = FetchType.EAGER)
> >     @JoinColumn(name = "prod_typ_cd", unique = false, nullable = true,
> >  insertable = true, updatable = true)
> >     public ProdAcctTypTbl getProdAcctTypTbl() {
> >         return this.prodAcctTypTbl;
> >     }
> >
> >     public void setProdAcctTypTbl(ProdAcctTypTbl prodAcctTypTbl) {
> >         this.prodAcctTypTbl = prodAcctTypTbl;
> >     }
> >
> >     @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
> >     @JoinColumn(name = "apcnt_id", unique = false, nullable = false,
> >  insertable = false, updatable = false)
> >     public ApplicantTbl getApcntTbl() {
> >         return this.apcntTbl;
> >     }
> >
> >     public void setApcntTbl(ApplicantTbl apcntTbl) {
> >         this.apcntTbl = apcntTbl;
> >     }
> >
> >     @ManyToOne(cascade = {}, fetch = FetchType.LAZY)
> >     @JoinColumn(name = "cr_acct_typ_cd", unique = false, nullable =
> false,
> >  insertable = false, updatable = false)
> >     public CreditAccountTypeTbl getCrAcctTypTbl() {
> >         return this.crAcctTypTbl;
> >     }
> >
> >     public void setCrAcctTypTbl(CreditAccountTypeTbl crAcctTypTbl) {
> >         this.crAcctTypTbl = crAcctTypTbl;
> >     }
> >
> >     @Temporal(TemporalType.DATE)
> >     @Column(name = "crt_dttm", unique = false, nullable = true,
> insertable =
> >  true, updatable = true, length = 4)
> >     public Timestamp getCrtDttm() {
> >         return this.crtDttm;
> >     }
> >
> >     public void setCrtDttm(Timestamp crtDttm) {
> >         this.crtDttm = crtDttm;
> >     }
> >
> >     @Column(name = "lst_upd_dttm", unique = false, nullable = true,
> >  insertable = true, updatable = true, length = 4)
> >     public Timestamp getLstUpdDttm() {
> >         return this.lstUpdDttm;
> >     }
> >
> >     public void setLstUpdDttm(Timestamp lstUpdDttm) {
> >         this.lstUpdDttm = lstUpdDttm;
> >     }
> >
> >     @Temporal(TemporalType.DATE)
> >     @Column(name = "eff_beg_dt", unique = false, nullable = true,
> insertable
> >  = true, updatable = true, length = 4)
> >     public Date getEffBegDt() {
> >         return this.effBegDt;
> >     }
> >
> >     public void setEffBegDt(Date effBegDt) {
> >         this.effBegDt = effBegDt;
> >     }
> >
> >     @Column(name = "lst_updd_by_txt", unique = false, nullable = true,
> >  insertable = true, updatable = true, length = 100)
> >     public String getLstUpddByTxt() {
> >         return this.lstUpddByTxt;
> >     }
> >
> >     public void setLstUpddByTxt(String lstUpddByTxt) {
> >         this.lstUpddByTxt = lstUpddByTxt;
> >     }
> >
> >     @Column(name = "loc_nbr", unique = false, nullable = false,
> insertable =
> >  true, updatable = true, precision = 4, scale = 255)
> >     public Double getLocNbr() {
> >         return this.locNbr;
> >     }
> >
> >     public void setLocNbr(Double locNbr) {
> >         this.locNbr = locNbr;
> >     }
> >
> >     @Column(name = "crlmt_nbr", unique = false, nullable = true,
> insertable
> >  = true, updatable = true, precision = 31, scale = 15)
> >     public Double getCrlmtNbr() {
> >         return this.crlmtNbr;
> >     }
> >
> >     public void setCrlmtNbr(Double crlmtNbr) {
> >         this.crlmtNbr = crlmtNbr;
> >     }
> >
> >     @Column(name = "apr", unique = false, nullable = true, insertable =
> >  true, updatable = true, precision = 10, scale = 5)
> >     public Double getApr() {
> >         return this.apr;
> >     }
> >
> >     public void setApr(Double apr) {
> >         this.apr = apr;
> >     }
> >
> >  }
> >
> >  The trick is that, I am using the join column that is actually part of
> a
> >  related class in the query and my guess is that it is not fetching it
> or if
> >  it is, it is coming back NULL and puking.  Any thoughts on getting
> around
> >  this?  I could go directly against the column as it is defined in this
> >  entity, but the attribute for the QL should be coming from the joined
> class
> >  shouldn't it?
> >
> >  Ron
> >
>
>
>
> --
> Patrick Linskey
> 202 669 5907
>



-- 
Ron DiFrango
Blog (www.captech-soa.blogspot.com)

Reply via email to