HHH-4881 - restrict polymorphic query results

This commit is contained in:
Strong Liu 2011-10-09 14:36:15 +08:00
parent e05b3a6c38
commit 884f6a2455
4 changed files with 9 additions and 20 deletions

View File

@ -63,7 +63,7 @@ public class UpdateTimestampsCache {
LOG.startingUpdateTimestampsCache(regionName);
this.region = settings.getRegionFactory().buildTimestampsRegion( regionName, props );
}
@SuppressWarnings({"UnusedDeclaration"})
public UpdateTimestampsCache(Settings settings, Properties props)
throws HibernateException {
this(settings, props, null);
@ -71,8 +71,6 @@ public class UpdateTimestampsCache {
@SuppressWarnings({"UnnecessaryBoxing"})
public void preinvalidate(Serializable[] spaces) throws CacheException {
// TODO: to handle concurrent writes correctly, this should return a Lock to the client
readWriteLock.writeLock().lock();
try {
@ -86,7 +84,6 @@ public class UpdateTimestampsCache {
factory.getStatisticsImplementor().updateTimestampsCachePut();
}
}
//TODO: return new Lock(ts);
}
finally {
readWriteLock.writeLock().unlock();
@ -95,13 +92,10 @@ public class UpdateTimestampsCache {
@SuppressWarnings({"UnnecessaryBoxing"})
public void invalidate(Serializable[] spaces) throws CacheException {
//TODO: to handle concurrent writes correctly, the client should pass in a Lock
readWriteLock.writeLock().lock();
try {
Long ts = new Long( region.nextTimestamp() );
//TODO: if lock.getTimestamp().equals(ts)
for (Serializable space : spaces) {
LOG.debugf("Invalidating space [%s], timestamp: %s", space, ts);
//put() has nowait semantics, is this really appropriate?
@ -144,7 +138,7 @@ public class UpdateTimestampsCache {
if ( factory != null && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor().updateTimestampsCacheHit();
}
if ( lastUpdate.longValue() >= timestamp.longValue() ) return false;
if ( lastUpdate >= timestamp ) return false;
}
}
return true;

View File

@ -87,12 +87,7 @@ public class DiscriminatorType extends AbstractType {
throw new HibernateException( "Unable to resolve discriminator value [" + discriminatorValue + "] to entity name" );
}
final EntityPersister entityPersister = session.getEntityPersister( entityName, null );
if ( EntityMode.POJO == entityPersister.getEntityMode() ) {
return entityPersister.getMappedClass();
}
else {
return entityName;
}
return ( EntityMode.POJO == entityPersister.getEntityMode() ) ? entityPersister.getMappedClass() : entityName;
}
public void nullSafeSet(

View File

@ -131,7 +131,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
if ( persistentClass.isPolymorphic() ) {
try {
discriminatorValue = new Integer( persistentClass.getSubclassId() );
discriminatorValue = persistentClass.getSubclassId();
discriminatorSQLString = discriminatorValue.toString();
}
catch ( Exception e ) {
@ -416,7 +416,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
factory.getSettings().getDefaultCatalogName(),
factory.getSettings().getDefaultSchemaName()
);
Integer tabnum = new Integer( getTableId( tabname, subclassTableNameClosure ) );
Integer tabnum = getTableId( tabname, subclassTableNameClosure );
propTableNumbers.add( tabnum );
Iterator citer = prop.getColumnIterator();
@ -474,7 +474,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
// we now use subclass ids that are consistent across all
// persisters for a class hierarchy, so that the use of
// "foo.class = Bar" works in HQL
Integer subclassId = new Integer( sc.getSubclassId() );//new Integer(k+1);
Integer subclassId = sc.getSubclassId();
subclassesByDiscriminatorValue.put( subclassId, sc.getEntityName() );
discriminatorValues[k] = subclassId.toString();
int id = getTableId(

View File

@ -145,7 +145,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
deleteCallable = new boolean[] { callable };
deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[] { checkStyle };
discriminatorValue = new Integer( persistentClass.getSubclassId() );
discriminatorValue = persistentClass.getSubclassId();
discriminatorSQLValue = String.valueOf( persistentClass.getSubclassId() );
// PROPERTIES
@ -156,7 +156,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
// SUBCLASSES
subclassByDiscriminatorValue.put(
new Integer( persistentClass.getSubclassId() ),
persistentClass.getSubclassId(),
persistentClass.getEntityName()
);
if ( persistentClass.isPolymorphic() ) {
@ -165,7 +165,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
while ( iter.hasNext() ) {
Subclass sc = (Subclass) iter.next();
subclassClosure[k++] = sc.getEntityName();
subclassByDiscriminatorValue.put( new Integer( sc.getSubclassId() ), sc.getEntityName() );
subclassByDiscriminatorValue.put( sc.getSubclassId(), sc.getEntityName() );
}
}