[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3478) @NaturalId queries not flushed from cache using EntityManager.remove(); exception results from query
Elias Ross (JIRA)
noreply at atlassian.com
Fri Sep 12 16:36:06 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31171#action_31171 ]
Elias Ross commented on HHH-3478:
---------------------------------
In StandardQueryCache, there is a "catch" which handles "UnresolvableObjectException" but not "EntityNotFoundException"
catch ( UnresolvableObjectException uoe ) {
if ( isNaturalKeyLookup ) {
//TODO: not really completely correct, since
// the uoe could occur while resolving
// associations, leaving the PC in an
// inconsistent state
log.debug( "could not reassemble cached result set" );
cacheRegion.evict( key );
return null;
}
This should be changed to account for this other type of exception. Since EntityNotFoundException is JPA-specific. Patch attached.
> @NaturalId queries not flushed from cache using EntityManager.remove(); exception results from query
> ----------------------------------------------------------------------------------------------------
>
> Key: HHH-3478
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3478
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.3.0.SP1
> Environment: Java 1.5, Maven dependencies:
> [INFO] (root)
> [INFO] | \- org.hibernate:hibernate-validator:jar:3.1.0.GA:compile
> [INFO] +- commons-codec:commons-codec:jar:1.3:compile
> [INFO] +- javax.persistence:persistence-api:jar:1.0:compile
> [INFO] +- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
> [INFO] | +- antlr:antlr:jar:2.7.6:compile
> [INFO] | +- commons-collections:commons-collections:jar:3.1:compile
> [INFO] | \- dom4j:dom4j:jar:1.6.1:compile
> [INFO] | \- xml-apis:xml-apis:jar:1.0.b2:compile
> [INFO] +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
> [INFO] | \- org.hibernate:ejb3-persistence:jar:1.0.2.GA:compile
> [INFO] +- org.hibernate:hibernate-commons-annotations:jar:3.3.0.ga:compile
> [INFO] | \- org.hibernate:hibernate:jar:3.2.1.ga:compile
> [INFO] | +- net.sf.ehcache:ehcache:jar:1.2.3:compile
> [INFO] | +- asm:asm-attrs:jar:1.5.3:compile
> [INFO] | +- cglib:cglib:jar:2.1_3:compile
> [INFO] | \- asm:asm:jar:1.5.3:compile
> [INFO] +- org.hibernate:hibernate-entitymanager:jar:3.4.0.GA:compile
> [INFO] | \- javassist:javassist:jar:3.4.GA:compile
> [INFO] +- javax.transaction:jta:jar:1.0.1B:compile
> [INFO] +- org.slf4j:slf4j-api:jar:1.5.2:compile
> [INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.2:compile
> [INFO] +- hsqldb:hsqldb:jar:1.8.0.10:test
> [INFO] \- junit:junit:jar:4.4:test
> Reporter: Elias Ross
> Attachments: Dummy.java, DummyTest.java, persistence.xml, query-patch.txt
>
>
> See attached test case and entity.
> Current Result:
> javax.persistence.EntityNotFoundException: Unable to find com.autodesk.lbs.cs.Dummy with id 1
> at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:113)
> at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
> at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
> at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
> at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
> at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:873)
> at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
> at org.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:219)
> at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:155)
> at org.hibernate.loader.Loader.getResultFromQueryCache(Loader.java:2184)
> at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2147)
> at org.hibernate.loader.Loader.list(Loader.java:2117)
> at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
> at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
> at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
> at com.autodesk.lbs.cs.DummyTest.naturalKeyCachedQuery(DummyTest.java:69)
> at com.autodesk.lbs.cs.DummyTest.naturalKeyCachedQuery(DummyTest.java:61)
> at com.autodesk.lbs.cs.DummyTest.testQuery(DummyTest.java:49)
> It's expected that a cache invalidation occurs with an entity's natural key when it is removed.
> I'll investigate a solution.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list