org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of cat.cis.portal.supplier.CWSHelp.persistence.EntityPO.entityId

Hibernate JIRA | Ben Geyer | 1 decade ago
  1. 0

    When I try to define a query by criteria on an object with a many to one relationship, it throws an IllegalArgumentException on the referred to object. Anyone have any ideas on what is causing this? When I change to using HQL instead, it seems to all work correctly. Request Class has a many to one relation with EntityPO ... <many-to-one name="EntityByApproverEntityId" class="cat.EntityPO" not-null="true" cascade="none" lazy="false" > <column name="APPROVER_ENTITY_ID" /> </many-to-one> ... Here's the table def for Request: CAR_ID NOT NULL NUMBER(10) REQUEST_TYPE_CODE NOT NULL CHAR(1) PROCESSED_DATETIME DATE REQUEST_STATE_CODE NOT NULL CHAR(1) REQUESTER_ENTITY_ID NOT NULL NUMBER(10) APPROVER_ENTITY_ID NOT NULL NUMBER(10) LOGIN_ID VARCHAR2(50) AFFILIATED_ORG_CODE VARCHAR2(30) SUBMITTED_DATETIME DATE APPROVED_DATETIME DATE DELEGATE_ENTITY_ID NUMBER(10) EntityPO Class has this: ... <set name="CWSAccountRequestsByApproverEntityId" lazy="false" inverse="false" cascade="none" > <key> <column name="APPROVER_ENTITY_ID" /> </key> <one-to-many class="cat.CWSAccountRequestPO" /> </set> Here's the table def for Entity: ENTITY_ID NOT NULL NUMBER(10) ENTITY_TYPE_CODE NOT NULL CHAR(1) FIRST_NAME NOT NULL VARCHAR2(30) LAST_NAME NOT NULL VARCHAR2(30) MIDDLE_INITIAL VARCHAR2(10) EMAIL_ADDRESS VARCHAR2(100) CUPID VARCHAR2(32) PHONE_NUMBER VARCHAR2(25) Here's the code that I use: criteria = session.createCriteria(CWSAccountRequestPO.class); criteria.add(Expression.eq("requestTypeCode", Constants.REQUEST_TYPE_NEW)); criteria.add(Expression.in("EntityByApproverEntityId", approverIds)); retVal = criteria.list(); The query looks fine. Here it is: select this_.CAR_ID as CAR1_0_, this_.REQUEST_TYPE_CODE as REQUEST2_0_0_, this_.PROCESSED_DATETIME as PROCESSED3_0_0_, this_.REQUEST_STATE_CODE as REQUEST4_0_0_, this_.LOGIN_ID as LOGIN5_0_0_, this_.AFFILIATED_ORG_CODE as AFFILIATED6_0_0_, this_.SUBMITTED_DATETIME as SUBMITTED7_0_0_, this_.APPROVED_DATETIME as APPROVED8_0_0_, this_.DELEGATE_ENTITY_ID as DELEGATE9_0_0_, this_.APPROVER_ENTITY_ID as APPROVER10_0_0_, this_.REQUESTER_ENTITY_ID as REQUESTER11_0_0_ from CWS_ACCOUNT_REQUESTS this_ where this_.REQUEST_TYPE_CODE=? and this_.APPROVER_ENTITY_ID in (?) Here's the stack trace I see. org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of cat.cis.portal.supplier.CWSHelp.persistence.EntityPO.entityId at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) at junit.framework.TestResult.runProtected(TestResult.java:135) at junit.framework.TestResult.run(TestResult.java:112) at junit.framework.TestCase.run(TestCase.java:119) at junit.framework.TestSuite.runTest(TestSuite.java:209) at junit.framework.TestSuite.run(TestSuite.java:205) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:399) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) at junit.framework.TestSuite.run(TestSuite.java:205) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:399) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) at org.hibernate.loader.Loader.list(Loader.java:1498) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:117) at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2947) at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2752) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:185) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:217) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:94) at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:50) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1045) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1130) at org.hibernate.loader.Loader.doQuery(Loader.java:415) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:212) at org.hibernate.loader.Loader.doList(Loader.java:1532) at org.hibernate.loader.Loader.list(Loader.java:1498) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1262) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:302) at cat.cis.portal.supplier.CWSHelp.factory.RequestFactory.getNewRequestsForApprover(RequestFactory.java:95) at cat.cis.portal.supplier.CWSHelp.factory.RequestFactoryTest.testGetNewRequestsForApproverWithArray(RequestFactoryTest.java:77) at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:107) at junit.framework.TestResult.runProtected(TestResult.java:135) at junit.framework.TestResult.run(TestResult.java:112) at junit.framework.TestCase.run(TestCase.java:119) at junit.framework.TestSuite.runTest(TestSuite.java:209) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288)

    Hibernate JIRA | 1 decade ago | Ben Geyer
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of cat.cis.portal.supplier.CWSHelp.persistence.EntityPO.entityId
  2. 0

    When I try to define a query by criteria on an object with a many to one relationship, it throws an IllegalArgumentException on the referred to object. Anyone have any ideas on what is causing this? When I change to using HQL instead, it seems to all work correctly. Request Class has a many to one relation with EntityPO ... <many-to-one name="EntityByApproverEntityId" class="cat.EntityPO" not-null="true" cascade="none" lazy="false" > <column name="APPROVER_ENTITY_ID" /> </many-to-one> ... Here's the table def for Request: CAR_ID NOT NULL NUMBER(10) REQUEST_TYPE_CODE NOT NULL CHAR(1) PROCESSED_DATETIME DATE REQUEST_STATE_CODE NOT NULL CHAR(1) REQUESTER_ENTITY_ID NOT NULL NUMBER(10) APPROVER_ENTITY_ID NOT NULL NUMBER(10) LOGIN_ID VARCHAR2(50) AFFILIATED_ORG_CODE VARCHAR2(30) SUBMITTED_DATETIME DATE APPROVED_DATETIME DATE DELEGATE_ENTITY_ID NUMBER(10) EntityPO Class has this: ... <set name="CWSAccountRequestsByApproverEntityId" lazy="false" inverse="false" cascade="none" > <key> <column name="APPROVER_ENTITY_ID" /> </key> <one-to-many class="cat.CWSAccountRequestPO" /> </set> Here's the table def for Entity: ENTITY_ID NOT NULL NUMBER(10) ENTITY_TYPE_CODE NOT NULL CHAR(1) FIRST_NAME NOT NULL VARCHAR2(30) LAST_NAME NOT NULL VARCHAR2(30) MIDDLE_INITIAL VARCHAR2(10) EMAIL_ADDRESS VARCHAR2(100) CUPID VARCHAR2(32) PHONE_NUMBER VARCHAR2(25) Here's the code that I use: criteria = session.createCriteria(CWSAccountRequestPO.class); criteria.add(Expression.eq("requestTypeCode", Constants.REQUEST_TYPE_NEW)); criteria.add(Expression.in("EntityByApproverEntityId", approverIds)); retVal = criteria.list(); The query looks fine. Here it is: select this_.CAR_ID as CAR1_0_, this_.REQUEST_TYPE_CODE as REQUEST2_0_0_, this_.PROCESSED_DATETIME as PROCESSED3_0_0_, this_.REQUEST_STATE_CODE as REQUEST4_0_0_, this_.LOGIN_ID as LOGIN5_0_0_, this_.AFFILIATED_ORG_CODE as AFFILIATED6_0_0_, this_.SUBMITTED_DATETIME as SUBMITTED7_0_0_, this_.APPROVED_DATETIME as APPROVED8_0_0_, this_.DELEGATE_ENTITY_ID as DELEGATE9_0_0_, this_.APPROVER_ENTITY_ID as APPROVER10_0_0_, this_.REQUESTER_ENTITY_ID as REQUESTER11_0_0_ from CWS_ACCOUNT_REQUESTS this_ where this_.REQUEST_TYPE_CODE=? and this_.APPROVER_ENTITY_ID in (?) Here's the stack trace I see. org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of cat.cis.portal.supplier.CWSHelp.persistence.EntityPO.entityId at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) at junit.framework.TestResult.runProtected(TestResult.java:135) at junit.framework.TestResult.run(TestResult.java:112) at junit.framework.TestCase.run(TestCase.java:119) at junit.framework.TestSuite.runTest(TestSuite.java:209) at junit.framework.TestSuite.run(TestSuite.java:205) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:399) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) at junit.framework.TestSuite.run(TestSuite.java:205) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:399) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) at org.hibernate.loader.Loader.list(Loader.java:1498) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:170) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:117) at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2947) at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2752) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:185) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:217) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:94) at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:50) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1045) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1130) at org.hibernate.loader.Loader.doQuery(Loader.java:415) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:212) at org.hibernate.loader.Loader.doList(Loader.java:1532) at org.hibernate.loader.Loader.list(Loader.java:1498) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1262) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:302) at cat.cis.portal.supplier.CWSHelp.factory.RequestFactory.getNewRequestsForApprover(RequestFactory.java:95) at cat.cis.portal.supplier.CWSHelp.factory.RequestFactoryTest.testGetNewRequestsForApproverWithArray(RequestFactoryTest.java:77) at java.lang.reflect.Method.invoke(Native Method) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:132) at junit.framework.TestResult$1.protect(TestResult.java:107) at junit.framework.TestResult.runProtected(TestResult.java:135) at junit.framework.TestResult.run(TestResult.java:112) at junit.framework.TestCase.run(TestCase.java:119) at junit.framework.TestSuite.runTest(TestSuite.java:209) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288)

    Hibernate JIRA | 1 decade ago | Ben Geyer
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of cat.cis.portal.supplier.CWSHelp.persistence.EntityPO.entityId
  3. 0

    IllegalArgumentException: object is not an instance of declaring class

    Google Groups | 4 months ago | Marco Luca Sbodio
    java.lang.AssertionError: IllegalArgumentException: object is not an instance of declaring class For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    The BalusC Code: Generic object converter

    omnifaces.org | 4 months ago
    java.lang.RuntimeException: Cannot convert from java.lang.Boolean to java.lang.Integer. Conversion failed with object is not an instance of declaring class
  6. 0

    *Original problem:* I have an abstract groovy class, and two (or more) concrete java subclasses extend it. The superclass has an abstract method, which each concrete subclass overrides (of course). When I use just one subclass, everything works fine: I call a superclass method that calls the abstract method, and I get the behavior I expect. But when the other subclass has already been loaded, things are different. Then, I get an IllegalArgumentException: object is not an instance of declaring class. This problem corresponds to testGenericSubclassWithBafflingSymptom() in the attached junit tests. See that test for additional details. *Simpler case that illustrates the likely underlying problem (and does not involve generics):* I have an abstract groovy class, and two concrete java subclasses extend it. If I have an instance of just one of the subclasses, then instance.metaClass.theClass returns exactly what I expect. But if I've already loaded the other subclass, then the metaClass on an instance of *either* subclass is for the class that was used first! {code:java} // snippet of the groovy version of testSubclass(), also attached OtherConcreteJavaSubclass unrelatedInstance = new OtherConcreteJavaSubclass(); ConcreteJavaSubclass instance = new ConcreteJavaSubclass(); assertEquals("this one works", OtherConcreteJavaSubclass, unrelatedInstance.metaClass.theClass) assertEquals("but this one is wrong", ConcreteJavaSubclass, instance.metaClass.theClass) {code} This mixture of groovy and java may sound a little odd, but we actually ran into it when converting an existing class from java to groovy, and it stumped us for quite a while.

    Apache's JIRA Issue Tracker | 6 years ago | Laura Dean
    java.lang.IllegalArgumentException: object is not an instance of declaring class

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      object is not an instance of declaring class

      at org.hibernate.tuple.AbstractTuplizer.getIdentifier()
    2. Hibernate
      CriteriaLoader.list
      1. org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:117)
      2. org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2947)
      3. org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2752)
      4. org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:185)
      5. org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:217)
      6. org.hibernate.type.EntityType.getIdentifier(EntityType.java:94)
      7. org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:50)
      8. org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1045)
      9. org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1130)
      10. org.hibernate.loader.Loader.doQuery(Loader.java:415)
      11. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:212)
      12. org.hibernate.loader.Loader.doList(Loader.java:1532)
      13. org.hibernate.loader.Loader.list(Loader.java:1498)
      14. org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
      14 frames
    3. Hibernate
      CriteriaImpl.list
      1. org.hibernate.impl.SessionImpl.list(SessionImpl.java:1262)
      2. org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:302)
      2 frames
    4. cat.cis.portal
      RequestFactoryTest.testGetNewRequestsForApproverWithArray
      1. cat.cis.portal.supplier.CWSHelp.factory.RequestFactory.getNewRequestsForApprover(RequestFactory.java:95)
      2. cat.cis.portal.supplier.CWSHelp.factory.RequestFactoryTest.testGetNewRequestsForApproverWithArray(RequestFactoryTest.java:77)
      2 frames
    5. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      1 frame
    6. JUnit
      TestSuite.runTest
      1. junit.framework.TestCase.runTest(TestCase.java:164)
      2. junit.framework.TestCase.runBare(TestCase.java:132)
      3. junit.framework.TestResult$1.protect(TestResult.java:107)
      4. junit.framework.TestResult.runProtected(TestResult.java:135)
      5. junit.framework.TestResult.run(TestResult.java:112)
      6. junit.framework.TestCase.run(TestCase.java:119)
      7. junit.framework.TestSuite.runTest(TestSuite.java:209)
      7 frames
    7. JUnit3 Runner
      RemoteTestRunner.run
      1. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:288)
      1 frame