Index: JetspeedSecurityPersistenceManager.java =================================================================== --- JetspeedSecurityPersistenceManager.java (revision 1688175) +++ JetspeedSecurityPersistenceManager.java (working copy) @@ -16,6 +16,16 @@ */ package org.apache.jetspeed.security.spi.impl; +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport; import org.apache.jetspeed.i18n.KeyedMessage; import org.apache.jetspeed.security.JetspeedPermission; @@ -59,15 +69,6 @@ import org.springframework.orm.ObjectRetrievalFailureException; import org.springframework.orm.ojb.PersistenceBrokerCallback; -import java.io.Serializable; -import java.sql.SQLException; -import java.sql.Types; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - /** * @version $Id$ */ @@ -371,7 +372,7 @@ { Object[] associatedFrom = iter.next(); associatedNamesFrom.add((String) associatedFrom[0]); - associatedIdsFrom.add(((Integer) associatedFrom[1]).longValue()); + associatedIdsFrom.add(getNumberAsLongValue(associatedFrom[1])); } // put result in cache try @@ -417,7 +418,7 @@ { Object[] associatedFrom = iter.next(); associatedNamesFrom.add((String) associatedFrom[0]); - associatedIdsFrom.add(((Integer) associatedFrom[1]).longValue()); + associatedIdsFrom.add(getNumberAsLongValue(associatedFrom[1])); } // put result in cache jspmCache.putAssociationQuery(cacheKey, principalFromId, associatedIdsFrom.toArray(new Long[associatedIdsFrom.size()]), fromSecurityDomain, toSecurityDomain, new ArrayList(associatedNamesFrom)); @@ -456,7 +457,7 @@ { Object[] associatedTo = iter.next(); associatedNamesTo.add((String) associatedTo[0]); - associatedIdsTo.add(((Integer) associatedTo[1]).longValue()); + associatedIdsTo.add(getNumberAsLongValue(associatedTo[1])); } // put result in cache try @@ -502,7 +503,7 @@ { Object[] associatedTo = iter.next(); associatedNamesTo.add((String) associatedTo[0]); - associatedIdsTo.add(((Integer) associatedTo[1]).longValue()); + associatedIdsTo.add(getNumberAsLongValue(associatedTo[1])); } // put result in cache jspmCache.putAssociationQuery(cacheKey, principalToId, associatedIdsTo.toArray(new Long[associatedIdsTo.size()]), fromSecurityDomain, toSecurityDomain, new ArrayList(associatedNamesTo)); @@ -1672,5 +1673,18 @@ queryContext.put(JetspeedPrincipalQueryContext.SECURITY_DOMAIN, securityDomain); return jppm.getPrincipals(queryContext); } - + + /** Oracle Fix: NUMBER type e.g. ID type NUMBER(38,0) is returned as BigDecimal ! + * @param number NUMBER object from database + * @return NUMBER object as Long value + */ + private Long getNumberAsLongValue(Object number) { + if (number instanceof BigDecimal) { + return ((BigDecimal) number).longValue(); + } + if (number instanceof Double) { + return ((Double) number).longValue(); + } + return ((Integer) number).longValue(); + } }