Author: julien(a)jboss.com
Date: 2007-07-16 11:35:24 -0400 (Mon, 16 Jul 2007)
New Revision: 7781
Modified:
branches/JBoss_Portal_Branch_2_6/core/build.xml
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
Log:
Fix oracle issue in a slightly simpler way
Modified: branches/JBoss_Portal_Branch_2_6/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-07-16 14:38:39 UTC (rev 7780)
+++ branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-07-16 15:35:24 UTC (rev 7781)
@@ -555,89 +555,11 @@
</x-sysproperty>
<x-test>
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalNodeTestCase"
- outfile="TEST-PortalNodeTestCase">
- <parameter name="CacheNaturalId" value="true"/>
- <parameter name="Config"
value="persistent-jboss-beans.xml"/>
- </zest>
- <!--
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalNodeTestCase"
- outfile="TEST-PortalObjectContainerTestCase">
- <parameter name="CacheNaturalId"
value="true"/>
- <parameter name="Config"
value="transient-jboss-beans.xml"/>
- </zest>
- -->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
<parameter name="CacheNaturalId" value="true"/>
<parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
- <!--
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
- outfile="TEST-PortalObjectContainerTestCase">
- <parameter name="CacheNaturalId"
value="true"/>
- <parameter name="Config"
value="transient-jboss-beans.xml"/>
- </zest>
- -->
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
-
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
- <parameter name="PersistLocally" value="true"/>
- <parameter name="CloneOnCreate" value="true"/>
- <parameter name="CacheNaturalId" value="true"/>
- <parameter name="Config"
value="persistent-jboss-beans.xml"/>
- </zest>
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
-
outfile="TEST-NotPersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
- <parameter name="PersistLocally"
value="false"/>
- <parameter name="CloneOnCreate" value="true"/>
- <parameter name="CacheNaturalId" value="true"/>
- <parameter name="Config"
value="persistent-jboss-beans.xml"/>
- </zest>
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
-
outfile="TEST-PersistedLocally-NotClonedOnCreate-InstanceContainerTestCase">
- <parameter name="PersistLocally" value="true"/>
- <parameter name="CloneOnCreate" value="false"/>
- <parameter name="CacheNaturalId" value="true"/>
- <parameter name="Config"
value="persistent-jboss-beans.xml"/>
- </zest>
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
-
outfile="TEST-NotPersistedLocally-NotClonedOnCreate-InstanceContainerTestCase">
- <parameter name="PersistLocally"
value="false"/>
- <parameter name="CloneOnCreate" value="false"/>
- <parameter name="CacheNaturalId" value="true"/>
- <parameter name="Config"
value="persistent-jboss-beans.xml"/>
- </zest>
-
- <!--
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
-
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
- <parameter name="PersistLocally"
value="true"/>
- <parameter name="CloneOnCreate"
value="true"/>
- <parameter name="CacheNaturalId"
value="true"/>
- <parameter name="Config"
value="transient-jboss-beans.xml"/>
- </zest>
- -->
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.ProducerTestCase"
- outfile="TEST-ProducerTestCase-WithoutRegistration">
- <parameter name="UseRegistration"
value="false"/>
- </zest>
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.ProducerTestCase"
- outfile="TEST-ProducerTestCase-WithRegistration">
- <parameter name="UseRegistration"
value="true"/>
- </zest>
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.RegistrationPersistenceManagerTestCase"
- outfile="TEST-RegistrationPersistenceManagerTestCase">
- </zest>
- <test todir="${test.reports}"
-
name="org.jboss.portal.test.core.model.portal.PortalObjectPermissionTestCase"/>
- <test todir="${test.reports}"
-
name="org.jboss.portal.test.core.deployment.JBossApplicationMetaDataFactoryTestCase"/>
- <test todir="${test.reports}"
-
name="org.jboss.portal.test.core.model.portal.PortalObjectIdTestCase"/>
- <test todir="${test.reports}"
-
name="org.jboss.portal.test.core.model.portal.PortalObjectPathTestCase"/>
-
-
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-core-lib.jar"/>
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-07-16
14:38:39 UTC (rev 7780)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/ObjectNode.java 2007-07-16
15:35:24 UTC (rev 7781)
@@ -243,7 +243,7 @@
public String toString()
{
- return path.toString() + PortalObjectId.NAMESPACE_SEPARATOR + name;
+ return "PortalObject[id=" + path + "]";
}
protected PortalObjectId toChildPath(String name)
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-07-16
14:38:39 UTC (rev 7780)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/portal/PersistentPortalObjectContainer.java 2007-07-16
15:35:24 UTC (rev 7781)
@@ -24,8 +24,6 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
@@ -48,7 +46,6 @@
{
/** The query for lookup when the path is null. */
- private static final String LOOKUP_QUERY_FOR_EMPTY_PATH = "from ObjectNode where
path=:path";
private static final String LOOKUP_QUERY_FOR_ROOT = "from ObjectNode where
path=:path or path is null";
/** . */
@@ -247,33 +244,26 @@
private ObjectNode getObjectNodeNoCache(Session session, PortalObjectId id)
{
Object result;
- if (id.getPath().getLength() == 0)
- {
- // Oracle returns the root object when using LOOKUP_QUERY_FOR_NULL_PATH thus
preventing the creation of the
- // dashboard node as null is never returned for it and is therefore cached...
- String queryString = LOOKUP_QUERY_FOR_EMPTY_PATH;
- if (id.toString().lastIndexOf(PortalObjectPath.CanonicalFormat.PATH_SEPARATOR)
== 0)
- {
- queryString = LOOKUP_QUERY_FOR_ROOT;
- }
+ // We need to lookup the root of the empty namespace with a special query in order
to fix
+ // oracle weird behavior with zero length strings considered as null value
+ if (id.getPath().getLength() == 0 && id.getNamespace().length() == 0)
+ {
+ String queryString = LOOKUP_QUERY_FOR_ROOT;
Query query = session.createQuery(queryString);
query.setParameter("path", id);
query.setCacheable(true);
- try
- {
- result = query.uniqueResult();
- }
- catch (ObjectNotFoundException e)
- {
- throw new HibernateException("Could not find ObjectNode with path
'" + id + "'", e);
- }
+
+ // Unique result will return null if no object is found
+ result = query.uniqueResult();
}
else
{
Criteria criteria = session.createCriteria(ObjectNode.class);
criteria.add(Restrictions.naturalId().set("path", id));
criteria.setCacheable(true);
+
+ // Unique result will return null if no object is found
result = criteria.uniqueResult();
}
return (ObjectNode)result;
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-07-16
14:38:39 UTC (rev 7780)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-07-16
15:35:24 UTC (rev 7781)
@@ -80,6 +80,14 @@
TransactionAssert.commitTransaction();
}
+ public void testRetrieveNonExistingObject()
+ {
+ TransactionAssert.beginTransaction();
+ PortalObject foo = container.getObject(PortalObjectId.parse("/foo",
PortalObjectPath.CANONICAL_FORMAT));
+ assertNull(foo);
+ TransactionAssert.commitTransaction();
+ }
+
public void testPropertyUpdateCascadeToDescendantsWhenTheyDoNotDeclareIt() throws
Exception
{
TransactionAssert.beginTransaction();
Show replies by date