javax.persistence.EntityNotFoundException: Unable to find org.jboss.essc.web.model.ProductCustomField with id 1

Hibernate JIRA | Ondra Žižka | 4 years ago
  1. 0

    I have this query: {code} public Release getRelease( String prodName, String version, boolean withDeps ) { return this.em.createQuery("SELECT rel FROM Release rel " + " LEFT JOIN FETCH rel.product pr " + " LEFT JOIN FETCH pr.customFields " + " LEFT JOIN FETCH rel.customFields " + (withDeps ? " LEFT JOIN FETCH rel.deps" : "") + " WHERE rel.product.name = ?1 AND rel.version = ?2", Release.class) .setParameter(1, prodName) .setParameter(2, version) .getSingleResult(); // Causes "firstResult/maxResults specified with collection fetch; applying in memory!" } {code} Which generates these 2 queries: {code} select release0_.id as id62_0_, product1_.id as id57_1_, customfiel2_.id as id59_2_, customfiel3_.id as id60_3_, release0_.extIdBugzilla as extIdBug2_62_0_, release0_.extIdJira as extIdJira62_0_, release0_.internal as internal62_0_, release0_.lastChanged as lastChan5_62_0_, release0_.note as note62_0_, release0_.plannedFor as plannedFor62_0_, release0_.product_id as product29_62_0_, release0_.status as status62_0_, release0_.gitHash as gitHash62_0_, release0_.link508 as link10_62_0_, release0_.linkBrew as linkBrew62_0_, release0_.linkBuildHowto as linkBui12_62_0_, release0_.linkCC as linkCC62_0_, release0_.linkCodeCoverage as linkCod14_62_0_, release0_.linkGitRepo as linkGit15_62_0_, release0_.linkIssuesFixed as linkIss16_62_0_, release0_.linkIssuesFound as linkIss17_62_0_, release0_.linkJavadoc as linkJav18_62_0_, release0_.linkMavenLocalRepo as linkMav19_62_0_, release0_.linkMead as linkMead62_0_, release0_.linkMeadJob as linkMea21_62_0_, release0_.linkReleasedBinaries as linkRel22_62_0_, release0_.linkReleasedDocs as linkRel23_62_0_, release0_.linkStagedBinaries as linkSta24_62_0_, release0_.linkStagedDocs as linkSta25_62_0_, release0_.linkTattleTale as linkTat26_62_0_, release0_.linkTck as linkTck62_0_, release0_.version as version62_0_, product1_.editorsGroupPrefix as editorsG2_57_1_, product1_.extIdBugzilla as extIdBug3_57_1_, product1_.extIdJira as extIdJira57_1_, product1_.name as name57_1_, product1_.note as note57_1_, product1_.gitHash as gitHash57_1_, product1_.link508 as link8_57_1_, product1_.linkBrew as linkBrew57_1_, product1_.linkBuildHowto as linkBui10_57_1_, product1_.linkCC as linkCC57_1_, product1_.linkCodeCoverage as linkCod12_57_1_, product1_.linkGitRepo as linkGit13_57_1_, product1_.linkIssuesFixed as linkIss14_57_1_, product1_.linkIssuesFound as linkIss15_57_1_, product1_.linkJavadoc as linkJav16_57_1_, product1_.linkMavenLocalRepo as linkMav17_57_1_, product1_.linkMead as linkMead57_1_, product1_.linkMeadJob as linkMea19_57_1_, product1_.linkReleasedBinaries as linkRel20_57_1_, product1_.linkReleasedDocs as linkRel21_57_1_, product1_.linkStagedBinaries as linkSta22_57_1_, product1_.linkStagedDocs as linkSta23_57_1_, product1_.linkTattleTale as linkTat24_57_1_, product1_.linkTck as linkTck57_1_, customfiel2_.label as label59_2_, customfiel2_.name as name59_2_, customfiel2_.product_id as product4_57_0__, customfiel2_.id as id0__, customfiel2_.name as formula2_0__, customfiel3_.field_id as field4_60_3_, customfiel3_.name as name60_3_, customfiel3_.release_id as release5_60_3_, customfiel3_.value as value60_3_, customfiel3_.release_id as release5_62_1__, customfiel3_.id as id1__, customfiel3_.name as name1__ from `release` release0_ left outer join product product1_ on release0_.product_id=product1_.id left outer join prod_custField customfiel2_ on product1_.id=customfiel2_.product_id left outer join rel_custField customfiel3_ on release0_.id=customfiel3_.release_id cross join product product4_ where release0_.product_id=product4_.id and product4_.name='EAP' and release0_.version='6.0.1.GA' ; select productcus0_.id as id59_0_, productcus0_.label as label59_0_, productcus0_.name as name59_0_ from prod_custField productcus0_ where productcus0_.id=1 ; {code} The first query gets the ID to be used in the second query in two columns - {code} customfiel2_.id as id59_2_ == 3 customfiel2_.id as id0__ == 3 {code} Despite of that both are correctly 3 in the resultset (verified by debugging), Hibernate decides to ask for ID 1 in the second question. Which results in: {code} javax.persistence.EntityNotFoundException: Unable to find org.jboss.essc.web.model.ProductCustomField with id 1 at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:155) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1077) at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1004) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:651) at org.hibernate.type.EntityType.resolve(EntityType.java:471) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:167) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1103) at org.hibernate.loader.Loader.processResultSet(Loader.java:960) at org.hibernate.loader.Loader.doQuery(Loader.java:910) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2516) at org.hibernate.loader.Loader.doList(Loader.java:2502) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332) at org.hibernate.loader.Loader.list(Loader.java:2327) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1246) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:283) {code}

    Hibernate JIRA | 4 years ago | Ondra Žižka
    javax.persistence.EntityNotFoundException: Unable to find org.jboss.essc.web.model.ProductCustomField with id 1
  2. 0

    I have this query: {code} public Release getRelease( String prodName, String version, boolean withDeps ) { return this.em.createQuery("SELECT rel FROM Release rel " + " LEFT JOIN FETCH rel.product pr " + " LEFT JOIN FETCH pr.customFields " + " LEFT JOIN FETCH rel.customFields " + (withDeps ? " LEFT JOIN FETCH rel.deps" : "") + " WHERE rel.product.name = ?1 AND rel.version = ?2", Release.class) .setParameter(1, prodName) .setParameter(2, version) .getSingleResult(); // Causes "firstResult/maxResults specified with collection fetch; applying in memory!" } {code} Which generates these 2 queries: {code} select release0_.id as id62_0_, product1_.id as id57_1_, customfiel2_.id as id59_2_, customfiel3_.id as id60_3_, release0_.extIdBugzilla as extIdBug2_62_0_, release0_.extIdJira as extIdJira62_0_, release0_.internal as internal62_0_, release0_.lastChanged as lastChan5_62_0_, release0_.note as note62_0_, release0_.plannedFor as plannedFor62_0_, release0_.product_id as product29_62_0_, release0_.status as status62_0_, release0_.gitHash as gitHash62_0_, release0_.link508 as link10_62_0_, release0_.linkBrew as linkBrew62_0_, release0_.linkBuildHowto as linkBui12_62_0_, release0_.linkCC as linkCC62_0_, release0_.linkCodeCoverage as linkCod14_62_0_, release0_.linkGitRepo as linkGit15_62_0_, release0_.linkIssuesFixed as linkIss16_62_0_, release0_.linkIssuesFound as linkIss17_62_0_, release0_.linkJavadoc as linkJav18_62_0_, release0_.linkMavenLocalRepo as linkMav19_62_0_, release0_.linkMead as linkMead62_0_, release0_.linkMeadJob as linkMea21_62_0_, release0_.linkReleasedBinaries as linkRel22_62_0_, release0_.linkReleasedDocs as linkRel23_62_0_, release0_.linkStagedBinaries as linkSta24_62_0_, release0_.linkStagedDocs as linkSta25_62_0_, release0_.linkTattleTale as linkTat26_62_0_, release0_.linkTck as linkTck62_0_, release0_.version as version62_0_, product1_.editorsGroupPrefix as editorsG2_57_1_, product1_.extIdBugzilla as extIdBug3_57_1_, product1_.extIdJira as extIdJira57_1_, product1_.name as name57_1_, product1_.note as note57_1_, product1_.gitHash as gitHash57_1_, product1_.link508 as link8_57_1_, product1_.linkBrew as linkBrew57_1_, product1_.linkBuildHowto as linkBui10_57_1_, product1_.linkCC as linkCC57_1_, product1_.linkCodeCoverage as linkCod12_57_1_, product1_.linkGitRepo as linkGit13_57_1_, product1_.linkIssuesFixed as linkIss14_57_1_, product1_.linkIssuesFound as linkIss15_57_1_, product1_.linkJavadoc as linkJav16_57_1_, product1_.linkMavenLocalRepo as linkMav17_57_1_, product1_.linkMead as linkMead57_1_, product1_.linkMeadJob as linkMea19_57_1_, product1_.linkReleasedBinaries as linkRel20_57_1_, product1_.linkReleasedDocs as linkRel21_57_1_, product1_.linkStagedBinaries as linkSta22_57_1_, product1_.linkStagedDocs as linkSta23_57_1_, product1_.linkTattleTale as linkTat24_57_1_, product1_.linkTck as linkTck57_1_, customfiel2_.label as label59_2_, customfiel2_.name as name59_2_, customfiel2_.product_id as product4_57_0__, customfiel2_.id as id0__, customfiel2_.name as formula2_0__, customfiel3_.field_id as field4_60_3_, customfiel3_.name as name60_3_, customfiel3_.release_id as release5_60_3_, customfiel3_.value as value60_3_, customfiel3_.release_id as release5_62_1__, customfiel3_.id as id1__, customfiel3_.name as name1__ from `release` release0_ left outer join product product1_ on release0_.product_id=product1_.id left outer join prod_custField customfiel2_ on product1_.id=customfiel2_.product_id left outer join rel_custField customfiel3_ on release0_.id=customfiel3_.release_id cross join product product4_ where release0_.product_id=product4_.id and product4_.name='EAP' and release0_.version='6.0.1.GA' ; select productcus0_.id as id59_0_, productcus0_.label as label59_0_, productcus0_.name as name59_0_ from prod_custField productcus0_ where productcus0_.id=1 ; {code} The first query gets the ID to be used in the second query in two columns - {code} customfiel2_.id as id59_2_ == 3 customfiel2_.id as id0__ == 3 {code} Despite of that both are correctly 3 in the resultset (verified by debugging), Hibernate decides to ask for ID 1 in the second question. Which results in: {code} javax.persistence.EntityNotFoundException: Unable to find org.jboss.essc.web.model.ProductCustomField with id 1 at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:155) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1077) at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1004) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:651) at org.hibernate.type.EntityType.resolve(EntityType.java:471) at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:167) at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1103) at org.hibernate.loader.Loader.processResultSet(Loader.java:960) at org.hibernate.loader.Loader.doQuery(Loader.java:910) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2516) at org.hibernate.loader.Loader.doList(Loader.java:2502) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332) at org.hibernate.loader.Loader.list(Loader.java:2327) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1246) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:283) {code}

    Hibernate JIRA | 4 years ago | Ondra Žižka
    javax.persistence.EntityNotFoundException: Unable to find org.jboss.essc.web.model.ProductCustomField with id 1
  3. 0

    Hibernate bug? Mishandling result columns, querying the DB for nonexistent ID

    Stack Overflow | 4 years ago | Ondra Žižka
    javax.persistence.EntityNotFoundException: Unable to find org.jboss.essc.web.model.ProductCustomField with id 1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    problem after upgrade to 2.10

    GitHub | 2 years ago | alucionet
    javax.persistence.EntityNotFoundException: Unable to find org.traccar.web.shared.model.Position with id -1
  6. 0

    Delete pipeline exception

    GitHub | 3 years ago | kukharm
    javax.persistence.EntityNotFoundException: Unable to find cz.cuni.xrg.intlib.commons.app.dpu.DPUInstanceRecord with id 1

    2 unregistered visitors
    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. javax.persistence.EntityNotFoundException

      Unable to find org.jboss.essc.web.model.ProductCustomField with id 1

      at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound()
    2. Hibernate EJB
      Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound
      1. org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:155)
      1 frame
    3. Hibernate
      QueryImpl.list
      1. org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:212)
      2. org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
      3. org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150)
      4. org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1077)
      5. org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1004)
      6. org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:651)
      7. org.hibernate.type.EntityType.resolve(EntityType.java:471)
      8. org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:167)
      9. org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
      10. org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1103)
      11. org.hibernate.loader.Loader.processResultSet(Loader.java:960)
      12. org.hibernate.loader.Loader.doQuery(Loader.java:910)
      13. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
      14. org.hibernate.loader.Loader.doList(Loader.java:2516)
      15. org.hibernate.loader.Loader.doList(Loader.java:2502)
      16. org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332)
      17. org.hibernate.loader.Loader.list(Loader.java:2327)
      18. org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490)
      19. org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
      20. org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
      21. org.hibernate.internal.SessionImpl.list(SessionImpl.java:1246)
      22. org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
      22 frames
    4. Hibernate EJB
      QueryImpl.getSingleResult
      1. org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:283)
      1 frame