Hibernate SVN: r15004 - in core/tags: hibernate-3.3.0.CR2 and 104 other directories.
by hibernate-commitsï¼ lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-07-31 16:03:48 -0400 (Thu, 31 Jul 2008)
New Revision: 15004
Added:
core/tags/hibernate-3.3.0.CR2/
core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml
core/tags/hibernate-3.3.0.CR2/changelog.txt
core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml
core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml
core/tags/hibernate-3.3.0.CR2/core/pom.xml
core/tags/hibernate-3.3.0.CR2/core/src/main/java/
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LoadEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LockEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LockEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/MergeEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/MergeEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PersistEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PersistEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRecreateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRecreateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRemoveEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRemoveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostDeleteEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostInsertEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostInsertEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostLoadEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRecreateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRecreateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRemoveEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRemoveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreDeleteEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreInsertEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreInsertEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreLoadEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/RefreshEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/RefreshEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/ReplicateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/ReplicateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/SaveOrUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/SaveOrUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractFlushingEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractReassociateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractSaveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultAutoFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultDirtyCheckEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultEvictEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultFlushEntityEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultInitializeCollectionEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPersistEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPersistOnFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPostLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPreLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultReplicateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultSaveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultSaveOrUpdateCopyEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultSaveOrUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DirtyCollectionSearchVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/EvictVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/FlushVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/OnLockVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/OnReplicateVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/OnUpdateVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/ProxyVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/ReattachVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/WrapVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/CacheSQLStateConverter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/Configurable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/ConstraintViolationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/DataException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/ExceptionUtils.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/GenericJDBCException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/JDBCConnectionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/JDBCExceptionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/LockAcquisitionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/Nestable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/NestableDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/NestableException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/NestableRuntimeException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLExceptionConverter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLExceptionConverterFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLGrammarException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLStateConverter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/TemplatedViolatedConstraintNameExtracter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/ViolatedConstraintNameExtracter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/CollectionProperties.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/CollectionSubqueryFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/FilterTranslator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/HolderInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/NameGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ParameterTranslations.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QueryExecutionRequestException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QuerySplitter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QueryTranslator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QueryTranslatorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/antlr/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ASTQueryTranslatorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/DetailedSemanticException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ErrorCounter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ErrorReporter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlASTFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlLexer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlSqlWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlToken.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/InvalidPathException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/InvalidWithClauseException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ParameterTranslationsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ParseErrorHandler.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/QuerySyntaxException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/SqlASTFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/SqlGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatementExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/BasicExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/StatementExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractRestrictableStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractSelectExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AggregateNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AssignmentSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BetweenOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BinaryArithmeticOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BinaryOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BooleanLiteralNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/Case2Node.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/CaseNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/CollectionFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ConstructorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/CountNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/DeleteStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/DisplayableNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ExpectedTypeAwareNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromElement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromElementFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromElementType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromReferenceNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/HqlSqlWalkerNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IdentNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ImpliedFromElement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/InLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IndexNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/InitializeableNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/InsertStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/JavaConstantNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/LiteralNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/MethodNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/Node.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/OperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/OrderByClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ParameterNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/PathNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/QueryNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ResolvableNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/RestrictableStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectExpressionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectExpressionList.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SessionFactoryAwareNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SqlFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SqlNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/Statement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UnaryArithmeticNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UnaryLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UnaryOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UpdateStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTAppender.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTParentsFirstIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTPrinter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTUtil.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/AliasGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ColumnHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/JoinProcessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/LiteralProcessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/PathHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/SessionFactoryHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/SyntheticAndFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/ClassicQueryTranslatorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/ClauseParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/FromParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/FromPathExpressionParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/GroupByParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/HavingParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/OrderByParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/Parser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/ParserHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/PathExpressionParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/PreprocessingParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/SelectParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/SelectPathExpressionParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/WhereParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/AbstractPostInsertGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/Assigned.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/Configurable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/ForeignGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/GUIDGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentifierGenerationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentifierGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentityGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IncrementGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/PostInsertIdentifierGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/PostInsertIdentityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SelectGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SequenceGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SequenceHiLoGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/TableGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/TableHiLoGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/UUIDHexGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/AccessCallback.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/DatabaseStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/Optimizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/SequenceStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/TableStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/AbstractReturningDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/AbstractSelectingDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/Binder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/IdentifierGeneratingInsert.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/InsertGeneratedIdentifierDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/InsertSelectIdentityInsert.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/AbstractQueryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/AbstractScrollableResults.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/AbstractSessionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/CollectionFilterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/CriteriaImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/FetchingScrollableResultsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/FilterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/IteratorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/QueryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SQLQueryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/ScrollableResultsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SessionFactoryObjectFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SessionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/StatelessSessionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/AbstractFieldInterceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/FieldInterceptionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/FieldInterceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/LazyPropertyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/cglib/CGLIBHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/cglib/FieldInterceptorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/javassist/FieldInterceptorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/javassist/JavassistHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/AbstractBatcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchFailedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchedTooManyRowsAffectedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Batcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatcherFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchingBatcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchingBatcherFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BorrowedConnectionProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ColumnNameCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ConnectionManager.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ConnectionWrapper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Expectation.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Expectations.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/JDBCContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/NonBatchingBatcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/NonBatchingBatcherFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ResultSetWrapper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/TooManyRowsAffectedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Work.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/BasicFormatterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/DDLFormatterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/FormatStyle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/Formatter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/SQLStatementLogger.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/BasicLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/CollectionAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/ColumnEntityAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/DefaultEntityAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/EntityAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/GeneratedCollectionAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/JoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/Loader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/OuterJoinLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/OuterJoinableAssociation.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/BasicCollectionJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/BasicCollectionLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/BatchingCollectionInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/CollectionInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/CollectionJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/CollectionLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/OneToManyJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/OneToManyLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/SubselectCollectionLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/SubselectOneToManyLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CollectionFetchReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CollectionReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/ColumnCollectionAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CustomLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CustomQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/EntityFetchReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/FetchReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/NonScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/Return.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/RootReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/ScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/AbstractEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/CascadeEntityJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/CascadeEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/CollectionElementLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/UniqueEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/hql/QueryLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/hql/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/BlobImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/ClobImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/ReaderInputStream.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/SerializableBlob.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/SerializableClob.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/AbstractAuxiliaryDatabaseObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Any.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Array.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/AuxiliaryDatabaseObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Backref.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Bag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Collection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Column.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Component.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Constraint.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/DenormalizedTable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/DependantValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Fetchable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Filterable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ForeignKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Formula.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IdentifierBag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IdentifierCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Index.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IndexBackref.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IndexedCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Join.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/KeyValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/List.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ManyToOne.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Map.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/MetaAttributable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/MetaAttribute.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/OneToMany.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/OneToOne.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PersistentClass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PersistentClassVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PrimaryKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PrimitiveArray.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Property.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PropertyGeneration.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/RelationalModel.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/RootClass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Selectable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Set.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/SimpleAuxiliaryDatabaseObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/SimpleValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Subclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Table.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/TableOwner.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ToOne.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/TypeDef.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/UnionSubclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/UniqueKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Value.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ValueVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/metadata/ClassMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/metadata/CollectionMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/metadata/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/AbstractExplicitParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/CollectionFilterKeyParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/DynamicFilterParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/ExplicitParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/NamedParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/ParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/PositionalParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/VersionTypeSeedParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/PersisterFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/BasicCollectionPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CollectionPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CollectionPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CollectionPropertyNames.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CompositeElementPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/ElementPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/NamedQueryCollectionInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/QueryableCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/SQLLoadableCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/BasicEntityPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Joinable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Loadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Lockable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/NamedQueryLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/OuterJoinLoadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/PropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Queryable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/SQLLoadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/SingleTableEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/UniqueKeyLoadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/pretty/MessageHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/pretty/Printer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/pretty/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/ChainedPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/Dom4jAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/Getter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/MapAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/NoopAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/PropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/PropertyAccessorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/Setter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/EntityNotFoundDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/HibernateProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/HibernateProxyHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/LazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/ProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/map/MapLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/map/MapProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/map/MapProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/cglib/SerializableProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/javassist/SerializableProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/HibernatePermission.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCConfiguration.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPermissions.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreInsertEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCSecurityListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ANSICaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ANSIJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Alias.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/CacheJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/CaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ConditionFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/DecodeCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Delete.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/DerbyCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/DisjunctionFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ForUpdateFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/HSQLCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/InFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Insert.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/InsertSelect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/JoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/MckoiCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/OracleJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/QueryJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/QuerySelect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Select.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/SelectFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/SimpleSelect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Sybase11JoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Template.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Update.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/CategorizedStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/CollectionStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/EntityStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/QueryStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/SecondLevelCacheStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/SessionStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/SessionStatisticsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/Statistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/StatisticsImplementor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ColumnMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ForeignKeyMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/IndexMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExportTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidatorTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/TableMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/BasicInstrumentationTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/cglib/InstrumentTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/javassist/InstrumentTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/BESTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/BTMTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/CMTTransaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/CMTTransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/CacheSynchronization.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JBossTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JDBCTransaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JDBCTransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JNDITransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JOTMTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JOnASTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JRun4TransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JTATransaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JTATransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/OC4JTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/OrionTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/ResinTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/SunONETransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionFactoryFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionManagerLookupFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/WebSphereExtendedJTATransactionLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/WebSphereTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/WeblogicTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/AliasToBeanResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/AliasToEntityMapResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/BasicTransformerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/DistinctResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/DistinctRootEntityResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/PassThroughResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/ResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/RootEntityResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/ToListResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/Transformers.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Dom4jInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/DynamicMapInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/ElementWrapper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/EntityModeToTuplizerMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/IdentifierProperty.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Instantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/PojoInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Property.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/PropertyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/StandardProperty.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Tuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/VersionProperty.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/AbstractComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/ComponentEntityModeToTuplizerMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/ComponentMetamodel.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/ComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/Dom4jComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/DynamicMapComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/Dom4jEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/DynamicMapEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/EntityEntityModeToTuplizerMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/EntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractBynaryType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractCharArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractComponentType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AdaptedImmutableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AnyType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AssociationType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BagType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BigDecimalType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BigIntegerType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BinaryType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BlobType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BooleanType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ByteType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CalendarDateType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CalendarType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharBooleanType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharacterArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharacterType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ClassType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ClobType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CollectionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ComponentType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CompositeCustomType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CurrencyType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CustomCollectionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CustomType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DateType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DbTimestampType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DiscriminatorType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DoubleType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/EmbeddedComponentType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/EntityType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/FloatType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ForeignKeyDirection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/IdentifierBagType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/IdentifierType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ImmutableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/IntegerType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ListType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/LiteralType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/LocaleType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/LongType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ManyToOneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/MapType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/MetaType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/MutableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/NullableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/OneToOneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/OrderedMapType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/OrderedSetType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/PrimitiveType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SerializableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SerializationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SetType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ShortType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SortedMapType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SortedSetType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SpecialOneToOneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/StringType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TextType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TimeType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TimeZoneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TimestampType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TrueFalseType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/Type.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TypeFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/VersionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/WrapperBinaryType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/YesNoType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/CompositeUserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/EnhancedUserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/LoggableUserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/ParameterizedType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/UserCollectionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/UserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/UserVersionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ArrayHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/BytesHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/CalendarComparator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/Cloneable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/CollectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ComparableComparator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ConfigHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/DTDEntityResolver.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/EmptyIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/EqualsHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ExternalSessionFactoryConfig.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/FastHashMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/FilterHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/IdentityMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/IdentitySet.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/JDBCExceptionReporter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/JTAHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/JoinedIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/LazyIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/MarkerObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/NamingHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/PropertiesHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ReflectHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SerializationHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SimpleMRUCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SingletonIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SoftLimitMRUCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/StringHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/XMLHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/package.html
core/tags/hibernate-3.3.0.CR2/distribution/pom.xml
core/tags/hibernate-3.3.0.CR2/documentation/manual/pom.xml
core/tags/hibernate-3.3.0.CR2/documentation/manual/src/main/docbook/en-US/Hibernate_Reference.xml
core/tags/hibernate-3.3.0.CR2/documentation/manual/src/main/docbook/en-US/content/tutorial.xml
core/tags/hibernate-3.3.0.CR2/documentation/pom.xml
core/tags/hibernate-3.3.0.CR2/documentation/releasenotes/pom.xml
core/tags/hibernate-3.3.0.CR2/jmx/pom.xml
core/tags/hibernate-3.3.0.CR2/parent/pom.xml
core/tags/hibernate-3.3.0.CR2/pom.xml
core/tags/hibernate-3.3.0.CR2/testing/pom.xml
core/tags/hibernate-3.3.0.CR2/testsuite/pom.xml
core/tags/hibernate-3.3.0.CR2/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java
core/tags/hibernate-3.3.0.CR2/tutorials/eg/pom.xml
core/tags/hibernate-3.3.0.CR2/tutorials/pom.xml
core/tags/hibernate-3.3.0.CR2/tutorials/web/pom.xml
Removed:
core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml
core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml
core/tags/hibernate-3.3.0.CR2/changelog.txt
core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml
core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml
core/tags/hibernate-3.3.0.CR2/core/pom.xml
core/tags/hibernate-3.3.0.CR2/core/src/main/java/
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LoadEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LockEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LockEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/MergeEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/MergeEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PersistEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PersistEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRecreateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRecreateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRemoveEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionRemoveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostCollectionUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostDeleteEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostInsertEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostInsertEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostLoadEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PostUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRecreateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRecreateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRemoveEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionRemoveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreCollectionUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreDeleteEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreInsertEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreInsertEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreLoadEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/PreUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/RefreshEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/RefreshEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/ReplicateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/ReplicateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/SaveOrUpdateEvent.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/SaveOrUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractFlushingEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractReassociateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractSaveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/AbstractVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultAutoFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultDirtyCheckEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultEvictEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultFlushEntityEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultInitializeCollectionEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultMergeEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPersistEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPersistOnFlushEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPostLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultPreLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultReplicateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultSaveEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultSaveOrUpdateCopyEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultSaveOrUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DefaultUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/DirtyCollectionSearchVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/EvictVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/FlushVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/OnLockVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/OnReplicateVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/OnUpdateVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/ProxyVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/ReattachVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/WrapVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/def/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/CacheSQLStateConverter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/Configurable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/ConstraintViolationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/DataException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/ExceptionUtils.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/GenericJDBCException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/JDBCConnectionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/JDBCExceptionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/LockAcquisitionException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/Nestable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/NestableDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/NestableException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/NestableRuntimeException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLExceptionConverter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLExceptionConverterFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLGrammarException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/SQLStateConverter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/TemplatedViolatedConstraintNameExtracter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/ViolatedConstraintNameExtracter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/exception/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/CollectionProperties.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/CollectionSubqueryFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/FilterTranslator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/HolderInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/NameGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ParameterTranslations.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QueryExecutionRequestException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QuerySplitter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QueryTranslator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/QueryTranslatorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/antlr/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ASTQueryTranslatorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/DetailedSemanticException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ErrorCounter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ErrorReporter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlASTFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlLexer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlSqlWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/HqlToken.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/InvalidPathException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/InvalidWithClauseException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ParameterTranslationsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/ParseErrorHandler.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/QuerySyntaxException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/QueryTranslatorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/SqlASTFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/SqlGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/AbstractStatementExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/BasicExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableDeleteExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/MultiTableUpdateExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/exec/StatementExecutor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractRestrictableStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractSelectExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AbstractStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AggregateNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/AssignmentSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BetweenOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BinaryArithmeticOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BinaryLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BinaryOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/BooleanLiteralNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/Case2Node.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/CaseNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/CollectionFunction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ConstructorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/CountNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/DeleteStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/DisplayableNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ExpectedTypeAwareNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromElement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromElementFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromElementType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/FromReferenceNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/HqlSqlWalkerNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IdentNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ImpliedFromElement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/InLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IndexNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/InitializeableNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/InsertStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IntoClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/JavaConstantNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/LiteralNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/MethodNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/Node.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/OperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/OrderByClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ParameterNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/PathNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/QueryNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/ResolvableNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/RestrictableStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectClause.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectExpression.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectExpressionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SelectExpressionList.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SessionFactoryAwareNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SqlFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/SqlNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/Statement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UnaryArithmeticNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UnaryLogicOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UnaryOperatorNode.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/tree/UpdateStatement.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTAppender.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTParentsFirstIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTPrinter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ASTUtil.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/AliasGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/ColumnHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/JoinProcessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/LiteralProcessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/PathHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/SessionFactoryHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/ast/util/SyntheticAndFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/ClassicQueryTranslatorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/ClauseParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/FromParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/FromPathExpressionParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/GroupByParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/HavingParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/OrderByParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/Parser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/ParserHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/PathExpressionParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/PreprocessingParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/QueryTranslatorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/SelectParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/SelectPathExpressionParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/WhereParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/classic/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/hql/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/AbstractPostInsertGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/Assigned.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/Configurable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/ForeignGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/GUIDGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentifierGenerationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentifierGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentifierGeneratorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IdentityGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/IncrementGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/PostInsertIdentifierGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/PostInsertIdentityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SelectGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SequenceGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SequenceHiLoGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/SequenceIdentityGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/TableGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/TableHiLoGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/UUIDHexGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/AccessCallback.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/DatabaseStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/Optimizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/SequenceStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/enhanced/TableStructure.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/AbstractReturningDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/AbstractSelectingDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/Binder.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/IdentifierGeneratingInsert.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/InsertGeneratedIdentifierDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/insert/InsertSelectIdentityInsert.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/id/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/AbstractQueryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/AbstractScrollableResults.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/AbstractSessionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/CollectionFilterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/CriteriaImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/FetchingScrollableResultsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/FilterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/IteratorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/QueryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SQLQueryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/ScrollableResultsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SessionFactoryObjectFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/SessionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/StatelessSessionImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/impl/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/AbstractFieldInterceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/FieldInterceptionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/FieldInterceptor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/LazyPropertyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/cglib/CGLIBHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/cglib/FieldInterceptorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/javassist/FieldInterceptorImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/javassist/JavassistHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/intercept/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/AbstractBatcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchFailedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchedTooManyRowsAffectedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Batcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatcherFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchingBatcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BatchingBatcherFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/BorrowedConnectionProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ColumnNameCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ConnectionManager.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ConnectionWrapper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Expectation.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Expectations.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/JDBCContext.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/NonBatchingBatcher.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/NonBatchingBatcherFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/ResultSetWrapper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/TooManyRowsAffectedException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/Work.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/BasicFormatterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/DDLFormatterImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/FormatStyle.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/Formatter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/jdbc/util/SQLStatementLogger.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/BasicLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/CollectionAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/ColumnEntityAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/DefaultEntityAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/EntityAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/GeneratedCollectionAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/JoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/Loader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/OuterJoinLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/OuterJoinableAssociation.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/BasicCollectionJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/BasicCollectionLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/BatchingCollectionInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/CollectionInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/CollectionJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/CollectionLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/OneToManyJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/OneToManyLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/SubselectCollectionLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/SubselectOneToManyLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/collection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/CriteriaJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/criteria/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CollectionFetchReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CollectionReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/ColumnCollectionAliases.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CustomLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/CustomQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/EntityFetchReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/FetchReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/NonScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/Return.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/RootReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/ScalarReturn.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/AbstractEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/CascadeEntityJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/CascadeEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/CollectionElementLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/UniqueEntityLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/entity/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/hql/QueryLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/hql/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/loader/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/BlobImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/ClobImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/ReaderInputStream.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/SerializableBlob.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/SerializableClob.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/lob/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/AbstractAuxiliaryDatabaseObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Any.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Array.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/AuxiliaryDatabaseObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Backref.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Bag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Collection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Column.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Component.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Constraint.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/DenormalizedTable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/DependantValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Fetchable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Filterable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ForeignKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Formula.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IdentifierBag.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IdentifierCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Index.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IndexBackref.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/IndexedCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Join.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/KeyValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/List.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ManyToOne.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Map.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/MetaAttributable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/MetaAttribute.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/OneToMany.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/OneToOne.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PersistentClass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PersistentClassVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PrimaryKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PrimitiveArray.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Property.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/PropertyGeneration.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/RelationalModel.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/RootClass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Selectable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Set.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/SimpleAuxiliaryDatabaseObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/SimpleValue.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Subclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Table.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/TableOwner.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ToOne.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/TypeDef.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/UnionSubclass.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/UniqueKey.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/Value.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/ValueVisitor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/mapping/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/metadata/ClassMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/metadata/CollectionMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/metadata/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/AbstractExplicitParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/CollectionFilterKeyParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/DynamicFilterParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/ExplicitParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/NamedParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/ParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/PositionalParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/param/VersionTypeSeedParameterSpecification.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/PersisterFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/BasicCollectionPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CollectionPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CollectionPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CollectionPropertyNames.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/CompositeElementPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/ElementPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/NamedQueryCollectionInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/QueryableCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/SQLLoadableCollection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/collection/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/BasicEntityPropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Joinable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Loadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Lockable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/NamedQueryLoader.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/OuterJoinLoadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/PropertyMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/Queryable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/SQLLoadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/SingleTableEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/UniqueKeyLoadable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/entity/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/persister/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/pretty/MessageHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/pretty/Printer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/pretty/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/ChainedPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/Dom4jAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/Getter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/MapAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/NoopAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/PropertyAccessor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/PropertyAccessorFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/Setter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/property/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/EntityNotFoundDelegate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/HibernateProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/HibernateProxyHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/LazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/ProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/map/MapLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/map/MapProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/map/MapProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/cglib/SerializableProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/proxy/pojo/javassist/SerializableProxy.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/HibernatePermission.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCConfiguration.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPermissions.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreDeleteEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreInsertEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreLoadEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCPreUpdateEventListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/JACCSecurityListener.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/secure/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ANSICaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ANSIJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Alias.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/CacheJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/CaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ConditionFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/DecodeCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Delete.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/DerbyCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/DisjunctionFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/ForUpdateFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/HSQLCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/InFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Insert.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/InsertSelect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/JoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/MckoiCaseFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/OracleJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/QueryJoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/QuerySelect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Select.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/SelectFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/SimpleSelect.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Sybase11JoinFragment.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Template.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/Update.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/sql/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/CategorizedStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/CollectionStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/EntityStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/QueryStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/SecondLevelCacheStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/SessionStatistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/SessionStatisticsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/Statistics.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/StatisticsImpl.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/StatisticsImplementor.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/stat/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ColumnMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/DatabaseMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ForeignKeyMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/IndexMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/ManagedProviderConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExportTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdateTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidatorTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/SuppliedConnectionProviderConnectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/TableMetadata.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/hbm2ddl/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/BasicInstrumentationTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/cglib/InstrumentTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/javassist/InstrumentTask.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tool/instrument/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/BESTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/BTMTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/CMTTransaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/CMTTransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/CacheSynchronization.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JBossTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JDBCTransaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JDBCTransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JNDITransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JOTMTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JOnASTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JRun4TransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JTATransaction.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/JTATransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/OC4JTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/OrionTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/ResinTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/SunONETransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionFactoryFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/TransactionManagerLookupFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/WebSphereExtendedJTATransactionLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/WebSphereTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/WeblogicTransactionManagerLookup.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transaction/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/AliasToBeanResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/AliasToEntityMapResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/DistinctRootEntityResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/PassThroughResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/ResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/RootEntityResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/ToListResultTransformer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/Transformers.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/transform/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Dom4jInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/DynamicMapInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/ElementWrapper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/EntityModeToTuplizerMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/IdentifierProperty.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Instantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/PojoInstantiator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Property.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/PropertyFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/StandardProperty.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/Tuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/VersionProperty.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/AbstractComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/ComponentEntityModeToTuplizerMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/ComponentMetamodel.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/ComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/Dom4jComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/DynamicMapComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/Dom4jEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/DynamicMapEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/EntityEntityModeToTuplizerMapping.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/EntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/tuple/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractBynaryType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractCharArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractComponentType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AbstractType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AdaptedImmutableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AnyType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/AssociationType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BagType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BigDecimalType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BigIntegerType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BinaryType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BlobType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/BooleanType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ByteType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CalendarDateType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CalendarType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharBooleanType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharacterArrayType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CharacterType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ClassType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ClobType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CollectionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ComponentType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CompositeCustomType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CurrencyType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CustomCollectionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/CustomType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DateType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DbTimestampType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DiscriminatorType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/DoubleType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/EmbeddedComponentType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/EntityType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/FloatType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ForeignKeyDirection.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/IdentifierBagType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/IdentifierType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ImmutableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/IntegerType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ListType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/LiteralType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/LocaleType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/LongType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ManyToOneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/MapType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/MetaType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/MutableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/NullableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/OneToOneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/OrderedMapType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/OrderedSetType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/PrimitiveType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SerializableType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SerializationException.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SetType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/ShortType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SortedMapType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SortedSetType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/SpecialOneToOneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/StringType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TextType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TimeType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TimeZoneType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TimestampType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TrueFalseType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/Type.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/TypeFactory.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/VersionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/WrapperBinaryType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/YesNoType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/type/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/CompositeUserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/EnhancedUserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/LoggableUserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/ParameterizedType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/UserCollectionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/UserType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/UserVersionType.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/usertype/package.html
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ArrayHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/BytesHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/CalendarComparator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/Cloneable.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/CollectionHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ComparableComparator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ConfigHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/DTDEntityResolver.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/EmptyIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/EqualsHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ExternalSessionFactoryConfig.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/FastHashMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/FilterHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/IdentityMap.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/IdentitySet.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/JDBCExceptionReporter.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/JTAHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/JoinedIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/LazyIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/MarkerObject.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/NamingHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/PropertiesHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/ReflectHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SerializationHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SimpleMRUCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SingletonIterator.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/SoftLimitMRUCache.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/StringHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/XMLHelper.java
core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/util/package.html
core/tags/hibernate-3.3.0.CR2/distribution/pom.xml
core/tags/hibernate-3.3.0.CR2/documentation/manual/pom.xml
core/tags/hibernate-3.3.0.CR2/documentation/manual/src/main/docbook/en-US/Hibernate_Reference.xml
core/tags/hibernate-3.3.0.CR2/documentation/manual/src/main/docbook/en-US/content/tutorial.xml
core/tags/hibernate-3.3.0.CR2/documentation/pom.xml
core/tags/hibernate-3.3.0.CR2/documentation/releasenotes/pom.xml
core/tags/hibernate-3.3.0.CR2/jmx/pom.xml
core/tags/hibernate-3.3.0.CR2/parent/pom.xml
core/tags/hibernate-3.3.0.CR2/pom.xml
core/tags/hibernate-3.3.0.CR2/testing/pom.xml
core/tags/hibernate-3.3.0.CR2/testsuite/pom.xml
core/tags/hibernate-3.3.0.CR2/testsuite/src/test/java/org/hibernate/test/ops/MergeTest.java
core/tags/hibernate-3.3.0.CR2/tutorials/eg/pom.xml
core/tags/hibernate-3.3.0.CR2/tutorials/pom.xml
core/tags/hibernate-3.3.0.CR2/tutorials/web/pom.xml
Log:
[maven-release-plugin] copy for tag hibernate-3.3.0.CR2
Copied: core/tags/hibernate-3.3.0.CR2 (from rev 14744, core/trunk)
Deleted: core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml
===================================================================
--- core/trunk/cache-ehcache/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,94 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-ehcache</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate Ehcache Integration</name>
- <description>Integration of Hibernate with Ehcache</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache</artifactId>
- <version>1.2.3</version>
- </dependency>
-
- <!-- testing deps -->
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>99.0-does-not-exist</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- <version>99.0-does-not-exist</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>test</scope>
- </dependency>
- <!-- these are optional on core... :( -->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.GA</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <version>2.1_3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>asm</groupId>
- <artifactId>asm-attrs</artifactId>
- <version>1.5.3</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml (from rev 15003, core/trunk/cache-ehcache/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/cache-ehcache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,94 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-ehcache</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate Ehcache Integration</name>
+ <description>Integration of Hibernate with Ehcache</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+
+ <!-- testing deps -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- these are optional on core... :( -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-attrs</artifactId>
+ <version>1.5.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml
===================================================================
--- core/trunk/cache-jbosscache/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,125 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-jbosscache</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate JBossCache Integration</name>
- <description>Integration of Hibernate with JBossCache (based on JBossCache1.x APIs)</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-cache</artifactId>
- <version>1.4.1.GA</version>
- </dependency>
- <!-- jboss-cache (the one from the jboss repo, anyway) does not properly define its dependencies -->
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-system</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-common</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-minimal</artifactId>
- <version>4.0.2</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-j2se</artifactId>
- <version>200504122039</version>
- </dependency>
- <dependency>
- <groupId>concurrent</groupId>
- <artifactId>concurrent</artifactId>
- <version>1.3.4</version>
- </dependency>
- <dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups-all</artifactId>
- <version>2.2.7</version>
- </dependency>
-
- <!-- testing deps -->
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>99.0-does-not-exist</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- <version>99.0-does-not-exist</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>test</scope>
- </dependency>
- <!-- these are optional on core... :( -->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.GA</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <version>2.1_3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>asm</groupId>
- <artifactId>asm-attrs</artifactId>
- <version>1.5.3</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml (from rev 15003, core/trunk/cache-jbosscache/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/cache-jbosscache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,125 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jbosscache</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate JBossCache Integration</name>
+ <description>Integration of Hibernate with JBossCache (based on JBossCache1.x APIs)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-cache</artifactId>
+ <version>1.4.1.GA</version>
+ </dependency>
+ <!-- jboss-cache (the one from the jboss repo, anyway) does not properly define its dependencies -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>4.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
+ <version>4.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-minimal</artifactId>
+ <version>4.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2se</artifactId>
+ <version>200504122039</version>
+ </dependency>
+ <dependency>
+ <groupId>concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+ <dependency>
+ <groupId>jgroups</groupId>
+ <artifactId>jgroups-all</artifactId>
+ <version>2.2.7</version>
+ </dependency>
+
+ <!-- testing deps -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- these are optional on core... :( -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-attrs</artifactId>
+ <version>1.5.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,187 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-jbosscache2</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate JBossCache2.x Integration</name>
- <description>Integration of Hibernate with JBossCache (based on JBossCache2.x APIs)</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.cache</groupId>
- <artifactId>jbosscache-core</artifactId>
- <version>2.1.1.GA</version>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-testing</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.8.0.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>99.0-does-not-exist</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- <version>99.0-does-not-exist</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.4.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>test</scope>
- </dependency>
- <!-- this is optional on core :( and needed for testing -->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.GA</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <filtering>false</filtering>
- <directory>src/test/java</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </testResource>
- <testResource>
- <filtering>true</filtering>
- <directory>src/test/resources</directory>
- </testResource>
- </testResources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- Skip a long-running test of a prototype class -->
- <exclude>**/ClusteredConcurrentTimestampRegionTestCase.java</exclude>
- </excludes>
- <systemProperties>
- <property>
- <name>hibernate.test.validatefailureexpected</name>
- <value>true</value>
- </property>
- <property>
- <name>jgroups.bind_addr</name>
- <value>${jgroups.bind_addr}</value>
- </property>
- <!-- There are problems with multicast and IPv6 on some
- OS/JDK combos, so we tell Java to use IPv4. If you
- have problems with multicast when running the tests
- you can try setting this to 'false', although typically
- that won't be helpful.
- -->
- <property>
- <name>java.net.preferIPv4Stack</name>
- <value>true</value>
- </property>
- <!-- Tell JGroups to only wait a short time for PING
- responses before determining coordinator. Speeds cluster
- formation during integration tests. (This is too
- low a value for a real system; only use for tests.)
- -->
- <property>
- <name>jgroups.ping.timeout</name>
- <value>500</value>
- </property>
- <!-- Tell JGroups to only require one PING response
- before determining coordinator. Speeds cluster
- formation during integration tests. (This is too
- low a value for a real system; only use for tests.)
- -->
- <property>
- <name>jgroups.ping.num_initial_members</name>
- <value>1</value>
- </property>
- <!-- Disable the JGroups message bundling feature
- to speed tests and avoid FLUSH issue -->
- <property>
- <name>jgroups.udp.enable_bundling</name>
- <value>false</value>
- </property>
- </systemProperties>
- <skipExec>${skipUnitTests}</skipExec>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <properties>
- <skipUnitTests>true</skipUnitTests>
- <!--
- Following is the default jgroups mcast address. If you find the testsuite runs very slowly, there
- may be problems with multicast on the interface JGroups uses by default on your machine. You can
- try to resolve setting 'jgroups.bind_addr' as a system-property to the jvm launching maven and
- setting the value to an interface where you know multicast works
- -->
- <jgroups.bind_addr>127.0.0.1</jgroups.bind_addr>
- </properties>
-
- <profiles>
- <profile>
- <id>test</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <properties>
- <skipUnitTests>false</skipUnitTests>
- </properties>
- </profile>
- </profiles>
-</project>
Copied: core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml (from rev 15003, core/trunk/cache-jbosscache2/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/cache-jbosscache2/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,187 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jbosscache2</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate JBossCache2.x Integration</name>
+ <description>Integration of Hibernate with JBossCache (based on JBossCache2.x APIs)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <version>2.1.1.GA</version>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>99.0-does-not-exist</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- this is optional on core :( and needed for testing -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/java</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </testResource>
+ <testResource>
+ <filtering>true</filtering>
+ <directory>src/test/resources</directory>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- Skip a long-running test of a prototype class -->
+ <exclude>**/ClusteredConcurrentTimestampRegionTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+ <name>hibernate.test.validatefailureexpected</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>jgroups.bind_addr</name>
+ <value>${jgroups.bind_addr}</value>
+ </property>
+ <!-- There are problems with multicast and IPv6 on some
+ OS/JDK combos, so we tell Java to use IPv4. If you
+ have problems with multicast when running the tests
+ you can try setting this to 'false', although typically
+ that won't be helpful.
+ -->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Tell JGroups to only wait a short time for PING
+ responses before determining coordinator. Speeds cluster
+ formation during integration tests. (This is too
+ low a value for a real system; only use for tests.)
+ -->
+ <property>
+ <name>jgroups.ping.timeout</name>
+ <value>500</value>
+ </property>
+ <!-- Tell JGroups to only require one PING response
+ before determining coordinator. Speeds cluster
+ formation during integration tests. (This is too
+ low a value for a real system; only use for tests.)
+ -->
+ <property>
+ <name>jgroups.ping.num_initial_members</name>
+ <value>1</value>
+ </property>
+ <!-- Disable the JGroups message bundling feature
+ to speed tests and avoid FLUSH issue -->
+ <property>
+ <name>jgroups.udp.enable_bundling</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ <skipExec>${skipUnitTests}</skipExec>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <skipUnitTests>true</skipUnitTests>
+ <!--
+ Following is the default jgroups mcast address. If you find the testsuite runs very slowly, there
+ may be problems with multicast on the interface JGroups uses by default on your machine. You can
+ try to resolve setting 'jgroups.bind_addr' as a system-property to the jvm launching maven and
+ setting the value to an interface where you know multicast works
+ -->
+ <jgroups.bind_addr>127.0.0.1</jgroups.bind_addr>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>test</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <skipUnitTests>false</skipUnitTests>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Deleted: core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml
===================================================================
--- core/trunk/cache-oscache/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-oscache</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate OSCache Integration</name>
- <description>Integration of Hibernate with OSCache</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>opensymphony</groupId>
- <artifactId>oscache</artifactId>
- <version>2.1</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml (from rev 15003, core/trunk/cache-oscache/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/cache-oscache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,31 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-oscache</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate OSCache Integration</name>
+ <description>Integration of Hibernate with OSCache</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>oscache</artifactId>
+ <version>2.1</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml
===================================================================
--- core/trunk/cache-swarmcache/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-swarmcache</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate SwarmCache Integration</name>
- <description>Integration of Hibernate with SwarmCache</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>swarmcache</groupId>
- <artifactId>swarmcache</artifactId>
- <version>1.0RC2</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml (from rev 15003, core/trunk/cache-swarmcache/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/cache-swarmcache/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,31 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-swarmcache</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate SwarmCache Integration</name>
+ <description>Integration of Hibernate with SwarmCache</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>swarmcache</groupId>
+ <artifactId>swarmcache</artifactId>
+ <version>1.0RC2</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/changelog.txt
===================================================================
--- core/trunk/changelog.txt 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/changelog.txt 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,2581 +0,0 @@
-Hibernate Changelog
-===================
-Note: Newer entries are automatically generated and the description might not
-match the actual issue resolution (i.e. a bug might not be a bug). Please
-refer to the particular case on JIRA using the issue tracking number to learn
-more about each case.
-
-
-Changes in version 3.3.0.CR1 (2008.03.18)
--------------------------------------------
-
-** Bug
- * [HHH-1312] - Unclosed ResultSet when using Identity
- * [HHH-1396] - Table.validateColumns fails on valid column
- * [HHH-1569] - Immutable Natural Id check fails with ArrayIndexOutOfBounds in some cases
- * [HHH-1593] - Infinite loop/StackOverflow when calling configuration.setListener(null)
- * [HHH-1753] - DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax
- * [HHH-1916] - param values in generator element should be trimmed during HbmBinding
- * [HHH-1920] - Incorrect documentation regarding XML manipulation in Hibernate reference manual (chapter 18.3).
- * [HHH-1956] - Interceptor.afterTransactionCompletion not called with JTATransaction (CacheSynchronization.hibernateTransaction not set)
- * [HHH-2159] - NullPointerException in FromElement#findIntendedAliasedFromElementBasedOnCrazyJPARequirements with 'hibernate.query.jpaql_strict_compliance' enabled
- * [HHH-2164] - Minor bug in section "20.1.1. Customizing the schema"
- * [HHH-2200] - Memory leak in AbstractBatcher with Generated Properties
- * [HHH-2320] - Regression: optional properties under a <join> tag no longer update properly
- * [HHH-2503] - AbstractEntityPersister swallows JDBCExceptions in processGeneratedProperties
- * [HHH-2513] - Abusive WARN logged during deserialization of replicated SessionFactory
- * [HHH-2542] - NullPointerException in TypeFactory.replaceAssociations for ComponentType
- * [HHH-2553] - New LoadContexts Implementation causing possible performance degradation
- * [HHH-2593] - Keyword UNION is prefixed with "this_." in filter conditions
- * [HHH-2616] - No event is fired on Collection recreate/remove/update action
- * [HHH-2627] - Generated properties leak prepared statements in Hibernate 3.2.3 and higher.
- * [HHH-2631] - Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
- * [HHH-2711] - PropertyAccessException with backref and <composite-map-key/>
- * [HHH-2726] - spelling o your CLASSPATH
- * [HHH-2728] - Calling session.clear() while retrieving objects via an iterator will cause a "LazyInitializationException - No Session" by the CGLIBLazyInitializer
- * [HHH-2788] - Oracl8iDialect No Dialect mapping for JDBC type 91
- * [HHH-2795] - CollectionLoadContexts for empy collections are not removed until PersistenceContext.clear()
- * [HHH-2816] - DefaultFlushEntityEventListener.checkNaturalId() causes extra SELECTs on read-only entities
- * [HHH-2833] - insert-select query fails with NPE when select includes join
- * [HHH-2857] - schemaSupport for HSQLDialect remote connections doesn't work
- * [HHH-2861] - cascade="delete-orphan,all" is ignored
- * [HHH-2863] - testsuite fix-ups for maven and/or directory changes
- * [HHH-2864] - Merging a detached instance with a new child in a unidirectional one-to-many association fails if the parent was previously loaded as a proxy
- * [HHH-2892] - skip up-to-date checks of query cache for natural-id only if immutable
- * [HHH-2928] - optimizers for enhanced id generators should be synchronized against multi-threaded access
- * [HHH-2948] - QueryStatistics.executionMinTime always = 0
- * [HHH-3111] - WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter.getStatus() implemented incorrect
- * [HHH-3140] - Region prefix ignored for entities and collections
-
-** Deprecation
- * [HHH-2755] - Wrong "jsdk.jar" referenced in the tutorial
-
-** Improvement
- * [HHH-1786] - JTASessionContext.CleanupSynch does not remove sessions from currentSessionMap
- * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
- * [HHH-2156] - Section 19.3, "Managing the caches" doesn't document CacheMode.IGNORE
- * [HHH-2533] - redesign Cache/CacheProviders
- * [HHH-2662] - Workaround PostgreSQL issues in testsuite
- * [HHH-2663] - Map java.sql.Types.REAL to Hibernate FloatType for auto-discovery stuff
- * [HHH-2665] - Split Oracle9Dialect into Oracle9iDialect and Oracle10gDialect
- * [HHH-2669] - Unequivocally map MySQL LOB types to the LONG variant
- * [HHH-2682] - support for auto-discovery of H2 dialect
- * [HHH-2696] - Consider migrating to slf4j
- * [HHH-2761] - Handle null and empty string consistently in PropertiesHelper
- * [HHH-2778] - TransactionManagerLookup implementation for Bitronix Transaction Manager
- * [HHH-2789] - Section 19.2 of the documentation does not show OSCache as supporting clusters. It does.
- * [HHH-2822] - timestamp extraction functions for SAPDBDialect
- * [HHH-2826] - IS [NOT] NULL checks with component values
- * [HHH-2859] - Introduce a 'Work' API for user to perform JDBC work
- * [HHH-3131] - Add a method to ActionQueue to tell whether there are currently entries in the executions collection
-
-** New Feature
- * [HHH-1] - Optimize Hibernate for the bulk insertion of related entities
- * [HHH-2555] - Create new RegionFactory for JBossCache
- * [HHH-2884] - Provide a sessionFactory close event or hook for the event listeners
-
-** Patch
- * [HHH-952] - Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
- * [HHH-2070] - Expand DB2Dialect auto-discovery support (Martin Renner)
- * [HHH-2519] - Schema dropping not documented with hibernate.hbm2ddl.auto=create
- * [HHH-2630] - Hibernate Dialect is not auto-detected for Sybase ASE and DB2 (Shelley McGowan)
- * [HHH-2758] - Patch IngresDialect based on certification
- * [HHH-2839] - Don't use dummy dual table for hsqldb (David Bala?ic)
- * [HHH-2849] - Better error logging in IdentifierGeneratorFactory (Antony Stubbs)
- * [HHH-2957] - ActionQueue Insertion sort performance degrades exponentially (Jay Erb)
- * [HHH-3084] - DialectFactory detection of Ingres metadata (Michael Leo)
-
-** Task
- * [HHH-2702] - Officially move to JDK 1.4
- * [HHH-2704] - Migrate to Maven2 for build
-
-
-Changes in version 3.2.6 (2008.02.07)
--------------------------------------------
-
-** Bug
- * [HHH-925] - DetachedCriteria.createCriteria not working with alias
- * [HHH-1312] - Unclosed ResultSet when using Identity
- * [HHH-1329] - SchemaValidator fail when views are involved
- * [HHH-1593] - Infinite loop/StackOverflow when calling configuration.setListener(null)
- * [HHH-1685] - DetachedCriteria doesn't create alias on subcriteria
- * [HHH-1753] - DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax
- * [HHH-1916] - param values in generator element should be trimmed during HbmBinding
- * [HHH-1956] - Interceptor.afterTransactionCompletion not called with JTATransaction (CacheSynchronization.hibernateTransaction not set)
- * [HHH-2016] - Oracle9Dialect registers last_day() function as "lastday"
- * [HHH-2159] - NullPointerException in FromElement#findIntendedAliasedFromElementBasedOnCrazyJPARequirements with 'hibernate.query.jpaql_strict_compliance' enabled
- * [HHH-2200] - Memory leak in AbstractBatcher with Generated Properties
- * [HHH-2261] - Setting hibernate.hbm2ddl.auto=validate causes problems on mySQL with numeric fields
- * [HHH-2320] - Regression: optional properties under a <join> tag no longer update properly
- * [HHH-2503] - AbstractEntityPersister swallows JDBCExceptions in processGeneratedProperties
- * [HHH-2542] - NullPointerException in TypeFactory.replaceAssociations for ComponentType
- * [HHH-2593] - Keyword UNION is prefixed with "this_." in filter conditions
- * [HHH-2598] - Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null
- * [HHH-2616] - No event is fired on Collection recreate/remove/update action
- * [HHH-2627] - Generated properties leak prepared statements in Hibernate 3.2.3 and higher.
- * [HHH-2728] - Calling session.clear() while retrieving objects via an iterator will cause a "LazyInitializationException - No Session" by the CGLIBLazyInitializer
- * [HHH-2788] - Oracl8iDialect No Dialect mapping for JDBC type 91
- * [HHH-2795] - CollectionLoadContexts for empy collections are not removed until PersistenceContext.clear()
- * [HHH-2816] - DefaultFlushEntityEventListener.checkNaturalId() causes extra SELECTs on read-only entities
- * [HHH-2833] - insert-select query fails with NPE when select includes join
- * [HHH-2857] - schemaSupport for HSQLDialect remote connections doesn't work
- * [HHH-2861] - cascade="delete-orphan,all" is ignored
- * [HHH-2864] - Merging a detached instance with a new child in a unidirectional one-to-many association fails if the parent was previously loaded as a proxy
- * [HHH-2892] - skip up-to-date checks of query cache for natural-id only if immutable
- * [HHH-2928] - optimizers for enhanced id generators should be synchronized against multi-threaded access
- * [HHH-2948] - QueryStatistics.executionMinTime always = 0
-
-** Improvement
- * [HHH-1630] - duplicate property mapping - more details
- * [HHH-1696] - Add outer join support for aliases on DetachedCriteria
- * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
- * [HHH-2682] - support for auto-discovery of H2 dialect
- * [HHH-2761] - Handle null and empty string consistently in PropertiesHelper
- * [HHH-2822] - timestamp extraction functions for SAPDBDialect
- * [HHH-2826] - IS [NOT] NULL checks with component values
- * [HHH-2852] - Better error messages when schema validation fails
-
-** Patch
- * [HHH-952] - Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
- * [HHH-2070] - Expand DB2Dialect auto-discovery support (Martin Renner)
- * [HHH-2839] - Don't use dummy dual table for hsqldb (David Bala?ic)
- * [HHH-2849] - Better error logging in IdentifierGeneratorFactory (Antony Stubbs)
- * [HHH-2957] - ActionQueue Insertion sort performance degrades exponentially (Jay Erb)
- * [HHH-3084] - DialectFactory detection of Ingres metadata (Michael Leo)
-
-** Task
- * [HHH-2559] - http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd needs to be updated
- * [HHH-3085] - Remove connector.jar (unnecessary library)
- * [HHH-3086] - Remove jdbc2_0-stdext.jar (unnecessary library)
-
-
-Changes in version 3.2.5 (2007.07.31)
--------------------------------------------
-
-** Bug
- * [HHH-1116] - batch-size typo
- * [HHH-1561] - Missing " in Documentation for H3, Chapter 15.8
- * [HHH-1569] - Immutable Natural Id check fails with ArrayIndexOutOfBounds in some cases
- * [HHH-1694] - Documentation Outdated: "10.4.4. Queries in native SQL"
- * [HHH-2180] - minordocumentation error in hbm xml
- * [HHH-2201] - session.iterate() does not exist
- * [HHH-2267] - A copy/paste mistake in the documentation for <schemavalidator> ant task
- * [HHH-2334] - Documentation error in section 5.1.3
- * [HHH-2420] - Error in 2.5. Contextual Sessions
- * [HHH-2502] - The second level caching documentation states that ehcache is not distributed.
- * [HHH-2631] - Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
- * [HHH-2649] - Batcher configuration parameter incorrectly documented
- * [HHH-2711] - PropertyAccessException with backref and <composite-map-key/>
- * [HHH-2713] - duplicated phrase in docs "of the of the"
- * [HHH-2714] - Three typos in code examples
- * [HHH-2719] - adddress --> address
- * [HHH-2720] - Monetory --> Monetary
-
-** Improvement
- * [HHH-1022] - incomplete documentation in _README.txt in the lib directory
- * [HHH-1682] - Improve the description of differences between save() and persist()
- * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
- * [HHH-2417] - Update book on Hibernate reference
- * [HHH-2418] - Refer HSQL DB website in chapter 1.2.3
- * [HHH-2487] - Typo in "5.1.7. version (optional)"
- * [HHH-2550] - Update API Class in 10.4.3. Criteria queries
- * [HHH-2662] - Workaround PostgreSQL issues in testsuite
- * [HHH-2663] - Map java.sql.Types.REAL to Hibernate FloatType for auto-discovery stuff
- * [HHH-2665] - Split Oracle9Dialect into Oracle9iDialect and Oracle10gDialect
-
-** Patch
- * [HHH-2520] - Miscellaneous config doc spelling fixes
- * [HHH-2630] - Hibernate Dialect is not auto-detected for Sybase ASE and DB2 (Shelley McGowan)
- * [HHH-2758] - Patch IngresDialect based on certification
-
-** Task
- * [HHH-2551] - Deprecate org.hibernate.criterion.Expression
- * [HHH-2566] - Replace usages of FlushMode.NEVER with FlushMode.MANUAL
- * [HHH-2567] - Update reference to use FlushMode.MANUAL
- * [HHH-2568] - Hibernate javadoc overview refering wrong classes and packages
-
-
-Changes in version 3.2.4.sp1 (2007.05.18)
--------------------------------------------
-
-** Bug
- * [HHH-2605] - Since 3.2.4 no value specified for row id
- * [HHH-2613] - LockMode.FORCE on non versioned entity leads to NPE
-
-
-Changes in version 3.2.4 (2007.05.09)
--------------------------------------------
-
-** Bug
- * [HHH-511] - reattach object from same session
- * [HHH-2316] - org.hibernate.cache.CacheKey.equals() can cause PropertyAccessException to be thrown
- * [HHH-2553] - New LoadContexts Implementation causing possible performance degradation
- * [HHH-2602] - instrumented many-to-one problem with aggressive release
-
-** Deprecation
- * [HHH-2603] - Deprecate the Session.connection() method
-
-** Improvement
- * [HHH-2549] - Warn users explicitly about schemaexport and schemaupdate does not support annotations
-
-** New Feature
- * [HHH-1] - Optimize Hibernate for the bulk insertion of related entities
-
-** Patch
- * [HHH-2301] - Identity generator with custom insert SQL broken in 3.2 (Scott Rankin and Gail Badner)
- * [HHH-2336] - paremeterizable and typedef-able UserCollectionType (Holger Brands)
- * [HHH-2580] - Performace: Too many lookups of WAS extended transaction support (Jesper Udby)
-
-
-Changes in version 3.2.3 (2007.04.02)
--------------------------------------------
-
-** Bug
- * [HHH-2376] - Query with fully qualified entity class fails
- * [HHH-2392] - LockModes referencing non-root joined-subclass class in HQL/Criteria
- * [HHH-2393] - Generated properties leave open ResultSet on Batcher to be closed on transaction completion
- * [HHH-2397] - hilo generator can generate negative numbers because of arithmetic overflow
- * [HHH-2469] - ArrayIndexOutOfBoundsException during update by rowid
- * [HHH-2476] - PersistentMap.put() incorrect on uninitialized, non-extra-lazy map
- * [HHH-2481] - Big memory leak in the use of CGLIB
- * [HHH-2499] - incorrect assertion failure relating to generated property values
- * [HHH-2513] - Abusive WARN logged during deserialization of replicated SessionFactory
- * [HHH-2521] - Fix cascading of merge across component properties
- * [HHH-2532] - update/delete executeUpdate() causes problems with JBossCache (at least in opt-locking setups)
-
-** Improvement
- * [HHH-2495] - encapsulate the notion of state pertaining to processing a result set
- * [HHH-2534] - better error message for illegal 'collection dereference' in HQL query
- * [HHH-2535] - Change Cache' Cache71Dialect so that sequence support returns false
-
-** New Feature
- * [HHH-2471] - create a set of "enhanced" generators
- * [HHH-2500] - apply Terradata certification results
-
-** Patch
- * [HHH-2367] - InformixDialect uses wrong data type
- * [HHH-2489] - SQL comments for HQL bulk operations
-
-
-Changes in version 3.2.2 (2007.01.24)
--------------------------------------------
-
-** Bug
- * [HHH-1471] - If the 'generated' attribute is set to 'insert' or 'always' on the property of a component it is ignored and the value is not read from the database.
- * [HHH-1646] - Bad code in FastClass.equals
- * [HHH-1889] - LockMode.UPGRADE not applied in all cases for SQL Server / Sybase
- * [HHH-2112] - ClassCastException in StatefulPersistenceContext.getCachedDatabaseSnapshot(...)
- * [HHH-2221] - MySQL temp table DDL and isolation
- * [HHH-2238] - SQLQuery executeUpdate doesn't respect Query.setFlushMode()
- * [HHH-2251] - Settings build unnecessary in schemaupdate/schemavalidate
- * [HHH-2257] - Query.iterate() results differ from Query.list() 2
- * [HHH-2259] - autoflush and autoclose not longer occur in JTA environment with hibernate 3.2
- * [HHH-2264] - NPE when NamedQuery contains space before variable name
- * [HHH-2274] - Collection ordering when many to many order by is used is not respected
- * [HHH-2275] - Mapping a composite element as a map key using formulas can lead to AOOBE
- * [HHH-2284] - HQL: selecting components inside components doesn't work
- * [HHH-2291] - collection based on property-ref not handled correctly during reattch
- * [HHH-2292] - merge detached instance fails to persist collection changes in case of bare collection reference
- * [HHH-2356] - NullableType.toString(Object) should account for nulls
- * [HHH-2366] - Changing a component's value does not trigger an update during flush
- * [HHH-2378] - replicate() of non-versioned entiy can result in wrong value for version in entity cache
-
-** Improvement
- * [HHH-1851] - relax special handling of 'id' property
- * [HHH-2130] - SQLQuery does not autoflush all entities used in the query
- * [HHH-2193] - Introduce a flag to avoid checking NamedQuery at startup
- * [HHH-2242] - Consider Allowing Optimistic Lock Strategies other than 'Version' with joined-subclass
- * [HHH-2250] - Create an appropriate error message if Query.setEntity is passed a NULL value
- * [HHH-2282] - PersistentClass property lookups do not properly account for embedded composite identifiers
- * [HHH-2286] - dialect informational metadata
- * [HHH-2372] - Allow tooling to create Settings via SettingsFactory without contacting the db
-
-** New Feature
- * [HHH-2246] - No way to specify CACHE_PROVIDER_CONFIG in HibernateServiceMBean
-
-** Patch
- * [HHH-2300] - Updated dialect for H2 database engine
- * [HHH-2371] - enhancements to C3P0ConnectionProvider
-
-** Task
- * [HHH-2032] - update c3p0 to 0.9.1
-
-
-
-Changes in version 3.2.1 (2006.11.16)
--------------------------------------------
-
-** Bug
- * [HHH-939] - 'class' property in HQL results in incorrect SQL for joined-subclass
- * [HHH-1401] - session.merge() executes unnecessary updates when one-to-many relationship is defined.
- * [HHH-1460] - Inconsistent behavior when using Session.get() with multiple subclasses
- * [HHH-1564] - deleting versioned object with collection leads to unecessary update
- * [HHH-1629] - SchemaUpdate/validator doesn't listen to quoting
- * [HHH-1631] - Missing table in SQL from clause that is referenced in where clause when using joined subclass
- * [HHH-1651] - hibernate does not find an existing sequence from an Oracle database
- * [HHH-1663] - <any/> with collection will produce "AssertionFailure: collection was not processed by flush()"
- * [HHH-1737] - Add a ConnectionWrapper interface to allow access to the underlying connection from a BorrowedConnectionProxy
- * [HHH-1756] - Proxy objects are not removed from the BatchFetchQueue during a session evict
- * [HHH-1774] - Component parameters bound incorrectly
- * [HHH-1921] - "dirty, but no dirty properties" thrown when Interceptor resets properties.
- * [HHH-1986] - javassist throws InvocationTargetException instead of original checked Exception
- * [HHH-2027] - merge listener over-writes Interceptor changes to component state for a transient entity
- * [HHH-2044] - DefaultMergeEventListener.entityIsDetached call StaleObjectStateException with wrong identifier
- * [HHH-2082] - UpdateTimestampsCache.isUpToDate returns before checking all spaces
- * [HHH-2108] - cacheable files broken
- * [HHH-2138] - merge with bidirectional one-to-one may fail
- * [HHH-2145] - set.retainAll calling set.addAll
- * [HHH-2174] - Wrong log message in SessionImpl.afterTransactionCompletion(...)
- * [HHH-2199] - Unique constraints on nullable columns should not be generated with unique-key is used and supportsNotNullUnique=false
- * [HHH-2202] - Clearing the connection warnings even when log is > WARN to workaround a Sybase issue
- * [HHH-2206] - SessionImpl tries to deserialize itself in an incorrect order
- * [HHH-2207] - Suggested fix for HQL - MySQL setMaxResults issue
- * [HHH-2226] - org.hibernate.hql.ast.tree.FromElementType contains warning log message that should be debug instead
- * [HHH-2229] - Performance issue with fix for HHH-1293, CGLIBLazyInitializer may be slower for certain Java classes
- * [HHH-2236] - Lazy property + setReadOnly + Instrumented classes results in NullPointerException when accessing lazy property
-
-** Improvement
- * [HHH-2037] - provide Query.setProperties(Map)
- * [HHH-2042] - Typo in FlushMode.MANUAL Javadoc
- * [HHH-2057] - Add "remove" cascading style to CascadeStyle for XML mappings
- * [HHH-2127] - Document <filter-def condition="defaultCondition"> and <filter-def>defaultCondition
- * [HHH-2135] - Hibernate Deserialization: In org.hibernate.type.SerializableType the code makes a test for the return of a null object by simply testing the object as to whether or not it is null.
- * [HHH-2185] - introduce setting to control cglib caching of classes
- * [HHH-2203] - Make Post*Events extend AbstractEvent
- * [HHH-2208] - Table schema use in DatabaseMetadata
- * [HHH-2209] - ehcache.jar is old and does not contain the SingletonCacheProvider which are advised in exception messages
- * [HHH-2217] - Collection write methods and dirtying the collection
-
-** New Feature
- * [HHH-2205] - Dialect for Intersystems' Cache SQL 2007.1
-
-** Patch
- * [HHH-1767] - read-only cache for immutable collection causes unnecessary warning
-
-** Task
- * [HHH-2219] - Upgrade to Javassist 3.4
-
-
-Changes in version 3.2.0.ga (16.10.2006)
------------------------------------------
-(retag of 3.2.0.cr5 (2006.10.16))
-
-Changes in version 3.2.0.cr5 (04.10.2006)
--------------------------------------------
-
-** Bug
- * [HHH-1668] - PersistentSet write methods mark collection as dirty even if entry is not written
- * [HHH-1714] - Session.get() behavior
- * [HHH-1891] - Since rc3 deprecation Warning: The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 5.2.
-
-** Improvement
- * [HHH-2093] - PERSIST_ON_FLUSH ineffective for recursive object graphs
- * [HHH-2103] - Rolling back 'SELECT is mandatory' on JPA strict compliance
-
-** Task
- * [HHH-1931] - verify that the instrument tasks actually work
-
-
-Changes in version 3.2.0.cr4 (24.08.2006)
--------------------------------------------
-
-** Bug
- * [HHH-1293] - java.lang.NoSuchMethodError: <persistent class>.getHibernateLazyInitializer()
- * [HHH-1677] - optimistic-lock="dirty|all" is ignored at delete time
- * [HHH-1710] - persistent collections with property-ref to secondary tables cannot be joined in HQL
- * [HHH-1713] - AbstractEntityPersister causes an exception when a row in a joined table is missing with fetch="select"
- * [HHH-1740] - Build-time instrumentation breaks lazy="proxy"
- * [HHH-1750] - Exception ORA-01000 too many open cursors by generated="insert"
- * [HHH-1806] - No Dialect mapping for JDBC type: 3
- * [HHH-1848] - A session.lock generates a query with a version column in a joined subclass which does not exist
- * [HHH-1892] - finish HHH-1789 for ordered and sorted collections
- * [HHH-1898] - With hibernate 3.2.0-cr3 there is an hql parsing error on a one-to-one relation
- * [HHH-1924] - ForeignKeys: TransientObjectException is thrown without a message because of a wrong bracket in the code
- * [HHH-1927] - persist() and then merge() not handled correctly for multiple entity instances representing the same logical state
- * [HHH-1937] - Proxy creation failure leads to NPEs
- * [HHH-1943] - PersistenceContext not checked to see whether the associated entity is transient or not
- * [HHH-1944] - generated subqueries and jpaql compliance (derived select clause) check
- * [HHH-1947] - OF part of MEMBER OF is optional
- * [HHH-1948] - Query Idetification variables are case insensitive in JPA
- * [HHH-1949] - having trim(BOTH from c.name) translated into having ltrim(rtrim(BOTH)) on DB2
- * [HHH-1954] - Proxies are never unassociated (evicted) from a session
- * [HHH-1958] - session.lock(LockMode.FORCE) can lead to NPE
- * [HHH-1963] - meta inheritance broken
- * [HHH-1992] - Some cascade actions should not trigger a property access on lazy properties
- * [HHH-2001] - javaassist does not setup the proper protection domain thus does not work with signed/secured deployments such as webstart
- * [HHH-2015] - where= does not set parenthesis leading to unexpected query when multiclause are used
- * [HHH-2017] - locate function defined on Oracle9Dialect is incorrect
- * [HHH-2022] - property names beginning with underscores cause Hibernate to generate invalid aliases
-
-** Improvement
- * [HHH-1470] - Enhance Hibernate-Mapping DTD Definition of type element
- * [HHH-1934] - logging NonUniqueObjectException and WrongClassException
- * [HHH-1941] - Be more specific about x not found and invalid mapping exceptions to allow tools to tell about it
- * [HHH-1968] - unify bytecode instrumentation
- * [HHH-1980] - disallow the mapping combination of <version/> and optimistic-lock
- * [HHH-2005] - more standard build script
- * [HHH-2023] - performance optimization of JTATransactionFactory.isTransactionInProgress()
-
-** Patch
- * [HHH-1271] - When using Stored Procedure for update or delete, the check is not done correctly.
-
-** Task
- * [HHH-1931] - verify that the instrument tasks actually work
-
-
-Chages in version 3.2 cr3 (2006.07.06)
--------------------------------------------
-
-** Bug
- * [HHH-1452] - Native SQL query is missing join if entity includes many-to-one on secondary table
- * [HHH-1507] - one-to-one can have formula or meta but not both of them.
- * [HHH-1552] - Error when using ?1 and parameterList
- * [HHH-1586] - ClassCastException in CollectionType.toLoggableString if using CustomCollectionType
- * [HHH-1732] - EhCache.toMap still assumes Serializable objects
- * [HHH-1734] - Connection leak when using hilo strategy in SE environment
- * [HHH-1741] - Bug in reference documentation
- * [HHH-1746] - NullPointerException at IdentNode.resolveAsNakedComponentPropertyRefLHS(IdentNode.java:195
- * [HHH-1748] - Setting a comment that contains a single quote on a query results in an unintuitive exception
- * [HHH-1763] - Bug in InputStream org.hibernate.util.ConfigHelper.getResourceAsStream(String resource)
- * [HHH-1791] - property update="false" ignored since 3.2.0.cr2
- * [HHH-1816] - serializing session from a named session factory to a different vm broken
- * [HHH-1822] - flushing entity linked to transient instance (non cascaded) should always fail
- * [HHH-1828] - registering a transaction marked for Rollback is illegal
- * [HHH-1833] - Not Generating HibernateException
- * [HHH-1838] - Wrong SQL generated for hql query on "any" relation
- * [HHH-1855] - booleans not properly handled in assignment clause of UPDATE statements
- * [HHH-1858] - wrong sql generated against many-to-any association table
- * [HHH-1871] - query type autodiscovery assume wrong column when mixing entities and scalars
-
-** Deprecation
- * [HHH-1792] - Callable update/insert/delete statements should not force rowcount out parameter
-
-** Improvement
- * [HHH-1617] - Check the second-level cache before adding a PK to a batch fetch
- * [HHH-1773] - Typo in ImprovedNamingStrategy
- * [HHH-1779] - Allow Session.remove() on transient object
- * [HHH-1789] - improve efficiency of collection initialization from L2 cache hits
- * [HHH-1795] - default cache provider to NoCacheProvider
- * [HHH-1796] - TreeCache based providers and Fqn
- * [HHH-1800] - session.get() / load() should raise exception when the id is of the wrong type
- * [HHH-1818] - remove() should force subsequent contains() calls to return false
- * [HHH-1831] - Batch loading the same EntityKey (one side of manytoone ) more than once
- * [HHH-1861] - More complete component handling in HQL
- * [HHH-1881] - introduce LoggableUserType interface
-
-** New Feature
- * [HHH-1709] - Be able to raise ENFE rather than LIE in proxies
- * [HHH-1727] - Add a SQLFunctionRegistry
- * [HHH-1817] - Introduce setting for JPA-QL strict compliance
- * [HHH-1826] - Built-in type for char[] -> VARCHAR Byte[] and Character[]
-
-** Patch
- * [HHH-1558] - Dialect for new database engine H2
- * [HHH-1847] - QBE 'like' clause with backslashes don't work with MySQL
-
-** Task
- * [HHH-1839] - rename FlushMode.NEVER -> FlushMode.MANUAL
-
-
-Changes in version 3.2 cr2 (2006.05.05)
--------------------------------------------
-
-** Bug
- * [HHH-1114] - The first (HSQL) Hibernate Application doesn't work as expected due to lack of database shutdown
- * [HHH-1175] - Exception when loading inheritance mapping in single file
- * [HHH-1560] - PropertiesHelper.resolvePlaceHolders() fails with non-String values in System properties
- * [HHH-1620] - Errors on max_lo <=1 boundaries
- * [HHH-1625] - Hibernate.isPropertyInitialized() returns false on instrumented transient object
- * [HHH-1648] - Exception while resuming a transaction is silently eaten
- * [HHH-1674] - Configuration serialization error: filterDefinitions map not serializable
- * [HHH-1695] - subsequent calls to non-existent proxy causes NPE
-
-** Improvement
- * [HHH-1266] - StatelessSession can implement refresh
- * [HHH-1414] - many-to-many and metadata order-by based on column from the target table
- * [HHH-1477] - Improve naming strategy for ANN-195
- * [HHH-1538] - aggregations functions in EJBQL queries does not return the appropriate types
- * [HHH-1670] - Update EhCache and EhCache provider to support EhCache 1.2
- * [HHH-1704] - Deduplicate unique constraints generation sharing the same column(s)
-
-** New Feature
- * [HHH-870] - support SQL updates in named queries
- * [HHH-1591] - Replace LazyInitializationException by EntityNotFoundException
- * [HHH-1719] - Provide a ClassTransformer interface to the BytecodeProvider
-
-
-Changes in version 3.2 cr1 (2006.03.27)
--------------------------------------------
-
-** Bug
- * [HHH-1453] - Broken exception handling in NullableType
-
-** Improvement
- * [HHH-227] - remove reflection optimizer
- * [HHH-587] - Make ResultTransformer available for all query methods
- * [HHH-1588] - delay inserts for insert-generated-identifiers outside transaction
- * [HHH-1590] - redesign how PostInsertIdentifierGenerators are handled at insertion
- * [HHH-1592] - allow SelectGenerator to use a defined natural-id (if one)
-
-** New Feature
- * [HHH-332] - create ability to add resulttransformer to HQL query
- * [HHH-1179] - support inline sequence id generation on Oracle using RETURNING clause
-
-
-Changes in version 3.2 alpha2 (2006.03.15)
--------------------------------------------
-
-** Bug
- * [HHH-535] - properties element causes exception in interface/abstract class
- * [HHH-1325] - ArrayOutOfBounds expected in DatabaseMetadata.isTable when specifing schema
- * [HHH-1435] - many-to-one lazy seems to be broken in 3.1.x
- * [HHH-1531] - NPE with many-to-many and property-ref
- * [HHH-1546] - generated version properties fail with multiple actions per flush
-
-** Improvement
- * [HHH-1540] - Better Error Feedback In CollectionEntry.postFlush(PersistentCollection)
- * [HHH-1555] - ConnectionReleaseMode.AFTER_STATEMENT and flushes
- * [HHH-1559] - introduce TransactionFactory.isTransactionInProgress to facilitate EJB3 joinTransaction handling
-
-
-Changes in version 3.2 alpha1 (2006.02.28)
--------------------------------------------
-
-** Bug
- * [HHH-687] - Exception QuerySyntaxError not really serializable
- * [HHH-1236] - Remove static reference to classloader, to avoid memory leak at webapp reload
- * [HHH-1287] - Problem with WAS ExtendedJTATransaction not available when using MDB
- * [HHH-1419] - Update + Exists doesn't seem to work
- * [HHH-1445] - SchemaUpdate closes shared ConnectionProvider
- * [HHH-1464] - QueryException from Query.getReturnAliases when query uses "fetch"
- * [HHH-1486] - Concurrent access issues with both SoftLimitMRUCache and SimpleMRUCache
- * [HHH-1508] - Session.createQuery() should not flush the session
-
-** Improvement
- * [HHH-1411] - Collection fetches and DISTINCT
- * [HHH-1412] - Collection fetches and firstResult/maxRows
- * [HHH-1416] - LockMode.FORCE to implement EJB3 LockModeType.WRITE
- * [HHH-1457] - support new optimisitc locking capabilities of JBossCache
- * [HHH-1466] - better handling of Antlr exceptions
- * [HHH-1516] - support DataDirect standard jdbc stored procedures
- * [HHH-1518] - Guarentee LockMode behaviors
- * [HHH-1520] - with clause with implied joins within an explicit join
- * [HHH-1526] - Improved DTDEntityResolver
-
-** New Feature
- * [HHH-1251] - Avoid replicating the clearing of TreeCache on SessionFactory..close()
- * [HHH-1410] - FlushMode.AUTO -> COMMIT when outside a transaction
- * [HHH-1447] - pluggable bytecode libraries
-
-
-Changes in version 3.1.2 (01.27.2006)
--------------------------------------------
-
-** Bug
- * [HHH-73] - Statistics for HQL queries use pre-processed query string
- * [HHH-1306] - HQL parsing problem with join fetching of arrays/collections of values
- * [HHH-1370] - Warning in hibernate-mapping-3.0.dtd
- * [HHH-1371] - MappingException is thrown when the same column is referenced with different case
- * [HHH-1386] - Numeric (long) literals not properly handled by HQL parser
- * [HHH-1390] - Session.isOpen() throws exeception when the session is closed with ThreadLocalSessionContext
- * [HHH-1391] - Invalid parameter index SQLException when using named parameters after positional parameters
- * [HHH-1392] - Proxies cannot be serialized after session is closed
- * [HHH-1398] - extends and entity-names broken with mapping-level package attribute
- * [HHH-1407] - return-join broken for entity collections
-
-** Improvement
- * [HHH-1364] - Defensive check of isClosed when obtaining a connection from ConnectionManager
- * [HHH-1367] - warn level log "this operation breaks ==" may be disturbing
-
-** New Feature
- * [HHH-1372] - Support for MySQL5 new varchar length
-
-** Patch
- * [HHH-1005] - Criteria LEFT JOIN capability when adding Order to associations
-
-** Task
- * [HHH-1373] - Document update versioned
-
-
-Changes in version 3.1.1 (01.13.2006)
--------------------------------------------
-
-** Bug
- * [HHH-853] - DML-style HQL queries and associations
- * [HHH-1281] - FORWARD_ONLY ScrollableResults#next() throw GenericJDBCException
- * [HHH-1286] - Set entity in HQL query without prefix -> incorrect SQL
- * [HHH-1308] - Session.createFilter(...).iterate() results in bogus column names for result set extraction
- * [HHH-1314] - float/double literals not sent to the database correctly
- * [HHH-1316] - SchemaUpdate : java.sql.SQLException: You cannot commit during a managed transaction!
- * [HHH-1328] - org.hibernate.util.SimpleMRUCache keeps a soft reference to the cache key, so cached values get collected prematurely
- * [HHH-1336] - ForeignGenerator does not handle transient entities with an entity-name properly
- * [HHH-1337] - Mapped <component> generated column names incorrect with ImprovedNamingStrategy
- * [HHH-1349] - HQL delete statement problem due to oracle lacking table aliases in delete clause
- * [HHH-1361] - creating temporary table for bulk delete will commit current transaction in managed environment such as J2EE
-
-** Improvement
- * [HHH-1019] - Native SQL return-property mapping doesn't support dot-syntax in return-property for components
- * [HHH-1290] - Defensive checking of session status
- * [HHH-1302] - query.getReturnTypes inconsistent
- * [HHH-1304] - better handling of borrowed connections in non-ON_CLOSE release semantics
- * [HHH-1309] - schemaupdate does not handle TableHiLoGenerator
- * [HHH-1339] - empty property name in mapping file gives imcomprehensible error message
- * [HHH-1344] - ANSI-SQL trim function for SQLServer
- * [HHH-1345] - ANSI-SQL mod function for SQLServer
- * [HHH-1346] - ANSI-SQL bit_length function for SQLServer
- * [HHH-1351] - <return-scalar name="blah"/> should be possible
- * [HHH-1360] - set autodiscovery flag for SQLQueries when resultsetmappings are used
-
-
-Changes in version 3.1 (12.12.2005)
--------------------------------------------
-
-** Bug
- * [HHH-849] - Cartesian product + implicit joins
- * [HHH-1065] - user provided connection not usable by default due to agressive release changes
- * [HHH-1101] - associations join fetched in HQL without owner being selected
- * [HHH-1133] - Comparators, defined for collections in mapping files, are not set
- * [HHH-1149] - NPE flushing reattached entity w/ non-mutable natural-id
- * [HHH-1170] - HQL 'cast' function doesn't work with MySQL 4 when casting to string
- * [HHH-1187] - Cannot delete a object having a delete-orphan collection when user_rollback_id is set
- * [HHH-1191] - HQL fails backward compatibility using classic translator
- * [HHH-1194] - hql delete statements with joined-subclass hierarchies with a mapped where attribute at the root
- * [HHH-1206] - Mappings.TableDescription is not serializable
- * [HHH-1212] - mismatch in entity-modes defined in DTD and EntityMode class
- * [HHH-1227] - ClassCastException on DOM4J replicate of Calendar property
- * [HHH-1239] - BinaryArithmeticOperatorNode.getDataType() does not properly handle date/time arithmetic
- * [HHH-1240] - Track connection leakage in JDBCContext.afterTransactionCompletion()
- * [HHH-1245] - Calling the Session should register it with the current JTA txn.
- * [HHH-1254] - Serialization of Sessions using JDBCTransactions with auto-flush/auto-close
-
-** New Feature
- * [HHH-1222] - Autodiscover scalar types in native-sql
- * [HHH-1243] - allow placeholders to system properties in config properties
- * [HHH-1244] - Support for MySQL5 stored procedures
- * [HHH-1260] - Configuration.mergeProperties()
-
-** Task
- * [HHH-1066] - Upgrade CGLIB to fix proxy memory leak
- * [HHH-1242] - upgrade ANTLR to 2.7.6rc1
-
-** Improvement
- * [HHH-860] - insert ... select ... and version numbers
- * [HHH-926] - TypeDef should be global
- * [HHH-1138] - No ConstraintName when using PostgreSQL
- * [HHH-1144] - Implement naming convention for temporary test failures
- * [HHH-1153] - PropertiesHelper fails reading primitive values from hibernate-mapping when doc has whitespace
- * [HHH-1182] - Access to filter metadata
- * [HHH-1183] - Getting sql "plan" for DML operations
- * [HHH-1197] - Support for HQL delete on MaxDB
- * [HHH-1198] - post-insert event pass the entity wo the id field filled when the generator is identity
- * [HHH-1213] - make JACC event listeners auto configurable (through initialize(Configuration))
- * [HHH-1215] - Added support for LVARCHAR in InformixDialect
- * [HHH-1218] - Add concat() function support to SAPDBDialect
- * [HHH-1255] - ThreadLocalSessionContext and Session serialization
-
-** Patch
- * [HHH-967] - executeUpdate on StatelessSession
- * [HHH-1172] - Missing configuration templates for the new MimerSQLDialect
-
-** Deprecation
- * [HHH-1229] - deprecate ability for entities to not define identifier properties
-
-
-Changes in version 3.1 rc3 (17.11.2005)
--------------------------------------------
-
-** Bug
- * [HHH-755] - Setter / Getter for property gDate are wrong
- * [HHH-764] - XML mapping
- * [HHH-1034] - The connection is closed *outside* the JTA transaction in TransactionHelper
- * [HHH-1062] - java:comp/UserTransaction not correct for JBoss
- * [HHH-1064] - Exception using JTATransaction in WebSphere 6
- * [HHH-1069] - Unnecessary commas generated in select with left outer joins
- * [HHH-1075] - New parser "not exists" command bug
- * [HHH-1077] - Typo in docs: "equiped"
- * [HHH-1080] - HQL delete fails on entities with where-fragments using operators other than '='
- * [HHH-1081] - missing parens in example code for Criteria Associations
- * [HHH-1084] - incorrect method name "sql" in Restrictions example, should be "sqlRestriction"
- * [HHH-1091] - Can't write transparent CurrentSessionContext for BMT
- * [HHH-1098] - Patch for build.sh to be able to build latest version on linux
- * [HHH-1106] - HQL "not in" generatad wrong SQL
- * [HHH-1111] - JDBCTransaction.rollback() results in a call to Interceptor.beforeTransactionCompletion()
- * [HHH-1128] - Column alias clashes under certain circumstances
- * [HHH-1146] - latest cvs(11/10/05) hibernate3 issue with classic query
- * [HHH-1156] - StatefulPersistenceContext not serializable when property-ref is used
- * [HHH-1160] - Incorrect use of getGeneratedKey() for Oracle
-
-** New Feature
- * [HHH-449] - korean hibernate reference manual
- * [HHH-1129] - use expected-type in 'untyped' Query.setParameter()
-
-** Improvement
- * [HHH-221] - Proxy for one-to-one with property-ref
- * [HHH-844] - move parameter "bookkeeping" into QueryTranslator
- * [HHH-1051] - "Compiled" native SQL queries are not cached
- * [HHH-1061] - import.sql should allow more human readable and usable files
- * [HHH-1078] - <dynamic-component> requires type on property
- * [HHH-1120] - Make NamingStrategy to work nicely with HA and EJB3 naming strategy
- * [HHH-1142] - added getSelectSequenceNextValString() and getCurrentTimestampSelectString() to TimesTenDialect
-
-** Patch
- * [HHH-1063] - support for 'locate' function in SQLServer and Sybase dialects
- * [HHH-1090] - Allow subqueries on criteria to obtain non-string results
- * [HHH-1095] - Hibernate takes incorrect HasCode when a lot of CompositeKeys and Lazy loading is involved
- * [HHH-1103] - finalize method filter for proxies
- * [HHH-1136] - more meaningful AssertionFailure message in org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(...)
-
-
-Changes in version 3.1 rc2 (17.10.2005)
--------------------------------------------
-** Bug
- * [HHH-1045] - Example contains inner classes that aren't serializable
- * [HHH-1055] - optimistic-lock is not inherited from class to subclass et.al.
-
-** Improvement
- * [HHH-702] - auto detect aliasing for collection properties (coll.key, coll.id etc.)
- * [HHH-1038] - make 'auto' the default for hibernate.connection.release_mode
- * [HHH-1042] - determine "expected type" of parameters during HQL parsing
-
-
-Changes in version 3.1 rc1 (07.10.2005)
--------------------------------------------
-** Bug
- * [HHH-528] - component.manyToOne.id in HQL causes join
- * [HHH-871] - Configuration.setListener(String type, Object listener) throws ClassCastException
- * [HHH-873] - referencing raw HQL FromElement alias outide the from clause of update and delete statements generates incorrect sql
- * [HHH-876] - PreparedStatement being closed before being executed by AbstractBatcher
- * [HHH-884] - SchemaExport does not propagate parent indexes to <union-subclass> tables
- * [HHH-887] - Aggressive release and Session.connection()
- * [HHH-893] - custom tuplizer are not instantiated for components
- * [HHH-905] - $PlaceHolder$ remains in generated SQL when filter is enabled
- * [HHH-907] - optimistic-lock="false" for timestamped object results in SQLException: Invalid column index
- * [HHH-908] - CLONE -NullPointerException when using BigInteger in a query
- * [HHH-911] - CGLIBLazyInitializer and Exceptions
- * [HHH-913] - NPE in CMTTransaction since javax.transaction.Transaction is never set
- * [HHH-918] - impossible to move objects to another session
- * [HHH-924] - Useless OracleErrorCodeConverter (and possibly others)
- * [HHH-932] - HQL UPDATE and <union-subclass>
- * [HHH-946] - QuerySyntaxException might not be serializable
- * [HHH-964] - ORA-00936 with joined subclass / Oracle
- * [HHH-986] - Need to check Thread.currentThread().getContextClassLoader() in ConfigHelper
- * [HHH-991] - Cannot use comparator class
- * [HHH-1000] - varchar(xxx char) not supported on Oracle8i
-
-** New Feature
- * [HHH-950] - interface for SessionFactory.getCurrentSession() handling
-
-
-** Improvement
- * [HHH-608] - update HSQLDialect for HSQL 1.8 sequence support
- * [HHH-889] - Add read-only cache-mode comment in <query and <sql-query
- * [HHH-898] - OracleDialect UTF8 varchar2
- * [HHH-909] - Onquoted primary key in IncrementGenerator
- * [HHH-988] - generated="never|insert|always"
- * [HHH-989] - add discussion of implicit and explcit joins
- * [HHH-1011] - Make disconnect/reconnect of a Session implicit
-
-** Patch
- * [HHH-994] - Sybase/SQLServer support for temporary tables
-
-
-Changes in version 3.1 beta 3 (13.09.2005)
--------------------------------------------
-** Bug
- * [HHH-528] - component.manyToOne.id in HQL causes join
- * [HHH-871] - Configuration.setListener(String type, Object listener) throws ClassCastException
- * [HHH-873] - referencing raw HQL FromElement alias of update and delete statements
- * [HHH-876] - PreparedStatement being closed before being executed by AbstractBatcher
- * [HHH-884] - SchemaExport does not propagate parent indexes to <union-subclass> tables
- * [HHH-887] - Aggressive release and Session.connection()
- * [HHH-893] - custom tuplizer are not instantiated for components
- * [HHH-905] - $PlaceHolder$ remains in generated SQL when filter is enabled
- * [HHH-907] - optimistic-lock="false" for timestamped object results in SQLException: Invalid column index
- * [HHH-908] - NullPointerException when using BigInteger in a query
- * [HHH-911] - CGLIBLazyInitializer and Exceptions
- * [HHH-913] - NPE in CMTTransaction since javax.transaction.Transaction is never set
- * [HHH-918] - impossible to move objects to another session
- * [HHH-924] - Removed ErrorCodeConverters
- * [HHH-946] - QuerySyntaxException might not be serializable
-
-** Improvement
- * [HHH-898] - OracleDialect UTF8 varchar2
- * [HHH-909] - Unquoted primary key in IncrementGenerator
-
-
-Changes in version 3.1 beta 2 (16.08.2005)
--------------------------------------------
-** Bug
- * [HHH-477] - Boolean discriminators generate invalid SQL for PostgreSQL dialect
- * [HHH-480] - SchemaExportTask ignores some properties not defined in hibernate.properties
- * [HHH-615] - SchemaExport outputFile ignores ant's basedir
- * [HHH-770] - hql query execution generates invalid SQL
- * [HHH-779] - Assertion failure occured with Hibernate 3 saving objects
- * [HHH-781] - SimpleExpression ignorecase regression
- * [HHH-799] - merge() and embedded composite identifiers
- * [HHH-801] - subselect fetch and named parameters
- * [HHH-802] - querying "mapped" composite identifiers
- * [HHH-803] - no version increment from delayed collection adds
- * [HHH-805] - Session.getStatistics().getEntityCount() throws UnsupportedOperationException
- * [HHH-819] - Firebird CONCAT SQL function
- * [HHH-821] - query by natural-id cache is not update when object is inserted or deleted
- * [HHH-822] - <key-property> will actually pick up <type> tags if it were allowed by the DTD
- * [HHH-825] - ReadWrite-Cache issues NullPointerException after modification of an array
- * [HHH-839] - Session.refresh not working for custom 'Load' SQL
- * [HHH-849] - Cartesian product + implicit joins
- * [HHH-854] - Class with mapped composite id can't have subclasses
- * [HHH-858] - Autocommit status inconsistent in connections created by DriverManagerConnectionProvider
- * [HHH-863] - Hibernate generates "notExists" instead of "not exists"
- * [HHH-868] - Missing parens after / or -
-
-** New Feature
- * [HHH-35] - add attribute haltonerror to schemaexport Ant task
- * [HHH-182] - Mimer SQL Dialect for Hibernate 3
- * [HHH-704] - Statistics for optimistic lock failures
- * [HHH-725] - Allow hooks into all executed sql by a session
- * [HHH-783] - collection lazy="extra"
- * [HHH-818] - Optimisitc locking using database current timestamp
- * [HHH-828] - session.getTransaction()
- * [HHH-829] - <cache include="all|non-lazy" ... />
- * [HHH-831] - allow database generated property values
- * [HHH-832] - allow database generated property values for versioning
- * [HHH-838] - Transaction.setTimeout()
- * [HHH-840] - allow definition of "auxiliary" database objects in mapping
- * [HHH-846] - Add Intializable interface for events
- * [HHH-848] - Validate mappings against JDBC metadata
- * [HHH-859] - post-commit events
-
-** Improvement
- * [HHH-133] - schemaexport task: provide independent drop/create output
- * [HHH-135] - parameterized types can't be used on key-property or ir (possible others)
- * [HHH-552] - NoopAccessor for HQL-only properties
- * [HHH-680] - Easier support for doing UserCollectionType's
- * [HHH-686] - Final classes and classes with private null ctors cause unhelpful NullPointerException
- * [HHH-754] - Allow HQL DML for implicit polymorphism
- * [HHH-782] - Avoid unnecessary updates when component property is update='false' but modified
- * [HHH-786] - Improve lazy options for <one-to-one>
- * [HHH-791] - Use cascade styles when fetching entities in refresh() and merge()
- * [HHH-815] - Confusing use of the term "dereference"
- * [HHH-830] - Improvements to caching lazy properties
-
-** Patch
- * [HHH-378] - Better LockMode.UPGRADE for DB2 UDB v8.2
- * [HHH-430] - Improved SizeExpression with greater, lesser, not equals, etc. capabilities
- * [HHH-735] - SchemaUpdate reads table metadata from wrong schema
- * [HHH-780] - org.hibernate.proxy.BasicLazyInitializer reflection hotspot
- * [HHH-864] - Use QUERY_CACHE for sessions with filters to improve performance
-
-
-Changes in version 3.1 beta 1 (21.07.2005)
--------------------------------------------
-
-** Bug
- * [HHH-145] - union-subclass and oracle 8i
- * [HHH-374] - EJB3 example delete query doesn't work in Hibernate.
- * [HHH-447] - EHCache integration prevents multiple session factories
- * [HHH-488] - JACCListeners are not working at all
- * [HHH-564] - missing commas for implicit joins
- * [HHH-577] - joins within subqueries on dbs supporting ansi-joins result in extraneous commas
- * [HHH-592] - cast() function doesn't know its returned Hibernate type
- * [HHH-639] - CGLIB instrumentation of subclasses
- * [HHH-658] - Bug in Alias Name Generation
- * [HHH-671] - Firebird support of sequences/generators
- * [HHH-679] - setLockMode(LockMode.UPGRADE_NOWAIT) does not translate to correct SQL on Oracle
- * [HHH-688] - Bad implementation in org.hibernate.type.CustomType.stringToObject
- * [HHH-691] - generated column alias is incorrect if there is a prior relationship and the table column names are similar to the table name
- * [HHH-694] - NPE when accessing the SLCache stats with TreeCache
- * [HHH-698] - Exception on EG , trying to change immutable id (natural-id)
- * [HHH-699] - Incorrect Tablename genetaion when using MySQL Dialect and no Schema definition
- * [HHH-708] - Restrictions.in could not be used properly on composite-ids
- * [HHH-709] - ArrayType.replaceElements fails if original.length != target.length
- * [HHH-718] - HQL "fetch all properties" not working for column level lazy props
- * [HHH-726] - ConstraintViolationException with primitive collection
- * [HHH-727] - java.lang.StackOverflowError when cascade="true" on both sides of bidirectional one-to-one association using FK
- * [HHH-734] - HQL incorrectly parses certain query strings
- * [HHH-736] - Use of sql functions containing space not supported in filter conditions
- * [HHH-738] - formula property with select-before-update
- * [HHH-747] - Order.toSQLString generates incorrect statement
- * [HHH-748] - component dereferencing in subquery from clauses
- * [HHH-752] - Typo in 8.5.3 bidirectional one-to-one jjoin table example
- * [HHH-757] - NullPointerException when using BigInteger in a query
-
-** New Feature
- * [HHH-595] - HQL insert select
- * [HHH-597] - Named XML resultsetmappings
- * [HHH-696] - handle discriminators on HQL insert
- * [HHH-697] - allow bumping versions in HQL update
- * [HHH-716] - handle version columns in bulk inserts
- * [HHH-723] - Need to be able to pass in javax.sql.DataSource in SF creation
- * [HHH-739] - Order.ignoreCase()
- * [HHH-741] - select clause subselects
- * [HHH-742] - Stateless session
- * [HHH-744] - collection fetching in scroll() via "break processing"
- * [HHH-768] - <many-to-many property-ref=".."/>
-
-** Improvement
- * [HHH-14] - Add Session.delete(String entityName, Object entity)
- * [HHH-295] - cleanup and expose the Tuplizers
- * [HHH-352] - HQL bulk and cache
- * [HHH-689] - exclude parens for components outside where-clause
- * [HHH-743] - {coll.key}, {coll.index}, {coll.element}, etc
- * [HHH-745] - EJB3 composite PK style
- * [HHH-749] - Cascade merge() and unidirectional one-to-many
- * [HHH-750] - use attribute name other than 'type' in dynamic-maps
- * [HHH-753] - Replace antlr System.exit with QueryException
- * [HHH-769] - property-ref="foo.bar" to a component property
- * [HHH-772] - null in maps are handled inconsistently
- * [TODO-18] - optimistic-lock="all|dirty" with components
-
-
-Changes in version 3.1 alpha 1 (24.06.2005)
-------------------------------------
-** Bug
- * [HHH-204] - Wrong/uncommon log name in class ...hql ast ErrorCounter
- * [HHH-241] - HQL lexer doesn't support unicode quoted strings
- * [HHH-354] - property named "full" breaks HQL queries
- * [HHH-493] - WARNING: Keyword 'member' is being intepreted as an ident
- * [HHH-538] - length() function does not work in SQLServerDialect
- * [HHH-539] - ClassCastException on mapping a property with a formula in a set of composite elements
- * [HHH-540] - Mapping a one-to-many collection with a non-null foreign key within a component fails on save
- * [HHH-547] - Cannot commit using UserCollectionType and debug logging
- * [HHH-548] - many-to-many faulty delete optimization when filter in use
- * [HHH-554] - Hibernate 3 HQL to SQL FROM Clause Comma Generation Problem
- * [HHH-558] - HQL doesn't support multi-byte character in class name and property names
- * [HHH-559] - quoted multi-byte character in HQL is translated into weird character in SQL.
- * [HHH-565] - delete-orphan generating AssertionFailure
- * [HHH-566] - The result is not correct in 'createQuery("select new Foor(x,x) from Foo").scroll()'
- * [HHH-570] - size operator fails on a many to many in HQL
- * [HHH-571] - JDK 1.3 Compatibility Issue
- * [HHH-573] - error when merging entity graph has cascade level>2
- * [HHH-575] - org.hibernate.cache.FilterKey is not Serializable
- * [HHH-589] - parameterized expression inside function
- * [HHH-594] - order-by mapping for collections overrides order by in HQL
- * [HHH-601] - New temporary table feature assumes all persisters are ready
- * [HHH-614] - SchemaUpdate broken in DB2/400
- * [HHH-622] - Spelling mistake 'intepreted' in org.hibernate.hql.PARSER warning
- * [HHH-642] - criterias with projection
- * [HHH-650] - FilterImpl is Serializable yet FilterDefinition is not
- * [HHH-657] - Date parse exception using EntityMode.DOM4J
- * [HHH-666] - JTAHelper.isInProgress( txn.getStatus()) throws NPE when txn null
-
-** New Feature
- * [HHH-620] - Extra join conditions in HQL
- * [HHH-640] - short-circuit dirty checking for instrumented classes
- * [HHH-643] - support mutable="false" for collections
- * [HHH-645] - Session.setReadOnly()
- * [HHH-549] - portable to_char() function
- * [HHH-576] - Hook to pre-process generated select strings in the Dialect
- * [HHH-662] - Add support for definition of functional composite key ("properties") in joined subclass
-
-** Improvement
- * [HHH-46] - Allow access to properties that are not joined
- * [HHH-261] - Stored procedure support for SQLServer dialects
- * [HHH-351] - multi-table bulk operations
- * [HHH-574] - improve in naming named-query
- * [HHH-596] - Auto-detect {..} in native SQL queries
- * [HHH-641] - create constraints for many-to-one property-ref
- * [HHH-501] - warn when a final method is tried to be proxied
- * [HHH-525] - cglib related startup performance
- * [HHH-557] - Helpful error message for non Serializable classes with a composite-id
- * [HHH-586] - check immutable natural-ids
- * [HHH-609] - Adds substr to PostgreSQL dialect
- * [HHH-618] - documentation bugs
-
-** Patch
- * [HHH-224] - JDataStore Dialect and updated Testfiles
- * [HHH-366] - InformixDialect SQLExceptionConverter
- * [HHH-536] - ImprovedNamingStrategy modifies capitalized column names inappropriately
- * [HHH-632] - Informix Dialect missing from automatic dialect discovery
- * [HHH-4] - CachedFile bugfix + configuration + autodetect resource as file
-
-
-Changes in version 3.0.5 (25.5.2005)
-------------------------------------
-
-** Bug
- * [HHH-516] - Interceptor.onFlushDirty() sometimes not called
- * [HHH-517] - getDatabaseMajorVersion() not available in JDK 1.3
- * [HHH-518] - SQL parser does not recognize all whitespace
- * [HHH-519] - broken SQL when traversing many-to-many to joined <subselect>
- * [HHH-529] - Bug in merge()
-
-** New Feature
- * added <natural-id> mapping
- * [HHH-533] - allow unique-key on <property> and <many-to-one>
- * [HHH-534] - efficient cache by natural key
- * support for <comment> on MySQL
-
-** Improvement
- * [HHH-526] - log "Aggressively releasing JDBC Connection" as DEBUG instead of INFO
- * various logging improvements
-
-
-Changes in version 3.0.4 (23.5.2005)
-------------------------------------
-
-** Bug
- * [HHH-452] - UnsavedValueFactory.instantiate does not wrap the Exception it catches
- * [HHH-456] - Session still holds references to entities after close()
- * [HHH-457] - Log info for structured second-level cache entries is incorrect
- * [HHH-466] - Made default for MS SQL dialect definition more flexible
- * [HHH-473] - Formula can't contain SQL cast keyword
- * [HHH-484] - Order-by not applied to collections fetched by OuterJoinLoader
- * [HHH-487] - Possible empty union in UnionSubclassEntityPersister
- * [HHH-505] - Possible NullPointerException in BigIntegerType
- * [HHH-507] - Cached List does not show additions
- * Fixed bugs in subselect fetching
-
-** New Feature
- * [HHH-455] - Obtain non-intercepted Session by passing an EmptyInterceptor
- * [HHH-467] - HQL: support for case when then else end IN select clause
- * [HHH-485] - Support multiple collection join fetches (attention: Cartesian product) in native SQL queries
- * Added SessionStatistics metric interface
- * Added support for table and column level <comment> blocks
- * Added Simplified Chinese translation of reference documentation (Xiaogang Cao)
-
-** Improvement
- * Any query may now join fetch >1 collection role (attention: Cartesian product)
- * [HHH-454] - Add 2292 integrityViolationCode to Oracle9Dialect
- * [HHH-503] - Implemented ViolatedConstraintNameExtracter for HSQLDialect (Frank Grimes)
-
-
-Changes in version 3.0.3 (8.5.2005)
------------------------------------
-* fixed bug in HQL for composite key classes which have a property named the same as the owning entity's id property
-* replaced 'connection.aggressive_release' with 'hibernate.connection.release_mode'
-* added ConnectionReleaseMode
-* added eager fetch for any associations with fetch=join, even after a HQL query, or cache retrieval (EJB3)
-* added replicate() isUpdate flag to OnReplicateVisitor, useful for native ids
-* fixed ParameterizedTypes order of initialization
-* fixed bug in DB2Dialect
-* fixed EntityMode.DOM4J creation of duplicate <set> output
-* fixed JDBCException error code handling
-* fixed Criteria Restrictions.isEmpty()/isNotEmpty() when collection is mapped to superclass
-* fixed HQL indexed collections access with no alias
-* fixed HQL aggregate functions on components when "id" property is used
-* fixed issue with non-cascading refresh to collections
-* fixed query-timeout not being applied to bulk HQL (Stephan Fudeus)
-* fixed pessimistic locking with Firebird (Yuichi Sugimura)
-* updated Ant 1.6.3
-* improved validation of sql queries, throw QueryException if addEntity() nor addScalar() was called
-* added automatic dialect detection if no dialect is configured
-* added new tutorial (Michael Gloegl, Christian Bauer)
-
-
-Changes in version 3.0.2 (27.4.2005)
-------------------------------------
-* fixed union operations on PostgreSQL
-* fixed HQL concat() function for Oracle dialect
-* fixed auto-close/auto-flush during getCurrentSession() processing
-* fixed ClassCastException with EntityMode.DOM4J
-* fixed HQL dynamic instantiation with iterate()
-* fixed HQL bug with missing parantheses and implicit joins
-* fixed bug were Interceptor.getEntity() wasn't called if in cache
-* fixed bug in merge() of sorted sets
-* fixed bug in EntityMode.DOM4J with non-lazy embedded many-to-ones
-* fixed Criteria/Projection ordering bug
-* fixed HQL referencing component attribute
-* fixed column duplication detection for components
-* fixed eager fetching for many-to-many associations
-* fixed stack overflow with auto_close_session and aggressive_release and unclosed ScrollableResults/HibernateIterator
-* fixed bug in HQL parser regarding naked property refs which reference component properties
-* fixed bug with eager fetched arrays not being loaded
-* fixed bug in filter against joined-subclass
-* improved CacheMode.GET/IGNORE, disabled cache put
-* improved HQL support for standard SQL functions, including coalesce() and nullif()
-* improved filtering of many-to-many associations
-* added HQL support for cast(x as type) if SQL database supports it
-* added increment id generation for union-subclass
-* added ConnectionProvider.supportsAggressiveRelease() for managed environments
-* added support for caching of queries if filter is enabled
-* added PreparedStatement count to Statistics
-* added transactional/nontransactional read()/get() to Cache API
-* added quotation of schema names
-* added Distinct to Projection API
-* added config parameter 'connection.aggressive_release'
-
-Changes in version 3.0.1 (18.4.2005)
-------------------------------------
-* added HQL tuple constructor/comparison feature
-* added HQL "fetch all properties" override if instrumentation is used for lazy loading
-* added HQL projection feature, return Lists instead of arrays for projection
-* added HQL projection feature, return Maps with user-defined HQL SELECT aliases as keys
-* added HQL support for expressions in aggregation functions
-* added new IntegrityViolationException to MySQL dialect
-* added value mapping type 'big_integer'
-* added not-found="ignore|exception" switch for legacy associations (i.e. broken database integrity)
-* added fully automatic Session scoping in JTA environments with sf.getCurrentSession()
-* fixed bug in DTD that wouldn't allow union-subclass in separate file
-* fixed a MS SQL Server case sensitivity issue with native SQL queries
-* fixed a minor bug in subselect fetching
-* fixed case sensitivity in HQL functions
-* fixed a bug with listener assignment for save() operation (Matthew Inger)
-* fixed return-property in named SQL queries to work with all identifier names
-* fixed TransactionManager lookup (again) for WAS 6.0
-* fixed a bug with HQL batch delete and MS SQL Server
-* fixed session not getting closed with auto_close when rollback occured
-* improved concatentation handling in AST parser
-* updated dom4j to avoid memory leak in old version
-* updated C3P0
-
-
-Changes in version 3.0 (31.3.2005)
-----------------------------------
-* added support for autoflush/autoclose to HibernateServiceMBean
-* fixed initialization/session association detection problem of collections
-* fixed creation of FK constraints to union superclass table
-* fixed bug where union-subclass table did not get a PK constraint
-* added a separate log category for HQL parser warnings and errors
-* fixed bulk delete operation on MS SQL Server
-* added support for proxying protected methods (Juozas)
-* added support for unicode quoted strings in new HQL parser
-* fixed implied joins in subselect WHERE clause in new HQL parser
-* added SQLServer7Dialect to handle differences in functions
-* added support for JNDI-bound cache instances, future use for JBoss Cache
-* added scale attribute to column mappings for numeric precision control
-* added fetch=subselect for collections
-* added support for bulk update/delete against discriminator-based inheritence hierarchies
-* added the ability to use naked property refs in HQL (required in update/delete statements)
-* updated CGLIB 2.1.0
-* fixed NPE at BasicEntityPersister.getPropertyIndex (Todd Nine)
-* fixed issue with entity-name and subclasses (Sverker Abrahamsson)
-* fixed issue with correlated subqueries in new HQL parser
-* fixed a problem with native SQL query mapping and embedded composite identifiers
-* improved mapping binding, allowing unordered extends for pure entity-name hiearchies
-* fixed NPE for delete() with deprecated Lifecycle interface
-* fixed a problem with serial joins ending in component value in new HQL parser
-* fixed inner join/subselect precedence problem in new HQL parser
-* fixed indices() function in new HQL parser
-* fixed a bug in InformixDialect, now correct LIMIT clause
-* fixed a bug in idbag.remove() (Sebastien Cesbron)
-* fixed a conflict on OracleDialect between setMaxResult and LockMode.UPGRADE
-* fixed XML configuration file issue with SchemaExport
-* fixed an ArrayIndexOutOfBounds problem
-* renamed executeUpate() to executeUpdate()
-* fixed batch loading for property-ref entities
-* fixed loading from cache of <key property-ref> collection owner
-* fixed minor bug in SQL exception reporting
-* fixed dynamic-component cannot be bound to XML
-* fixed querying component with formula property
-* fixed incorrect table alias for order-by on many-to-many
-* fixed a bug for unidirectional one-to-many with moving child objects
-* fixed a bug with union-subclasses and persister creation
-* fixed a HQL concatenation problem on MySQL
-* fixed a bug where an unnecessary exception was thrown for a property-ref to a superclass property
-* fixed minor dtd bug
-* fixed new bug in Clob/Blob support
-* fixed issue with INDEX_OP and subclass joins on theta-join dialects
-* fixed some minor issues in query cache regions, including HB-1449
-* fixed superflous import and regression bug in verifyparameters
-* fixed two bugs in select id generator (Malcolm Green)
-* fixed increment generator for union-subclass mappings
-* updated JBoss Cache to 1.2.1alpha, fixing locking issues
-* made stat classes serializable
-* fixed merge(), now ignores blob and clob fields
-* added support/dialect for TimesTen
-* improved algorithm for batch fetching, more aggressive
-* improved toStrings()s for Statistics objects (Ryan Lynch)
-* renamed <result-*> to <return-*> for externalized SQL query mapping
-* renamed Session.openSession() for EntityMode to Session.getSession()
-* added support for CASE in HQL
-* fixed bug with filters and polymorphic queries
-* fixed import ordering problem of super/subclass mappings
-* switched to patched ANTLR 2.7.5, now using context classloader before doing class.forname
-* TableHiloGenerator now falls back to TableGenerator properly with max_lo < 2 (Emmanuel Bernard)
-* better transaction handling of TableGenerator in a JTA environment (Emmanuel Bernard)
-* removed hard coded log4j dependency (Emmanuel Bernard)
-* added support for stored procedure in named queries (Max Andersen)
-* added <property-result> to named SQL queries to allow users to use sql without {}-markup
-* added multi-column property support to native SQL mapping
-
-Changes in version 3.0rc1 (28.2.2005)
-----------------------------------
-* introduced EntityModes, and XML mapping preview
-* several minor dialect improvements
-* fixed a problem where filters were not applied to subclasses
-* fixed a problem where InstrumentTask would fail if applied to already-instrumented classes
-* fixed many problems with new parser and made it the default (thanks again to Joshua for the new parser)
-* implemented bulk update/delete queries for the new parser
-* fixed a minor bug in the classic query parser
-* renamed create() to persist() as per EJB3edr2
-
-Changes in version 3.0 beta 4 (11.2.2005)
------------------------------------------
-* support unidirection one-to-many with a not-null foreign key
-* support formulas for index and element of collections
-* support one-to-ones mapped to formulas
-* fixed a bug in proxying methods that return "this"
-* optimized proxies for embededded composite id classes
-* fixed a bug affecting <key-many-to-one>
-* fixed a bug caching newly inserted objects
-* introduced DetachedCriteria
-* support subselects in Criteria queries
-* miscellaneous Criteria API enhancements
-* fixed a problem where hibernate.max_fetch_depth applied to eager fetching via setFetchMode()
-* use inner joins for join fetching not-null fk associations
-* support unique="true" in <component> and <properties> mappings
-* union-subclass hierarchies may own collections (dtd bug)
-* added guid support for Oracle
-* new mechanism for auto-detecting unsaved-value
-* pass state array in delete events
-* improved implementation of hibernate.auto_close_session and hibernate.close_before_completion
-* fixed a bug where components with only collections would be incorrectly nullified
-* fixed a bug where criteria queries with projection could not be cached
-* fixed a problem where duplicate column name aliases could be generated
-
-Changes in version 3.0 beta 3 (30.1.2005)
-------------------------------------------
-* Major rework of Criteria queries, support for projection, grouping, aggregation, ordering by any attribute
-* various improvements to new HQL parser (Joshua Davis)
-* fixed a bug where <join fetch="select"> was broken for subclasses with duplicated property names
-* fixed problems with long types in Oracle DDL generation
-* added EnhancedUserType, UserCollectionType, UserVersionType
-* added CacheMode
-* fixed minor performance problem where cascade delete could add objects to second-level cache
-* added hibernate.default_batch_fetch_size
-* added hibernate.cache.use_structured_entries
-* different classes and collection roles may now share a cache region
-* don't include discriminators for abstract classes in generated SQL
-* it is no longer truly necessary for composite identifier classes to implement equals()/hashCode() (but still recommended)
-* workaround for bug in MySQL InnoDB with self-referential foreign keys
-* added lazy="true" to many-to-one and one-to-one mappings (requires bytecode instrumentation)
-
-Changes in version 3.0 beta 2 (24.1.2005)
-------------------------------------------
-* added LockAcquisitionErrorCodes to MySQL dialect (Jesse Barnum, Emmanuel Bernard)
-* added MultipleHiLoPerTableGenerator, one hi value per row/per table (compliant with EJB3)
-* added a generator handling multiple hi values per table (Emmanuel Bernard)
-* added events for pre/post SQL operation interception
-* added experimental support for JACC-aware configuration and events
-* added full support for implicit polymorphism in Criteria queries
-* added support annotated classes through XML configuration (Emmanuel Bernard)
-* added support for WebSphere's weird TxManagerLookup
-* added support for filters with dynamic-class mappings
-* added support for lists of parameters in filters
-* added support for scalar queries in createSQLQuery (Michael Gloegl)
-* added support for scalar results in native SQL queries (Michael Gloegl)
-* fixed SchemaExport/SchemaUpdate, now respect default_schema and default_catalog (Michael Gloegl)
-* fixed a bug in one-to-one mapping with property-ref
-* fixed a bug in the query cache lookup routine
-* fixed compilation problems on IBM JDK 1.4. and JDK 1.3.1
-* fixed custom SQL for loading when using composite identifiers
-* fixed exception thrown from optimistic locking failures
-* fixed support for limit queries (select first ?) in Informix
-* improved SchemaExport/Update, now respect default_schema and default_catalog
-* improved dialect handling, throw an exception if no dialect has been set
-* improved loading of mappings, no ordering of super/subclasses required anymore
-* improved statistics for second-level cache
-* improved table generators for hi/lo, can now be used in a JTA environment (Emmanuel Bernard)
-* query engine: added support for 'trim([leading | trailing | both] [expression from] expression)'
-* query engine: added support for DISTINCT and ALL
-* query engine: added support for FETCH
-* query engine: added support for HAVING count()
-* query engine: added support for HQL NOT IN and EJBQL '[NOT] MEMBER OF'
-* query engine: added support for ORDER BY COUNT(*)
-* query engine: added support for collections of scalar values
-* query engine: added support for literals in constructor select expressions.
-* query engine: added support for select elements(..) from Foo f
-* query engine: added support for template functions in the SELECT clause
-* query engine: fixed NOT LIKE
-* query engine: introduced EMPTY and added it to constant (support for IS [NOT] EMPTY)
-* updated dom4j, OSCache, EHCache, JBoss Cache, Xerces, Xalan, and Log4j
-* associated class where filter now applies to <one-to-one property-ref>
-
-Changes in version 3.0 beta 1 (21.12.2004)
-------------------------------------------
-* reimplemented HQL using an ANTLR-based AST parser (Joshua Davis)
-* added class="select" id generator
-* added Query.setReadOnly()
-* added hibernate.order_updates
-* introduced cascade refresh
-* added typed JDBC exceptions (Steve Ebersole)
-* improved lifecycle for CacheProviders (Steve Ebersole)
-* added Expression.isEmpty()
-* fixed some minor mapping DTD bugs (Ben Sommerville)
-* fixed auto-commit mode for SchemaUpdate
-* added default-lazy to <hibernate-mapping>, which defaults to true!
-* added fetch="join|select" and deprecated outer-join attribute
-* fixed a bug where <custom-insert> was not used for entities with "identity" id generation
-* fixed some problems with dynamic-class
-* added property-level optimistic-lock attribute, to allow an unchecked property
-* cascade lock() now cascades with LockMode.NONE
-* fixed some bugs in filter handling (Steve Ebersole)
-* added hibernate.transaction.flush_before_completion and hibernate.transaction.auto_flush_session
-* added JSR-220 compliant create() and merge() operations
-* cascade attribute is now multi-valued, with values save-update,create,merge,delete,delete-orphan,lock,evict,replicate,all-delete-orphan
-* index and unique-key attributes may now be multi-valued
-* introduced unsaved-value="undefined", the default for "assigned" ids and <composite-id>, which forces Hibernate to hit the db
-* primitive typed <id> property mappings now default to unsaved-value="0"
-* added ScrollMode
-* added dialect for Derby (Simon Johnston)
-* added MySQLMyISAMDialect and MySQLInnoDBDialect
-* added precision and scale mapping attributes, for numeric types in DDL
-* fixed a problem with duplicate column mappings on Sybase
-* read-write cache now uses version numbers to ensure consistency with database, if available
-* native SQL queries may now fetch a collection role (Steve Ebersole)
-* added sequential-select, optional and inverse attributes to <join/>
-* added <properties> element, which can be the target of a property-ref
-* fixed a bug relating to composite property-refs
-* Hibernate now much more robust if user does not implement equals()/hashCode() on id and unique key classes
-* enabled batch deletes for versioned data
-* fixed a minor bug in Session.close()
-* removed uuid.string and renamed uuid.hex to plain uuid
-* workaround for a MySQL bug in SchemaUpdate
-* added JDBCException.getSQL() and made various improvements to exception flow
-* createSQLQuery() now fully supports components
-* fixed a bug in SQL generation for <joined-subclass> mappings
-* fixed a bug where filter and query parameters could be bound in the wrong order (Steve Ebersole)
-* fixed a problem where quantifiers could not appear in SQL fragments
-* fixed a bug with dynamic components
-* fixed a bug where Dialect default properties overrode user-specified properties (Ben Sommerville)
-* fixed a bug where duplicate column name in a joined table caused an exception
-* implemented two-phase load for dynamic components
-* fixed a bug where cancelQuery() canceled a re-pooled statement
-* deleted collections are now removed from session-level cache
-* fixed a bug in LocaleType (Steve Ebersole)
-* use "with rr" to obtain UPGRADE locks in DB2
-* package attribute now significant for extends
-* fixed a minor problem with Hibernate Clobs and Blobs
-* extends attribute does no longer require specific ordering of mapping files
-
-Changes in version 3.0 alpha (23.8.2004)
-----------------------------------------
-* package rename net.sf.hibernate -> org.hibernate
-* checked exceptions are now runtime exceptions
-* some session methods deprecated and moved to org.hibernate.classic.Session
-* removed various deprecated functionality
-* added Filter API and mappings, for temporal, regional and permissioned data (Steve Ebersole, Gavin King)
-* support cascade delete via ON DELETE CASCADE constraint
-* added extra attributes to named query definition
-* added hibernate.use_identifier_rollback
-* added subselect mappings
-* added lazy="true" to property mappings
-* added <join/> for multitable mappings
-* added <union-subclass/> for table-per-concrete-class strategy
-* added Statistics API and JMX MBean (Gavin King, Emmanuel Bernard)
-* introduced new event-driven design (Steve Ebersole)
-* support for faster startup with Configuration.addCachableFile() (Joris Verschoor, Max Andersen)
-* mask connection password for log level greater of equals to info (Joris Verschoor, Emmanuel Bernard)
-* add check of named queries when building SessionFactory (Joris Verschoor, Emmanuel Bernard)
-* added custom EntityResolver setting capability (Emmanuel Ligne, Emmanuel Bernard)
-* PropertyValueException for null values in not-null properties of components (Emmanuel Bernard)
-* enhanced support for single- and no-argument sql-functions in HQL select clause (Michael Gloegl)
-* Added catalog element, to enable table names like catalog.schema.table (Michael Gloegl)
-* Added <sql-insert>, <sql-update> and <sql-delete> support (Max Andersen)
-* Support callable statements (stored procedures/functions) via callable="true" on custom sql (Max Andersen)
-* Added support for type parameters and typedefs (Michael Gloegl)
-* Added support for JDBC escape sequences in createSQLQuery (Max Andersen)
-* Added statistics per SessionFactory (Gavin King, Emmanuel Bernard)
-* Added a StatisticsService MBean for JMX publucation (Emmanuel Bernard)
-* support for updates via rownum in Oracle
-* fixed problems with SchemaUpdate
-* support for <column formula="..."/>
-* added hibernate.use_sql_comments
-* added property-ref to collection <key/>
-* fixed performance problems with <one-to-one property-ref=.../>
-* enhanced UserType with new methods assemble()/disassemble()
-* better algorithm for batch fetch batch sizes
-* added <dynamic-class>
-* added entity-name concept, and session methods save(entityName, object), update(entityName, object), etc
-* added framework in proxy package
-* native SQL queries may now fetch a collection role
-* added <loader/> for class and collection mappings
-* added getEntity() and getEntityName() to Interceptor
-* formula-based discriminators and association mappings
-* added "guid" id generation strategy
-* various improvements to dialects
-* <discriminator force="true"/> now acts as a filter on collections
-* where filters now apply in the on clause in an outer join
-* added hibernate.jdbc.factory_class to select a custom batcher
-* session now uses entity name + id to enforce uniqueness, instead of table name + id
-
-Changes in version 2.1.6 (9.8.2004)
-------------------------------------
-* fixed Quickstart/readme.txt instructions
-* fixed DB2/400 identity column support
-* fixed the scroll() query method
-* fixed exotic classloader problems with CGLIB
-* added insert="false" for discriminator columns which are part of a composite identifier
-* added several new configuration settings to JMX HibernateService
-* added new instantiate() method to SessionFactory.getClassMetadata()
-* improved the HSQL DB dialect with features from new version
-* added hibernate.jdbc.batch_versioned_data (Steve Ebersole)
-
-Changes in version 2.1.4 (2.6.2004)
-------------------------------------
-* improved Session serialization support by adding ability to serialize unflushed sessions (Steve Ebersole)
-* fixed Session.clear() functionality to clear the internal nonExists cache (Steve Ebersole)
-* much better implementation of scroll() (Steve Ebersole)
-* support "select new ..." for iterate() and scroll() (Steve Ebersole)
-* added support for multi-parameter SQL functions (Steve Ebersole)
-* fixed hbm2ddl generating infinite indexes on MySQL (Michael Gloegl)
-* fixed alias precedence in HQL queries, function names are second (Steve Ebersole)
-* added "transactional" as allowed cache concurrency strategy in XML configuration file
-* improved System.getProperties() with security exception warning in secure environments
-* improved Proxool integration, better property handling
-* fixed problem with use of getDefinedMethod() in secure environments (Ken Arnold)
-* fixed bug in createSQLQuery() which prohibited multiple aliases for the same entity (Max Andersen)
-* fixed query cache misses when using named bind parameters (Michael Greer)
-* recognize "left" and "right as keywords in SQL fragments
-* recognize SQL quoted identifiers in SQL fragments
-* improved identity handling on SQL Server by using scope_identity() for update counts (Arthur Fitt)
-* added DB2390Dialect for DB2/390 databases (Kristoffer Dyrkorn)
-* fixed a bug in toArray() of identifier bag collections (Khachchou Mohammed)
-* fixed a problem with DDL generation for serial columns in Informix
-* fixed a problem with DDL generation for timestamp columns in Informix (Michael Schmidt)
-* fixed a NPE that occurred calling saveOrUpdateCopy() for components
-* fixed a bug with replicate() and uninitialized collections
-* fixed a bug caching one-to-one associations
-* fixed eviction from named query cache regions
-
-Changes in version 2.1.3 (25.4.2004)
------------------------------------
-* added SELECT-clause SQL function support to main Dialects
-* fixed a problem where some unnecessary selects where issued for optional one-to-one associations
-* fixed a bug in SQL generation for criteria queries with multiple one-to-many joins
-* deprecated everything related to PersistentEnum
-* fixed an NPE that occurred when using <one-to-one property-ref> with composite ids
-* fixed a problem with JCA adaptor on WebLogic (Michael Gloegl)
-* improved behavior when removing elements from <idbag>s
-* fixed a bug in getGeneratedKeys() support (Michael Gloegl, Kevin Day)
-* fixed a bug when using Criteria queries with collections of joined-subclasses
-* fixed an NPE that occurred when calling comparator() on a lazy sorted set (Attila Szegedi)
-* fixed a bug when using setMaxResults() with native SQL queries in some Dialects
-* validate that composite id classes override hashCode() (Adrien)
-* fixed some minor problems with saveOrUpdateCopy()
-* fixed some problems in OSCache provider
-* fixed an NPE that occurred when calling a lazy collection after evicting from session
-* fixed an NPE that occurred when select-before-update is used with unversioned data (Patrick Peralta)
-* fixed a bug where dynamic-components could not be queried (Massimo Ferrari)
-* SQL formula parser now recognizes all Dialect-specific SQL functions (Anthony Patricio)
-* fixed a problem where SQL CASE statements could not appear in SQL formulas
-* fixed a problem where subselects with joins could not appear in SQL formulas
-* C3P0 and Proxool pools now cleaned up after SessionFactory.close()
-* fixed a bug where dirty checking of mutable properties was broken after lock()
-* fixed a minor bug where orphan delete was broken for newly saved instances
-* added Query.setFetchSize() and Criteria.setFetchSize()
-* PreparedStatement pooling in DBCPConnectionProvider can now be disabled (Emmanuel Bernard)
-* Query.setProperties(Object) now detects array and collection valued properties and delegates to Query.setParameterList() (Max Andersen, Nick Heudecker)
-* lengths of positional parameters and types arrays are now validated
-* fixed an obscure problem where a PreparedStatement was not closed
-
-Changes in version 2.1.2 (4.2.2004)
------------------------------------
-* added Session.isDirty()
-* fixed a very obscure concurrency problem with read-write cache for inverse collections
-* deprecated Criteria.returnMaps() / Criteria.returnRootEntities() in favor of new ResultTransformer framework
-* don't cache objects with dynamic-update="true" or <joined-subclass> mappings immediately after insert/update
-* added version checking to saveOrUpdateCopy()
-* fixed constraint violations that occurred when mixing identity columns with other id generation strategies
-* added Sybase 11.9.2 dialect to support older versions of Sybase that do not support ANSI joins (Colm O' Flaherty)
-* added Informix9Dialect (Finn McCann and Max Andersen)
-* added DB2400Dialect (Peter DeGregorio)
-* fixed a problem where mapping validation failure was reported as duplicate import (Michael Gloegl)
-* fixed a problem with Expression.not() in MySQL (Michael Gloegl)
-* added support for ResultSet.getGeneratedKeys() (David Morris, John Kristian)
-* added check attribute to allow check constraints in DDL
-* implicit polymorphism for Criteria queries (Shorn Tolley)
-* use IF EXISTS for dropping hilo tables (Michael Gloegl)
-* better exception report if deleted object is resaved by cascade
-* support nested components in Example queries (Emmanuel Bernard)
-* fixed a minor problem with onDelete() callbacks
-* fixed an obscure problem with select-before-update
-* added SunONETransactionManagerLookup (Robert Davidson)
-* fixed a problem with replicate() and <joined-subclass> mappings
-* made setParameterList() accept empty lists and deny null values (Max Andersen)
-* validation check on query parameters now allows setParameter(x, null) (Max Andersen)
-* added default-access to DTD (Max Andersen)
-* made Query.setParameterList() accept empty lists and deny null values (Max Andersen)
-* allow Query.setParameter(x, null) (Max Andersen)
-* queries with "select new" now cacheable
-* throw meaningful exception when lazy initialization occurs on disconnected session
-* added default-access to <hibernate-mapping> (Max Andersen)
-* added -text support to SchemaUpdate (Max Andersen, Matt Hall)
-* fixed broken implementation of embedded composite keys with createSQLQuery() (Max Andersen)
-* added hibernate.cache.use_minimal_puts config property to reduce unnecessary second-level cache puts
-* optimized performance of orphan delete detection (Bertrand Renuart)
-* fixed problem where unnecessary UPDATE occurred after INSERT for versioned objects with collections
-* WebSphereTransactionManagerLookup for WAS 5.1 (Edina Pimp)
-* Criteria queries now cacheable (Mario Ivankovits)
-* fixed problem with ordered, paginated queries in DB2 (Tim Collins)
-* fixed a bug caching <idbag>s
-* lazy="true" collections are now lazy even when available in cache
-* fixed a problem with version unsaved-value="negative"
-* added hibernate.cache.region_prefix config property (William Drai)
-* fixed problem where configuration input streams were not closed (Rajesh Patel)
-
-Changes in version 2.1.1 (17.12.2003)
--------------------------------------
-* added optional package attribute to <hibernate-mapping>
-* added <meta-value> element to allow simpler <any> mapping
-* native SQL queries are now cacheable - added <synchronize> element to allow correct result set expiry
-* fixed a bug in CGLIB2 integration (Chris Nockleberg)
-* added NamingStrategy
-* don't cache objects with formula properties immediately after insert/update
-* log generated SQL to a special category
-* type of property with access="field" may now be guessed using reflection
-
-Changes in version 2.1 final (12.12.2003)
------------------------------------------
-* fixed a problem with CGLIB2 proxies and method calls inside constructors
-* fixed a bug running SchemaExportTask with mappings in jar files (Tom McCune)
-* allow custom persister declaration for subclasses (Nick Johnson)
-* fixed handling of sequences in SchemaUpdate on Oracle (Andrew Delpha)
-* fixed a bug where Iterator did not handle single null values correctly
-* detect and throw exception in the case of a duplicate property mapping
-* don't auto-create indexes for collection foreign keys (roll back to 2.0.x)
-
-Changes in version 2.1 rc1 (29.11.2003)
----------------------------------------
-* long identifier and discriminator column names are now safely aliased (Max Andersen)
-* cleaned up mapping package to allow applications to manipulate metamodel programmatically
-* fixed a recent bug where collection sort order was lost in second-level cache
-* formula attribute now supported for joined-subclass mappings
-* formula properties may now be used anywhere in queries
-* dialect-specific query pagination for SQL Server
-* fixed a bug where a long path expression ending in collection access by index missed some tables in SQL FROM clause
-* fixed a very ancient performance problem where null one-to-one associations caused n+1 selects
-* added Session.saveOrUpdateCopy()
-* fixed some bugs in Example queries
-* fixed some minor bugs in dialect-specific query pagination
-* immutable entity passed to update() is now lock()ed instead
-* reworked the semantics of nonstrict-read-write
-* JCS cache support now deprecated
-* fixed some obscure bugs in collection handling
-* migrated to CGLIB2 (thanks to Chris Nockleberg)
-* fixed bugs in replicate()
-* fixed a bug affecting joined-subclass mappings with dynamic-update=true
-* performance improvements to boolean type mappings (Bertrand Renuart)
-* integrated JBoss TreeCache clustered cache (thanks to Bela Ban and Ben Wang)
-* fixed a bug in new query parameter validation (Steve Ebersole)
-* fixed a bug where <any> mappings caused unnecessary ObjectDeletedException at flush time
-* fixed a bug where associations with property-ref mappings were not properly cached
-* throw PropertyValueException when not-null properties are null at flush time
-* added unsaved-value attribute to version property mapping (Emmanuel Bernard)
-* tolerate classnames containing $ (Steve Ebersole)
-
-Changes in version 2.1 beta 6 (5.11.2003)
------------------------------------------
-* added Session.cancelQuery()
-* improvements to transaction handling for failed commit (thanks to Juergen Hoeller)
-* added cascade="delete-orphan"
-* fixed an exception that occurred when a property was declared not-null="true" update="false" (thanks to John Kristian)
-* support multiple named query cache regions (Mikheil Kapanadze)
-* some improvements to collection reattachment
-* fixed a bad bug with adds to an uninitialized bag or list
-* removed support for <dynabean/> components
-* added <dynamic-component/> mapping for properties of type Map
-* fixed a bug where schema export generated index names that were too long for DB2
-* allow per-region expiry policies in OSCache (Matthias Bogaert)
-* fixed a stack overflow that could occur while initializing nonlazy collections
-* fixed a bug in case-insensitive like for Example queries
-* fixed a bug in ScrollableResults.setRowNumber() (Martin Priekopa)
-* improvements to the cache concurrency strategies
-
-Changes in version 2.1 beta 5 (30.10.2003)
-------------------------------------------
-* Support for custom CollectionPersister (Nick Johnson, Max Andersen)
-* Support for named SQL queries (Max Andersen)
-* duplicate named queries now throws MappingException instead of just logging warning (Max Andersen)
-* fixed problems with WebSphereTransactionManagerLookup (Ralf Taugerbeck, Daniel Bradby)
-* added support for custom collection persisters (thanks to Max Anderson, Nick Johnson)
-* fixed a performance problem during query compilation (Bulent Erdemir)
-* composite keys now supported in createSQLQuery() (Max Andersen)
-* fixed JCA adaptor to run in WebLogic (Daniel Bradby)
-* integrated SwarmCache (Jason Carreira)
-* integrated OSCache (Matthias Bogaert)
-* fixed an NPE that could occur with lists and orphan delete
-* allow nullable one-to-one with property-ref
-* improved usage of Dialect-specific limit SQL
-* fixed problem where non-lazy collections held by cached objects were not immediately initialized
-* fixed getReturnTypes() for native SQL queries (Max Andersen)
-* fixed problems with Criterions that applied to multi-column properties
-* check of rowcounts when JDBC batch updates enabled
-* added named SQL queries using <sql-query> element (Max Andersen)
-* added some extra validations so Hibernate fails earlier when user makes mistakes
-* allow lazy="true" as an alternative to proxy="ClassName"
-* removed dependency to commons-lang
-* SchemaExport now creates indexes for collection foreign key columns if specified by Dialect
-* fixed a bug parsing named parameters in setParameterList()
-* select new Foo(...) will now tolerate null values if the constructor accepts a wrapper type
-* fixed a problem detecting Proxool
-* added logging of persistent object states during flush()
-* allow "not null" as a discriminator value
-* added "parameters" config param to "sequence" generator (Matthias Bogaert)
-
-Changes in version 2.1 beta 4 (3.10.2003)
------------------------------------------
-* fixed a bug where <any> mappings did not handle proxies correctly
-* implemented new optimistic-lock strategies
-* fixed several bugs in Criteria query API
-* fixed a bug caching property-ref associations
-* improvements to XML Databinder (Ara Abrahamian)
-* added Session.replicate() and ReplicationMode
-* added ScrollableResults.setRowNumber() / ScrollableResults.getRowNumber()
-* added query cache and Query.setCacheable()
-* added Criteria.returnMaps()
-* fixed some problems with CGLIB proxies
-* fixed an NPE that occurred when a joined-subclass of a versioned entity defined only collections
-* added the access attribute, direct field access and the PropertyAccessor extension point
-* added MatchMode for use with Criteria queries (thanks to Michael Gloegl)
-* fixed a bug where some lazy="false" collections were not immediately initialized
-* fixed problem with WebSphere 5 TransactionManager
-* support schema attribute in MySQL, by using an underscore in the table name (Chris Hane)
-* now seperate Dialects for Interbase and Firebird (Reha Cenani, Max Andersen)
-* removed built-in PreparedStatement cache
-* added Session.getSessionFactory()
-* fixed problem with native SQL queries and Query.setProperties() (Max Andersen)
-* Query now fully validates parameters against the query string before passing them to JDBC (Max Andersen)
-* fixed an NPE in SessionFactory.close()
-* fixed an NPE that occurred when using <idbag>s
-* added SQL-level query results paging to DB2Dialect
-* "foreign" id generator now handles detached instances
-
-Changes in version 2.1 beta 3 (7.9.2003)
-----------------------------------------
-* added Example queries
-* fixed an exception that occurred at startup with <key-many-to-one> and <joined-subclass>
-* fixed a bug where composite-elements were not being updated if a property not in the equals() was changed
-* <parent> property of a composite-element may now be used in equals()
-* named parameters may now be used in HQL order by clause
-* null value of version property now indicates unsaved instance
-* added select-before-update attribute
-* two-phase loading now use for components
-* better implementation of equals()/hashCode() for proxies
-* added property-ref attribute to <many-to-one>
-* renamed result() to uniqueResult()
-* added Session.get()
-* added HashtableCacheProvider
-* JTA TransactionManager now used even when not using Hibernate Transaction API
-* always bypass process-level cache for LockMode.READ
-
-Changes in version 2.1 beta 2 (27.8.2003)
------------------------------------------
-* <subclass> and <joined-subclass> may now appear outside of a <class> element, by providing the extends attribute (Max Andersen)
-* fixed an NPE at startup that was introduced in beta 1
-* fixed a bug in Map.putAll()
-* new pluggable cache API
-- deprecated <jcs-cache> in favor of <cache>
-- net.sf.hibernate.cache.CacheProvider settable via hibernate.cache.provider_class
-* more aggressive caching
-* added Hibernate.close(Iterator)
-* Criteria queries may now include joins
-- Criteria.addJoin()
-- Criteria.createCriteria()
-* hibernate.transaction.manager_lookup_class should now ALWAYS be specified in JTA environment when using jcs caching
-* fixed a bug caching <key-many-to-one>
-* fixed bug where cached component did not get <parent> property populated
-* added hibernate.max_fetch_depth property
-* smarter outer-join fetching
-* transient object may now be associated with session using Session.lock()
-* added Query.result(), Criteria.result()
-
-Changes in version 2.1 beta 1 (10.8.2003)
------------------------------------------
-* batch-size attribute for collection and class mappings, to allow batch loading
-* collections of "value types" (including composite-elements) may now appear in HQL from clause
-* more efficient loading of collections, and better handling of non-lazy collections
-* added HQL index() function to allow access to collection element index
-* added Session.createSQLQuery() (Max Andersen)
-* added outer-join attribute to collection mappings
-* Criteria.setFetchMode() now applies to collection-valued path expressions
-* added property-ref attribute to <one-to-one>, enabling unique foreign key associations
-* added hibernate.max_fetch_depth config property
-* added hibernate.hbm2ddl.auto config property
-* fixed a bug with combination of <jcs-cache> and <key-many-to-one>
-* support for Dialect-specific SQL functions in HQL select clause (David Channon)
-* added Session.clear()
-
-Changes in version 2.0.2 (2.8.2003)
------------------------------------
-* subqueries may now use HAVING and GROUP BY clauses
-* fixed a bug with setMaxResults(), setFirstResult() in HSQL (introduced in 2.0.1)
-* fixed a bug in Set.removeAll()
-* fixed a bug in SchemaUpdate (Mathias Bogaert)
-* added weak typing functionality to ScrollableResults
-* fixed a bug with "calendar" versioning in IBM JDK1.3.1 (workaround for JDK bug)
-* fixed a bug in mapping DTD that caused a problem for hbm2java (Max Andersen)
-* fixed a bug querying nested components
-* SQL generation now prefers ANSI-style inner joins to theta inner joins
-* fixed a bug caching collection references loaded using FETCH
-* fixed a bug with composite foreign keys in normalized table mappings (Tom Sedge)
-* limit support for Interbase (Ludovic Orban)
-* added where attribute to <class> mappings
-* added cascade="all-delete-orphan" for collection mappings
-* fixed a bug binding named parameters with setMaxResults()/setFirstResults()
-* fixed some minor bugs in HQL translator
-* fixed a long-standing bug where a <key-many-to-one> could not be dereferenced in HQL
-* SQL UPDATEs now occur in a predictable order (same order as objects were loaded)
-* support for SELECT ... FOR UPDATE in SAPDB
-* fixed bug where Criteria queries against a subclass also returned superclass instances
-* fixed a very rare bug where an update could get lost with normalized mappings
-* fixed a problem with proxied class heirarchies rooted at an interface or abstract class
-* where and order-by attributes now allow SQL function calls and subselects
-* added formula attribute to <property> tag, to allow "computed" properties
-* fixed a bug where PreparedStatements were sometimes not closed when an exception occured
-* workaround for a problem with <joined-subclass> and Interceptor.onFlushDirty()
-
-Changes in version 2.0.1 (17.6.2003)
-------------------------------------
-* fixed some problems with new dialect-specific LIMIT clauses
-* improved parsing of collection where attribute
-* made one-to-many bags more efficient (they are really sets!)
-* allowed type="calendar" for <version> properties
-* fixed a bug with locking a versioned composite-id class
-* refresh() may now take a transient instance
-* added ProxoolConnectionProvider (Martin Crawford)
-* fixed some minor JCA issues (Mike Mosiewicz)
-* fixed a bug with FETCH and sorted associations
-* improved performance of SchemaUpdate tool (Teodor Danciu)
-* fixed a bug in Configuration.addFile(String) (Ken Geis)
-* tidied up and documented hbm2ddl package (esp. Ant tasks)
-* deprecated CounterGenerator in favor of IncrementGenerator
-* improved logging during initialization
-* deprecated "vm" in favor of "increment" id generator
-
-Changes in version 2.0 final (8.6.2003)
----------------------------------------
-* added "fetch" keyword to HQL
-* added evict() methods to SessionFactory for JVM-level cache
-* destroy caches from SessionFactory.close()
-* fixed an NPE in Session.evict() (Simon Spero)
-* added Query.setLockMode()
-* tidied up implementation of Loader
-* release ResultSets more aggressively
-* miscellaneous improvements to some Dialects
-* hbm2java now honors the sort attribute (Max Andersen)
-* added exceptions to Interceptor interface
-* fixed problem with setMaxResults(), setFirstResult() in Oracle (introduced in beta 6)
-* fixed some SQL generation that was a problem for Sybase (Dietmar Posselt)
-* fixed some problems with ODMG API (Oliver Gries)
-* added JOTMTransactionManagerLookup (Low Heng Sin)
-* added JOnASTransactionManagerLookup (?)
-* fixed a bug in WeblogicTransactionManagerLookup (Mathias Bogaert)
-* added Criteria.setFetchMode()
-* added new Expressions
-* much more elegant/robust handling of quoted identifiers
-* renamed Hibernate.association() to Hibernate.entity()
-* added dynamic-update and dynamic-insert mapping attributes
-* fixed a bug with refresh() of objects with collections
-* HQL aliases now optional - "from Cat" now legal
-* platform-independant quoting of identifiers using backticks
-
-Changes in version 2.0 beta 6 (10.5.2003)
------------------------------------------
-* fixed a bug querying one-to-many associations to a <joined-subclass>
-* added support for dialect-specific LIMIT-style clauses (David White)
-* added <idbag>
-* fixed bug in hashCode() of persistent collections
-* <joined-subclass> now supported in HSQL (Wolfgang Jung)
-* fixed problem for XML parsers which ignore default values declared in DTD
-* <meta> tags can now be set to not be inheritable
-* fixed bug in Expression.in()
-* fixed an NPE that could occur from update() in very strange cases (Chris Nockleberg)
-* disabled outer-join back to owner when initializing one-to-many (performance improvement)
-* fixed a bug in Query.setParameterList() (Nick Heudecker)
-* improved JCA support (Igor Fedorenko)
-
-Changes in version 2.0 beta 5 (21.4.2003)
------------------------------------------
-* Informix support (Steve Molitor)
-* fixed a bug parsing "select new ... " queries
-* deprecated "object" type in favor of <any> mappings
-* added Session.contains()
-* added extra DBCP config options (Alex Burgel)
-* SessionFactory.close() now unbinds from JNDI
-* added Session.evict()
-* got rid of an unnecessary SQL DELETE issued when an empty collection was dereferenced
-* where attribute of collection mappings no longer ignored for deletion
-* improved logging
-* support polymorphic associations to "embedded" composite id classes
-* various bugfixes to collection filter parameter binding
-* fixed some problems with proxies introduced in earlier beta versions
-* fixed bug with self-reference in the case of identity column id generation
-* added hibernate.cglib.use_reflection_optimizer property
-* added nonstrict-read-write cache
-* fixed an SQL-generation bug in new Criteria API
-* added CompositeUserType
-* sequence and table id generators now aware of default-schema
-* added update and insert attributes to <component> element
-* fixed a bug with expressions like elements(foo.bar.baz) in where clause
-* more efficient Set initialization (two-phase load)
-* removed support for hibernate.query.imports and added <import> mapping element
-* fixed problem in DBCP connection validation and added new config properties
-* hbm2java can now generate finder methods for persistent objects (experimental) (Matt Hall)
-* hbm2java small fixes/refactorings to support generating more than one file per persistent object (Max Andersen)
-
-Changes in version 2.0 beta 4 (22.3.2003)
------------------------------------------
-* Major HQL improvements
-- from "Foo as foo join foo.bars as bar" instead of "from foo in class Foo, bar in elements(foo.bars)"
-- "select new Foo(bar.name, bar.amount) from ...."
-- outer and full join support
-* Query methods now return this, to allow chaining
-* FrontBase support (Run Lussier)
-* experimental JCA support (Daniel Bradby)
-* hbm2java now can generate Beans style property events (Klaus Zimmermann)
-* support SQL identifiers quoted with []
-* fixed bug with PostgreSQL
-* name attribute now optional in .cfg.xml
-* support for postgres ilike operator (M Lang)
-* squash warnings with GNU JAXP (Chris Nockleberg)
-* fixed a bug in Query.setParameterList()
-* Ingres support (Ian Booth)
-* collections now detect changes not made via wrapper for newly saved objects
-* new (experimental) Criteria + Expression APIs
-* Query.setEntity(), etc, now aware of proxies (also improved hueristics for guessing Type)
-* added Hibernate.isInitialized()
-* detect changes made directly to newly-wrapped collection (ie. not via the wrapper)
-* added Hibernate.refresh(Object, LockMode)
-* update(), saveOrUpdate() no longer initialize a proxy
-* fixed problems with Sybase
-* added force attribute to <discriminator>
-* improved handling of null discriminator-value
-* support SQL-style '' escape for HQL strings
-
-Changes in version 2.0 beta 3 (24.2.2003)
-----------------------------------------
-* collections now represent null elements as a missing row
-* collections now deserialize correctly (fix for bug in beta 2)
-* standardised on dom4j for XML parsing
-* fixed bugs in collection caching (an exception occurred for some sorted collections and some kinds of maps)
-* allowed null discriminators
-* set autocommit to true in SchemaUpdate
-* fixed a stack overflow that could occur in toString() of classes created with hbm2java (Max Andersen)
-* fixed a bug where composite-element <parent> property was not being set after retrieval from cache
-* added where attribute to collection mappings to allow filtering
-* fixed a exception that occurred when wrapping collections with sort="MyComparator" (Jason Horne)
-* objects with mutable="false" are now never updated
-* fixed an exception that occurs with <key-many-to-one> association to a class with a composite id (Stefano Travelli)
-* added SchemaExport Ant task (Rong C Ou)
-* integrated latest CGLIB release (Juozas Baliuka)
-- added support for new CGLIB reflection optimizer (Juozas Baliuka)
-* improved query cache algorithm (Who?)
-* fixed a bug in "object" type
-* Lists and arrays now represent null elements as a missing row
-* fixed a bug in Hibernate PreparedStatement cache where maxRows and fetchSize were not cleared before re-caching
-* fixed a bug in HibernateService that caused a restart to fail
-* added SybaseAnywhereDialect (?)
-* added SessionFactory.close()
-
-Changes in version 2.0 beta 2 (2.2.2003)
-----------------------------------------
-* property column names may now be of any length (Mark Woon)
-* fixed problem where CodeGenerator created private get/set pairs (Max Andersen)
-* fixed all silly bugs in Configuration.configure()
-* efficient collection updates from Session.update()
-* added <jcs-class-cache> and <jcs-collection-cache> elements to hibernate-configuration.dtd
-* support for normalized mappings for databases with DECODE instead of CASE (Simon Harris)
-* added Oracle9Dialect
-* added JRun4TransactionManagerLookup (Joseph Bissen)
-* fixed JDBCException to keep reference to underlying SQLException
-* fixed a bug loading many-to-many associations with a repeated column name
-* fixed a bug in ShortType
-* added IngresDialect (Ian Booth)
-* added --config option to SchemaExport
-
-Changed in version 2.0 beta 1 (28.1.2003)
------------------------------------------
-* renamed packages to net.sf.hibernate.*
-* all API methods now wrap SQLExceptions
-* removed support for toplevel collections / subcollections
-* created hibernate-mapping-2.0.dtd
-- renamed 'readonly' attribute to 'inverse'
-- renamed 'role' attribute to 'name'
-- changed default value for 'unsaved-value' to "null"
-- added mandatory 'name' attribute to <param>
-- added <meta> tag
-* created hibernate-configuration-2.0.dtd
-* brand new Configuration API, including exposed mapping package
-* completely reworked IdentifierGenerator framework
-- built-in generators now auto-detect the type (so integer identity columns are supported, for example)
-- parameters are now named
-- built-in strategies are renamed
-* expanded Interceptor interface
-* removed exceptions that occur if an object is saved or deleted multiple times in a session
-* added <parent> subelement to <composite-element> and <nested-composite-element>
-* collections except for <bag>s now implement by-value equals() and hashCode()
-* removed all deprecated methods
-* added Session.refresh()
-* added dynamic-update functionality
-* added update and insert attributes to <property> and <many-to-one> mappings
-* added elements(), indices(), size(), maxelement(), minelement(), maxindex(), minindex() collection functions to query language
-* huge improvements to CodeGenerator (Max Andersen)
-* enhanced outerjoin fetching support in queries
-* experimental support for DynaBeans as components
-
-Changes in version 1.2.3 (28.1.2003)
-------------------------------------
-* fixed a recently-introduced problem with Timestamp dirty checking
-* added createClob(), createBlob() for streams (Benoit Menendez)
-* SchemaUpdate now configures Dialect correctly (Michael Locher)
-* update() now working for classes with embedded composite ids
-* unsaved-value attribute now recognized for <composite-id>
-* fixed a minor problem where a very specific kind of SQL select did not qualify a column name
-* added Query.getQueryString()
-* fixed an NPE that sometimes occurred when hibernate.connection.username was not specified
-* fixed a bug in SchemaExport where foreign key constraints did not use qualified tablenames
-* added isFirst(), isLast() to ScrollableResults
-* fixed bug finding properties inherited by mapped interfaces
-
-Changes in version 1.2.1b (4.1.2003)
-------------------------------------
-* fixed an NPE that occurred while loading Hibernate classes in IBM JVM
-* arbitrary JNDI InitialContext properties may now be passed as hibernate.jndi.*
-* fixed a problem where index column was not being nullified when an entity was removed from a one-to-many
-
-Changes in version 1.2.1 (31.12.2002)
--------------------------------------
-* Changed the MySQL mapping of Hibernate "timestamp" to MySQL "DATETIME" (Matthias Schwinn)
-* TransactionManagerLookup classes now define defaut UserTransaction JNDI names
-* support for WebSphere 5 (Venkat Srinivasan)
-* fixed a bug with query expressions of the form "foo.bar.id" for normalized mappings
-* experimental Blob/Clob support (thanks to Benoit Menendez and Mark Woon)
-* improvements to SchemaUpdater (Benoit Menendez)
-* deprecated suspendFlushes() / resumeFlushes() in favor of FlushMode
-* deprecated IDGenerationException in favor of IdentifierGenerationException
-* fixed a bug introduced in 1.2 final where cascade save-update was sometimes ignored for readonly="true" bags
-* fixed a bug caching null-valued one-to-one associations
-* CodeGenerator now supports <bag> and <joined-subclass>
-* fixed problem with TimestampType on DB2 (Jonas)
-* fixed a bug in generated SQL for collections with <joined-subclass> mappings (Robson Miranda)
-* fixed a bug caching Maps (Benoit Menendez)
-* SchemaExport now accepts a .jar file as a source of mappings
-* hibernate.dbcp.validationQuery setting (Juozas Baliuka)
-* hibernate.c3p0.validate setting
-* added Query.setTimeout()
-* setMaxResults() now behaves sensibly on SAPDB (Russel Smyth)
-* added Query.setProperties() and Query.getNamedParameters(), fixed a bug in Query.getReturnTypes()
-* CodeGenerator now generates equals() and hashCode() for composite-id classes (and toString() for all classes)
-* CodeGenerator now includes superclass properties in subclass constructors (Max Andersen)
-* added Hibernate.custom()
-
-Changes in version 1.2 final (7.12.2002)
-----------------------------------------
-* fixed a bug where uppercase IS NOT NULL, NOT IN, etc were not parsed correctly
-* addition to readonly="true" bags now no longer requires collection initialization
-* added ResinTransactionManagerLookup (Aapo Laakkonen)
-* improved exception message when setting null to primitive type (Max Andersen)
-* improved exception message for an unserializable identifier
-* support for overloaded setter methods (patch by Alex Staubo)
-* CodeGenerator support for <composite-element> (patch by Wolfgang Jung)
-
-Changes in version 1.2 beta 4 (29.11.2002)
-------------------------------------------
-* fixed bugs in one-to-many associations to a <joined-subclass>
-* LockMode class now properly serializable
-* exceptions thrown by proxied objects are now propagated correctly (rather than being wrapped)
-* made Calendar types compilable in JDK1.2
-* added --format and --delimiter options to SchemaExport (thanks to Richard Mixon)
-* fix for problem with class with no properties + native id generation + MS SQL Server contributed by Max Andersen
-* fixed a BAD bug in Hibernate.configure() (thanks to Rob Stokes)
-* CodeGenerator now recognizes <key-many-to-one> (patch by Wolfgang Jung)
-* CodeGenerator now recognizes <version> and <timestamp> (patch by Max Andersen)
-
-Changes in version 1.2 beta 3 (26.11.2002)
-------------------------------------------
-* fixed bug in UPDATE SQL generation for <joined-subclass> mapping strategy (fix by Robson Miranda)
-* support <composite-id> correctly in CodeGenerator (patch by Tom Cellucci)
-* fixed an exception that occurred with short qualified tablenames
-* added the polymorphism attribute to the <class> element
-* allow "not between", "not in" in query language
-* allow subqueries beginning with a from clause in query language
-* query expressions like "not (foo.bar.baz=1)" now translated to "(bar.baz!=1 and foo.bar=bar.id)"
-* support for PostgreSQL ~ operator (regular expression match)
-* load(id, lockMode) now working for normalized table mappings
-* now compiling properly under JDK1.2, 1.3 (fix by Tom Cellucci)
-* support for subcollections in query language: foo.bars[2]['index'], foo.bars[4].elements, foo.bars[0].size, etc.
-* added calendar and calendar_date types
-* find() queries may now return scalar values
-* component-type properties may appear in a select clause
-* ConnectionProviders now set isolation level before toggle autocommit
-* Iterator.next() now throws NoSuchElementException as per Iterator contract (fix by Alex Staubo)
-* database reverse engineering GUI tool contributed by Tom Cellucci
-* SchemaExport now generates column in mapping file order (rather than alphabetical order)
-* <joined-subclass> mappings working on Oracle (?)
-
-Changes in version 1.2 beta 2 (15.11.2002)
-------------------------------------------
-* support multi-argument SQL functions in queries
-* reintroduced deprecated form of update() with slightly altered semantics
-* fixed BAD problem in the generated SQL for certain queries
-* added OrionTransactionManagerLookup
-
-Changes in version 1.2 beta 1 (11.11.2002)
-------------------------------------------
-* Fixed a bad bug binding to JNDI with servers that use serialization in preference to getReference()
-* support for quoted SQL identifiers (patch by Jean-Francois Nadeau)
-* Hibernate.initialize() allows the user to force initialization of a proxy or persistent collection
-* fix to minor bug in CodeGenerator by Max Andersen
-* fixed a problem with outerjoin fetching of one-to-one associations defined on subclasses
-* fixed a minor problem with proxies of classes that override finalize()
-* finished work on normalized table mappings using <joined-subclass> declaration (only for databases with ANSI OUTER JOIN and CASE)
-* deprecated hibernate-mapping.dtd in favor of hibernate-mapping-1.1.dtd
-* reworked unmapped class / interface / table-per-concrete-class query functionality, fixing several problems
-* removed deprecated methods
-* deprecated findIdentifiers()
-* fixed some problems with embedded composite identifiers
-* fixed a bug cascading deletes to one-to-one associations
-* CodeGenerator now generates isFoo() style getters for boolean properties (patch by Aapo Laakkonen)
-* components may now have a nonpublic constructor (patch by Jon Lipsky)
-* changes / bugfixes to MapGenerator tool
-* experimental SchemaUpdate tool contributed by Christoph Sturm
-
-Changes in version 1.1.8 (30.10.2002)
--------------------------------------
-* full support for composite keys in query language
-* fixed bug where character type could not be null
-* fixed bug parsing collection filters like: "group by this.date"
-* fixed a bad bug where C3P0 properties were not always being used
-* replaced hibernate.use_jdbc_batch with hibernate.jdbc.batch_size
-* renamed some other properties to hibernate.jdbc.*
-* made hibernate.show_sql settable from JMX (patch by Matas Veitas)
-* added SessionFactory.getAllClassMetadata(), getAllCollectionMetadata (patch by Max Andersen)
-* allowed use of concrete-class proxies with inherited classes ie. <subclass name="ConcreteClass" proxy="ConcreteClass">
-* HibernateException extends Apache commons lang NestableException (patch by Max Andersen)
-* <parent> subelement of <component> allows a component to get a reference back to owning entity
-* Query.setParameterList() to bind lists of values to "in (:list)"
-* Java constants may now be used in Queries
-* serialization of an object graph now removes all initialized proxies
-* several other improvements to proxy handling
-* proxies may now be used in JDK 1.2
-
-Changes in version 1.1.7 (25.10.2002)
--------------------------------------
-* added Session.createFilter()
-* fixed a bug parsing queries with properties of form idXXX (introduced in 1.1.6)
-* fixed a bug parsing queries with the id property named in the select clause (introduced in 1.1.6)
-* fixed a bug dirty checking big_decimal (fix by Andrea Aime)
-
-Changes in version 1.1.6 (24.10.2002)
--------------------------------------
-* classes without subclasses may now declare themselves as their own proxy
-* outer-join attribute now working for component properties and <many-to-many>
-* outer-join="true" will now force outerjoin loading for an association even if associated class has a proxy
-* enabled oracle-style outerjoins for SAP DB
-* version properties may now be long or short (previously always integer)
-* discriminators may now be boolean type
-* fixed the foo.bar.id.baz syntax for queries doing composite-key joins
-* fixed an NPE that occurred when no Dialect was specified
-* CodeGenerator now fully proxy-aware (patch by Max Andersen)
-* removed dependency upon trove4j
-
-Changes in version 1.1.5b (20.10.2002)
---------------------------------------
-* fixed an NPE that occurred on JMX startup
-* smarter fetching for one-to-one associations
-
-Changes in version 1.1.5 (19.10.2002)
--------------------------------------
-* added built-in currency and timezone types
-* hibernate-mapping-1.1.dtd
-- added <index-many-to-many> and <composite-index> subelements of <map>
-- added <key-property> and <key-many-to-one>
-- renamed "save/update" to "save-update"
-- tightened up the dtd (now using enumerated attribute types)
-* enabled multi-column map indexes (ie. key of a Map)
-* composited-id may now include a many-to-one association
-* improvements to Databinder contributed by Brad Clow
-* fixed bugs in minIndex, maxIndex, minElement, maxElement
-* fixed a problem with JTATransaction in a JBoss BMT bean
-* added addMapResource() to the MBean
-* minor improvements to Configuration
-* more accurate cache entry timestamping to increase the likelihood of cache hits
-* JCS cache may now be used with JTATransaction in WebSphere, Weblogic, JBoss (thanks to Matt Baird)
-* improvements to CodeGenerator contributed by Andrea Aime
-* stopped a TransientObjectException that was being thrown when it shouldn't be
-* re-enabled primary key export for tables of sets with not-null elements
-* hibernate.statement.fetch_size configuration contributed by Matas Veitas
-* added Interceptor application callback interface
-* added metadata package to expose persistence metadata to the application
-* changed filter() argument type from Collection to Object to allow filtering of arrays and Maps
-* added <column> index attribute to allow table indexes to be specified in mapping document
-* implemented support for queries against interfaces and abstract superclasses
-
-Changes in version 1.1.4b (4.10.2002)
--------------------------------------
-* fixed problems for JDK1.2 (thanks to Chris Webb)
-
-Changes in version 1.1.4 (4.10.2002)
-------------------------------------
-* New locking API
-* disabled 2-phase load for objects contained in Sets (because they should be initialized before equals() or hashCode() is called)
-* fixed a bug where non-serializable cache entries could not be cached by JCS auxiliary cache
-* fixed a bug in dirty checking PersistentEnums
-* deprecated getID() in favor of getIdentifier() (for mainly cosmetic reasons)
-* HibernateService may now be subclassed to obtain mapping files by some other mechanism (patch by Chris Winters)
-
-Changes in version 1.1.3 (1.10.2002)
-------------------------------------
-* new 2-phase loading process (replaces complicated "deferred" loading process)
-* new ScrollableResults interface for efficiently navigating Query results
-* removed deprecated interfaces
-* created engine package to hold "internal" APIs (ie. the external contract of the impl package)
-* fixed bug where a component defined before all collections in the mapping file caused collections to not be persisted (thanks to Michael Link)
-* fixed a bug where cascaded saveOrUpdate was ignoring the unsaved-value setting
-* faster Timestamp dirty checking
-
-Changes in version 1.1.2 (29.9.2002)
-------------------------------------
-* added persister attibute of class mapping to support custom persistence strategies
-* Support for Oracle outerjoins contributed by Jon Lipsky
-* Reworked versioning, fixing bugs (and tightening tests)
-* Fixed a bug where an ObjectNotFoundException was thrown for null one-to-one associations
-* fixed problems with timestamps introduced in 1.1.1
-* added batch file for running demo
-
-Changes in version 1.1.1 (27.9.2002)
-------------------------------------
-* Major refactoring / abstraction of persistence logic
-* added maxIndex, minIndex, maxElement, minElement properties for collections
-* added support for class names in where clause of queries
-* fixed a bug where an association could become null after caching
-* fixed a bug where an NPE could occur for a null component
-* fixed minor bugs in SortedMap, SortedSet
-* object type is now cacheable
-* added big_integer type
-* improved dirty checking for timestamp type
-
-Changes in version 1.1.0 (22.9.2002)
-------------------------------------
-* implemented collection indexing with [] in query language
-* fixed some minor query-language bugs
-
-Changes in version 1.1 beta 14 (19.9.2002)
-------------------------------------------
-* bags now implement java.util.List
-* delete() may now take a transient object
-* bug where sorted collections were not being sorted fixed by Brad Clow
-* fixed a bug in many-to-many association filtering
-* no longer try to query connection metadata when using user-supplied connections
-* added hibernate.use_scrollable_resultsets for user-supplied connections
-* fixed a problem where sublists were not being proxied
-* fixed a problem where Hibernate could not call methods of package-visibility classes
-* removed obsolete select attribute from MapGenerator
-* multiple occurrences of same path in a query no longer require multiple joins
-* added WrongClassException
-
-Changes in version 1.1 beta 13 (15.9.2002)
-------------------------------------------
-* added constants to Lifecycle interface
-* fix for circular cascade="save/update"
-* fixed a bug in cascaded update introduced in version 1.1 beta 11
-* added object type
-
-Changes in version 1.1 beta 12 (14.9.2002)
-------------------------------------------
-* Session.filter() for applying a filter query to collections
-* experimental ODMG API (OQL features are not yet compliant)
-* new DBCPConnectionProvider for Apache commons-dbcp connection pool
-* Session.lock() now does version number check even on databases with no FOR UPDATE clause
-* introduced new cascade styles: cascade="save/update", cascade="delete"
-* added default-cascade attribute
-* foreign key columns lengths now automatically set to primary key column lengths for SchemaExport
-* added error checking of row update counts when batching disabled
-* major improvements to ProxyGenerator tool
-* CodeGenerator now aware of proxy attribute
-* integrated PointbaseDialect contributed by Ed Mackenzie
-* fix for problem where Proxies were being initialized on identifier access by Christoph Sturm
-
-Changes in version 1.1 beta 11 (7.9.2002)
------------------------------------------
-* deprecated update() in favor of saveOrUpdate() and introduced unsaved-value attribute of <id>
-* children mapped with cascade="all" are now always saved/updated even without a call to update(parent)
-* support for composite-id classes where the composite id consists of properties of the persistent class
-* added constrained attribute to <one-to-one> element
-* added Validatable interface
-* renamed several config properties (Hibernate issues log warnings for obsolete property usage)
-* arbitrary JDBC connection properties may now be passed using hibernate.connection.*
-* fixed a classloading bug in C3P0ConnectionProvider (introduced in 1.1 beta 10)
-* CodeGenerator may now take multiple mapping files on the commandline
-
-Changes in version 1.1 beta 10 (28.8.2002)
-------------------------------------------
-* fixed a bug that occurred when calling Session.update() for an object with no properties
-* changed class loading to use the context classloader first
-* introduced <timestamp> as an alternative to <version>
-* added Query.getReturnTypes()
-* fixed a bug with composite-elements introduced in 1.1 beta 7
-* save() may now be used to persist classes with composite-ids
-* improved handling of nanoseconds values in Timestamps
-* support for composite id properties + objects in select clause of iterate()
-* beefed-up collection tests
-
-Changes in version 1.1 beta 9 (26.8.2002)
------------------------------------------
-* fixed a bug introduced in 1.1 beta 8 that could cause an NPE after deserializing a session with proxies
-* deprecated insert() in favor of more flexible save()
-* deprecated IDGenerator in favor of new IdentifierGenerator interface
-* "assigned" id generator now returns the existing value of the id property instead of throwing an Exception
-* fixed a problem where PreparedStatements were not being recached after retrieving a natively generated id
-
-Changes in version 1.1 beta 8 (25.8.2002)
------------------------------------------
-* fixed a bug introduced in 1.1 beta 6 where an updated element of an indexed one-to-many collection caused an SQLException
-* uninitialized collections passed to update() may now be initialized in the new Session
-* uninitialized proxies passed to update() may now be initialized in the new Session
-
-Changes in version 1.1 beta 7 (23.8.2002)
------------------------------------------
-* fixed a bug where Hibernate was not returning statements to the cache when batch updates were disabled
-* fixed a bad bug parsing mappings with toplevel one-to-many associations
-* fixed a bug with versioning and subcollections
-* reworked Set updates again for much improved efficiency
-* schema export now creates primary keys for indexed collection tables
-* minor refactor to Type hierarchy
-* improved some user-error detection
-* fixed foreign key constraint creation for MySQL with Innodb tables
-
-Changes in version 1.1 beta 6b (20.8.2002)
-------------------------------------------
-* Fixed a problem updating Sets
-* added <bag> mapping for java.util.Collection
-
-Changes in version 1.1 beta 6 (20.8.2002)
------------------------------------------
-* completely reworked fetching code
-- one-to-many associations now always fetched in a single select
-- many-to-many associations fetched in a single select when outerjoin fetching is enabled
-- this includes nested outerjoin fetching of the associated class!
-- outerjoin fetching for <many-to-one> nested inside <component> or <composite-element>
-- code refactored to be cleaner and faster
-* removed unnecessary order by clause in List and array fetching SQL
-* collections now individually update, insert and delete only rows that changed (thanks to Doug Currie)
-* fixed a problem where exceptions were being wrapped in a LazyInitializationException for non-lazy collections
-* added order-by attribute to <set> and <map> to specify a table column as defining the iteration order (JDK1.4 only)
-* improved error detection in Session.update()
-* further usage of JDBC2 batch updates
-* some fine-tuning of JDBC2 feature usage configuration
-* CodeGenerator will now generate components and arrays
-* fixed problem where CodeGenerator could not generate classes in the default package
-* improved logging of flush() activity
-* renamed property hibernate.use_jdbc2 to hibernate.use_jdbc_batch
-
-Changes in version 1.1 beta 5 (13.8.2002)
------------------------------------------
-* hibernate.query.imports property to allow use of unqualified classnames in queries
-* fixed a bug in collection flushing that was introduced in 1.1 beta 4
-
-Changes in version 1.1 beta 4 (11.8.2002)
------------------------------------------
-* JMX integration (thanks to John Urberg)
-* "having" clause in query language
-
-Changes in version 1.1 beta 3 (10.8.2002)
------------------------------------------
-* removed the select="all" attribute for <class> mappings - "select distinct" now specified in the hibernate query
-* system properties now override hibernate.properties
-* Session now flushes changes even less often (only when actual updates to the queried table(s) are waiting)
-* fixed a *very* rare problem where an unnecessary update could be accidently issued before a delete
-
-Changes in version 1.1 beta 2 (6.8.2002)
-----------------------------------------
-* fixed a bug exporting schemas with identity columns
-* implemented factory-level caching of collections
-* Datastore.storeJar() contributed by Christian Meunier
-* added <mapping jar="jarfile"> to hibernate.cfg.xml
-
-Changes in version 1.1 beta 1 (4.8.2002)
-----------------------------------------
-* new Query API including named parameters, pageable results
-* subqueries in Hibernate queries (only for databases that support subselects)
-* new DocBook documentation (contributed by Christian Bauer)
-* support collections .elements, .indices inside select clause (even in aggregate functions)
-* don't load collections before removal unless absolutely necessary
-* mutable="false" attribute in <class> element to map immutable classes
-* use JDBC batch to insert collection elements if hibernate.use_jdbc2 is set
-* brand new PreparedStatementCache
-* improvements to MYSQL dialect for long datatypes
-* always check isAccessible() before setAccessible(true)
-* removed extra unnecessary table join in queries with one-to-many association
-* removed ugly "WHERE 1=1" from generated SQL
-* fixed exception mapping a class with no properties (fix by Rob Stokes)
-* logging enhancements including SQLException logging
-* reworked factory-level cache and integrated JCS support (thanks to Christian Meunier)
-* fixed a bug with circular references in cached data
-* removed blocking cache support
-* now rendering outerjoins as "LEFT OUTER JOIN" because "LEFT JOIN" caused problems for some Sybase versions
-* added default Hibernate properties to Dialects
-* native id generation now falls back to sequence id generation when identity columns not supported by the dialect
-* fixed some problems with native id generation under HSQL
-* may now use Session.insert() even when using native id generation
-
-Changes in version 1.0.1b (18.7.2002)
--------------------------------------
-* fixed a bad bug in query parser when hibernate.query.substitutions was unset
-* much improved build.xml Ant script
-* latest c3p0.jar
-
-Changes in version 1.0.1 (17.7.2002)
-------------------------------------
-* enabled use of scalar values and aggregate SQL functions in select clause of iterate() queries
-* fixed bug in JNDI lookup for SessionFactory
-* changed ordering of SQL inserts/deletes for child collections of a cascade-enabled association
-- better behaviour for some not-null constraints
-- performance optimization for bidirectional many-to-one associations
-* added hibernate.query.substitutions property to allow named query constants (eg. translate 'true' to '1')
-* added locale type for java.util.Locale
-* added sequence hi/lo generator (seqhilo.long)
-* fixed bug where load(), onLoad() callbacks were sometimes called at wrong time
-* fixed an exception (fix by Eric Everman) and improved identifier searching in MapGenerator tool
-* refactored SerializableType
-* extra logging + error handling
-* documentation enhancements
-
-Changes in version 0.9.17 (3.7.2002)
-------------------------------------
-* Added UserType interface
-* documented Lifecycle
-* added some new trace messages to log
-* bugfix to allow SQL functions like upper(), lower(), etc to work on all platforms
-* documented SAP DB support (dialect contributed by Brad Clow)
-* foreign key constraint export for SAP DB
-* map index may be the composite-id of the element class (contributed by Jon Lipsky)
-* fixes to CodeGenerator tool (contributed by Uros Jurglic)
-
-Changes in version 0.9.16 (19.6.2002)
-------------------------------------
-* fixed bug cacheing objects with references to themselves
-* support for composite ids of classes with no id property
-* may now disable outer join (deep) fetching for an association by setting outer-join="false"
-* enabled outer join fetching for one-to-one
-* fixed a bug for mappings that specify class attribute of <one-to-many>
-* fixed a bug where Hashbelt did not expire cached data in a timely fashion
-* fixed a mistake in the mapping DTD
-* new user-error check in update()
-
-Changes in version 0.9.15 (15.6.2002)
-------------------------------------
-* one-to-one associations
-* support for "tricky" mappings in SchemaExport tool (multiple properties to one column, etc)
-* Transaction API contributed by Anton van Straaten
-* SessionFactory may be bound to JNDI name by setting hibernate.session_factory_name
-* Sessions are now Serializable!
-* added Session.findIdentifiers() query methods
-* new Lifecycle interface to replace deprecated PersistentLifecycle
-* fixed problem where session did not autoflush on iterate() queries
-* performance enhancements to collection dirty checking
-* added Hibernate.configure() and configuration file format
-* removed some deprecated methods
-* refactored Type hierarchy
-* query language identifiers now case sensitive (bugfix for case sensitive SQL dialects)
-* username/password now optional for datasource (contributed by Emmanuel Bourg)
-* much improved API documentation
-* binary types now saved using streams if hibernate.use_streams_for_binary=true (contributed by Jon Lipsky)
-* MySQL Strings now mapped to TEXT columns if length > 255 (contributed by Christoph Beck)
-
-Changes in version 0.9.14 (4.6.2002)
--------------------------------------
-* lifecycle objects - properties now have a cascade attribute to cascade save, update, delete
-* composite id properties may now be used in queries eg. foo.id.bar (contributed by Jon Lipsky)
-* slightly changed semantics of update() so it now also save()s new transient instances
-* Session now flushes() itself less often before query execution (performance enhancement)
-* fixed problem where Session.save() returned null instead of the natively generated id
-* fixed bug with object identity for cached classes
-* fixed bug where delete(x) could not be called after update(x)
-* MUCH improved Exception hierarchy
-* deprecated create()
-* added sql-type attribute to <column> tag to allow user to override default type mapping
-* deeper fetching with use_outer_join
-* new ConnectionProvider framework
-* fixed a bug where blocking cache could return stale data
-* now working again in JDK1.2.2
-* fixed problem with not-null associations + native key generation
-* minor changes to PersistentLifecycle interface
-* initial, minimal version of new Transaction mechanism
-* MUCH improved documentation
-
-Changes in version 0.9.13 (25.5.2002)
--------------------------------------
-* Datastore.storeResource() to load mapping files from classpath
-* fixed a problem executing under JDK1.3 when compiled from JDK1.4
-* documentation improvements
-
-Changes in version 0.9.12 (24.5.2002)
-------------------------------------
-* Session.update() methods to update a persistent instance from transient copy (as requested by many users)
-* discriminator column name, type, length, etc now configurable by <discriminator> tag in mapping file
-* discriminator column values configurable by discriminator-value attribute of <class> and <subclass> tags
-* added Session.insert(object, id) for classes with no identifier property
-* fixed another bad bug with connection handling (fix by Anton van Straaten)
-* fixed a problem with deferred loading
-* fixed a problem with sorted collections (fix by Anton van Straaten)
-* nested collections of objects now require 2 SQL SELECTs to load, rather than size+1
-* session is NO LONGER atomic - application should discard session when exception occurs
-* fixed problem where character type was mapped to VARCHAR column
-* arrays of proxies now possible by using new element-class attribute of <array> tag
-* fixed various problems with proxies
-* added proxy generation tool
-* proxy unit tests
-* replaced two RuntimeExceptions with checked exceptions
-* made hibernate.username/hibernate.password optional for DriverManager
-* CodeGenerator now supports all hibernate basic types
-* much improved caching algorithm for compiled queries
-* may now specify properties simply by placing hibernate.properties in classpath
-* documentation improvements + fixes
-* --abstract switch to MapGenerator (contributed by Eric Everman)
-
-Changes in version 0.9.11 (12.5.2002)
-------------------------------------
-* fixed major bug with connection handling (fix by Anton van Straaten)
-
-Changes in version 0.9.10 (11.5.2002)
-------------------------------------
-* set a default schema name using SessionFactory property hibernate.default_schema
-* code generator tool contributed by Brad Clow (www.workingmouse.com)
-* lazy object initialization under JDK 1.3 and above
-* fixed some error messages to go to logging framework, not stdout
-* new system property hibernate.show_sql=true logs all executed SQL to stdout
-* integration of bugfixes in c3p0
-* wrap IllegalArgumentExceptions in HibernateExceptions
-* added ObjectNotFoundException and StaleObjectStateException
-* fixed a bug when using schemas
-* new caching strategy (and documented cache feature)
-
-Changes in version 0.9.9 (25.4.2002)
------------------------------------
-* sorted sets and maps (thanks to Doug Currie)
-* mapping files may now be loaded using getResourceAsStream() (thanks to Markus Meissner)
-* hibernate messages now logged by Apache commons-logging
-* default hi/lo generator table now has column named "next_id", instead of "next"
-* query language may now refer to identifier property name (eg. foo.fooKey as alternative to foo.id)
-* hibernate.jndi_class, hibernate.jndi_url now optional when using datasource
-* hibernate now throws an exception if you try to persist an object with a reference to a transient object
-* improved connection pooling algorithm (hibernate.pool_size limits pooled conections)
-* very experimental integration of c3p0 JDBC connection pool (http://sourceforge.net/projects/c3p0)
-* now compiles under JDK 1.2.2
-* fixed bug persisting null components
-* fixed bug where cached prepared statements were not cleaned up after disconnect() session
-* fixed a null pointer exception in MappingByReflection
-
-Changes in version 0.9.8 (13.3.2002)
------------------------------------
-* supports database native key generation in Sybase, MS SQL, MySQL, DB2, Hypersonic (contributed by Christoph Sturm)
-* supports Mckoi (dialect contributed by Doug Currie)
-* supports Progress (dialect contributed by Phillip Baird)
-* added exceptions to catch Session reentrancy from PersistentLifecycle.load() + store()
-* experimental cross-transaction cache
-* Session.lock() and Session.loadWithLock() for pessimistic locking
-* HiLoGenerators may now use their own DriverManager connection properties + may now use same table across diff mapping files
-* Session.flush(), Session.close() and Session.connection() replace Session.commit(), Session.cancel()
-* Session.disconnect() and Session.reconnect() for long transactions
-* added single JVM id generators vm.long, vm.hex
-* added unique column constraints to mappings
-* extensions to IDGenerator framework
-* support sequence-style ID generation in Oracle, PostgreSQL, DB2, Interbase
-
-* fixed problem where subcollections of a collection that changed roles would be deleted
-* changed class loading strategy to be compatible with JBoss
-* stopped queries retrieving unnecessary columns
-* mutable types (binary + serializable) now always detected as dirty
-
-Changes in version 0.9.7 (26.2.2002)
------------------------------------
-* save() now safe from foreign key violations (so create() is no longer preferred method of adding data)
-* delete() now completely safe from foreign key violations - it no longer matters what order objects are deleted in
-* removed Session.copy()
-* hilo generators now NOT for use with application server datasources
-
-* fixed two intermittent bugs in queries
-* fixed a problem where components not detected as dirty
-* fixed broken hilo generator which was not updating database
-* fixed a minor bug when hibernate.use_outer_join was set
-
-Changes in version 0.9.6 (24.2.2002)
------------------------------------
-* experimental XML generation
-* added support for bi-directional associations (one-to-set, set-to-set) with <set readonly="true"> config
-* reflective generation of mappings tool was contributed by Doug Currie
-* Session operations now atomic, so exceptions are recoverable
-* made ID properties optional in persistent classes
-* support for multiple schemas through schema attribute of <hibernate-mapping>, <class>, <set>, <map>, etc.
-* auto-creation of tables for hilo id generators (restriction: cannot use same table from more than one mapping file)
-* added some more assertions to catch user "mistakes" like deleting transient or saving persistent objects
-
-* major rework of collections and fixed some bad bugs
-* lazy initialization re-enabled for one-to-many associations (thanks to Georg Schneemayer)
-* fixed a problem in the mapping DTD to allow nested components in collections
-* fixed a BAD bug in RelationalDatabaseSession when loading objects with PersistentLifecycle callbacks (thanks to Paul Szego)
-* fixed problems with quoted strings in query language
-* fixed a bug where a stack overflow occurred instead of HibernateException thrown (thanks to Georg Schneemayer)
-* fixed a bug deleting updated versioned data
-* fixed some problems with name generation for indexes + foreign keys
-* fixed problem in Sun JDK 1.4 (only?) where IllegalArgumentException was not handled
-* minor improvements to handling of dates and times
-* HiLoGenerator now safe for all transaction isolation levels + safe when rollback occurs
-* noticed and fixed obscure piece of nonthreadsafe code outside of core persistence engine
-* removed unnecessary drop constraints for some dialects
-
-* MUCH more comprehensive test suite
-
-* changed some terminology used in documentation
-* added javadoc for API classes
-* commented the mapping DTD
-
-Changes in version 0.9.5 (8.2.2002)
------------------------------------
-* supports HypersonicSQL (dialect contributed by Phillip Baird)
-* supports Microsoft SQL server (with third party JDBC driver)
-* proper command-line tool for schema generation and export
-* deprecated the interface cirrus.hibernate.Persistent (due to popular demand)
-* changes to hibernate-mapping DTD (required to support optional Persistent interface):
-- deprecated <property type="package.PersistentClassName"/> in favor of <many-to-one class="package.PersistentClassName"/>
-- deprecated <element type="package.PersistentClassName"/> in favor of <many-to-many class="package.PersistentClassName"/>
-- deprecated <property role="..."/> in favor of <collection role="..."/>
-- deprecated <element role=".."/> in favor of <subcollection role="..."/>
-- deprecated <association> in favor of <one-to-many>
-* class attribute optional in <component> and <composite-id> tags (determined by reflection)
-* querying components of components now supported
-* one-shot table creation (no use of unportable "alter table")
-* time dataype support
-* reflective mappings of java.sql.Time, java.sql.Timestamp, java.sql.Date
-* fixed error msg thrown when class is missing a method but has a superclass
-* property names now conform to JavaBean spec ("foo" instead of "Foo"). Note that "Foo" still works
-* constructors of persistent classes may now be non-public
-* collection indexes now mapped to not-null columns
-* fixed obscure bug with querying collections inside components of components
-* fixed potential bug related to cacheing of compiled queries
-* major rewrite of code relating to O-R mappings
-* Session.copy() and Session.equals() as convenience for users
-* fixed repeated invocations of hasNext() on iterator + iterators now always work with distinct SQL resultsets
-* McKoi dialect was contributed by Gabe Hicks
-
-Changes in version 0.9.4 (29.1.2002)
-------------------------------------
-* fixed BAD bug where XML parsing would not work for parsers other than Xerces - thanks to Christian Winkler
-* added some more assertions to catch user "mistakes" like changing ids or reusing existing ids
-
-Changes in version 0.9.3 (27.1.2002)
-------------------------------------
-* repackaged (corrupted DatasourceConnectionProvider.class)
-* better exception reporting using datasource
-* added Datastore.storeClass() which looks for mapping file in classpath (class foo.Bar -> foo/Bar.hbm.xml)
-* improved documentation
-
-Changes in version 0.9.2 (25.1.2002)
-------------------------------------
-* iterate over query results (lazy instantiation of query results)
-* added "select foo, bar" style queries returning multiple objects per row
-* delete by query
-* composite key support
-* outer joins for faster (?) loading of associated objects ( set "hibernate.use_outer_join" to "true" )
-* connection pooling when using DriverManager
-* foreign key constraint from unkeyed collection table to owner entity table
-* improved drop tables script execution (still not infallible)
-* added <composite-element> tag
-* added not-null properties and elements
-* added an optimisation for dates and components
-* made some XML attributes optional
-* fixed errors in documentation + documented some extra features
-* bugfix: store() not getting called on lifecycle interface
-* bugfix: schema generation for indexed associations
-* added many tests
-
-Changes in version 0.9.1 (20.1.2002)
-------------------------------------
-Too many to list
-
-version 0.8.1
--------------
-Initial alpha version
-
Copied: core/tags/hibernate-3.3.0.CR2/changelog.txt (from rev 15001, core/trunk/changelog.txt)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/changelog.txt (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/changelog.txt 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,2618 @@
+Hibernate Changelog
+===================
+Note: Newer entries are automatically generated and the description might not
+match the actual issue resolution (i.e. a bug might not be a bug). Please
+refer to the particular case on JIRA using the issue tracking number to learn
+more about each case.
+
+
+Changes in version 3.3.0.CR2 (2008.07.31)
+-------------------------------------------
+
+** Bug
+ * [HHH-1697] - OracleDialect fails to recognize sequence accessible through syonyms when validating schema
+ * [HHH-2604] - Isolator.JdbcDelegate masks the exception if it isn't possible to open a connection.
+ * [HHH-2683] - "datediff" is declared as NoArgSQLFunction in H2Dialect, but actually accepts 3 arguments.
+ * [HHH-3006] - ConcurrentModificationException in AbstractBatcher results in infinite loop
+ * [HHH-3229] - Merge can fail when there is a transient entity reachable by multiple paths and at least one path does not cascade on merge
+ * [HHH-3257] - Content images not displayed
+ * [HHH-3260] - Hibernate wraps a listener init or destroy exception into an AssertionFailure
+ * [HHH-3261] - Do not wrap exceptions raised by event listeners (at init or destroy time)
+ * [HHH-3265] - change license url in pom to http://www.gnu.org/licenses/lgpl-2.1.html
+ * [HHH-3266] - distribution bundle missing jta dependency
+ * [HHH-3272] - using of Integer.valueOf(int), which is not available in JDK 1.4
+ * [HHH-3282] - DB2Dialect should report supportsLobValueChangePropogation() == false
+ * [HHH-3309] - Serialize/Deserialize problem in AbstractLazyInitializer with entitymode.MAP.
+ * [HHH-3409] - ResultTransformers need smarter equals() and hashCode() impls
+
+** Improvement
+ * [HHH-1786] - JTASessionContext.CleanupSynch does not remove sessions from currentSessionMap
+ * [HHH-2060] - To be able to use <generator> with <composite-id>
+ * [HHH-2506] - Make javassist the default ByteCodeProvider
+ * [HHH-2875] - repackage cglib/asm under org.hibernate namespace
+ * [HHH-3269] - upgrade to jDocBook plugin version 2.1.1
+ * [HHH-3283] - protect BulkManipulationTest#testInsertWithGeneratedTimestampVersion where Dialect#supportsParametersInInsertSelect == false
+ * [HHH-3358] - Enable JTATransactionFactory and JTATransaction factory to work without JNDI
+ * [HHH-3390] - Use READ_COMMITTED for JBC 2 cache
+
+** Patch
+ * [HHH-3294] - Version incorrectly incremented for unchanged persistent entity that is parent of a one to many relationship
+
+** Task
+ * [HHH-3270] - follow up on documentation license questions
+
+
+
+Changes in version 3.3.0.CR1 (2008.04.28)
+-------------------------------------------
+
+** Bug
+ * [HHH-1312] - Unclosed ResultSet when using Identity
+ * [HHH-1396] - Table.validateColumns fails on valid column
+ * [HHH-1569] - Immutable Natural Id check fails with ArrayIndexOutOfBounds in some cases
+ * [HHH-1593] - Infinite loop/StackOverflow when calling configuration.setListener(null)
+ * [HHH-1753] - DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax
+ * [HHH-1916] - param values in generator element should be trimmed during HbmBinding
+ * [HHH-1920] - Incorrect documentation regarding XML manipulation in Hibernate reference manual (chapter 18.3).
+ * [HHH-1956] - Interceptor.afterTransactionCompletion not called with JTATransaction (CacheSynchronization.hibernateTransaction not set)
+ * [HHH-2159] - NullPointerException in FromElement#findIntendedAliasedFromElementBasedOnCrazyJPARequirements with 'hibernate.query.jpaql_strict_compliance' enabled
+ * [HHH-2164] - Minor bug in section "20.1.1. Customizing the schema"
+ * [HHH-2200] - Memory leak in AbstractBatcher with Generated Properties
+ * [HHH-2320] - Regression: optional properties under a <join> tag no longer update properly
+ * [HHH-2503] - AbstractEntityPersister swallows JDBCExceptions in processGeneratedProperties
+ * [HHH-2513] - Abusive WARN logged during deserialization of replicated SessionFactory
+ * [HHH-2542] - NullPointerException in TypeFactory.replaceAssociations for ComponentType
+ * [HHH-2553] - New LoadContexts Implementation causing possible performance degradation
+ * [HHH-2593] - Keyword UNION is prefixed with "this_." in filter conditions
+ * [HHH-2616] - No event is fired on Collection recreate/remove/update action
+ * [HHH-2627] - Generated properties leak prepared statements in Hibernate 3.2.3 and higher.
+ * [HHH-2631] - Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
+ * [HHH-2711] - PropertyAccessException with backref and <composite-map-key/>
+ * [HHH-2726] - spelling o your CLASSPATH
+ * [HHH-2728] - Calling session.clear() while retrieving objects via an iterator will cause a "LazyInitializationException - No Session" by the CGLIBLazyInitializer
+ * [HHH-2788] - Oracl8iDialect No Dialect mapping for JDBC type 91
+ * [HHH-2795] - CollectionLoadContexts for empy collections are not removed until PersistenceContext.clear()
+ * [HHH-2816] - DefaultFlushEntityEventListener.checkNaturalId() causes extra SELECTs on read-only entities
+ * [HHH-2833] - insert-select query fails with NPE when select includes join
+ * [HHH-2857] - schemaSupport for HSQLDialect remote connections doesn't work
+ * [HHH-2861] - cascade="delete-orphan,all" is ignored
+ * [HHH-2863] - testsuite fix-ups for maven and/or directory changes
+ * [HHH-2864] - Merging a detached instance with a new child in a unidirectional one-to-many association fails if the parent was previously loaded as a proxy
+ * [HHH-2892] - skip up-to-date checks of query cache for natural-id only if immutable
+ * [HHH-2928] - optimizers for enhanced id generators should be synchronized against multi-threaded access
+ * [HHH-2948] - QueryStatistics.executionMinTime always = 0
+ * [HHH-3111] - WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter.getStatus() implemented incorrect
+ * [HHH-3140] - Region prefix ignored for entities and collections
+
+** Deprecation
+ * [HHH-2755] - Wrong "jsdk.jar" referenced in the tutorial
+
+** Improvement
+ * [HHH-1786] - JTASessionContext.CleanupSynch does not remove sessions from currentSessionMap
+ * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
+ * [HHH-2156] - Section 19.3, "Managing the caches" doesn't document CacheMode.IGNORE
+ * [HHH-2533] - redesign Cache/CacheProviders
+ * [HHH-2662] - Workaround PostgreSQL issues in testsuite
+ * [HHH-2663] - Map java.sql.Types.REAL to Hibernate FloatType for auto-discovery stuff
+ * [HHH-2665] - Split Oracle9Dialect into Oracle9iDialect and Oracle10gDialect
+ * [HHH-2669] - Unequivocally map MySQL LOB types to the LONG variant
+ * [HHH-2682] - support for auto-discovery of H2 dialect
+ * [HHH-2696] - Consider migrating to slf4j
+ * [HHH-2761] - Handle null and empty string consistently in PropertiesHelper
+ * [HHH-2778] - TransactionManagerLookup implementation for Bitronix Transaction Manager
+ * [HHH-2789] - Section 19.2 of the documentation does not show OSCache as supporting clusters. It does.
+ * [HHH-2822] - timestamp extraction functions for SAPDBDialect
+ * [HHH-2826] - IS [NOT] NULL checks with component values
+ * [HHH-2859] - Introduce a 'Work' API for user to perform JDBC work
+ * [HHH-3131] - Add a method to ActionQueue to tell whether there are currently entries in the executions collection
+
+** New Feature
+ * [HHH-1] - Optimize Hibernate for the bulk insertion of related entities
+ * [HHH-2555] - Create new RegionFactory for JBossCache
+ * [HHH-2884] - Provide a sessionFactory close event or hook for the event listeners
+
+** Patch
+ * [HHH-952] - Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
+ * [HHH-2070] - Expand DB2Dialect auto-discovery support (Martin Renner)
+ * [HHH-2519] - Schema dropping not documented with hibernate.hbm2ddl.auto=create
+ * [HHH-2630] - Hibernate Dialect is not auto-detected for Sybase ASE and DB2 (Shelley McGowan)
+ * [HHH-2758] - Patch IngresDialect based on certification
+ * [HHH-2839] - Don't use dummy dual table for hsqldb (David Bala?ic)
+ * [HHH-2849] - Better error logging in IdentifierGeneratorFactory (Antony Stubbs)
+ * [HHH-2957] - ActionQueue Insertion sort performance degrades exponentially (Jay Erb)
+ * [HHH-3084] - DialectFactory detection of Ingres metadata (Michael Leo)
+
+** Task
+ * [HHH-2702] - Officially move to JDK 1.4
+ * [HHH-2704] - Migrate to Maven2 for build
+
+
+Changes in version 3.2.6 (2008.02.07)
+-------------------------------------------
+
+** Bug
+ * [HHH-925] - DetachedCriteria.createCriteria not working with alias
+ * [HHH-1312] - Unclosed ResultSet when using Identity
+ * [HHH-1329] - SchemaValidator fail when views are involved
+ * [HHH-1593] - Infinite loop/StackOverflow when calling configuration.setListener(null)
+ * [HHH-1685] - DetachedCriteria doesn't create alias on subcriteria
+ * [HHH-1753] - DB2Dialect.getCurrentTimestampSQLFunctionName() uses Oracle syntax
+ * [HHH-1916] - param values in generator element should be trimmed during HbmBinding
+ * [HHH-1956] - Interceptor.afterTransactionCompletion not called with JTATransaction (CacheSynchronization.hibernateTransaction not set)
+ * [HHH-2016] - Oracle9Dialect registers last_day() function as "lastday"
+ * [HHH-2159] - NullPointerException in FromElement#findIntendedAliasedFromElementBasedOnCrazyJPARequirements with 'hibernate.query.jpaql_strict_compliance' enabled
+ * [HHH-2200] - Memory leak in AbstractBatcher with Generated Properties
+ * [HHH-2261] - Setting hibernate.hbm2ddl.auto=validate causes problems on mySQL with numeric fields
+ * [HHH-2320] - Regression: optional properties under a <join> tag no longer update properly
+ * [HHH-2503] - AbstractEntityPersister swallows JDBCExceptions in processGeneratedProperties
+ * [HHH-2542] - NullPointerException in TypeFactory.replaceAssociations for ComponentType
+ * [HHH-2593] - Keyword UNION is prefixed with "this_." in filter conditions
+ * [HHH-2598] - Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null
+ * [HHH-2616] - No event is fired on Collection recreate/remove/update action
+ * [HHH-2627] - Generated properties leak prepared statements in Hibernate 3.2.3 and higher.
+ * [HHH-2728] - Calling session.clear() while retrieving objects via an iterator will cause a "LazyInitializationException - No Session" by the CGLIBLazyInitializer
+ * [HHH-2788] - Oracl8iDialect No Dialect mapping for JDBC type 91
+ * [HHH-2795] - CollectionLoadContexts for empy collections are not removed until PersistenceContext.clear()
+ * [HHH-2816] - DefaultFlushEntityEventListener.checkNaturalId() causes extra SELECTs on read-only entities
+ * [HHH-2833] - insert-select query fails with NPE when select includes join
+ * [HHH-2857] - schemaSupport for HSQLDialect remote connections doesn't work
+ * [HHH-2861] - cascade="delete-orphan,all" is ignored
+ * [HHH-2864] - Merging a detached instance with a new child in a unidirectional one-to-many association fails if the parent was previously loaded as a proxy
+ * [HHH-2892] - skip up-to-date checks of query cache for natural-id only if immutable
+ * [HHH-2928] - optimizers for enhanced id generators should be synchronized against multi-threaded access
+ * [HHH-2948] - QueryStatistics.executionMinTime always = 0
+
+** Improvement
+ * [HHH-1630] - duplicate property mapping - more details
+ * [HHH-1696] - Add outer join support for aliases on DetachedCriteria
+ * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
+ * [HHH-2682] - support for auto-discovery of H2 dialect
+ * [HHH-2761] - Handle null and empty string consistently in PropertiesHelper
+ * [HHH-2822] - timestamp extraction functions for SAPDBDialect
+ * [HHH-2826] - IS [NOT] NULL checks with component values
+ * [HHH-2852] - Better error messages when schema validation fails
+
+** Patch
+ * [HHH-952] - Patch to allow subqueries with joins using Criteria API and Subqueries with DetachedCriteria
+ * [HHH-2070] - Expand DB2Dialect auto-discovery support (Martin Renner)
+ * [HHH-2839] - Don't use dummy dual table for hsqldb (David Bala?ic)
+ * [HHH-2849] - Better error logging in IdentifierGeneratorFactory (Antony Stubbs)
+ * [HHH-2957] - ActionQueue Insertion sort performance degrades exponentially (Jay Erb)
+ * [HHH-3084] - DialectFactory detection of Ingres metadata (Michael Leo)
+
+** Task
+ * [HHH-2559] - http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd needs to be updated
+ * [HHH-3085] - Remove connector.jar (unnecessary library)
+ * [HHH-3086] - Remove jdbc2_0-stdext.jar (unnecessary library)
+
+
+Changes in version 3.2.5 (2007.07.31)
+-------------------------------------------
+
+** Bug
+ * [HHH-1116] - batch-size typo
+ * [HHH-1561] - Missing " in Documentation for H3, Chapter 15.8
+ * [HHH-1569] - Immutable Natural Id check fails with ArrayIndexOutOfBounds in some cases
+ * [HHH-1694] - Documentation Outdated: "10.4.4. Queries in native SQL"
+ * [HHH-2180] - minordocumentation error in hbm xml
+ * [HHH-2201] - session.iterate() does not exist
+ * [HHH-2267] - A copy/paste mistake in the documentation for <schemavalidator> ant task
+ * [HHH-2334] - Documentation error in section 5.1.3
+ * [HHH-2420] - Error in 2.5. Contextual Sessions
+ * [HHH-2502] - The second level caching documentation states that ehcache is not distributed.
+ * [HHH-2631] - Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
+ * [HHH-2649] - Batcher configuration parameter incorrectly documented
+ * [HHH-2711] - PropertyAccessException with backref and <composite-map-key/>
+ * [HHH-2713] - duplicated phrase in docs "of the of the"
+ * [HHH-2714] - Three typos in code examples
+ * [HHH-2719] - adddress --> address
+ * [HHH-2720] - Monetory --> Monetary
+
+** Improvement
+ * [HHH-1022] - incomplete documentation in _README.txt in the lib directory
+ * [HHH-1682] - Improve the description of differences between save() and persist()
+ * [HHH-2048] - Incomplete MappingException at org.hibernate.mapping.SimpleValue
+ * [HHH-2417] - Update book on Hibernate reference
+ * [HHH-2418] - Refer HSQL DB website in chapter 1.2.3
+ * [HHH-2487] - Typo in "5.1.7. version (optional)"
+ * [HHH-2550] - Update API Class in 10.4.3. Criteria queries
+ * [HHH-2662] - Workaround PostgreSQL issues in testsuite
+ * [HHH-2663] - Map java.sql.Types.REAL to Hibernate FloatType for auto-discovery stuff
+ * [HHH-2665] - Split Oracle9Dialect into Oracle9iDialect and Oracle10gDialect
+
+** Patch
+ * [HHH-2520] - Miscellaneous config doc spelling fixes
+ * [HHH-2630] - Hibernate Dialect is not auto-detected for Sybase ASE and DB2 (Shelley McGowan)
+ * [HHH-2758] - Patch IngresDialect based on certification
+
+** Task
+ * [HHH-2551] - Deprecate org.hibernate.criterion.Expression
+ * [HHH-2566] - Replace usages of FlushMode.NEVER with FlushMode.MANUAL
+ * [HHH-2567] - Update reference to use FlushMode.MANUAL
+ * [HHH-2568] - Hibernate javadoc overview refering wrong classes and packages
+
+
+Changes in version 3.2.4.sp1 (2007.05.18)
+-------------------------------------------
+
+** Bug
+ * [HHH-2605] - Since 3.2.4 no value specified for row id
+ * [HHH-2613] - LockMode.FORCE on non versioned entity leads to NPE
+
+
+Changes in version 3.2.4 (2007.05.09)
+-------------------------------------------
+
+** Bug
+ * [HHH-511] - reattach object from same session
+ * [HHH-2316] - org.hibernate.cache.CacheKey.equals() can cause PropertyAccessException to be thrown
+ * [HHH-2553] - New LoadContexts Implementation causing possible performance degradation
+ * [HHH-2602] - instrumented many-to-one problem with aggressive release
+
+** Deprecation
+ * [HHH-2603] - Deprecate the Session.connection() method
+
+** Improvement
+ * [HHH-2549] - Warn users explicitly about schemaexport and schemaupdate does not support annotations
+
+** New Feature
+ * [HHH-1] - Optimize Hibernate for the bulk insertion of related entities
+
+** Patch
+ * [HHH-2301] - Identity generator with custom insert SQL broken in 3.2 (Scott Rankin and Gail Badner)
+ * [HHH-2336] - paremeterizable and typedef-able UserCollectionType (Holger Brands)
+ * [HHH-2580] - Performace: Too many lookups of WAS extended transaction support (Jesper Udby)
+
+
+Changes in version 3.2.3 (2007.04.02)
+-------------------------------------------
+
+** Bug
+ * [HHH-2376] - Query with fully qualified entity class fails
+ * [HHH-2392] - LockModes referencing non-root joined-subclass class in HQL/Criteria
+ * [HHH-2393] - Generated properties leave open ResultSet on Batcher to be closed on transaction completion
+ * [HHH-2397] - hilo generator can generate negative numbers because of arithmetic overflow
+ * [HHH-2469] - ArrayIndexOutOfBoundsException during update by rowid
+ * [HHH-2476] - PersistentMap.put() incorrect on uninitialized, non-extra-lazy map
+ * [HHH-2481] - Big memory leak in the use of CGLIB
+ * [HHH-2499] - incorrect assertion failure relating to generated property values
+ * [HHH-2513] - Abusive WARN logged during deserialization of replicated SessionFactory
+ * [HHH-2521] - Fix cascading of merge across component properties
+ * [HHH-2532] - update/delete executeUpdate() causes problems with JBossCache (at least in opt-locking setups)
+
+** Improvement
+ * [HHH-2495] - encapsulate the notion of state pertaining to processing a result set
+ * [HHH-2534] - better error message for illegal 'collection dereference' in HQL query
+ * [HHH-2535] - Change Cache' Cache71Dialect so that sequence support returns false
+
+** New Feature
+ * [HHH-2471] - create a set of "enhanced" generators
+ * [HHH-2500] - apply Terradata certification results
+
+** Patch
+ * [HHH-2367] - InformixDialect uses wrong data type
+ * [HHH-2489] - SQL comments for HQL bulk operations
+
+
+Changes in version 3.2.2 (2007.01.24)
+-------------------------------------------
+
+** Bug
+ * [HHH-1471] - If the 'generated' attribute is set to 'insert' or 'always' on the property of a component it is ignored and the value is not read from the database.
+ * [HHH-1646] - Bad code in FastClass.equals
+ * [HHH-1889] - LockMode.UPGRADE not applied in all cases for SQL Server / Sybase
+ * [HHH-2112] - ClassCastException in StatefulPersistenceContext.getCachedDatabaseSnapshot(...)
+ * [HHH-2221] - MySQL temp table DDL and isolation
+ * [HHH-2238] - SQLQuery executeUpdate doesn't respect Query.setFlushMode()
+ * [HHH-2251] - Settings build unnecessary in schemaupdate/schemavalidate
+ * [HHH-2257] - Query.iterate() results differ from Query.list() 2
+ * [HHH-2259] - autoflush and autoclose not longer occur in JTA environment with hibernate 3.2
+ * [HHH-2264] - NPE when NamedQuery contains space before variable name
+ * [HHH-2274] - Collection ordering when many to many order by is used is not respected
+ * [HHH-2275] - Mapping a composite element as a map key using formulas can lead to AOOBE
+ * [HHH-2284] - HQL: selecting components inside components doesn't work
+ * [HHH-2291] - collection based on property-ref not handled correctly during reattch
+ * [HHH-2292] - merge detached instance fails to persist collection changes in case of bare collection reference
+ * [HHH-2356] - NullableType.toString(Object) should account for nulls
+ * [HHH-2366] - Changing a component's value does not trigger an update during flush
+ * [HHH-2378] - replicate() of non-versioned entiy can result in wrong value for version in entity cache
+
+** Improvement
+ * [HHH-1851] - relax special handling of 'id' property
+ * [HHH-2130] - SQLQuery does not autoflush all entities used in the query
+ * [HHH-2193] - Introduce a flag to avoid checking NamedQuery at startup
+ * [HHH-2242] - Consider Allowing Optimistic Lock Strategies other than 'Version' with joined-subclass
+ * [HHH-2250] - Create an appropriate error message if Query.setEntity is passed a NULL value
+ * [HHH-2282] - PersistentClass property lookups do not properly account for embedded composite identifiers
+ * [HHH-2286] - dialect informational metadata
+ * [HHH-2372] - Allow tooling to create Settings via SettingsFactory without contacting the db
+
+** New Feature
+ * [HHH-2246] - No way to specify CACHE_PROVIDER_CONFIG in HibernateServiceMBean
+
+** Patch
+ * [HHH-2300] - Updated dialect for H2 database engine
+ * [HHH-2371] - enhancements to C3P0ConnectionProvider
+
+** Task
+ * [HHH-2032] - update c3p0 to 0.9.1
+
+
+
+Changes in version 3.2.1 (2006.11.16)
+-------------------------------------------
+
+** Bug
+ * [HHH-939] - 'class' property in HQL results in incorrect SQL for joined-subclass
+ * [HHH-1401] - session.merge() executes unnecessary updates when one-to-many relationship is defined.
+ * [HHH-1460] - Inconsistent behavior when using Session.get() with multiple subclasses
+ * [HHH-1564] - deleting versioned object with collection leads to unecessary update
+ * [HHH-1629] - SchemaUpdate/validator doesn't listen to quoting
+ * [HHH-1631] - Missing table in SQL from clause that is referenced in where clause when using joined subclass
+ * [HHH-1651] - hibernate does not find an existing sequence from an Oracle database
+ * [HHH-1663] - <any/> with collection will produce "AssertionFailure: collection was not processed by flush()"
+ * [HHH-1737] - Add a ConnectionWrapper interface to allow access to the underlying connection from a BorrowedConnectionProxy
+ * [HHH-1756] - Proxy objects are not removed from the BatchFetchQueue during a session evict
+ * [HHH-1774] - Component parameters bound incorrectly
+ * [HHH-1921] - "dirty, but no dirty properties" thrown when Interceptor resets properties.
+ * [HHH-1986] - javassist throws InvocationTargetException instead of original checked Exception
+ * [HHH-2027] - merge listener over-writes Interceptor changes to component state for a transient entity
+ * [HHH-2044] - DefaultMergeEventListener.entityIsDetached call StaleObjectStateException with wrong identifier
+ * [HHH-2082] - UpdateTimestampsCache.isUpToDate returns before checking all spaces
+ * [HHH-2108] - cacheable files broken
+ * [HHH-2138] - merge with bidirectional one-to-one may fail
+ * [HHH-2145] - set.retainAll calling set.addAll
+ * [HHH-2174] - Wrong log message in SessionImpl.afterTransactionCompletion(...)
+ * [HHH-2199] - Unique constraints on nullable columns should not be generated with unique-key is used and supportsNotNullUnique=false
+ * [HHH-2202] - Clearing the connection warnings even when log is > WARN to workaround a Sybase issue
+ * [HHH-2206] - SessionImpl tries to deserialize itself in an incorrect order
+ * [HHH-2207] - Suggested fix for HQL - MySQL setMaxResults issue
+ * [HHH-2226] - org.hibernate.hql.ast.tree.FromElementType contains warning log message that should be debug instead
+ * [HHH-2229] - Performance issue with fix for HHH-1293, CGLIBLazyInitializer may be slower for certain Java classes
+ * [HHH-2236] - Lazy property + setReadOnly + Instrumented classes results in NullPointerException when accessing lazy property
+
+** Improvement
+ * [HHH-2037] - provide Query.setProperties(Map)
+ * [HHH-2042] - Typo in FlushMode.MANUAL Javadoc
+ * [HHH-2057] - Add "remove" cascading style to CascadeStyle for XML mappings
+ * [HHH-2127] - Document <filter-def condition="defaultCondition"> and <filter-def>defaultCondition
+ * [HHH-2135] - Hibernate Deserialization: In org.hibernate.type.SerializableType the code makes a test for the return of a null object by simply testing the object as to whether or not it is null.
+ * [HHH-2185] - introduce setting to control cglib caching of classes
+ * [HHH-2203] - Make Post*Events extend AbstractEvent
+ * [HHH-2208] - Table schema use in DatabaseMetadata
+ * [HHH-2209] - ehcache.jar is old and does not contain the SingletonCacheProvider which are advised in exception messages
+ * [HHH-2217] - Collection write methods and dirtying the collection
+
+** New Feature
+ * [HHH-2205] - Dialect for Intersystems' Cache SQL 2007.1
+
+** Patch
+ * [HHH-1767] - read-only cache for immutable collection causes unnecessary warning
+
+** Task
+ * [HHH-2219] - Upgrade to Javassist 3.4
+
+
+Changes in version 3.2.0.ga (16.10.2006)
+-----------------------------------------
+(retag of 3.2.0.cr5 (2006.10.16))
+
+Changes in version 3.2.0.cr5 (04.10.2006)
+-------------------------------------------
+
+** Bug
+ * [HHH-1668] - PersistentSet write methods mark collection as dirty even if entry is not written
+ * [HHH-1714] - Session.get() behavior
+ * [HHH-1891] - Since rc3 deprecation Warning: The syntax 'TYPE=storage_engine' is deprecated and will be removed in MySQL 5.2.
+
+** Improvement
+ * [HHH-2093] - PERSIST_ON_FLUSH ineffective for recursive object graphs
+ * [HHH-2103] - Rolling back 'SELECT is mandatory' on JPA strict compliance
+
+** Task
+ * [HHH-1931] - verify that the instrument tasks actually work
+
+
+Changes in version 3.2.0.cr4 (24.08.2006)
+-------------------------------------------
+
+** Bug
+ * [HHH-1293] - java.lang.NoSuchMethodError: <persistent class>.getHibernateLazyInitializer()
+ * [HHH-1677] - optimistic-lock="dirty|all" is ignored at delete time
+ * [HHH-1710] - persistent collections with property-ref to secondary tables cannot be joined in HQL
+ * [HHH-1713] - AbstractEntityPersister causes an exception when a row in a joined table is missing with fetch="select"
+ * [HHH-1740] - Build-time instrumentation breaks lazy="proxy"
+ * [HHH-1750] - Exception ORA-01000 too many open cursors by generated="insert"
+ * [HHH-1806] - No Dialect mapping for JDBC type: 3
+ * [HHH-1848] - A session.lock generates a query with a version column in a joined subclass which does not exist
+ * [HHH-1892] - finish HHH-1789 for ordered and sorted collections
+ * [HHH-1898] - With hibernate 3.2.0-cr3 there is an hql parsing error on a one-to-one relation
+ * [HHH-1924] - ForeignKeys: TransientObjectException is thrown without a message because of a wrong bracket in the code
+ * [HHH-1927] - persist() and then merge() not handled correctly for multiple entity instances representing the same logical state
+ * [HHH-1937] - Proxy creation failure leads to NPEs
+ * [HHH-1943] - PersistenceContext not checked to see whether the associated entity is transient or not
+ * [HHH-1944] - generated subqueries and jpaql compliance (derived select clause) check
+ * [HHH-1947] - OF part of MEMBER OF is optional
+ * [HHH-1948] - Query Idetification variables are case insensitive in JPA
+ * [HHH-1949] - having trim(BOTH from c.name) translated into having ltrim(rtrim(BOTH)) on DB2
+ * [HHH-1954] - Proxies are never unassociated (evicted) from a session
+ * [HHH-1958] - session.lock(LockMode.FORCE) can lead to NPE
+ * [HHH-1963] - meta inheritance broken
+ * [HHH-1992] - Some cascade actions should not trigger a property access on lazy properties
+ * [HHH-2001] - javaassist does not setup the proper protection domain thus does not work with signed/secured deployments such as webstart
+ * [HHH-2015] - where= does not set parenthesis leading to unexpected query when multiclause are used
+ * [HHH-2017] - locate function defined on Oracle9Dialect is incorrect
+ * [HHH-2022] - property names beginning with underscores cause Hibernate to generate invalid aliases
+
+** Improvement
+ * [HHH-1470] - Enhance Hibernate-Mapping DTD Definition of type element
+ * [HHH-1934] - logging NonUniqueObjectException and WrongClassException
+ * [HHH-1941] - Be more specific about x not found and invalid mapping exceptions to allow tools to tell about it
+ * [HHH-1968] - unify bytecode instrumentation
+ * [HHH-1980] - disallow the mapping combination of <version/> and optimistic-lock
+ * [HHH-2005] - more standard build script
+ * [HHH-2023] - performance optimization of JTATransactionFactory.isTransactionInProgress()
+
+** Patch
+ * [HHH-1271] - When using Stored Procedure for update or delete, the check is not done correctly.
+
+** Task
+ * [HHH-1931] - verify that the instrument tasks actually work
+
+
+Chages in version 3.2 cr3 (2006.07.06)
+-------------------------------------------
+
+** Bug
+ * [HHH-1452] - Native SQL query is missing join if entity includes many-to-one on secondary table
+ * [HHH-1507] - one-to-one can have formula or meta but not both of them.
+ * [HHH-1552] - Error when using ?1 and parameterList
+ * [HHH-1586] - ClassCastException in CollectionType.toLoggableString if using CustomCollectionType
+ * [HHH-1732] - EhCache.toMap still assumes Serializable objects
+ * [HHH-1734] - Connection leak when using hilo strategy in SE environment
+ * [HHH-1741] - Bug in reference documentation
+ * [HHH-1746] - NullPointerException at IdentNode.resolveAsNakedComponentPropertyRefLHS(IdentNode.java:195
+ * [HHH-1748] - Setting a comment that contains a single quote on a query results in an unintuitive exception
+ * [HHH-1763] - Bug in InputStream org.hibernate.util.ConfigHelper.getResourceAsStream(String resource)
+ * [HHH-1791] - property update="false" ignored since 3.2.0.cr2
+ * [HHH-1816] - serializing session from a named session factory to a different vm broken
+ * [HHH-1822] - flushing entity linked to transient instance (non cascaded) should always fail
+ * [HHH-1828] - registering a transaction marked for Rollback is illegal
+ * [HHH-1833] - Not Generating HibernateException
+ * [HHH-1838] - Wrong SQL generated for hql query on "any" relation
+ * [HHH-1855] - booleans not properly handled in assignment clause of UPDATE statements
+ * [HHH-1858] - wrong sql generated against many-to-any association table
+ * [HHH-1871] - query type autodiscovery assume wrong column when mixing entities and scalars
+
+** Deprecation
+ * [HHH-1792] - Callable update/insert/delete statements should not force rowcount out parameter
+
+** Improvement
+ * [HHH-1617] - Check the second-level cache before adding a PK to a batch fetch
+ * [HHH-1773] - Typo in ImprovedNamingStrategy
+ * [HHH-1779] - Allow Session.remove() on transient object
+ * [HHH-1789] - improve efficiency of collection initialization from L2 cache hits
+ * [HHH-1795] - default cache provider to NoCacheProvider
+ * [HHH-1796] - TreeCache based providers and Fqn
+ * [HHH-1800] - session.get() / load() should raise exception when the id is of the wrong type
+ * [HHH-1818] - remove() should force subsequent contains() calls to return false
+ * [HHH-1831] - Batch loading the same EntityKey (one side of manytoone ) more than once
+ * [HHH-1861] - More complete component handling in HQL
+ * [HHH-1881] - introduce LoggableUserType interface
+
+** New Feature
+ * [HHH-1709] - Be able to raise ENFE rather than LIE in proxies
+ * [HHH-1727] - Add a SQLFunctionRegistry
+ * [HHH-1817] - Introduce setting for JPA-QL strict compliance
+ * [HHH-1826] - Built-in type for char[] -> VARCHAR Byte[] and Character[]
+
+** Patch
+ * [HHH-1558] - Dialect for new database engine H2
+ * [HHH-1847] - QBE 'like' clause with backslashes don't work with MySQL
+
+** Task
+ * [HHH-1839] - rename FlushMode.NEVER -> FlushMode.MANUAL
+
+
+Changes in version 3.2 cr2 (2006.05.05)
+-------------------------------------------
+
+** Bug
+ * [HHH-1114] - The first (HSQL) Hibernate Application doesn't work as expected due to lack of database shutdown
+ * [HHH-1175] - Exception when loading inheritance mapping in single file
+ * [HHH-1560] - PropertiesHelper.resolvePlaceHolders() fails with non-String values in System properties
+ * [HHH-1620] - Errors on max_lo <=1 boundaries
+ * [HHH-1625] - Hibernate.isPropertyInitialized() returns false on instrumented transient object
+ * [HHH-1648] - Exception while resuming a transaction is silently eaten
+ * [HHH-1674] - Configuration serialization error: filterDefinitions map not serializable
+ * [HHH-1695] - subsequent calls to non-existent proxy causes NPE
+
+** Improvement
+ * [HHH-1266] - StatelessSession can implement refresh
+ * [HHH-1414] - many-to-many and metadata order-by based on column from the target table
+ * [HHH-1477] - Improve naming strategy for ANN-195
+ * [HHH-1538] - aggregations functions in EJBQL queries does not return the appropriate types
+ * [HHH-1670] - Update EhCache and EhCache provider to support EhCache 1.2
+ * [HHH-1704] - Deduplicate unique constraints generation sharing the same column(s)
+
+** New Feature
+ * [HHH-870] - support SQL updates in named queries
+ * [HHH-1591] - Replace LazyInitializationException by EntityNotFoundException
+ * [HHH-1719] - Provide a ClassTransformer interface to the BytecodeProvider
+
+
+Changes in version 3.2 cr1 (2006.03.27)
+-------------------------------------------
+
+** Bug
+ * [HHH-1453] - Broken exception handling in NullableType
+
+** Improvement
+ * [HHH-227] - remove reflection optimizer
+ * [HHH-587] - Make ResultTransformer available for all query methods
+ * [HHH-1588] - delay inserts for insert-generated-identifiers outside transaction
+ * [HHH-1590] - redesign how PostInsertIdentifierGenerators are handled at insertion
+ * [HHH-1592] - allow SelectGenerator to use a defined natural-id (if one)
+
+** New Feature
+ * [HHH-332] - create ability to add resulttransformer to HQL query
+ * [HHH-1179] - support inline sequence id generation on Oracle using RETURNING clause
+
+
+Changes in version 3.2 alpha2 (2006.03.15)
+-------------------------------------------
+
+** Bug
+ * [HHH-535] - properties element causes exception in interface/abstract class
+ * [HHH-1325] - ArrayOutOfBounds expected in DatabaseMetadata.isTable when specifing schema
+ * [HHH-1435] - many-to-one lazy seems to be broken in 3.1.x
+ * [HHH-1531] - NPE with many-to-many and property-ref
+ * [HHH-1546] - generated version properties fail with multiple actions per flush
+
+** Improvement
+ * [HHH-1540] - Better Error Feedback In CollectionEntry.postFlush(PersistentCollection)
+ * [HHH-1555] - ConnectionReleaseMode.AFTER_STATEMENT and flushes
+ * [HHH-1559] - introduce TransactionFactory.isTransactionInProgress to facilitate EJB3 joinTransaction handling
+
+
+Changes in version 3.2 alpha1 (2006.02.28)
+-------------------------------------------
+
+** Bug
+ * [HHH-687] - Exception QuerySyntaxError not really serializable
+ * [HHH-1236] - Remove static reference to classloader, to avoid memory leak at webapp reload
+ * [HHH-1287] - Problem with WAS ExtendedJTATransaction not available when using MDB
+ * [HHH-1419] - Update + Exists doesn't seem to work
+ * [HHH-1445] - SchemaUpdate closes shared ConnectionProvider
+ * [HHH-1464] - QueryException from Query.getReturnAliases when query uses "fetch"
+ * [HHH-1486] - Concurrent access issues with both SoftLimitMRUCache and SimpleMRUCache
+ * [HHH-1508] - Session.createQuery() should not flush the session
+
+** Improvement
+ * [HHH-1411] - Collection fetches and DISTINCT
+ * [HHH-1412] - Collection fetches and firstResult/maxRows
+ * [HHH-1416] - LockMode.FORCE to implement EJB3 LockModeType.WRITE
+ * [HHH-1457] - support new optimisitc locking capabilities of JBossCache
+ * [HHH-1466] - better handling of Antlr exceptions
+ * [HHH-1516] - support DataDirect standard jdbc stored procedures
+ * [HHH-1518] - Guarentee LockMode behaviors
+ * [HHH-1520] - with clause with implied joins within an explicit join
+ * [HHH-1526] - Improved DTDEntityResolver
+
+** New Feature
+ * [HHH-1251] - Avoid replicating the clearing of TreeCache on SessionFactory..close()
+ * [HHH-1410] - FlushMode.AUTO -> COMMIT when outside a transaction
+ * [HHH-1447] - pluggable bytecode libraries
+
+
+Changes in version 3.1.2 (01.27.2006)
+-------------------------------------------
+
+** Bug
+ * [HHH-73] - Statistics for HQL queries use pre-processed query string
+ * [HHH-1306] - HQL parsing problem with join fetching of arrays/collections of values
+ * [HHH-1370] - Warning in hibernate-mapping-3.0.dtd
+ * [HHH-1371] - MappingException is thrown when the same column is referenced with different case
+ * [HHH-1386] - Numeric (long) literals not properly handled by HQL parser
+ * [HHH-1390] - Session.isOpen() throws exeception when the session is closed with ThreadLocalSessionContext
+ * [HHH-1391] - Invalid parameter index SQLException when using named parameters after positional parameters
+ * [HHH-1392] - Proxies cannot be serialized after session is closed
+ * [HHH-1398] - extends and entity-names broken with mapping-level package attribute
+ * [HHH-1407] - return-join broken for entity collections
+
+** Improvement
+ * [HHH-1364] - Defensive check of isClosed when obtaining a connection from ConnectionManager
+ * [HHH-1367] - warn level log "this operation breaks ==" may be disturbing
+
+** New Feature
+ * [HHH-1372] - Support for MySQL5 new varchar length
+
+** Patch
+ * [HHH-1005] - Criteria LEFT JOIN capability when adding Order to associations
+
+** Task
+ * [HHH-1373] - Document update versioned
+
+
+Changes in version 3.1.1 (01.13.2006)
+-------------------------------------------
+
+** Bug
+ * [HHH-853] - DML-style HQL queries and associations
+ * [HHH-1281] - FORWARD_ONLY ScrollableResults#next() throw GenericJDBCException
+ * [HHH-1286] - Set entity in HQL query without prefix -> incorrect SQL
+ * [HHH-1308] - Session.createFilter(...).iterate() results in bogus column names for result set extraction
+ * [HHH-1314] - float/double literals not sent to the database correctly
+ * [HHH-1316] - SchemaUpdate : java.sql.SQLException: You cannot commit during a managed transaction!
+ * [HHH-1328] - org.hibernate.util.SimpleMRUCache keeps a soft reference to the cache key, so cached values get collected prematurely
+ * [HHH-1336] - ForeignGenerator does not handle transient entities with an entity-name properly
+ * [HHH-1337] - Mapped <component> generated column names incorrect with ImprovedNamingStrategy
+ * [HHH-1349] - HQL delete statement problem due to oracle lacking table aliases in delete clause
+ * [HHH-1361] - creating temporary table for bulk delete will commit current transaction in managed environment such as J2EE
+
+** Improvement
+ * [HHH-1019] - Native SQL return-property mapping doesn't support dot-syntax in return-property for components
+ * [HHH-1290] - Defensive checking of session status
+ * [HHH-1302] - query.getReturnTypes inconsistent
+ * [HHH-1304] - better handling of borrowed connections in non-ON_CLOSE release semantics
+ * [HHH-1309] - schemaupdate does not handle TableHiLoGenerator
+ * [HHH-1339] - empty property name in mapping file gives imcomprehensible error message
+ * [HHH-1344] - ANSI-SQL trim function for SQLServer
+ * [HHH-1345] - ANSI-SQL mod function for SQLServer
+ * [HHH-1346] - ANSI-SQL bit_length function for SQLServer
+ * [HHH-1351] - <return-scalar name="blah"/> should be possible
+ * [HHH-1360] - set autodiscovery flag for SQLQueries when resultsetmappings are used
+
+
+Changes in version 3.1 (12.12.2005)
+-------------------------------------------
+
+** Bug
+ * [HHH-849] - Cartesian product + implicit joins
+ * [HHH-1065] - user provided connection not usable by default due to agressive release changes
+ * [HHH-1101] - associations join fetched in HQL without owner being selected
+ * [HHH-1133] - Comparators, defined for collections in mapping files, are not set
+ * [HHH-1149] - NPE flushing reattached entity w/ non-mutable natural-id
+ * [HHH-1170] - HQL 'cast' function doesn't work with MySQL 4 when casting to string
+ * [HHH-1187] - Cannot delete a object having a delete-orphan collection when user_rollback_id is set
+ * [HHH-1191] - HQL fails backward compatibility using classic translator
+ * [HHH-1194] - hql delete statements with joined-subclass hierarchies with a mapped where attribute at the root
+ * [HHH-1206] - Mappings.TableDescription is not serializable
+ * [HHH-1212] - mismatch in entity-modes defined in DTD and EntityMode class
+ * [HHH-1227] - ClassCastException on DOM4J replicate of Calendar property
+ * [HHH-1239] - BinaryArithmeticOperatorNode.getDataType() does not properly handle date/time arithmetic
+ * [HHH-1240] - Track connection leakage in JDBCContext.afterTransactionCompletion()
+ * [HHH-1245] - Calling the Session should register it with the current JTA txn.
+ * [HHH-1254] - Serialization of Sessions using JDBCTransactions with auto-flush/auto-close
+
+** New Feature
+ * [HHH-1222] - Autodiscover scalar types in native-sql
+ * [HHH-1243] - allow placeholders to system properties in config properties
+ * [HHH-1244] - Support for MySQL5 stored procedures
+ * [HHH-1260] - Configuration.mergeProperties()
+
+** Task
+ * [HHH-1066] - Upgrade CGLIB to fix proxy memory leak
+ * [HHH-1242] - upgrade ANTLR to 2.7.6rc1
+
+** Improvement
+ * [HHH-860] - insert ... select ... and version numbers
+ * [HHH-926] - TypeDef should be global
+ * [HHH-1138] - No ConstraintName when using PostgreSQL
+ * [HHH-1144] - Implement naming convention for temporary test failures
+ * [HHH-1153] - PropertiesHelper fails reading primitive values from hibernate-mapping when doc has whitespace
+ * [HHH-1182] - Access to filter metadata
+ * [HHH-1183] - Getting sql "plan" for DML operations
+ * [HHH-1197] - Support for HQL delete on MaxDB
+ * [HHH-1198] - post-insert event pass the entity wo the id field filled when the generator is identity
+ * [HHH-1213] - make JACC event listeners auto configurable (through initialize(Configuration))
+ * [HHH-1215] - Added support for LVARCHAR in InformixDialect
+ * [HHH-1218] - Add concat() function support to SAPDBDialect
+ * [HHH-1255] - ThreadLocalSessionContext and Session serialization
+
+** Patch
+ * [HHH-967] - executeUpdate on StatelessSession
+ * [HHH-1172] - Missing configuration templates for the new MimerSQLDialect
+
+** Deprecation
+ * [HHH-1229] - deprecate ability for entities to not define identifier properties
+
+
+Changes in version 3.1 rc3 (17.11.2005)
+-------------------------------------------
+
+** Bug
+ * [HHH-755] - Setter / Getter for property gDate are wrong
+ * [HHH-764] - XML mapping
+ * [HHH-1034] - The connection is closed *outside* the JTA transaction in TransactionHelper
+ * [HHH-1062] - java:comp/UserTransaction not correct for JBoss
+ * [HHH-1064] - Exception using JTATransaction in WebSphere 6
+ * [HHH-1069] - Unnecessary commas generated in select with left outer joins
+ * [HHH-1075] - New parser "not exists" command bug
+ * [HHH-1077] - Typo in docs: "equiped"
+ * [HHH-1080] - HQL delete fails on entities with where-fragments using operators other than '='
+ * [HHH-1081] - missing parens in example code for Criteria Associations
+ * [HHH-1084] - incorrect method name "sql" in Restrictions example, should be "sqlRestriction"
+ * [HHH-1091] - Can't write transparent CurrentSessionContext for BMT
+ * [HHH-1098] - Patch for build.sh to be able to build latest version on linux
+ * [HHH-1106] - HQL "not in" generatad wrong SQL
+ * [HHH-1111] - JDBCTransaction.rollback() results in a call to Interceptor.beforeTransactionCompletion()
+ * [HHH-1128] - Column alias clashes under certain circumstances
+ * [HHH-1146] - latest cvs(11/10/05) hibernate3 issue with classic query
+ * [HHH-1156] - StatefulPersistenceContext not serializable when property-ref is used
+ * [HHH-1160] - Incorrect use of getGeneratedKey() for Oracle
+
+** New Feature
+ * [HHH-449] - korean hibernate reference manual
+ * [HHH-1129] - use expected-type in 'untyped' Query.setParameter()
+
+** Improvement
+ * [HHH-221] - Proxy for one-to-one with property-ref
+ * [HHH-844] - move parameter "bookkeeping" into QueryTranslator
+ * [HHH-1051] - "Compiled" native SQL queries are not cached
+ * [HHH-1061] - import.sql should allow more human readable and usable files
+ * [HHH-1078] - <dynamic-component> requires type on property
+ * [HHH-1120] - Make NamingStrategy to work nicely with HA and EJB3 naming strategy
+ * [HHH-1142] - added getSelectSequenceNextValString() and getCurrentTimestampSelectString() to TimesTenDialect
+
+** Patch
+ * [HHH-1063] - support for 'locate' function in SQLServer and Sybase dialects
+ * [HHH-1090] - Allow subqueries on criteria to obtain non-string results
+ * [HHH-1095] - Hibernate takes incorrect HasCode when a lot of CompositeKeys and Lazy loading is involved
+ * [HHH-1103] - finalize method filter for proxies
+ * [HHH-1136] - more meaningful AssertionFailure message in org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(...)
+
+
+Changes in version 3.1 rc2 (17.10.2005)
+-------------------------------------------
+** Bug
+ * [HHH-1045] - Example contains inner classes that aren't serializable
+ * [HHH-1055] - optimistic-lock is not inherited from class to subclass et.al.
+
+** Improvement
+ * [HHH-702] - auto detect aliasing for collection properties (coll.key, coll.id etc.)
+ * [HHH-1038] - make 'auto' the default for hibernate.connection.release_mode
+ * [HHH-1042] - determine "expected type" of parameters during HQL parsing
+
+
+Changes in version 3.1 rc1 (07.10.2005)
+-------------------------------------------
+** Bug
+ * [HHH-528] - component.manyToOne.id in HQL causes join
+ * [HHH-871] - Configuration.setListener(String type, Object listener) throws ClassCastException
+ * [HHH-873] - referencing raw HQL FromElement alias outide the from clause of update and delete statements generates incorrect sql
+ * [HHH-876] - PreparedStatement being closed before being executed by AbstractBatcher
+ * [HHH-884] - SchemaExport does not propagate parent indexes to <union-subclass> tables
+ * [HHH-887] - Aggressive release and Session.connection()
+ * [HHH-893] - custom tuplizer are not instantiated for components
+ * [HHH-905] - $PlaceHolder$ remains in generated SQL when filter is enabled
+ * [HHH-907] - optimistic-lock="false" for timestamped object results in SQLException: Invalid column index
+ * [HHH-908] - CLONE -NullPointerException when using BigInteger in a query
+ * [HHH-911] - CGLIBLazyInitializer and Exceptions
+ * [HHH-913] - NPE in CMTTransaction since javax.transaction.Transaction is never set
+ * [HHH-918] - impossible to move objects to another session
+ * [HHH-924] - Useless OracleErrorCodeConverter (and possibly others)
+ * [HHH-932] - HQL UPDATE and <union-subclass>
+ * [HHH-946] - QuerySyntaxException might not be serializable
+ * [HHH-964] - ORA-00936 with joined subclass / Oracle
+ * [HHH-986] - Need to check Thread.currentThread().getContextClassLoader() in ConfigHelper
+ * [HHH-991] - Cannot use comparator class
+ * [HHH-1000] - varchar(xxx char) not supported on Oracle8i
+
+** New Feature
+ * [HHH-950] - interface for SessionFactory.getCurrentSession() handling
+
+
+** Improvement
+ * [HHH-608] - update HSQLDialect for HSQL 1.8 sequence support
+ * [HHH-889] - Add read-only cache-mode comment in <query and <sql-query
+ * [HHH-898] - OracleDialect UTF8 varchar2
+ * [HHH-909] - Onquoted primary key in IncrementGenerator
+ * [HHH-988] - generated="never|insert|always"
+ * [HHH-989] - add discussion of implicit and explcit joins
+ * [HHH-1011] - Make disconnect/reconnect of a Session implicit
+
+** Patch
+ * [HHH-994] - Sybase/SQLServer support for temporary tables
+
+
+Changes in version 3.1 beta 3 (13.09.2005)
+-------------------------------------------
+** Bug
+ * [HHH-528] - component.manyToOne.id in HQL causes join
+ * [HHH-871] - Configuration.setListener(String type, Object listener) throws ClassCastException
+ * [HHH-873] - referencing raw HQL FromElement alias of update and delete statements
+ * [HHH-876] - PreparedStatement being closed before being executed by AbstractBatcher
+ * [HHH-884] - SchemaExport does not propagate parent indexes to <union-subclass> tables
+ * [HHH-887] - Aggressive release and Session.connection()
+ * [HHH-893] - custom tuplizer are not instantiated for components
+ * [HHH-905] - $PlaceHolder$ remains in generated SQL when filter is enabled
+ * [HHH-907] - optimistic-lock="false" for timestamped object results in SQLException: Invalid column index
+ * [HHH-908] - NullPointerException when using BigInteger in a query
+ * [HHH-911] - CGLIBLazyInitializer and Exceptions
+ * [HHH-913] - NPE in CMTTransaction since javax.transaction.Transaction is never set
+ * [HHH-918] - impossible to move objects to another session
+ * [HHH-924] - Removed ErrorCodeConverters
+ * [HHH-946] - QuerySyntaxException might not be serializable
+
+** Improvement
+ * [HHH-898] - OracleDialect UTF8 varchar2
+ * [HHH-909] - Unquoted primary key in IncrementGenerator
+
+
+Changes in version 3.1 beta 2 (16.08.2005)
+-------------------------------------------
+** Bug
+ * [HHH-477] - Boolean discriminators generate invalid SQL for PostgreSQL dialect
+ * [HHH-480] - SchemaExportTask ignores some properties not defined in hibernate.properties
+ * [HHH-615] - SchemaExport outputFile ignores ant's basedir
+ * [HHH-770] - hql query execution generates invalid SQL
+ * [HHH-779] - Assertion failure occured with Hibernate 3 saving objects
+ * [HHH-781] - SimpleExpression ignorecase regression
+ * [HHH-799] - merge() and embedded composite identifiers
+ * [HHH-801] - subselect fetch and named parameters
+ * [HHH-802] - querying "mapped" composite identifiers
+ * [HHH-803] - no version increment from delayed collection adds
+ * [HHH-805] - Session.getStatistics().getEntityCount() throws UnsupportedOperationException
+ * [HHH-819] - Firebird CONCAT SQL function
+ * [HHH-821] - query by natural-id cache is not update when object is inserted or deleted
+ * [HHH-822] - <key-property> will actually pick up <type> tags if it were allowed by the DTD
+ * [HHH-825] - ReadWrite-Cache issues NullPointerException after modification of an array
+ * [HHH-839] - Session.refresh not working for custom 'Load' SQL
+ * [HHH-849] - Cartesian product + implicit joins
+ * [HHH-854] - Class with mapped composite id can't have subclasses
+ * [HHH-858] - Autocommit status inconsistent in connections created by DriverManagerConnectionProvider
+ * [HHH-863] - Hibernate generates "notExists" instead of "not exists"
+ * [HHH-868] - Missing parens after / or -
+
+** New Feature
+ * [HHH-35] - add attribute haltonerror to schemaexport Ant task
+ * [HHH-182] - Mimer SQL Dialect for Hibernate 3
+ * [HHH-704] - Statistics for optimistic lock failures
+ * [HHH-725] - Allow hooks into all executed sql by a session
+ * [HHH-783] - collection lazy="extra"
+ * [HHH-818] - Optimisitc locking using database current timestamp
+ * [HHH-828] - session.getTransaction()
+ * [HHH-829] - <cache include="all|non-lazy" ... />
+ * [HHH-831] - allow database generated property values
+ * [HHH-832] - allow database generated property values for versioning
+ * [HHH-838] - Transaction.setTimeout()
+ * [HHH-840] - allow definition of "auxiliary" database objects in mapping
+ * [HHH-846] - Add Intializable interface for events
+ * [HHH-848] - Validate mappings against JDBC metadata
+ * [HHH-859] - post-commit events
+
+** Improvement
+ * [HHH-133] - schemaexport task: provide independent drop/create output
+ * [HHH-135] - parameterized types can't be used on key-property or ir (possible others)
+ * [HHH-552] - NoopAccessor for HQL-only properties
+ * [HHH-680] - Easier support for doing UserCollectionType's
+ * [HHH-686] - Final classes and classes with private null ctors cause unhelpful NullPointerException
+ * [HHH-754] - Allow HQL DML for implicit polymorphism
+ * [HHH-782] - Avoid unnecessary updates when component property is update='false' but modified
+ * [HHH-786] - Improve lazy options for <one-to-one>
+ * [HHH-791] - Use cascade styles when fetching entities in refresh() and merge()
+ * [HHH-815] - Confusing use of the term "dereference"
+ * [HHH-830] - Improvements to caching lazy properties
+
+** Patch
+ * [HHH-378] - Better LockMode.UPGRADE for DB2 UDB v8.2
+ * [HHH-430] - Improved SizeExpression with greater, lesser, not equals, etc. capabilities
+ * [HHH-735] - SchemaUpdate reads table metadata from wrong schema
+ * [HHH-780] - org.hibernate.proxy.BasicLazyInitializer reflection hotspot
+ * [HHH-864] - Use QUERY_CACHE for sessions with filters to improve performance
+
+
+Changes in version 3.1 beta 1 (21.07.2005)
+-------------------------------------------
+
+** Bug
+ * [HHH-145] - union-subclass and oracle 8i
+ * [HHH-374] - EJB3 example delete query doesn't work in Hibernate.
+ * [HHH-447] - EHCache integration prevents multiple session factories
+ * [HHH-488] - JACCListeners are not working at all
+ * [HHH-564] - missing commas for implicit joins
+ * [HHH-577] - joins within subqueries on dbs supporting ansi-joins result in extraneous commas
+ * [HHH-592] - cast() function doesn't know its returned Hibernate type
+ * [HHH-639] - CGLIB instrumentation of subclasses
+ * [HHH-658] - Bug in Alias Name Generation
+ * [HHH-671] - Firebird support of sequences/generators
+ * [HHH-679] - setLockMode(LockMode.UPGRADE_NOWAIT) does not translate to correct SQL on Oracle
+ * [HHH-688] - Bad implementation in org.hibernate.type.CustomType.stringToObject
+ * [HHH-691] - generated column alias is incorrect if there is a prior relationship and the table column names are similar to the table name
+ * [HHH-694] - NPE when accessing the SLCache stats with TreeCache
+ * [HHH-698] - Exception on EG , trying to change immutable id (natural-id)
+ * [HHH-699] - Incorrect Tablename genetaion when using MySQL Dialect and no Schema definition
+ * [HHH-708] - Restrictions.in could not be used properly on composite-ids
+ * [HHH-709] - ArrayType.replaceElements fails if original.length != target.length
+ * [HHH-718] - HQL "fetch all properties" not working for column level lazy props
+ * [HHH-726] - ConstraintViolationException with primitive collection
+ * [HHH-727] - java.lang.StackOverflowError when cascade="true" on both sides of bidirectional one-to-one association using FK
+ * [HHH-734] - HQL incorrectly parses certain query strings
+ * [HHH-736] - Use of sql functions containing space not supported in filter conditions
+ * [HHH-738] - formula property with select-before-update
+ * [HHH-747] - Order.toSQLString generates incorrect statement
+ * [HHH-748] - component dereferencing in subquery from clauses
+ * [HHH-752] - Typo in 8.5.3 bidirectional one-to-one jjoin table example
+ * [HHH-757] - NullPointerException when using BigInteger in a query
+
+** New Feature
+ * [HHH-595] - HQL insert select
+ * [HHH-597] - Named XML resultsetmappings
+ * [HHH-696] - handle discriminators on HQL insert
+ * [HHH-697] - allow bumping versions in HQL update
+ * [HHH-716] - handle version columns in bulk inserts
+ * [HHH-723] - Need to be able to pass in javax.sql.DataSource in SF creation
+ * [HHH-739] - Order.ignoreCase()
+ * [HHH-741] - select clause subselects
+ * [HHH-742] - Stateless session
+ * [HHH-744] - collection fetching in scroll() via "break processing"
+ * [HHH-768] - <many-to-many property-ref=".."/>
+
+** Improvement
+ * [HHH-14] - Add Session.delete(String entityName, Object entity)
+ * [HHH-295] - cleanup and expose the Tuplizers
+ * [HHH-352] - HQL bulk and cache
+ * [HHH-689] - exclude parens for components outside where-clause
+ * [HHH-743] - {coll.key}, {coll.index}, {coll.element}, etc
+ * [HHH-745] - EJB3 composite PK style
+ * [HHH-749] - Cascade merge() and unidirectional one-to-many
+ * [HHH-750] - use attribute name other than 'type' in dynamic-maps
+ * [HHH-753] - Replace antlr System.exit with QueryException
+ * [HHH-769] - property-ref="foo.bar" to a component property
+ * [HHH-772] - null in maps are handled inconsistently
+ * [TODO-18] - optimistic-lock="all|dirty" with components
+
+
+Changes in version 3.1 alpha 1 (24.06.2005)
+------------------------------------
+** Bug
+ * [HHH-204] - Wrong/uncommon log name in class ...hql ast ErrorCounter
+ * [HHH-241] - HQL lexer doesn't support unicode quoted strings
+ * [HHH-354] - property named "full" breaks HQL queries
+ * [HHH-493] - WARNING: Keyword 'member' is being intepreted as an ident
+ * [HHH-538] - length() function does not work in SQLServerDialect
+ * [HHH-539] - ClassCastException on mapping a property with a formula in a set of composite elements
+ * [HHH-540] - Mapping a one-to-many collection with a non-null foreign key within a component fails on save
+ * [HHH-547] - Cannot commit using UserCollectionType and debug logging
+ * [HHH-548] - many-to-many faulty delete optimization when filter in use
+ * [HHH-554] - Hibernate 3 HQL to SQL FROM Clause Comma Generation Problem
+ * [HHH-558] - HQL doesn't support multi-byte character in class name and property names
+ * [HHH-559] - quoted multi-byte character in HQL is translated into weird character in SQL.
+ * [HHH-565] - delete-orphan generating AssertionFailure
+ * [HHH-566] - The result is not correct in 'createQuery("select new Foor(x,x) from Foo").scroll()'
+ * [HHH-570] - size operator fails on a many to many in HQL
+ * [HHH-571] - JDK 1.3 Compatibility Issue
+ * [HHH-573] - error when merging entity graph has cascade level>2
+ * [HHH-575] - org.hibernate.cache.FilterKey is not Serializable
+ * [HHH-589] - parameterized expression inside function
+ * [HHH-594] - order-by mapping for collections overrides order by in HQL
+ * [HHH-601] - New temporary table feature assumes all persisters are ready
+ * [HHH-614] - SchemaUpdate broken in DB2/400
+ * [HHH-622] - Spelling mistake 'intepreted' in org.hibernate.hql.PARSER warning
+ * [HHH-642] - criterias with projection
+ * [HHH-650] - FilterImpl is Serializable yet FilterDefinition is not
+ * [HHH-657] - Date parse exception using EntityMode.DOM4J
+ * [HHH-666] - JTAHelper.isInProgress( txn.getStatus()) throws NPE when txn null
+
+** New Feature
+ * [HHH-620] - Extra join conditions in HQL
+ * [HHH-640] - short-circuit dirty checking for instrumented classes
+ * [HHH-643] - support mutable="false" for collections
+ * [HHH-645] - Session.setReadOnly()
+ * [HHH-549] - portable to_char() function
+ * [HHH-576] - Hook to pre-process generated select strings in the Dialect
+ * [HHH-662] - Add support for definition of functional composite key ("properties") in joined subclass
+
+** Improvement
+ * [HHH-46] - Allow access to properties that are not joined
+ * [HHH-261] - Stored procedure support for SQLServer dialects
+ * [HHH-351] - multi-table bulk operations
+ * [HHH-574] - improve in naming named-query
+ * [HHH-596] - Auto-detect {..} in native SQL queries
+ * [HHH-641] - create constraints for many-to-one property-ref
+ * [HHH-501] - warn when a final method is tried to be proxied
+ * [HHH-525] - cglib related startup performance
+ * [HHH-557] - Helpful error message for non Serializable classes with a composite-id
+ * [HHH-586] - check immutable natural-ids
+ * [HHH-609] - Adds substr to PostgreSQL dialect
+ * [HHH-618] - documentation bugs
+
+** Patch
+ * [HHH-224] - JDataStore Dialect and updated Testfiles
+ * [HHH-366] - InformixDialect SQLExceptionConverter
+ * [HHH-536] - ImprovedNamingStrategy modifies capitalized column names inappropriately
+ * [HHH-632] - Informix Dialect missing from automatic dialect discovery
+ * [HHH-4] - CachedFile bugfix + configuration + autodetect resource as file
+
+
+Changes in version 3.0.5 (25.5.2005)
+------------------------------------
+
+** Bug
+ * [HHH-516] - Interceptor.onFlushDirty() sometimes not called
+ * [HHH-517] - getDatabaseMajorVersion() not available in JDK 1.3
+ * [HHH-518] - SQL parser does not recognize all whitespace
+ * [HHH-519] - broken SQL when traversing many-to-many to joined <subselect>
+ * [HHH-529] - Bug in merge()
+
+** New Feature
+ * added <natural-id> mapping
+ * [HHH-533] - allow unique-key on <property> and <many-to-one>
+ * [HHH-534] - efficient cache by natural key
+ * support for <comment> on MySQL
+
+** Improvement
+ * [HHH-526] - log "Aggressively releasing JDBC Connection" as DEBUG instead of INFO
+ * various logging improvements
+
+
+Changes in version 3.0.4 (23.5.2005)
+------------------------------------
+
+** Bug
+ * [HHH-452] - UnsavedValueFactory.instantiate does not wrap the Exception it catches
+ * [HHH-456] - Session still holds references to entities after close()
+ * [HHH-457] - Log info for structured second-level cache entries is incorrect
+ * [HHH-466] - Made default for MS SQL dialect definition more flexible
+ * [HHH-473] - Formula can't contain SQL cast keyword
+ * [HHH-484] - Order-by not applied to collections fetched by OuterJoinLoader
+ * [HHH-487] - Possible empty union in UnionSubclassEntityPersister
+ * [HHH-505] - Possible NullPointerException in BigIntegerType
+ * [HHH-507] - Cached List does not show additions
+ * Fixed bugs in subselect fetching
+
+** New Feature
+ * [HHH-455] - Obtain non-intercepted Session by passing an EmptyInterceptor
+ * [HHH-467] - HQL: support for case when then else end IN select clause
+ * [HHH-485] - Support multiple collection join fetches (attention: Cartesian product) in native SQL queries
+ * Added SessionStatistics metric interface
+ * Added support for table and column level <comment> blocks
+ * Added Simplified Chinese translation of reference documentation (Xiaogang Cao)
+
+** Improvement
+ * Any query may now join fetch >1 collection role (attention: Cartesian product)
+ * [HHH-454] - Add 2292 integrityViolationCode to Oracle9Dialect
+ * [HHH-503] - Implemented ViolatedConstraintNameExtracter for HSQLDialect (Frank Grimes)
+
+
+Changes in version 3.0.3 (8.5.2005)
+-----------------------------------
+* fixed bug in HQL for composite key classes which have a property named the same as the owning entity's id property
+* replaced 'connection.aggressive_release' with 'hibernate.connection.release_mode'
+* added ConnectionReleaseMode
+* added eager fetch for any associations with fetch=join, even after a HQL query, or cache retrieval (EJB3)
+* added replicate() isUpdate flag to OnReplicateVisitor, useful for native ids
+* fixed ParameterizedTypes order of initialization
+* fixed bug in DB2Dialect
+* fixed EntityMode.DOM4J creation of duplicate <set> output
+* fixed JDBCException error code handling
+* fixed Criteria Restrictions.isEmpty()/isNotEmpty() when collection is mapped to superclass
+* fixed HQL indexed collections access with no alias
+* fixed HQL aggregate functions on components when "id" property is used
+* fixed issue with non-cascading refresh to collections
+* fixed query-timeout not being applied to bulk HQL (Stephan Fudeus)
+* fixed pessimistic locking with Firebird (Yuichi Sugimura)
+* updated Ant 1.6.3
+* improved validation of sql queries, throw QueryException if addEntity() nor addScalar() was called
+* added automatic dialect detection if no dialect is configured
+* added new tutorial (Michael Gloegl, Christian Bauer)
+
+
+Changes in version 3.0.2 (27.4.2005)
+------------------------------------
+* fixed union operations on PostgreSQL
+* fixed HQL concat() function for Oracle dialect
+* fixed auto-close/auto-flush during getCurrentSession() processing
+* fixed ClassCastException with EntityMode.DOM4J
+* fixed HQL dynamic instantiation with iterate()
+* fixed HQL bug with missing parantheses and implicit joins
+* fixed bug were Interceptor.getEntity() wasn't called if in cache
+* fixed bug in merge() of sorted sets
+* fixed bug in EntityMode.DOM4J with non-lazy embedded many-to-ones
+* fixed Criteria/Projection ordering bug
+* fixed HQL referencing component attribute
+* fixed column duplication detection for components
+* fixed eager fetching for many-to-many associations
+* fixed stack overflow with auto_close_session and aggressive_release and unclosed ScrollableResults/HibernateIterator
+* fixed bug in HQL parser regarding naked property refs which reference component properties
+* fixed bug with eager fetched arrays not being loaded
+* fixed bug in filter against joined-subclass
+* improved CacheMode.GET/IGNORE, disabled cache put
+* improved HQL support for standard SQL functions, including coalesce() and nullif()
+* improved filtering of many-to-many associations
+* added HQL support for cast(x as type) if SQL database supports it
+* added increment id generation for union-subclass
+* added ConnectionProvider.supportsAggressiveRelease() for managed environments
+* added support for caching of queries if filter is enabled
+* added PreparedStatement count to Statistics
+* added transactional/nontransactional read()/get() to Cache API
+* added quotation of schema names
+* added Distinct to Projection API
+* added config parameter 'connection.aggressive_release'
+
+Changes in version 3.0.1 (18.4.2005)
+------------------------------------
+* added HQL tuple constructor/comparison feature
+* added HQL "fetch all properties" override if instrumentation is used for lazy loading
+* added HQL projection feature, return Lists instead of arrays for projection
+* added HQL projection feature, return Maps with user-defined HQL SELECT aliases as keys
+* added HQL support for expressions in aggregation functions
+* added new IntegrityViolationException to MySQL dialect
+* added value mapping type 'big_integer'
+* added not-found="ignore|exception" switch for legacy associations (i.e. broken database integrity)
+* added fully automatic Session scoping in JTA environments with sf.getCurrentSession()
+* fixed bug in DTD that wouldn't allow union-subclass in separate file
+* fixed a MS SQL Server case sensitivity issue with native SQL queries
+* fixed a minor bug in subselect fetching
+* fixed case sensitivity in HQL functions
+* fixed a bug with listener assignment for save() operation (Matthew Inger)
+* fixed return-property in named SQL queries to work with all identifier names
+* fixed TransactionManager lookup (again) for WAS 6.0
+* fixed a bug with HQL batch delete and MS SQL Server
+* fixed session not getting closed with auto_close when rollback occured
+* improved concatentation handling in AST parser
+* updated dom4j to avoid memory leak in old version
+* updated C3P0
+
+
+Changes in version 3.0 (31.3.2005)
+----------------------------------
+* added support for autoflush/autoclose to HibernateServiceMBean
+* fixed initialization/session association detection problem of collections
+* fixed creation of FK constraints to union superclass table
+* fixed bug where union-subclass table did not get a PK constraint
+* added a separate log category for HQL parser warnings and errors
+* fixed bulk delete operation on MS SQL Server
+* added support for proxying protected methods (Juozas)
+* added support for unicode quoted strings in new HQL parser
+* fixed implied joins in subselect WHERE clause in new HQL parser
+* added SQLServer7Dialect to handle differences in functions
+* added support for JNDI-bound cache instances, future use for JBoss Cache
+* added scale attribute to column mappings for numeric precision control
+* added fetch=subselect for collections
+* added support for bulk update/delete against discriminator-based inheritence hierarchies
+* added the ability to use naked property refs in HQL (required in update/delete statements)
+* updated CGLIB 2.1.0
+* fixed NPE at BasicEntityPersister.getPropertyIndex (Todd Nine)
+* fixed issue with entity-name and subclasses (Sverker Abrahamsson)
+* fixed issue with correlated subqueries in new HQL parser
+* fixed a problem with native SQL query mapping and embedded composite identifiers
+* improved mapping binding, allowing unordered extends for pure entity-name hiearchies
+* fixed NPE for delete() with deprecated Lifecycle interface
+* fixed a problem with serial joins ending in component value in new HQL parser
+* fixed inner join/subselect precedence problem in new HQL parser
+* fixed indices() function in new HQL parser
+* fixed a bug in InformixDialect, now correct LIMIT clause
+* fixed a bug in idbag.remove() (Sebastien Cesbron)
+* fixed a conflict on OracleDialect between setMaxResult and LockMode.UPGRADE
+* fixed XML configuration file issue with SchemaExport
+* fixed an ArrayIndexOutOfBounds problem
+* renamed executeUpate() to executeUpdate()
+* fixed batch loading for property-ref entities
+* fixed loading from cache of <key property-ref> collection owner
+* fixed minor bug in SQL exception reporting
+* fixed dynamic-component cannot be bound to XML
+* fixed querying component with formula property
+* fixed incorrect table alias for order-by on many-to-many
+* fixed a bug for unidirectional one-to-many with moving child objects
+* fixed a bug with union-subclasses and persister creation
+* fixed a HQL concatenation problem on MySQL
+* fixed a bug where an unnecessary exception was thrown for a property-ref to a superclass property
+* fixed minor dtd bug
+* fixed new bug in Clob/Blob support
+* fixed issue with INDEX_OP and subclass joins on theta-join dialects
+* fixed some minor issues in query cache regions, including HB-1449
+* fixed superflous import and regression bug in verifyparameters
+* fixed two bugs in select id generator (Malcolm Green)
+* fixed increment generator for union-subclass mappings
+* updated JBoss Cache to 1.2.1alpha, fixing locking issues
+* made stat classes serializable
+* fixed merge(), now ignores blob and clob fields
+* added support/dialect for TimesTen
+* improved algorithm for batch fetching, more aggressive
+* improved toStrings()s for Statistics objects (Ryan Lynch)
+* renamed <result-*> to <return-*> for externalized SQL query mapping
+* renamed Session.openSession() for EntityMode to Session.getSession()
+* added support for CASE in HQL
+* fixed bug with filters and polymorphic queries
+* fixed import ordering problem of super/subclass mappings
+* switched to patched ANTLR 2.7.5, now using context classloader before doing class.forname
+* TableHiloGenerator now falls back to TableGenerator properly with max_lo < 2 (Emmanuel Bernard)
+* better transaction handling of TableGenerator in a JTA environment (Emmanuel Bernard)
+* removed hard coded log4j dependency (Emmanuel Bernard)
+* added support for stored procedure in named queries (Max Andersen)
+* added <property-result> to named SQL queries to allow users to use sql without {}-markup
+* added multi-column property support to native SQL mapping
+
+Changes in version 3.0rc1 (28.2.2005)
+----------------------------------
+* introduced EntityModes, and XML mapping preview
+* several minor dialect improvements
+* fixed a problem where filters were not applied to subclasses
+* fixed a problem where InstrumentTask would fail if applied to already-instrumented classes
+* fixed many problems with new parser and made it the default (thanks again to Joshua for the new parser)
+* implemented bulk update/delete queries for the new parser
+* fixed a minor bug in the classic query parser
+* renamed create() to persist() as per EJB3edr2
+
+Changes in version 3.0 beta 4 (11.2.2005)
+-----------------------------------------
+* support unidirection one-to-many with a not-null foreign key
+* support formulas for index and element of collections
+* support one-to-ones mapped to formulas
+* fixed a bug in proxying methods that return "this"
+* optimized proxies for embededded composite id classes
+* fixed a bug affecting <key-many-to-one>
+* fixed a bug caching newly inserted objects
+* introduced DetachedCriteria
+* support subselects in Criteria queries
+* miscellaneous Criteria API enhancements
+* fixed a problem where hibernate.max_fetch_depth applied to eager fetching via setFetchMode()
+* use inner joins for join fetching not-null fk associations
+* support unique="true" in <component> and <properties> mappings
+* union-subclass hierarchies may own collections (dtd bug)
+* added guid support for Oracle
+* new mechanism for auto-detecting unsaved-value
+* pass state array in delete events
+* improved implementation of hibernate.auto_close_session and hibernate.close_before_completion
+* fixed a bug where components with only collections would be incorrectly nullified
+* fixed a bug where criteria queries with projection could not be cached
+* fixed a problem where duplicate column name aliases could be generated
+
+Changes in version 3.0 beta 3 (30.1.2005)
+------------------------------------------
+* Major rework of Criteria queries, support for projection, grouping, aggregation, ordering by any attribute
+* various improvements to new HQL parser (Joshua Davis)
+* fixed a bug where <join fetch="select"> was broken for subclasses with duplicated property names
+* fixed problems with long types in Oracle DDL generation
+* added EnhancedUserType, UserCollectionType, UserVersionType
+* added CacheMode
+* fixed minor performance problem where cascade delete could add objects to second-level cache
+* added hibernate.default_batch_fetch_size
+* added hibernate.cache.use_structured_entries
+* different classes and collection roles may now share a cache region
+* don't include discriminators for abstract classes in generated SQL
+* it is no longer truly necessary for composite identifier classes to implement equals()/hashCode() (but still recommended)
+* workaround for bug in MySQL InnoDB with self-referential foreign keys
+* added lazy="true" to many-to-one and one-to-one mappings (requires bytecode instrumentation)
+
+Changes in version 3.0 beta 2 (24.1.2005)
+------------------------------------------
+* added LockAcquisitionErrorCodes to MySQL dialect (Jesse Barnum, Emmanuel Bernard)
+* added MultipleHiLoPerTableGenerator, one hi value per row/per table (compliant with EJB3)
+* added a generator handling multiple hi values per table (Emmanuel Bernard)
+* added events for pre/post SQL operation interception
+* added experimental support for JACC-aware configuration and events
+* added full support for implicit polymorphism in Criteria queries
+* added support annotated classes through XML configuration (Emmanuel Bernard)
+* added support for WebSphere's weird TxManagerLookup
+* added support for filters with dynamic-class mappings
+* added support for lists of parameters in filters
+* added support for scalar queries in createSQLQuery (Michael Gloegl)
+* added support for scalar results in native SQL queries (Michael Gloegl)
+* fixed SchemaExport/SchemaUpdate, now respect default_schema and default_catalog (Michael Gloegl)
+* fixed a bug in one-to-one mapping with property-ref
+* fixed a bug in the query cache lookup routine
+* fixed compilation problems on IBM JDK 1.4. and JDK 1.3.1
+* fixed custom SQL for loading when using composite identifiers
+* fixed exception thrown from optimistic locking failures
+* fixed support for limit queries (select first ?) in Informix
+* improved SchemaExport/Update, now respect default_schema and default_catalog
+* improved dialect handling, throw an exception if no dialect has been set
+* improved loading of mappings, no ordering of super/subclasses required anymore
+* improved statistics for second-level cache
+* improved table generators for hi/lo, can now be used in a JTA environment (Emmanuel Bernard)
+* query engine: added support for 'trim([leading | trailing | both] [expression from] expression)'
+* query engine: added support for DISTINCT and ALL
+* query engine: added support for FETCH
+* query engine: added support for HAVING count()
+* query engine: added support for HQL NOT IN and EJBQL '[NOT] MEMBER OF'
+* query engine: added support for ORDER BY COUNT(*)
+* query engine: added support for collections of scalar values
+* query engine: added support for literals in constructor select expressions.
+* query engine: added support for select elements(..) from Foo f
+* query engine: added support for template functions in the SELECT clause
+* query engine: fixed NOT LIKE
+* query engine: introduced EMPTY and added it to constant (support for IS [NOT] EMPTY)
+* updated dom4j, OSCache, EHCache, JBoss Cache, Xerces, Xalan, and Log4j
+* associated class where filter now applies to <one-to-one property-ref>
+
+Changes in version 3.0 beta 1 (21.12.2004)
+------------------------------------------
+* reimplemented HQL using an ANTLR-based AST parser (Joshua Davis)
+* added class="select" id generator
+* added Query.setReadOnly()
+* added hibernate.order_updates
+* introduced cascade refresh
+* added typed JDBC exceptions (Steve Ebersole)
+* improved lifecycle for CacheProviders (Steve Ebersole)
+* added Expression.isEmpty()
+* fixed some minor mapping DTD bugs (Ben Sommerville)
+* fixed auto-commit mode for SchemaUpdate
+* added default-lazy to <hibernate-mapping>, which defaults to true!
+* added fetch="join|select" and deprecated outer-join attribute
+* fixed a bug where <custom-insert> was not used for entities with "identity" id generation
+* fixed some problems with dynamic-class
+* added property-level optimistic-lock attribute, to allow an unchecked property
+* cascade lock() now cascades with LockMode.NONE
+* fixed some bugs in filter handling (Steve Ebersole)
+* added hibernate.transaction.flush_before_completion and hibernate.transaction.auto_flush_session
+* added JSR-220 compliant create() and merge() operations
+* cascade attribute is now multi-valued, with values save-update,create,merge,delete,delete-orphan,lock,evict,replicate,all-delete-orphan
+* index and unique-key attributes may now be multi-valued
+* introduced unsaved-value="undefined", the default for "assigned" ids and <composite-id>, which forces Hibernate to hit the db
+* primitive typed <id> property mappings now default to unsaved-value="0"
+* added ScrollMode
+* added dialect for Derby (Simon Johnston)
+* added MySQLMyISAMDialect and MySQLInnoDBDialect
+* added precision and scale mapping attributes, for numeric types in DDL
+* fixed a problem with duplicate column mappings on Sybase
+* read-write cache now uses version numbers to ensure consistency with database, if available
+* native SQL queries may now fetch a collection role (Steve Ebersole)
+* added sequential-select, optional and inverse attributes to <join/>
+* added <properties> element, which can be the target of a property-ref
+* fixed a bug relating to composite property-refs
+* Hibernate now much more robust if user does not implement equals()/hashCode() on id and unique key classes
+* enabled batch deletes for versioned data
+* fixed a minor bug in Session.close()
+* removed uuid.string and renamed uuid.hex to plain uuid
+* workaround for a MySQL bug in SchemaUpdate
+* added JDBCException.getSQL() and made various improvements to exception flow
+* createSQLQuery() now fully supports components
+* fixed a bug in SQL generation for <joined-subclass> mappings
+* fixed a bug where filter and query parameters could be bound in the wrong order (Steve Ebersole)
+* fixed a problem where quantifiers could not appear in SQL fragments
+* fixed a bug with dynamic components
+* fixed a bug where Dialect default properties overrode user-specified properties (Ben Sommerville)
+* fixed a bug where duplicate column name in a joined table caused an exception
+* implemented two-phase load for dynamic components
+* fixed a bug where cancelQuery() canceled a re-pooled statement
+* deleted collections are now removed from session-level cache
+* fixed a bug in LocaleType (Steve Ebersole)
+* use "with rr" to obtain UPGRADE locks in DB2
+* package attribute now significant for extends
+* fixed a minor problem with Hibernate Clobs and Blobs
+* extends attribute does no longer require specific ordering of mapping files
+
+Changes in version 3.0 alpha (23.8.2004)
+----------------------------------------
+* package rename net.sf.hibernate -> org.hibernate
+* checked exceptions are now runtime exceptions
+* some session methods deprecated and moved to org.hibernate.classic.Session
+* removed various deprecated functionality
+* added Filter API and mappings, for temporal, regional and permissioned data (Steve Ebersole, Gavin King)
+* support cascade delete via ON DELETE CASCADE constraint
+* added extra attributes to named query definition
+* added hibernate.use_identifier_rollback
+* added subselect mappings
+* added lazy="true" to property mappings
+* added <join/> for multitable mappings
+* added <union-subclass/> for table-per-concrete-class strategy
+* added Statistics API and JMX MBean (Gavin King, Emmanuel Bernard)
+* introduced new event-driven design (Steve Ebersole)
+* support for faster startup with Configuration.addCachableFile() (Joris Verschoor, Max Andersen)
+* mask connection password for log level greater of equals to info (Joris Verschoor, Emmanuel Bernard)
+* add check of named queries when building SessionFactory (Joris Verschoor, Emmanuel Bernard)
+* added custom EntityResolver setting capability (Emmanuel Ligne, Emmanuel Bernard)
+* PropertyValueException for null values in not-null properties of components (Emmanuel Bernard)
+* enhanced support for single- and no-argument sql-functions in HQL select clause (Michael Gloegl)
+* Added catalog element, to enable table names like catalog.schema.table (Michael Gloegl)
+* Added <sql-insert>, <sql-update> and <sql-delete> support (Max Andersen)
+* Support callable statements (stored procedures/functions) via callable="true" on custom sql (Max Andersen)
+* Added support for type parameters and typedefs (Michael Gloegl)
+* Added support for JDBC escape sequences in createSQLQuery (Max Andersen)
+* Added statistics per SessionFactory (Gavin King, Emmanuel Bernard)
+* Added a StatisticsService MBean for JMX publucation (Emmanuel Bernard)
+* support for updates via rownum in Oracle
+* fixed problems with SchemaUpdate
+* support for <column formula="..."/>
+* added hibernate.use_sql_comments
+* added property-ref to collection <key/>
+* fixed performance problems with <one-to-one property-ref=.../>
+* enhanced UserType with new methods assemble()/disassemble()
+* better algorithm for batch fetch batch sizes
+* added <dynamic-class>
+* added entity-name concept, and session methods save(entityName, object), update(entityName, object), etc
+* added framework in proxy package
+* native SQL queries may now fetch a collection role
+* added <loader/> for class and collection mappings
+* added getEntity() and getEntityName() to Interceptor
+* formula-based discriminators and association mappings
+* added "guid" id generation strategy
+* various improvements to dialects
+* <discriminator force="true"/> now acts as a filter on collections
+* where filters now apply in the on clause in an outer join
+* added hibernate.jdbc.factory_class to select a custom batcher
+* session now uses entity name + id to enforce uniqueness, instead of table name + id
+
+Changes in version 2.1.6 (9.8.2004)
+------------------------------------
+* fixed Quickstart/readme.txt instructions
+* fixed DB2/400 identity column support
+* fixed the scroll() query method
+* fixed exotic classloader problems with CGLIB
+* added insert="false" for discriminator columns which are part of a composite identifier
+* added several new configuration settings to JMX HibernateService
+* added new instantiate() method to SessionFactory.getClassMetadata()
+* improved the HSQL DB dialect with features from new version
+* added hibernate.jdbc.batch_versioned_data (Steve Ebersole)
+
+Changes in version 2.1.4 (2.6.2004)
+------------------------------------
+* improved Session serialization support by adding ability to serialize unflushed sessions (Steve Ebersole)
+* fixed Session.clear() functionality to clear the internal nonExists cache (Steve Ebersole)
+* much better implementation of scroll() (Steve Ebersole)
+* support "select new ..." for iterate() and scroll() (Steve Ebersole)
+* added support for multi-parameter SQL functions (Steve Ebersole)
+* fixed hbm2ddl generating infinite indexes on MySQL (Michael Gloegl)
+* fixed alias precedence in HQL queries, function names are second (Steve Ebersole)
+* added "transactional" as allowed cache concurrency strategy in XML configuration file
+* improved System.getProperties() with security exception warning in secure environments
+* improved Proxool integration, better property handling
+* fixed problem with use of getDefinedMethod() in secure environments (Ken Arnold)
+* fixed bug in createSQLQuery() which prohibited multiple aliases for the same entity (Max Andersen)
+* fixed query cache misses when using named bind parameters (Michael Greer)
+* recognize "left" and "right as keywords in SQL fragments
+* recognize SQL quoted identifiers in SQL fragments
+* improved identity handling on SQL Server by using scope_identity() for update counts (Arthur Fitt)
+* added DB2390Dialect for DB2/390 databases (Kristoffer Dyrkorn)
+* fixed a bug in toArray() of identifier bag collections (Khachchou Mohammed)
+* fixed a problem with DDL generation for serial columns in Informix
+* fixed a problem with DDL generation for timestamp columns in Informix (Michael Schmidt)
+* fixed a NPE that occurred calling saveOrUpdateCopy() for components
+* fixed a bug with replicate() and uninitialized collections
+* fixed a bug caching one-to-one associations
+* fixed eviction from named query cache regions
+
+Changes in version 2.1.3 (25.4.2004)
+-----------------------------------
+* added SELECT-clause SQL function support to main Dialects
+* fixed a problem where some unnecessary selects where issued for optional one-to-one associations
+* fixed a bug in SQL generation for criteria queries with multiple one-to-many joins
+* deprecated everything related to PersistentEnum
+* fixed an NPE that occurred when using <one-to-one property-ref> with composite ids
+* fixed a problem with JCA adaptor on WebLogic (Michael Gloegl)
+* improved behavior when removing elements from <idbag>s
+* fixed a bug in getGeneratedKeys() support (Michael Gloegl, Kevin Day)
+* fixed a bug when using Criteria queries with collections of joined-subclasses
+* fixed an NPE that occurred when calling comparator() on a lazy sorted set (Attila Szegedi)
+* fixed a bug when using setMaxResults() with native SQL queries in some Dialects
+* validate that composite id classes override hashCode() (Adrien)
+* fixed some minor problems with saveOrUpdateCopy()
+* fixed some problems in OSCache provider
+* fixed an NPE that occurred when calling a lazy collection after evicting from session
+* fixed an NPE that occurred when select-before-update is used with unversioned data (Patrick Peralta)
+* fixed a bug where dynamic-components could not be queried (Massimo Ferrari)
+* SQL formula parser now recognizes all Dialect-specific SQL functions (Anthony Patricio)
+* fixed a problem where SQL CASE statements could not appear in SQL formulas
+* fixed a problem where subselects with joins could not appear in SQL formulas
+* C3P0 and Proxool pools now cleaned up after SessionFactory.close()
+* fixed a bug where dirty checking of mutable properties was broken after lock()
+* fixed a minor bug where orphan delete was broken for newly saved instances
+* added Query.setFetchSize() and Criteria.setFetchSize()
+* PreparedStatement pooling in DBCPConnectionProvider can now be disabled (Emmanuel Bernard)
+* Query.setProperties(Object) now detects array and collection valued properties and delegates to Query.setParameterList() (Max Andersen, Nick Heudecker)
+* lengths of positional parameters and types arrays are now validated
+* fixed an obscure problem where a PreparedStatement was not closed
+
+Changes in version 2.1.2 (4.2.2004)
+-----------------------------------
+* added Session.isDirty()
+* fixed a very obscure concurrency problem with read-write cache for inverse collections
+* deprecated Criteria.returnMaps() / Criteria.returnRootEntities() in favor of new ResultTransformer framework
+* don't cache objects with dynamic-update="true" or <joined-subclass> mappings immediately after insert/update
+* added version checking to saveOrUpdateCopy()
+* fixed constraint violations that occurred when mixing identity columns with other id generation strategies
+* added Sybase 11.9.2 dialect to support older versions of Sybase that do not support ANSI joins (Colm O' Flaherty)
+* added Informix9Dialect (Finn McCann and Max Andersen)
+* added DB2400Dialect (Peter DeGregorio)
+* fixed a problem where mapping validation failure was reported as duplicate import (Michael Gloegl)
+* fixed a problem with Expression.not() in MySQL (Michael Gloegl)
+* added support for ResultSet.getGeneratedKeys() (David Morris, John Kristian)
+* added check attribute to allow check constraints in DDL
+* implicit polymorphism for Criteria queries (Shorn Tolley)
+* use IF EXISTS for dropping hilo tables (Michael Gloegl)
+* better exception report if deleted object is resaved by cascade
+* support nested components in Example queries (Emmanuel Bernard)
+* fixed a minor problem with onDelete() callbacks
+* fixed an obscure problem with select-before-update
+* added SunONETransactionManagerLookup (Robert Davidson)
+* fixed a problem with replicate() and <joined-subclass> mappings
+* made setParameterList() accept empty lists and deny null values (Max Andersen)
+* validation check on query parameters now allows setParameter(x, null) (Max Andersen)
+* added default-access to DTD (Max Andersen)
+* made Query.setParameterList() accept empty lists and deny null values (Max Andersen)
+* allow Query.setParameter(x, null) (Max Andersen)
+* queries with "select new" now cacheable
+* throw meaningful exception when lazy initialization occurs on disconnected session
+* added default-access to <hibernate-mapping> (Max Andersen)
+* added -text support to SchemaUpdate (Max Andersen, Matt Hall)
+* fixed broken implementation of embedded composite keys with createSQLQuery() (Max Andersen)
+* added hibernate.cache.use_minimal_puts config property to reduce unnecessary second-level cache puts
+* optimized performance of orphan delete detection (Bertrand Renuart)
+* fixed problem where unnecessary UPDATE occurred after INSERT for versioned objects with collections
+* WebSphereTransactionManagerLookup for WAS 5.1 (Edina Pimp)
+* Criteria queries now cacheable (Mario Ivankovits)
+* fixed problem with ordered, paginated queries in DB2 (Tim Collins)
+* fixed a bug caching <idbag>s
+* lazy="true" collections are now lazy even when available in cache
+* fixed a problem with version unsaved-value="negative"
+* added hibernate.cache.region_prefix config property (William Drai)
+* fixed problem where configuration input streams were not closed (Rajesh Patel)
+
+Changes in version 2.1.1 (17.12.2003)
+-------------------------------------
+* added optional package attribute to <hibernate-mapping>
+* added <meta-value> element to allow simpler <any> mapping
+* native SQL queries are now cacheable - added <synchronize> element to allow correct result set expiry
+* fixed a bug in CGLIB2 integration (Chris Nockleberg)
+* added NamingStrategy
+* don't cache objects with formula properties immediately after insert/update
+* log generated SQL to a special category
+* type of property with access="field" may now be guessed using reflection
+
+Changes in version 2.1 final (12.12.2003)
+-----------------------------------------
+* fixed a problem with CGLIB2 proxies and method calls inside constructors
+* fixed a bug running SchemaExportTask with mappings in jar files (Tom McCune)
+* allow custom persister declaration for subclasses (Nick Johnson)
+* fixed handling of sequences in SchemaUpdate on Oracle (Andrew Delpha)
+* fixed a bug where Iterator did not handle single null values correctly
+* detect and throw exception in the case of a duplicate property mapping
+* don't auto-create indexes for collection foreign keys (roll back to 2.0.x)
+
+Changes in version 2.1 rc1 (29.11.2003)
+---------------------------------------
+* long identifier and discriminator column names are now safely aliased (Max Andersen)
+* cleaned up mapping package to allow applications to manipulate metamodel programmatically
+* fixed a recent bug where collection sort order was lost in second-level cache
+* formula attribute now supported for joined-subclass mappings
+* formula properties may now be used anywhere in queries
+* dialect-specific query pagination for SQL Server
+* fixed a bug where a long path expression ending in collection access by index missed some tables in SQL FROM clause
+* fixed a very ancient performance problem where null one-to-one associations caused n+1 selects
+* added Session.saveOrUpdateCopy()
+* fixed some bugs in Example queries
+* fixed some minor bugs in dialect-specific query pagination
+* immutable entity passed to update() is now lock()ed instead
+* reworked the semantics of nonstrict-read-write
+* JCS cache support now deprecated
+* fixed some obscure bugs in collection handling
+* migrated to CGLIB2 (thanks to Chris Nockleberg)
+* fixed bugs in replicate()
+* fixed a bug affecting joined-subclass mappings with dynamic-update=true
+* performance improvements to boolean type mappings (Bertrand Renuart)
+* integrated JBoss TreeCache clustered cache (thanks to Bela Ban and Ben Wang)
+* fixed a bug in new query parameter validation (Steve Ebersole)
+* fixed a bug where <any> mappings caused unnecessary ObjectDeletedException at flush time
+* fixed a bug where associations with property-ref mappings were not properly cached
+* throw PropertyValueException when not-null properties are null at flush time
+* added unsaved-value attribute to version property mapping (Emmanuel Bernard)
+* tolerate classnames containing $ (Steve Ebersole)
+
+Changes in version 2.1 beta 6 (5.11.2003)
+-----------------------------------------
+* added Session.cancelQuery()
+* improvements to transaction handling for failed commit (thanks to Juergen Hoeller)
+* added cascade="delete-orphan"
+* fixed an exception that occurred when a property was declared not-null="true" update="false" (thanks to John Kristian)
+* support multiple named query cache regions (Mikheil Kapanadze)
+* some improvements to collection reattachment
+* fixed a bad bug with adds to an uninitialized bag or list
+* removed support for <dynabean/> components
+* added <dynamic-component/> mapping for properties of type Map
+* fixed a bug where schema export generated index names that were too long for DB2
+* allow per-region expiry policies in OSCache (Matthias Bogaert)
+* fixed a stack overflow that could occur while initializing nonlazy collections
+* fixed a bug in case-insensitive like for Example queries
+* fixed a bug in ScrollableResults.setRowNumber() (Martin Priekopa)
+* improvements to the cache concurrency strategies
+
+Changes in version 2.1 beta 5 (30.10.2003)
+------------------------------------------
+* Support for custom CollectionPersister (Nick Johnson, Max Andersen)
+* Support for named SQL queries (Max Andersen)
+* duplicate named queries now throws MappingException instead of just logging warning (Max Andersen)
+* fixed problems with WebSphereTransactionManagerLookup (Ralf Taugerbeck, Daniel Bradby)
+* added support for custom collection persisters (thanks to Max Anderson, Nick Johnson)
+* fixed a performance problem during query compilation (Bulent Erdemir)
+* composite keys now supported in createSQLQuery() (Max Andersen)
+* fixed JCA adaptor to run in WebLogic (Daniel Bradby)
+* integrated SwarmCache (Jason Carreira)
+* integrated OSCache (Matthias Bogaert)
+* fixed an NPE that could occur with lists and orphan delete
+* allow nullable one-to-one with property-ref
+* improved usage of Dialect-specific limit SQL
+* fixed problem where non-lazy collections held by cached objects were not immediately initialized
+* fixed getReturnTypes() for native SQL queries (Max Andersen)
+* fixed problems with Criterions that applied to multi-column properties
+* check of rowcounts when JDBC batch updates enabled
+* added named SQL queries using <sql-query> element (Max Andersen)
+* added some extra validations so Hibernate fails earlier when user makes mistakes
+* allow lazy="true" as an alternative to proxy="ClassName"
+* removed dependency to commons-lang
+* SchemaExport now creates indexes for collection foreign key columns if specified by Dialect
+* fixed a bug parsing named parameters in setParameterList()
+* select new Foo(...) will now tolerate null values if the constructor accepts a wrapper type
+* fixed a problem detecting Proxool
+* added logging of persistent object states during flush()
+* allow "not null" as a discriminator value
+* added "parameters" config param to "sequence" generator (Matthias Bogaert)
+
+Changes in version 2.1 beta 4 (3.10.2003)
+-----------------------------------------
+* fixed a bug where <any> mappings did not handle proxies correctly
+* implemented new optimistic-lock strategies
+* fixed several bugs in Criteria query API
+* fixed a bug caching property-ref associations
+* improvements to XML Databinder (Ara Abrahamian)
+* added Session.replicate() and ReplicationMode
+* added ScrollableResults.setRowNumber() / ScrollableResults.getRowNumber()
+* added query cache and Query.setCacheable()
+* added Criteria.returnMaps()
+* fixed some problems with CGLIB proxies
+* fixed an NPE that occurred when a joined-subclass of a versioned entity defined only collections
+* added the access attribute, direct field access and the PropertyAccessor extension point
+* added MatchMode for use with Criteria queries (thanks to Michael Gloegl)
+* fixed a bug where some lazy="false" collections were not immediately initialized
+* fixed problem with WebSphere 5 TransactionManager
+* support schema attribute in MySQL, by using an underscore in the table name (Chris Hane)
+* now seperate Dialects for Interbase and Firebird (Reha Cenani, Max Andersen)
+* removed built-in PreparedStatement cache
+* added Session.getSessionFactory()
+* fixed problem with native SQL queries and Query.setProperties() (Max Andersen)
+* Query now fully validates parameters against the query string before passing them to JDBC (Max Andersen)
+* fixed an NPE in SessionFactory.close()
+* fixed an NPE that occurred when using <idbag>s
+* added SQL-level query results paging to DB2Dialect
+* "foreign" id generator now handles detached instances
+
+Changes in version 2.1 beta 3 (7.9.2003)
+----------------------------------------
+* added Example queries
+* fixed an exception that occurred at startup with <key-many-to-one> and <joined-subclass>
+* fixed a bug where composite-elements were not being updated if a property not in the equals() was changed
+* <parent> property of a composite-element may now be used in equals()
+* named parameters may now be used in HQL order by clause
+* null value of version property now indicates unsaved instance
+* added select-before-update attribute
+* two-phase loading now use for components
+* better implementation of equals()/hashCode() for proxies
+* added property-ref attribute to <many-to-one>
+* renamed result() to uniqueResult()
+* added Session.get()
+* added HashtableCacheProvider
+* JTA TransactionManager now used even when not using Hibernate Transaction API
+* always bypass process-level cache for LockMode.READ
+
+Changes in version 2.1 beta 2 (27.8.2003)
+-----------------------------------------
+* <subclass> and <joined-subclass> may now appear outside of a <class> element, by providing the extends attribute (Max Andersen)
+* fixed an NPE at startup that was introduced in beta 1
+* fixed a bug in Map.putAll()
+* new pluggable cache API
+- deprecated <jcs-cache> in favor of <cache>
+- net.sf.hibernate.cache.CacheProvider settable via hibernate.cache.provider_class
+* more aggressive caching
+* added Hibernate.close(Iterator)
+* Criteria queries may now include joins
+- Criteria.addJoin()
+- Criteria.createCriteria()
+* hibernate.transaction.manager_lookup_class should now ALWAYS be specified in JTA environment when using jcs caching
+* fixed a bug caching <key-many-to-one>
+* fixed bug where cached component did not get <parent> property populated
+* added hibernate.max_fetch_depth property
+* smarter outer-join fetching
+* transient object may now be associated with session using Session.lock()
+* added Query.result(), Criteria.result()
+
+Changes in version 2.1 beta 1 (10.8.2003)
+-----------------------------------------
+* batch-size attribute for collection and class mappings, to allow batch loading
+* collections of "value types" (including composite-elements) may now appear in HQL from clause
+* more efficient loading of collections, and better handling of non-lazy collections
+* added HQL index() function to allow access to collection element index
+* added Session.createSQLQuery() (Max Andersen)
+* added outer-join attribute to collection mappings
+* Criteria.setFetchMode() now applies to collection-valued path expressions
+* added property-ref attribute to <one-to-one>, enabling unique foreign key associations
+* added hibernate.max_fetch_depth config property
+* added hibernate.hbm2ddl.auto config property
+* fixed a bug with combination of <jcs-cache> and <key-many-to-one>
+* support for Dialect-specific SQL functions in HQL select clause (David Channon)
+* added Session.clear()
+
+Changes in version 2.0.2 (2.8.2003)
+-----------------------------------
+* subqueries may now use HAVING and GROUP BY clauses
+* fixed a bug with setMaxResults(), setFirstResult() in HSQL (introduced in 2.0.1)
+* fixed a bug in Set.removeAll()
+* fixed a bug in SchemaUpdate (Mathias Bogaert)
+* added weak typing functionality to ScrollableResults
+* fixed a bug with "calendar" versioning in IBM JDK1.3.1 (workaround for JDK bug)
+* fixed a bug in mapping DTD that caused a problem for hbm2java (Max Andersen)
+* fixed a bug querying nested components
+* SQL generation now prefers ANSI-style inner joins to theta inner joins
+* fixed a bug caching collection references loaded using FETCH
+* fixed a bug with composite foreign keys in normalized table mappings (Tom Sedge)
+* limit support for Interbase (Ludovic Orban)
+* added where attribute to <class> mappings
+* added cascade="all-delete-orphan" for collection mappings
+* fixed a bug binding named parameters with setMaxResults()/setFirstResults()
+* fixed some minor bugs in HQL translator
+* fixed a long-standing bug where a <key-many-to-one> could not be dereferenced in HQL
+* SQL UPDATEs now occur in a predictable order (same order as objects were loaded)
+* support for SELECT ... FOR UPDATE in SAPDB
+* fixed bug where Criteria queries against a subclass also returned superclass instances
+* fixed a very rare bug where an update could get lost with normalized mappings
+* fixed a problem with proxied class heirarchies rooted at an interface or abstract class
+* where and order-by attributes now allow SQL function calls and subselects
+* added formula attribute to <property> tag, to allow "computed" properties
+* fixed a bug where PreparedStatements were sometimes not closed when an exception occured
+* workaround for a problem with <joined-subclass> and Interceptor.onFlushDirty()
+
+Changes in version 2.0.1 (17.6.2003)
+------------------------------------
+* fixed some problems with new dialect-specific LIMIT clauses
+* improved parsing of collection where attribute
+* made one-to-many bags more efficient (they are really sets!)
+* allowed type="calendar" for <version> properties
+* fixed a bug with locking a versioned composite-id class
+* refresh() may now take a transient instance
+* added ProxoolConnectionProvider (Martin Crawford)
+* fixed some minor JCA issues (Mike Mosiewicz)
+* fixed a bug with FETCH and sorted associations
+* improved performance of SchemaUpdate tool (Teodor Danciu)
+* fixed a bug in Configuration.addFile(String) (Ken Geis)
+* tidied up and documented hbm2ddl package (esp. Ant tasks)
+* deprecated CounterGenerator in favor of IncrementGenerator
+* improved logging during initialization
+* deprecated "vm" in favor of "increment" id generator
+
+Changes in version 2.0 final (8.6.2003)
+---------------------------------------
+* added "fetch" keyword to HQL
+* added evict() methods to SessionFactory for JVM-level cache
+* destroy caches from SessionFactory.close()
+* fixed an NPE in Session.evict() (Simon Spero)
+* added Query.setLockMode()
+* tidied up implementation of Loader
+* release ResultSets more aggressively
+* miscellaneous improvements to some Dialects
+* hbm2java now honors the sort attribute (Max Andersen)
+* added exceptions to Interceptor interface
+* fixed problem with setMaxResults(), setFirstResult() in Oracle (introduced in beta 6)
+* fixed some SQL generation that was a problem for Sybase (Dietmar Posselt)
+* fixed some problems with ODMG API (Oliver Gries)
+* added JOTMTransactionManagerLookup (Low Heng Sin)
+* added JOnASTransactionManagerLookup (?)
+* fixed a bug in WeblogicTransactionManagerLookup (Mathias Bogaert)
+* added Criteria.setFetchMode()
+* added new Expressions
+* much more elegant/robust handling of quoted identifiers
+* renamed Hibernate.association() to Hibernate.entity()
+* added dynamic-update and dynamic-insert mapping attributes
+* fixed a bug with refresh() of objects with collections
+* HQL aliases now optional - "from Cat" now legal
+* platform-independant quoting of identifiers using backticks
+
+Changes in version 2.0 beta 6 (10.5.2003)
+-----------------------------------------
+* fixed a bug querying one-to-many associations to a <joined-subclass>
+* added support for dialect-specific LIMIT-style clauses (David White)
+* added <idbag>
+* fixed bug in hashCode() of persistent collections
+* <joined-subclass> now supported in HSQL (Wolfgang Jung)
+* fixed problem for XML parsers which ignore default values declared in DTD
+* <meta> tags can now be set to not be inheritable
+* fixed bug in Expression.in()
+* fixed an NPE that could occur from update() in very strange cases (Chris Nockleberg)
+* disabled outer-join back to owner when initializing one-to-many (performance improvement)
+* fixed a bug in Query.setParameterList() (Nick Heudecker)
+* improved JCA support (Igor Fedorenko)
+
+Changes in version 2.0 beta 5 (21.4.2003)
+-----------------------------------------
+* Informix support (Steve Molitor)
+* fixed a bug parsing "select new ... " queries
+* deprecated "object" type in favor of <any> mappings
+* added Session.contains()
+* added extra DBCP config options (Alex Burgel)
+* SessionFactory.close() now unbinds from JNDI
+* added Session.evict()
+* got rid of an unnecessary SQL DELETE issued when an empty collection was dereferenced
+* where attribute of collection mappings no longer ignored for deletion
+* improved logging
+* support polymorphic associations to "embedded" composite id classes
+* various bugfixes to collection filter parameter binding
+* fixed some problems with proxies introduced in earlier beta versions
+* fixed bug with self-reference in the case of identity column id generation
+* added hibernate.cglib.use_reflection_optimizer property
+* added nonstrict-read-write cache
+* fixed an SQL-generation bug in new Criteria API
+* added CompositeUserType
+* sequence and table id generators now aware of default-schema
+* added update and insert attributes to <component> element
+* fixed a bug with expressions like elements(foo.bar.baz) in where clause
+* more efficient Set initialization (two-phase load)
+* removed support for hibernate.query.imports and added <import> mapping element
+* fixed problem in DBCP connection validation and added new config properties
+* hbm2java can now generate finder methods for persistent objects (experimental) (Matt Hall)
+* hbm2java small fixes/refactorings to support generating more than one file per persistent object (Max Andersen)
+
+Changes in version 2.0 beta 4 (22.3.2003)
+-----------------------------------------
+* Major HQL improvements
+- from "Foo as foo join foo.bars as bar" instead of "from foo in class Foo, bar in elements(foo.bars)"
+- "select new Foo(bar.name, bar.amount) from ...."
+- outer and full join support
+* Query methods now return this, to allow chaining
+* FrontBase support (Run Lussier)
+* experimental JCA support (Daniel Bradby)
+* hbm2java now can generate Beans style property events (Klaus Zimmermann)
+* support SQL identifiers quoted with []
+* fixed bug with PostgreSQL
+* name attribute now optional in .cfg.xml
+* support for postgres ilike operator (M Lang)
+* squash warnings with GNU JAXP (Chris Nockleberg)
+* fixed a bug in Query.setParameterList()
+* Ingres support (Ian Booth)
+* collections now detect changes not made via wrapper for newly saved objects
+* new (experimental) Criteria + Expression APIs
+* Query.setEntity(), etc, now aware of proxies (also improved hueristics for guessing Type)
+* added Hibernate.isInitialized()
+* detect changes made directly to newly-wrapped collection (ie. not via the wrapper)
+* added Hibernate.refresh(Object, LockMode)
+* update(), saveOrUpdate() no longer initialize a proxy
+* fixed problems with Sybase
+* added force attribute to <discriminator>
+* improved handling of null discriminator-value
+* support SQL-style '' escape for HQL strings
+
+Changes in version 2.0 beta 3 (24.2.2003)
+----------------------------------------
+* collections now represent null elements as a missing row
+* collections now deserialize correctly (fix for bug in beta 2)
+* standardised on dom4j for XML parsing
+* fixed bugs in collection caching (an exception occurred for some sorted collections and some kinds of maps)
+* allowed null discriminators
+* set autocommit to true in SchemaUpdate
+* fixed a stack overflow that could occur in toString() of classes created with hbm2java (Max Andersen)
+* fixed a bug where composite-element <parent> property was not being set after retrieval from cache
+* added where attribute to collection mappings to allow filtering
+* fixed a exception that occurred when wrapping collections with sort="MyComparator" (Jason Horne)
+* objects with mutable="false" are now never updated
+* fixed an exception that occurs with <key-many-to-one> association to a class with a composite id (Stefano Travelli)
+* added SchemaExport Ant task (Rong C Ou)
+* integrated latest CGLIB release (Juozas Baliuka)
+- added support for new CGLIB reflection optimizer (Juozas Baliuka)
+* improved query cache algorithm (Who?)
+* fixed a bug in "object" type
+* Lists and arrays now represent null elements as a missing row
+* fixed a bug in Hibernate PreparedStatement cache where maxRows and fetchSize were not cleared before re-caching
+* fixed a bug in HibernateService that caused a restart to fail
+* added SybaseAnywhereDialect (?)
+* added SessionFactory.close()
+
+Changes in version 2.0 beta 2 (2.2.2003)
+----------------------------------------
+* property column names may now be of any length (Mark Woon)
+* fixed problem where CodeGenerator created private get/set pairs (Max Andersen)
+* fixed all silly bugs in Configuration.configure()
+* efficient collection updates from Session.update()
+* added <jcs-class-cache> and <jcs-collection-cache> elements to hibernate-configuration.dtd
+* support for normalized mappings for databases with DECODE instead of CASE (Simon Harris)
+* added Oracle9Dialect
+* added JRun4TransactionManagerLookup (Joseph Bissen)
+* fixed JDBCException to keep reference to underlying SQLException
+* fixed a bug loading many-to-many associations with a repeated column name
+* fixed a bug in ShortType
+* added IngresDialect (Ian Booth)
+* added --config option to SchemaExport
+
+Changed in version 2.0 beta 1 (28.1.2003)
+-----------------------------------------
+* renamed packages to net.sf.hibernate.*
+* all API methods now wrap SQLExceptions
+* removed support for toplevel collections / subcollections
+* created hibernate-mapping-2.0.dtd
+- renamed 'readonly' attribute to 'inverse'
+- renamed 'role' attribute to 'name'
+- changed default value for 'unsaved-value' to "null"
+- added mandatory 'name' attribute to <param>
+- added <meta> tag
+* created hibernate-configuration-2.0.dtd
+* brand new Configuration API, including exposed mapping package
+* completely reworked IdentifierGenerator framework
+- built-in generators now auto-detect the type (so integer identity columns are supported, for example)
+- parameters are now named
+- built-in strategies are renamed
+* expanded Interceptor interface
+* removed exceptions that occur if an object is saved or deleted multiple times in a session
+* added <parent> subelement to <composite-element> and <nested-composite-element>
+* collections except for <bag>s now implement by-value equals() and hashCode()
+* removed all deprecated methods
+* added Session.refresh()
+* added dynamic-update functionality
+* added update and insert attributes to <property> and <many-to-one> mappings
+* added elements(), indices(), size(), maxelement(), minelement(), maxindex(), minindex() collection functions to query language
+* huge improvements to CodeGenerator (Max Andersen)
+* enhanced outerjoin fetching support in queries
+* experimental support for DynaBeans as components
+
+Changes in version 1.2.3 (28.1.2003)
+------------------------------------
+* fixed a recently-introduced problem with Timestamp dirty checking
+* added createClob(), createBlob() for streams (Benoit Menendez)
+* SchemaUpdate now configures Dialect correctly (Michael Locher)
+* update() now working for classes with embedded composite ids
+* unsaved-value attribute now recognized for <composite-id>
+* fixed a minor problem where a very specific kind of SQL select did not qualify a column name
+* added Query.getQueryString()
+* fixed an NPE that sometimes occurred when hibernate.connection.username was not specified
+* fixed a bug in SchemaExport where foreign key constraints did not use qualified tablenames
+* added isFirst(), isLast() to ScrollableResults
+* fixed bug finding properties inherited by mapped interfaces
+
+Changes in version 1.2.1b (4.1.2003)
+------------------------------------
+* fixed an NPE that occurred while loading Hibernate classes in IBM JVM
+* arbitrary JNDI InitialContext properties may now be passed as hibernate.jndi.*
+* fixed a problem where index column was not being nullified when an entity was removed from a one-to-many
+
+Changes in version 1.2.1 (31.12.2002)
+-------------------------------------
+* Changed the MySQL mapping of Hibernate "timestamp" to MySQL "DATETIME" (Matthias Schwinn)
+* TransactionManagerLookup classes now define defaut UserTransaction JNDI names
+* support for WebSphere 5 (Venkat Srinivasan)
+* fixed a bug with query expressions of the form "foo.bar.id" for normalized mappings
+* experimental Blob/Clob support (thanks to Benoit Menendez and Mark Woon)
+* improvements to SchemaUpdater (Benoit Menendez)
+* deprecated suspendFlushes() / resumeFlushes() in favor of FlushMode
+* deprecated IDGenerationException in favor of IdentifierGenerationException
+* fixed a bug introduced in 1.2 final where cascade save-update was sometimes ignored for readonly="true" bags
+* fixed a bug caching null-valued one-to-one associations
+* CodeGenerator now supports <bag> and <joined-subclass>
+* fixed problem with TimestampType on DB2 (Jonas)
+* fixed a bug in generated SQL for collections with <joined-subclass> mappings (Robson Miranda)
+* fixed a bug caching Maps (Benoit Menendez)
+* SchemaExport now accepts a .jar file as a source of mappings
+* hibernate.dbcp.validationQuery setting (Juozas Baliuka)
+* hibernate.c3p0.validate setting
+* added Query.setTimeout()
+* setMaxResults() now behaves sensibly on SAPDB (Russel Smyth)
+* added Query.setProperties() and Query.getNamedParameters(), fixed a bug in Query.getReturnTypes()
+* CodeGenerator now generates equals() and hashCode() for composite-id classes (and toString() for all classes)
+* CodeGenerator now includes superclass properties in subclass constructors (Max Andersen)
+* added Hibernate.custom()
+
+Changes in version 1.2 final (7.12.2002)
+----------------------------------------
+* fixed a bug where uppercase IS NOT NULL, NOT IN, etc were not parsed correctly
+* addition to readonly="true" bags now no longer requires collection initialization
+* added ResinTransactionManagerLookup (Aapo Laakkonen)
+* improved exception message when setting null to primitive type (Max Andersen)
+* improved exception message for an unserializable identifier
+* support for overloaded setter methods (patch by Alex Staubo)
+* CodeGenerator support for <composite-element> (patch by Wolfgang Jung)
+
+Changes in version 1.2 beta 4 (29.11.2002)
+------------------------------------------
+* fixed bugs in one-to-many associations to a <joined-subclass>
+* LockMode class now properly serializable
+* exceptions thrown by proxied objects are now propagated correctly (rather than being wrapped)
+* made Calendar types compilable in JDK1.2
+* added --format and --delimiter options to SchemaExport (thanks to Richard Mixon)
+* fix for problem with class with no properties + native id generation + MS SQL Server contributed by Max Andersen
+* fixed a BAD bug in Hibernate.configure() (thanks to Rob Stokes)
+* CodeGenerator now recognizes <key-many-to-one> (patch by Wolfgang Jung)
+* CodeGenerator now recognizes <version> and <timestamp> (patch by Max Andersen)
+
+Changes in version 1.2 beta 3 (26.11.2002)
+------------------------------------------
+* fixed bug in UPDATE SQL generation for <joined-subclass> mapping strategy (fix by Robson Miranda)
+* support <composite-id> correctly in CodeGenerator (patch by Tom Cellucci)
+* fixed an exception that occurred with short qualified tablenames
+* added the polymorphism attribute to the <class> element
+* allow "not between", "not in" in query language
+* allow subqueries beginning with a from clause in query language
+* query expressions like "not (foo.bar.baz=1)" now translated to "(bar.baz!=1 and foo.bar=bar.id)"
+* support for PostgreSQL ~ operator (regular expression match)
+* load(id, lockMode) now working for normalized table mappings
+* now compiling properly under JDK1.2, 1.3 (fix by Tom Cellucci)
+* support for subcollections in query language: foo.bars[2]['index'], foo.bars[4].elements, foo.bars[0].size, etc.
+* added calendar and calendar_date types
+* find() queries may now return scalar values
+* component-type properties may appear in a select clause
+* ConnectionProviders now set isolation level before toggle autocommit
+* Iterator.next() now throws NoSuchElementException as per Iterator contract (fix by Alex Staubo)
+* database reverse engineering GUI tool contributed by Tom Cellucci
+* SchemaExport now generates column in mapping file order (rather than alphabetical order)
+* <joined-subclass> mappings working on Oracle (?)
+
+Changes in version 1.2 beta 2 (15.11.2002)
+------------------------------------------
+* support multi-argument SQL functions in queries
+* reintroduced deprecated form of update() with slightly altered semantics
+* fixed BAD problem in the generated SQL for certain queries
+* added OrionTransactionManagerLookup
+
+Changes in version 1.2 beta 1 (11.11.2002)
+------------------------------------------
+* Fixed a bad bug binding to JNDI with servers that use serialization in preference to getReference()
+* support for quoted SQL identifiers (patch by Jean-Francois Nadeau)
+* Hibernate.initialize() allows the user to force initialization of a proxy or persistent collection
+* fix to minor bug in CodeGenerator by Max Andersen
+* fixed a problem with outerjoin fetching of one-to-one associations defined on subclasses
+* fixed a minor problem with proxies of classes that override finalize()
+* finished work on normalized table mappings using <joined-subclass> declaration (only for databases with ANSI OUTER JOIN and CASE)
+* deprecated hibernate-mapping.dtd in favor of hibernate-mapping-1.1.dtd
+* reworked unmapped class / interface / table-per-concrete-class query functionality, fixing several problems
+* removed deprecated methods
+* deprecated findIdentifiers()
+* fixed some problems with embedded composite identifiers
+* fixed a bug cascading deletes to one-to-one associations
+* CodeGenerator now generates isFoo() style getters for boolean properties (patch by Aapo Laakkonen)
+* components may now have a nonpublic constructor (patch by Jon Lipsky)
+* changes / bugfixes to MapGenerator tool
+* experimental SchemaUpdate tool contributed by Christoph Sturm
+
+Changes in version 1.1.8 (30.10.2002)
+-------------------------------------
+* full support for composite keys in query language
+* fixed bug where character type could not be null
+* fixed bug parsing collection filters like: "group by this.date"
+* fixed a bad bug where C3P0 properties were not always being used
+* replaced hibernate.use_jdbc_batch with hibernate.jdbc.batch_size
+* renamed some other properties to hibernate.jdbc.*
+* made hibernate.show_sql settable from JMX (patch by Matas Veitas)
+* added SessionFactory.getAllClassMetadata(), getAllCollectionMetadata (patch by Max Andersen)
+* allowed use of concrete-class proxies with inherited classes ie. <subclass name="ConcreteClass" proxy="ConcreteClass">
+* HibernateException extends Apache commons lang NestableException (patch by Max Andersen)
+* <parent> subelement of <component> allows a component to get a reference back to owning entity
+* Query.setParameterList() to bind lists of values to "in (:list)"
+* Java constants may now be used in Queries
+* serialization of an object graph now removes all initialized proxies
+* several other improvements to proxy handling
+* proxies may now be used in JDK 1.2
+
+Changes in version 1.1.7 (25.10.2002)
+-------------------------------------
+* added Session.createFilter()
+* fixed a bug parsing queries with properties of form idXXX (introduced in 1.1.6)
+* fixed a bug parsing queries with the id property named in the select clause (introduced in 1.1.6)
+* fixed a bug dirty checking big_decimal (fix by Andrea Aime)
+
+Changes in version 1.1.6 (24.10.2002)
+-------------------------------------
+* classes without subclasses may now declare themselves as their own proxy
+* outer-join attribute now working for component properties and <many-to-many>
+* outer-join="true" will now force outerjoin loading for an association even if associated class has a proxy
+* enabled oracle-style outerjoins for SAP DB
+* version properties may now be long or short (previously always integer)
+* discriminators may now be boolean type
+* fixed the foo.bar.id.baz syntax for queries doing composite-key joins
+* fixed an NPE that occurred when no Dialect was specified
+* CodeGenerator now fully proxy-aware (patch by Max Andersen)
+* removed dependency upon trove4j
+
+Changes in version 1.1.5b (20.10.2002)
+--------------------------------------
+* fixed an NPE that occurred on JMX startup
+* smarter fetching for one-to-one associations
+
+Changes in version 1.1.5 (19.10.2002)
+-------------------------------------
+* added built-in currency and timezone types
+* hibernate-mapping-1.1.dtd
+- added <index-many-to-many> and <composite-index> subelements of <map>
+- added <key-property> and <key-many-to-one>
+- renamed "save/update" to "save-update"
+- tightened up the dtd (now using enumerated attribute types)
+* enabled multi-column map indexes (ie. key of a Map)
+* composited-id may now include a many-to-one association
+* improvements to Databinder contributed by Brad Clow
+* fixed bugs in minIndex, maxIndex, minElement, maxElement
+* fixed a problem with JTATransaction in a JBoss BMT bean
+* added addMapResource() to the MBean
+* minor improvements to Configuration
+* more accurate cache entry timestamping to increase the likelihood of cache hits
+* JCS cache may now be used with JTATransaction in WebSphere, Weblogic, JBoss (thanks to Matt Baird)
+* improvements to CodeGenerator contributed by Andrea Aime
+* stopped a TransientObjectException that was being thrown when it shouldn't be
+* re-enabled primary key export for tables of sets with not-null elements
+* hibernate.statement.fetch_size configuration contributed by Matas Veitas
+* added Interceptor application callback interface
+* added metadata package to expose persistence metadata to the application
+* changed filter() argument type from Collection to Object to allow filtering of arrays and Maps
+* added <column> index attribute to allow table indexes to be specified in mapping document
+* implemented support for queries against interfaces and abstract superclasses
+
+Changes in version 1.1.4b (4.10.2002)
+-------------------------------------
+* fixed problems for JDK1.2 (thanks to Chris Webb)
+
+Changes in version 1.1.4 (4.10.2002)
+------------------------------------
+* New locking API
+* disabled 2-phase load for objects contained in Sets (because they should be initialized before equals() or hashCode() is called)
+* fixed a bug where non-serializable cache entries could not be cached by JCS auxiliary cache
+* fixed a bug in dirty checking PersistentEnums
+* deprecated getID() in favor of getIdentifier() (for mainly cosmetic reasons)
+* HibernateService may now be subclassed to obtain mapping files by some other mechanism (patch by Chris Winters)
+
+Changes in version 1.1.3 (1.10.2002)
+------------------------------------
+* new 2-phase loading process (replaces complicated "deferred" loading process)
+* new ScrollableResults interface for efficiently navigating Query results
+* removed deprecated interfaces
+* created engine package to hold "internal" APIs (ie. the external contract of the impl package)
+* fixed bug where a component defined before all collections in the mapping file caused collections to not be persisted (thanks to Michael Link)
+* fixed a bug where cascaded saveOrUpdate was ignoring the unsaved-value setting
+* faster Timestamp dirty checking
+
+Changes in version 1.1.2 (29.9.2002)
+------------------------------------
+* added persister attibute of class mapping to support custom persistence strategies
+* Support for Oracle outerjoins contributed by Jon Lipsky
+* Reworked versioning, fixing bugs (and tightening tests)
+* Fixed a bug where an ObjectNotFoundException was thrown for null one-to-one associations
+* fixed problems with timestamps introduced in 1.1.1
+* added batch file for running demo
+
+Changes in version 1.1.1 (27.9.2002)
+------------------------------------
+* Major refactoring / abstraction of persistence logic
+* added maxIndex, minIndex, maxElement, minElement properties for collections
+* added support for class names in where clause of queries
+* fixed a bug where an association could become null after caching
+* fixed a bug where an NPE could occur for a null component
+* fixed minor bugs in SortedMap, SortedSet
+* object type is now cacheable
+* added big_integer type
+* improved dirty checking for timestamp type
+
+Changes in version 1.1.0 (22.9.2002)
+------------------------------------
+* implemented collection indexing with [] in query language
+* fixed some minor query-language bugs
+
+Changes in version 1.1 beta 14 (19.9.2002)
+------------------------------------------
+* bags now implement java.util.List
+* delete() may now take a transient object
+* bug where sorted collections were not being sorted fixed by Brad Clow
+* fixed a bug in many-to-many association filtering
+* no longer try to query connection metadata when using user-supplied connections
+* added hibernate.use_scrollable_resultsets for user-supplied connections
+* fixed a problem where sublists were not being proxied
+* fixed a problem where Hibernate could not call methods of package-visibility classes
+* removed obsolete select attribute from MapGenerator
+* multiple occurrences of same path in a query no longer require multiple joins
+* added WrongClassException
+
+Changes in version 1.1 beta 13 (15.9.2002)
+------------------------------------------
+* added constants to Lifecycle interface
+* fix for circular cascade="save/update"
+* fixed a bug in cascaded update introduced in version 1.1 beta 11
+* added object type
+
+Changes in version 1.1 beta 12 (14.9.2002)
+------------------------------------------
+* Session.filter() for applying a filter query to collections
+* experimental ODMG API (OQL features are not yet compliant)
+* new DBCPConnectionProvider for Apache commons-dbcp connection pool
+* Session.lock() now does version number check even on databases with no FOR UPDATE clause
+* introduced new cascade styles: cascade="save/update", cascade="delete"
+* added default-cascade attribute
+* foreign key columns lengths now automatically set to primary key column lengths for SchemaExport
+* added error checking of row update counts when batching disabled
+* major improvements to ProxyGenerator tool
+* CodeGenerator now aware of proxy attribute
+* integrated PointbaseDialect contributed by Ed Mackenzie
+* fix for problem where Proxies were being initialized on identifier access by Christoph Sturm
+
+Changes in version 1.1 beta 11 (7.9.2002)
+-----------------------------------------
+* deprecated update() in favor of saveOrUpdate() and introduced unsaved-value attribute of <id>
+* children mapped with cascade="all" are now always saved/updated even without a call to update(parent)
+* support for composite-id classes where the composite id consists of properties of the persistent class
+* added constrained attribute to <one-to-one> element
+* added Validatable interface
+* renamed several config properties (Hibernate issues log warnings for obsolete property usage)
+* arbitrary JDBC connection properties may now be passed using hibernate.connection.*
+* fixed a classloading bug in C3P0ConnectionProvider (introduced in 1.1 beta 10)
+* CodeGenerator may now take multiple mapping files on the commandline
+
+Changes in version 1.1 beta 10 (28.8.2002)
+------------------------------------------
+* fixed a bug that occurred when calling Session.update() for an object with no properties
+* changed class loading to use the context classloader first
+* introduced <timestamp> as an alternative to <version>
+* added Query.getReturnTypes()
+* fixed a bug with composite-elements introduced in 1.1 beta 7
+* save() may now be used to persist classes with composite-ids
+* improved handling of nanoseconds values in Timestamps
+* support for composite id properties + objects in select clause of iterate()
+* beefed-up collection tests
+
+Changes in version 1.1 beta 9 (26.8.2002)
+-----------------------------------------
+* fixed a bug introduced in 1.1 beta 8 that could cause an NPE after deserializing a session with proxies
+* deprecated insert() in favor of more flexible save()
+* deprecated IDGenerator in favor of new IdentifierGenerator interface
+* "assigned" id generator now returns the existing value of the id property instead of throwing an Exception
+* fixed a problem where PreparedStatements were not being recached after retrieving a natively generated id
+
+Changes in version 1.1 beta 8 (25.8.2002)
+-----------------------------------------
+* fixed a bug introduced in 1.1 beta 6 where an updated element of an indexed one-to-many collection caused an SQLException
+* uninitialized collections passed to update() may now be initialized in the new Session
+* uninitialized proxies passed to update() may now be initialized in the new Session
+
+Changes in version 1.1 beta 7 (23.8.2002)
+-----------------------------------------
+* fixed a bug where Hibernate was not returning statements to the cache when batch updates were disabled
+* fixed a bad bug parsing mappings with toplevel one-to-many associations
+* fixed a bug with versioning and subcollections
+* reworked Set updates again for much improved efficiency
+* schema export now creates primary keys for indexed collection tables
+* minor refactor to Type hierarchy
+* improved some user-error detection
+* fixed foreign key constraint creation for MySQL with Innodb tables
+
+Changes in version 1.1 beta 6b (20.8.2002)
+------------------------------------------
+* Fixed a problem updating Sets
+* added <bag> mapping for java.util.Collection
+
+Changes in version 1.1 beta 6 (20.8.2002)
+-----------------------------------------
+* completely reworked fetching code
+- one-to-many associations now always fetched in a single select
+- many-to-many associations fetched in a single select when outerjoin fetching is enabled
+- this includes nested outerjoin fetching of the associated class!
+- outerjoin fetching for <many-to-one> nested inside <component> or <composite-element>
+- code refactored to be cleaner and faster
+* removed unnecessary order by clause in List and array fetching SQL
+* collections now individually update, insert and delete only rows that changed (thanks to Doug Currie)
+* fixed a problem where exceptions were being wrapped in a LazyInitializationException for non-lazy collections
+* added order-by attribute to <set> and <map> to specify a table column as defining the iteration order (JDK1.4 only)
+* improved error detection in Session.update()
+* further usage of JDBC2 batch updates
+* some fine-tuning of JDBC2 feature usage configuration
+* CodeGenerator will now generate components and arrays
+* fixed problem where CodeGenerator could not generate classes in the default package
+* improved logging of flush() activity
+* renamed property hibernate.use_jdbc2 to hibernate.use_jdbc_batch
+
+Changes in version 1.1 beta 5 (13.8.2002)
+-----------------------------------------
+* hibernate.query.imports property to allow use of unqualified classnames in queries
+* fixed a bug in collection flushing that was introduced in 1.1 beta 4
+
+Changes in version 1.1 beta 4 (11.8.2002)
+-----------------------------------------
+* JMX integration (thanks to John Urberg)
+* "having" clause in query language
+
+Changes in version 1.1 beta 3 (10.8.2002)
+-----------------------------------------
+* removed the select="all" attribute for <class> mappings - "select distinct" now specified in the hibernate query
+* system properties now override hibernate.properties
+* Session now flushes changes even less often (only when actual updates to the queried table(s) are waiting)
+* fixed a *very* rare problem where an unnecessary update could be accidently issued before a delete
+
+Changes in version 1.1 beta 2 (6.8.2002)
+----------------------------------------
+* fixed a bug exporting schemas with identity columns
+* implemented factory-level caching of collections
+* Datastore.storeJar() contributed by Christian Meunier
+* added <mapping jar="jarfile"> to hibernate.cfg.xml
+
+Changes in version 1.1 beta 1 (4.8.2002)
+----------------------------------------
+* new Query API including named parameters, pageable results
+* subqueries in Hibernate queries (only for databases that support subselects)
+* new DocBook documentation (contributed by Christian Bauer)
+* support collections .elements, .indices inside select clause (even in aggregate functions)
+* don't load collections before removal unless absolutely necessary
+* mutable="false" attribute in <class> element to map immutable classes
+* use JDBC batch to insert collection elements if hibernate.use_jdbc2 is set
+* brand new PreparedStatementCache
+* improvements to MYSQL dialect for long datatypes
+* always check isAccessible() before setAccessible(true)
+* removed extra unnecessary table join in queries with one-to-many association
+* removed ugly "WHERE 1=1" from generated SQL
+* fixed exception mapping a class with no properties (fix by Rob Stokes)
+* logging enhancements including SQLException logging
+* reworked factory-level cache and integrated JCS support (thanks to Christian Meunier)
+* fixed a bug with circular references in cached data
+* removed blocking cache support
+* now rendering outerjoins as "LEFT OUTER JOIN" because "LEFT JOIN" caused problems for some Sybase versions
+* added default Hibernate properties to Dialects
+* native id generation now falls back to sequence id generation when identity columns not supported by the dialect
+* fixed some problems with native id generation under HSQL
+* may now use Session.insert() even when using native id generation
+
+Changes in version 1.0.1b (18.7.2002)
+-------------------------------------
+* fixed a bad bug in query parser when hibernate.query.substitutions was unset
+* much improved build.xml Ant script
+* latest c3p0.jar
+
+Changes in version 1.0.1 (17.7.2002)
+------------------------------------
+* enabled use of scalar values and aggregate SQL functions in select clause of iterate() queries
+* fixed bug in JNDI lookup for SessionFactory
+* changed ordering of SQL inserts/deletes for child collections of a cascade-enabled association
+- better behaviour for some not-null constraints
+- performance optimization for bidirectional many-to-one associations
+* added hibernate.query.substitutions property to allow named query constants (eg. translate 'true' to '1')
+* added locale type for java.util.Locale
+* added sequence hi/lo generator (seqhilo.long)
+* fixed bug where load(), onLoad() callbacks were sometimes called at wrong time
+* fixed an exception (fix by Eric Everman) and improved identifier searching in MapGenerator tool
+* refactored SerializableType
+* extra logging + error handling
+* documentation enhancements
+
+Changes in version 0.9.17 (3.7.2002)
+------------------------------------
+* Added UserType interface
+* documented Lifecycle
+* added some new trace messages to log
+* bugfix to allow SQL functions like upper(), lower(), etc to work on all platforms
+* documented SAP DB support (dialect contributed by Brad Clow)
+* foreign key constraint export for SAP DB
+* map index may be the composite-id of the element class (contributed by Jon Lipsky)
+* fixes to CodeGenerator tool (contributed by Uros Jurglic)
+
+Changes in version 0.9.16 (19.6.2002)
+------------------------------------
+* fixed bug cacheing objects with references to themselves
+* support for composite ids of classes with no id property
+* may now disable outer join (deep) fetching for an association by setting outer-join="false"
+* enabled outer join fetching for one-to-one
+* fixed a bug for mappings that specify class attribute of <one-to-many>
+* fixed a bug where Hashbelt did not expire cached data in a timely fashion
+* fixed a mistake in the mapping DTD
+* new user-error check in update()
+
+Changes in version 0.9.15 (15.6.2002)
+------------------------------------
+* one-to-one associations
+* support for "tricky" mappings in SchemaExport tool (multiple properties to one column, etc)
+* Transaction API contributed by Anton van Straaten
+* SessionFactory may be bound to JNDI name by setting hibernate.session_factory_name
+* Sessions are now Serializable!
+* added Session.findIdentifiers() query methods
+* new Lifecycle interface to replace deprecated PersistentLifecycle
+* fixed problem where session did not autoflush on iterate() queries
+* performance enhancements to collection dirty checking
+* added Hibernate.configure() and configuration file format
+* removed some deprecated methods
+* refactored Type hierarchy
+* query language identifiers now case sensitive (bugfix for case sensitive SQL dialects)
+* username/password now optional for datasource (contributed by Emmanuel Bourg)
+* much improved API documentation
+* binary types now saved using streams if hibernate.use_streams_for_binary=true (contributed by Jon Lipsky)
+* MySQL Strings now mapped to TEXT columns if length > 255 (contributed by Christoph Beck)
+
+Changes in version 0.9.14 (4.6.2002)
+-------------------------------------
+* lifecycle objects - properties now have a cascade attribute to cascade save, update, delete
+* composite id properties may now be used in queries eg. foo.id.bar (contributed by Jon Lipsky)
+* slightly changed semantics of update() so it now also save()s new transient instances
+* Session now flushes() itself less often before query execution (performance enhancement)
+* fixed problem where Session.save() returned null instead of the natively generated id
+* fixed bug with object identity for cached classes
+* fixed bug where delete(x) could not be called after update(x)
+* MUCH improved Exception hierarchy
+* deprecated create()
+* added sql-type attribute to <column> tag to allow user to override default type mapping
+* deeper fetching with use_outer_join
+* new ConnectionProvider framework
+* fixed a bug where blocking cache could return stale data
+* now working again in JDK1.2.2
+* fixed problem with not-null associations + native key generation
+* minor changes to PersistentLifecycle interface
+* initial, minimal version of new Transaction mechanism
+* MUCH improved documentation
+
+Changes in version 0.9.13 (25.5.2002)
+-------------------------------------
+* Datastore.storeResource() to load mapping files from classpath
+* fixed a problem executing under JDK1.3 when compiled from JDK1.4
+* documentation improvements
+
+Changes in version 0.9.12 (24.5.2002)
+------------------------------------
+* Session.update() methods to update a persistent instance from transient copy (as requested by many users)
+* discriminator column name, type, length, etc now configurable by <discriminator> tag in mapping file
+* discriminator column values configurable by discriminator-value attribute of <class> and <subclass> tags
+* added Session.insert(object, id) for classes with no identifier property
+* fixed another bad bug with connection handling (fix by Anton van Straaten)
+* fixed a problem with deferred loading
+* fixed a problem with sorted collections (fix by Anton van Straaten)
+* nested collections of objects now require 2 SQL SELECTs to load, rather than size+1
+* session is NO LONGER atomic - application should discard session when exception occurs
+* fixed problem where character type was mapped to VARCHAR column
+* arrays of proxies now possible by using new element-class attribute of <array> tag
+* fixed various problems with proxies
+* added proxy generation tool
+* proxy unit tests
+* replaced two RuntimeExceptions with checked exceptions
+* made hibernate.username/hibernate.password optional for DriverManager
+* CodeGenerator now supports all hibernate basic types
+* much improved caching algorithm for compiled queries
+* may now specify properties simply by placing hibernate.properties in classpath
+* documentation improvements + fixes
+* --abstract switch to MapGenerator (contributed by Eric Everman)
+
+Changes in version 0.9.11 (12.5.2002)
+------------------------------------
+* fixed major bug with connection handling (fix by Anton van Straaten)
+
+Changes in version 0.9.10 (11.5.2002)
+------------------------------------
+* set a default schema name using SessionFactory property hibernate.default_schema
+* code generator tool contributed by Brad Clow (www.workingmouse.com)
+* lazy object initialization under JDK 1.3 and above
+* fixed some error messages to go to logging framework, not stdout
+* new system property hibernate.show_sql=true logs all executed SQL to stdout
+* integration of bugfixes in c3p0
+* wrap IllegalArgumentExceptions in HibernateExceptions
+* added ObjectNotFoundException and StaleObjectStateException
+* fixed a bug when using schemas
+* new caching strategy (and documented cache feature)
+
+Changes in version 0.9.9 (25.4.2002)
+-----------------------------------
+* sorted sets and maps (thanks to Doug Currie)
+* mapping files may now be loaded using getResourceAsStream() (thanks to Markus Meissner)
+* hibernate messages now logged by Apache commons-logging
+* default hi/lo generator table now has column named "next_id", instead of "next"
+* query language may now refer to identifier property name (eg. foo.fooKey as alternative to foo.id)
+* hibernate.jndi_class, hibernate.jndi_url now optional when using datasource
+* hibernate now throws an exception if you try to persist an object with a reference to a transient object
+* improved connection pooling algorithm (hibernate.pool_size limits pooled conections)
+* very experimental integration of c3p0 JDBC connection pool (http://sourceforge.net/projects/c3p0)
+* now compiles under JDK 1.2.2
+* fixed bug persisting null components
+* fixed bug where cached prepared statements were not cleaned up after disconnect() session
+* fixed a null pointer exception in MappingByReflection
+
+Changes in version 0.9.8 (13.3.2002)
+-----------------------------------
+* supports database native key generation in Sybase, MS SQL, MySQL, DB2, Hypersonic (contributed by Christoph Sturm)
+* supports Mckoi (dialect contributed by Doug Currie)
+* supports Progress (dialect contributed by Phillip Baird)
+* added exceptions to catch Session reentrancy from PersistentLifecycle.load() + store()
+* experimental cross-transaction cache
+* Session.lock() and Session.loadWithLock() for pessimistic locking
+* HiLoGenerators may now use their own DriverManager connection properties + may now use same table across diff mapping files
+* Session.flush(), Session.close() and Session.connection() replace Session.commit(), Session.cancel()
+* Session.disconnect() and Session.reconnect() for long transactions
+* added single JVM id generators vm.long, vm.hex
+* added unique column constraints to mappings
+* extensions to IDGenerator framework
+* support sequence-style ID generation in Oracle, PostgreSQL, DB2, Interbase
+
+* fixed problem where subcollections of a collection that changed roles would be deleted
+* changed class loading strategy to be compatible with JBoss
+* stopped queries retrieving unnecessary columns
+* mutable types (binary + serializable) now always detected as dirty
+
+Changes in version 0.9.7 (26.2.2002)
+-----------------------------------
+* save() now safe from foreign key violations (so create() is no longer preferred method of adding data)
+* delete() now completely safe from foreign key violations - it no longer matters what order objects are deleted in
+* removed Session.copy()
+* hilo generators now NOT for use with application server datasources
+
+* fixed two intermittent bugs in queries
+* fixed a problem where components not detected as dirty
+* fixed broken hilo generator which was not updating database
+* fixed a minor bug when hibernate.use_outer_join was set
+
+Changes in version 0.9.6 (24.2.2002)
+-----------------------------------
+* experimental XML generation
+* added support for bi-directional associations (one-to-set, set-to-set) with <set readonly="true"> config
+* reflective generation of mappings tool was contributed by Doug Currie
+* Session operations now atomic, so exceptions are recoverable
+* made ID properties optional in persistent classes
+* support for multiple schemas through schema attribute of <hibernate-mapping>, <class>, <set>, <map>, etc.
+* auto-creation of tables for hilo id generators (restriction: cannot use same table from more than one mapping file)
+* added some more assertions to catch user "mistakes" like deleting transient or saving persistent objects
+
+* major rework of collections and fixed some bad bugs
+* lazy initialization re-enabled for one-to-many associations (thanks to Georg Schneemayer)
+* fixed a problem in the mapping DTD to allow nested components in collections
+* fixed a BAD bug in RelationalDatabaseSession when loading objects with PersistentLifecycle callbacks (thanks to Paul Szego)
+* fixed problems with quoted strings in query language
+* fixed a bug where a stack overflow occurred instead of HibernateException thrown (thanks to Georg Schneemayer)
+* fixed a bug deleting updated versioned data
+* fixed some problems with name generation for indexes + foreign keys
+* fixed problem in Sun JDK 1.4 (only?) where IllegalArgumentException was not handled
+* minor improvements to handling of dates and times
+* HiLoGenerator now safe for all transaction isolation levels + safe when rollback occurs
+* noticed and fixed obscure piece of nonthreadsafe code outside of core persistence engine
+* removed unnecessary drop constraints for some dialects
+
+* MUCH more comprehensive test suite
+
+* changed some terminology used in documentation
+* added javadoc for API classes
+* commented the mapping DTD
+
+Changes in version 0.9.5 (8.2.2002)
+-----------------------------------
+* supports HypersonicSQL (dialect contributed by Phillip Baird)
+* supports Microsoft SQL server (with third party JDBC driver)
+* proper command-line tool for schema generation and export
+* deprecated the interface cirrus.hibernate.Persistent (due to popular demand)
+* changes to hibernate-mapping DTD (required to support optional Persistent interface):
+- deprecated <property type="package.PersistentClassName"/> in favor of <many-to-one class="package.PersistentClassName"/>
+- deprecated <element type="package.PersistentClassName"/> in favor of <many-to-many class="package.PersistentClassName"/>
+- deprecated <property role="..."/> in favor of <collection role="..."/>
+- deprecated <element role=".."/> in favor of <subcollection role="..."/>
+- deprecated <association> in favor of <one-to-many>
+* class attribute optional in <component> and <composite-id> tags (determined by reflection)
+* querying components of components now supported
+* one-shot table creation (no use of unportable "alter table")
+* time dataype support
+* reflective mappings of java.sql.Time, java.sql.Timestamp, java.sql.Date
+* fixed error msg thrown when class is missing a method but has a superclass
+* property names now conform to JavaBean spec ("foo" instead of "Foo"). Note that "Foo" still works
+* constructors of persistent classes may now be non-public
+* collection indexes now mapped to not-null columns
+* fixed obscure bug with querying collections inside components of components
+* fixed potential bug related to cacheing of compiled queries
+* major rewrite of code relating to O-R mappings
+* Session.copy() and Session.equals() as convenience for users
+* fixed repeated invocations of hasNext() on iterator + iterators now always work with distinct SQL resultsets
+* McKoi dialect was contributed by Gabe Hicks
+
+Changes in version 0.9.4 (29.1.2002)
+------------------------------------
+* fixed BAD bug where XML parsing would not work for parsers other than Xerces - thanks to Christian Winkler
+* added some more assertions to catch user "mistakes" like changing ids or reusing existing ids
+
+Changes in version 0.9.3 (27.1.2002)
+------------------------------------
+* repackaged (corrupted DatasourceConnectionProvider.class)
+* better exception reporting using datasource
+* added Datastore.storeClass() which looks for mapping file in classpath (class foo.Bar -> foo/Bar.hbm.xml)
+* improved documentation
+
+Changes in version 0.9.2 (25.1.2002)
+------------------------------------
+* iterate over query results (lazy instantiation of query results)
+* added "select foo, bar" style queries returning multiple objects per row
+* delete by query
+* composite key support
+* outer joins for faster (?) loading of associated objects ( set "hibernate.use_outer_join" to "true" )
+* connection pooling when using DriverManager
+* foreign key constraint from unkeyed collection table to owner entity table
+* improved drop tables script execution (still not infallible)
+* added <composite-element> tag
+* added not-null properties and elements
+* added an optimisation for dates and components
+* made some XML attributes optional
+* fixed errors in documentation + documented some extra features
+* bugfix: store() not getting called on lifecycle interface
+* bugfix: schema generation for indexed associations
+* added many tests
+
+Changes in version 0.9.1 (20.1.2002)
+------------------------------------
+Too many to list
+
+version 0.8.1
+-------------
+Initial alpha version
+
Deleted: core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml
===================================================================
--- core/trunk/connection-c3p0/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-c3p0</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate C3P0 ConnectionProvider</name>
- <description>C3P0-based implementation of the Hibernate ConnectionProvder contract</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>c3p0</groupId>
- <artifactId>c3p0</artifactId>
- <version>0.9.1</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml (from rev 15003, core/trunk/connection-c3p0/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/connection-c3p0/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,31 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-c3p0</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate C3P0 ConnectionProvider</name>
+ <description>C3P0-based implementation of the Hibernate ConnectionProvder contract</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>c3p0</groupId>
+ <artifactId>c3p0</artifactId>
+ <version>0.9.1</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml
===================================================================
--- core/trunk/connection-proxool/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-proxool</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate Proxool ConnectionProvider</name>
- <description>Proxool-based implementation of the Hibernate ConnectionProvder contract</description>
-
- <dependencies>
- <dependency>
- <groupId>${groupId}</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>proxool</groupId>
- <artifactId>proxool</artifactId>
- <version>0.8.3</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml (from rev 15003, core/trunk/connection-proxool/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/connection-proxool/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,31 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-proxool</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate Proxool ConnectionProvider</name>
+ <description>Proxool-based implementation of the Hibernate ConnectionProvder contract</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>proxool</groupId>
+ <artifactId>proxool</artifactId>
+ <version>0.8.3</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ core/tags/hibernate-3.3.0.CR2/core/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,138 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <packaging>jar</packaging>
-
- <name>Hibernate Core</name>
- <description>The core functionality of Hibernate</description>
-
- <dependencies>
- <dependency>
- <groupId>antlr</groupId>
- <artifactId>antlr</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </dependency>
-
- <dependency>
- <!-- YUCK, YUCK, YUCK!!!! -->
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jaas</artifactId>
- <version>1.0.01</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.security</groupId>
- <artifactId>jacc</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.6.5</version>
- <scope>provided</scope>
- </dependency>
-
- <!-- optional deps for bytecode providers until those are finally properly scoped -->
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.GA</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-cglib-repack</artifactId>
- <version>2.1_3</version>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>antlr-maven-plugin</artifactId>
- <version>${antlrPluginVersion}</version>
- <configuration>
- <grammars>hql.g,hql-sql.g,sql-gen.g</grammars>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>antlr-maven-plugin</artifactId>
- <version>${antlrPluginVersion}</version>
- <configuration>
- <!-- eventually should be based on the second phase grammar -->
- <grammars>hql.g</grammars>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!--
- for the time being, gonna ignore the custom stylesheet (what did it do anyway???)
- <stylesheetfile>xyz</stylesheetfile>
- -->
- <groups>
- <group>
- <title>Core API</title>
- <packages>org.hibernate:org.hibernate.classic:org.hibernate.criterion:org.hibernate.metadata:org.hibernate.cfg:org.hibernate.usertype</packages>
- </group>
- <group>
- <title>Extension API</title>
- <packages>org.hibernate.id:org.hibernate.connection:org.hibernate.transaction:org.hibernate.type:org.hibernate.dialect*:org.hibernate.cache*:org.hibernate.event*:org.hibernate.action:org.hibernate.property:org.hibernate.loader*:org.hibernate.persister*:org.hibernate.proxy:org.hibernate.tuple:org.hibernate.transform:org.hibernate.collection:org.hibernate.jdbc</packages>
- </group>
- <group>
- <title>Miscellaneous API</title>
- <packages>org.hibernate.stat:org.hibernate.tool.hbm2ddl:org.hibernate.jmx:org.hibernate.mapping:org.hibernate.tool.instrument</packages>
- </group>
- <group>
- <title>Internal Implementation</title>
- <packages>org.hibernate.engine:org.hibernate.impl:org.hibernate.sql:org.hibernate.lob:org.hibernate.util:org.hibernate.exception:org.hibernate.hql:org.hibernate.hql.ast:org.hibernate.hql.antlr:org.hibernate.hql.classic:org.hibernate.intercept:org.hibernate.secure:org.hibernate.pretty</packages>
- </group>
- </groups>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
- <properties>
- <antlrPluginVersion>2.1</antlrPluginVersion>
- </properties>
-</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/pom.xml (from rev 15003, core/trunk/core/pom.xml)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/pom.xml (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/pom.xml 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,138 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.0.CR2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate Core</name>
+ <description>The core functionality of Hibernate</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- YUCK, YUCK, YUCK!!!! -->
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jacc</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- optional deps for bytecode providers until those are finally properly scoped -->
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-cglib-repack</artifactId>
+ <version>2.1_3</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>antlr-maven-plugin</artifactId>
+ <version>${antlrPluginVersion}</version>
+ <configuration>
+ <grammars>hql.g,hql-sql.g,sql-gen.g</grammars>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>antlr-maven-plugin</artifactId>
+ <version>${antlrPluginVersion}</version>
+ <configuration>
+ <!-- eventually should be based on the second phase grammar -->
+ <grammars>hql.g</grammars>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!--
+ for the time being, gonna ignore the custom stylesheet (what did it do anyway???)
+ <stylesheetfile>xyz</stylesheetfile>
+ -->
+ <groups>
+ <group>
+ <title>Core API</title>
+ <packages>org.hibernate:org.hibernate.classic:org.hibernate.criterion:org.hibernate.metadata:org.hibernate.cfg:org.hibernate.usertype</packages>
+ </group>
+ <group>
+ <title>Extension API</title>
+ <packages>org.hibernate.id:org.hibernate.connection:org.hibernate.transaction:org.hibernate.type:org.hibernate.dialect*:org.hibernate.cache*:org.hibernate.event*:org.hibernate.action:org.hibernate.property:org.hibernate.loader*:org.hibernate.persister*:org.hibernate.proxy:org.hibernate.tuple:org.hibernate.transform:org.hibernate.collection:org.hibernate.jdbc</packages>
+ </group>
+ <group>
+ <title>Miscellaneous API</title>
+ <packages>org.hibernate.stat:org.hibernate.tool.hbm2ddl:org.hibernate.jmx:org.hibernate.mapping:org.hibernate.tool.instrument</packages>
+ </group>
+ <group>
+ <title>Internal Implementation</title>
+ <packages>org.hibernate.engine:org.hibernate.impl:org.hibernate.sql:org.hibernate.lob:org.hibernate.util:org.hibernate.exception:org.hibernate.hql:org.hibernate.hql.ast:org.hibernate.hql.antlr:org.hibernate.hql.classic:org.hibernate.intercept:org.hibernate.secure:org.hibernate.pretty</packages>
+ </group>
+ </groups>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <properties>
+ <antlrPluginVersion>2.1</antlrPluginVersion>
+ </properties>
+</project>
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java (from rev 14992, core/trunk/core/src/main/java)
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/AssertionFailure.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,36 +0,0 @@
-//$Id: AssertionFailure.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-import org.hibernate.exception.NestableRuntimeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Indicates failure of an assertion: a possible bug in Hibernate.
- *
- * @author Gavin King
- */
-
-public class AssertionFailure extends NestableRuntimeException {
-
- private static final Logger log = LoggerFactory.getLogger(AssertionFailure.class);
-
- private static final String MESSAGE = "an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)";
-
- public AssertionFailure(String s) {
- super(s);
- log.error(MESSAGE, this);
- }
-
- public AssertionFailure(String s, Throwable t) {
- super(s, t);
- log.error(MESSAGE, t);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/AssertionFailure.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/AssertionFailure.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.hibernate.exception.NestableRuntimeException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Indicates failure of an assertion: a possible bug in Hibernate.
+ *
+ * @author Gavin King
+ */
+public class AssertionFailure extends NestableRuntimeException {
+
+ private static final Logger log = LoggerFactory.getLogger( AssertionFailure.class );
+
+ private static final String MESSAGE = "an assertion failure occured" +
+ " (this may indicate a bug in Hibernate, but is more likely due" +
+ " to unsafe use of the session)";
+
+ public AssertionFailure(String s) {
+ super( s );
+ log.error( MESSAGE, this );
+ }
+
+ public AssertionFailure(String s, Throwable t) {
+ super( s, t );
+ log.error( MESSAGE, t );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/CacheMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,78 +0,0 @@
-//$Id: CacheMode.java 9194 2006-02-01 19:59:07Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Controls how the session interacts with the second-level
- * cache and query cache.
- *
- * @see Session#setCacheMode(CacheMode)
- * @author Gavin King
- */
-public final class CacheMode implements Serializable {
- private final String name;
- private final boolean isPutEnabled;
- private final boolean isGetEnabled;
- private static final Map INSTANCES = new HashMap();
-
- private CacheMode(String name, boolean isPutEnabled, boolean isGetEnabled) {
- this.name=name;
- this.isPutEnabled = isPutEnabled;
- this.isGetEnabled = isGetEnabled;
- }
- public String toString() {
- return name;
- }
- public boolean isPutEnabled() {
- return isPutEnabled;
- }
- public boolean isGetEnabled() {
- return isGetEnabled;
- }
- /**
- * The session may read items from the cache, and add items to the cache
- */
- public static final CacheMode NORMAL = new CacheMode("NORMAL", true, true);
- /**
- * The session will never interact with the cache, except to invalidate
- * cache items when updates occur
- */
- public static final CacheMode IGNORE = new CacheMode("IGNORE", false, false);
- /**
- * The session may read items from the cache, but will not add items,
- * except to invalidate items when updates occur
- */
- public static final CacheMode GET = new CacheMode("GET", false, true);
- /**
- * The session will never read items from the cache, but will add items
- * to the cache as it reads them from the database.
- */
- public static final CacheMode PUT = new CacheMode("PUT", true, false);
-
- /**
- * The session will never read items from the cache, but will add items
- * to the cache as it reads them from the database. In this mode, the
- * effect of <tt>hibernate.cache.use_minimal_puts</tt> is bypassed, in
- * order to <em>force</em> a cache refresh
- */
- public static final CacheMode REFRESH = new CacheMode("REFRESH", true, false);
-
- static {
- INSTANCES.put( NORMAL.name, NORMAL );
- INSTANCES.put( IGNORE.name, IGNORE );
- INSTANCES.put( GET.name, GET );
- INSTANCES.put( PUT.name, PUT );
- INSTANCES.put( REFRESH.name, REFRESH );
- }
-
- private Object readResolve() {
- return INSTANCES.get( name );
- }
-
- public static CacheMode parse(String name) {
- return ( CacheMode ) INSTANCES.get( name );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/CacheMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CacheMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Controls how the session interacts with the second-level
+ * cache and query cache.
+ *
+ * @see Session#setCacheMode(CacheMode)
+ * @author Gavin King
+ */
+public final class CacheMode implements Serializable {
+ private final String name;
+ private final boolean isPutEnabled;
+ private final boolean isGetEnabled;
+ private static final Map INSTANCES = new HashMap();
+
+ private CacheMode(String name, boolean isPutEnabled, boolean isGetEnabled) {
+ this.name=name;
+ this.isPutEnabled = isPutEnabled;
+ this.isGetEnabled = isGetEnabled;
+ }
+ public String toString() {
+ return name;
+ }
+ public boolean isPutEnabled() {
+ return isPutEnabled;
+ }
+ public boolean isGetEnabled() {
+ return isGetEnabled;
+ }
+ /**
+ * The session may read items from the cache, and add items to the cache
+ */
+ public static final CacheMode NORMAL = new CacheMode("NORMAL", true, true);
+ /**
+ * The session will never interact with the cache, except to invalidate
+ * cache items when updates occur
+ */
+ public static final CacheMode IGNORE = new CacheMode("IGNORE", false, false);
+ /**
+ * The session may read items from the cache, but will not add items,
+ * except to invalidate items when updates occur
+ */
+ public static final CacheMode GET = new CacheMode("GET", false, true);
+ /**
+ * The session will never read items from the cache, but will add items
+ * to the cache as it reads them from the database.
+ */
+ public static final CacheMode PUT = new CacheMode("PUT", true, false);
+
+ /**
+ * The session will never read items from the cache, but will add items
+ * to the cache as it reads them from the database. In this mode, the
+ * effect of <tt>hibernate.cache.use_minimal_puts</tt> is bypassed, in
+ * order to <em>force</em> a cache refresh
+ */
+ public static final CacheMode REFRESH = new CacheMode("REFRESH", true, false);
+
+ static {
+ INSTANCES.put( NORMAL.name, NORMAL );
+ INSTANCES.put( IGNORE.name, IGNORE );
+ INSTANCES.put( GET.name, GET );
+ INSTANCES.put( PUT.name, PUT );
+ INSTANCES.put( REFRESH.name, REFRESH );
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get( name );
+ }
+
+ public static CacheMode parse(String name) {
+ return ( CacheMode ) INSTANCES.get( name );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/CallbackException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,34 +0,0 @@
-//$Id: CallbackException.java 4242 2004-08-11 09:10:45Z oneovthafew $
-package org.hibernate;
-
-
-/**
- * Should be thrown by persistent objects from <tt>Lifecycle</tt>
- * or <tt>Interceptor</tt> callbacks.
- *
- * @see Lifecycle
- * @see Interceptor
- * @author Gavin King
- */
-
-public class CallbackException extends HibernateException {
-
- public CallbackException(Exception root) {
- super("An exception occurred in a callback", root);
- }
-
- public CallbackException(String message) {
- super(message);
- }
-
- public CallbackException(String message, Exception e) {
- super(message, e);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/CallbackException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/CallbackException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Should be thrown by persistent objects from <tt>Lifecycle</tt>
+ * or <tt>Interceptor</tt> callbacks.
+ *
+ * @see org.hibernate.classic.Lifecycle
+ * @see Interceptor
+ * @author Gavin King
+ */
+
+public class CallbackException extends HibernateException {
+
+ public CallbackException(Exception root) {
+ super("An exception occurred in a callback", root);
+ }
+
+ public CallbackException(String message) {
+ super(message);
+ }
+
+ public CallbackException(String message, Exception e) {
+ super(message, e);
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/ConnectionReleaseMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,77 +0,0 @@
-// $Id: ConnectionReleaseMode.java 8409 2005-10-14 20:28:18Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-
-/**
- * Defines the various policies by which Hibernate might release its underlying
- * JDBC connection.
- *
- * @author Steve Ebersole
- */
-public class ConnectionReleaseMode implements Serializable {
-
- /**
- * Indicates that JDBC connection should be aggressively released after each
- * SQL statement is executed. In this mode, the application <em>must</em>
- * explicitly close all iterators and scrollable results. This mode may
- * only be used with a JTA datasource.
- */
- public static final ConnectionReleaseMode AFTER_STATEMENT = new ConnectionReleaseMode( "after_statement" );
-
- /**
- * Indicates that JDBC connections should be released after each transaction
- * ends (works with both JTA-registered synch and HibernateTransaction API).
- * This mode may not be used with an application server JTA datasource.
- * <p/>
- * This is the default mode starting in 3.1; was previously {@link #ON_CLOSE}.
- */
- public static final ConnectionReleaseMode AFTER_TRANSACTION = new ConnectionReleaseMode( "after_transaction" );
-
- /**
- * Indicates that connections should only be released when the Session is explicitly closed
- * or disconnected; this is the legacy (Hibernate2 and pre-3.1) behavior.
- */
- public static final ConnectionReleaseMode ON_CLOSE = new ConnectionReleaseMode( "on_close" );
-
-
- private String name;
-
- private ConnectionReleaseMode(String name) {
- this.name = name;
- }
-
- /**
- * Override of Object.toString(). Returns the release mode name.
- *
- * @return The release mode name.
- */
- public String toString() {
- return name;
- }
-
- /**
- * Determine the correct ConnectionReleaseMode instance based on the given
- * name.
- *
- * @param modeName The release mode name.
- * @return The appropriate ConnectionReleaseMode instance
- * @throws HibernateException Indicates the modeName param did not match any known modes.
- */
- public static ConnectionReleaseMode parse(String modeName) throws HibernateException {
- if ( AFTER_STATEMENT.name.equals( modeName ) ) {
- return AFTER_STATEMENT;
- }
- else if ( AFTER_TRANSACTION.name.equals( modeName ) ) {
- return AFTER_TRANSACTION;
- }
- else if ( ON_CLOSE.name.equals( modeName ) ) {
- return ON_CLOSE;
- }
- throw new HibernateException( "could not determine appropriate connection release mode [" + modeName + "]" );
- }
-
- private Object readResolve() {
- return parse( name );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/ConnectionReleaseMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ConnectionReleaseMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,100 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+/**
+ * Defines the various policies by which Hibernate might release its underlying
+ * JDBC connection.
+ *
+ * @author Steve Ebersole
+ */
+public class ConnectionReleaseMode implements Serializable {
+
+ /**
+ * Indicates that JDBC connection should be aggressively released after each
+ * SQL statement is executed. In this mode, the application <em>must</em>
+ * explicitly close all iterators and scrollable results. This mode may
+ * only be used with a JTA datasource.
+ */
+ public static final ConnectionReleaseMode AFTER_STATEMENT = new ConnectionReleaseMode( "after_statement" );
+
+ /**
+ * Indicates that JDBC connections should be released after each transaction
+ * ends (works with both JTA-registered synch and HibernateTransaction API).
+ * This mode may not be used with an application server JTA datasource.
+ * <p/>
+ * This is the default mode starting in 3.1; was previously {@link #ON_CLOSE}.
+ */
+ public static final ConnectionReleaseMode AFTER_TRANSACTION = new ConnectionReleaseMode( "after_transaction" );
+
+ /**
+ * Indicates that connections should only be released when the Session is explicitly closed
+ * or disconnected; this is the legacy (Hibernate2 and pre-3.1) behavior.
+ */
+ public static final ConnectionReleaseMode ON_CLOSE = new ConnectionReleaseMode( "on_close" );
+
+
+ private String name;
+
+ private ConnectionReleaseMode(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Override of Object.toString(). Returns the release mode name.
+ *
+ * @return The release mode name.
+ */
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Determine the correct ConnectionReleaseMode instance based on the given
+ * name.
+ *
+ * @param modeName The release mode name.
+ * @return The appropriate ConnectionReleaseMode instance
+ * @throws HibernateException Indicates the modeName param did not match any known modes.
+ */
+ public static ConnectionReleaseMode parse(String modeName) throws HibernateException {
+ if ( AFTER_STATEMENT.name.equals( modeName ) ) {
+ return AFTER_STATEMENT;
+ }
+ else if ( AFTER_TRANSACTION.name.equals( modeName ) ) {
+ return AFTER_TRANSACTION;
+ }
+ else if ( ON_CLOSE.name.equals( modeName ) ) {
+ return ON_CLOSE;
+ }
+ throw new HibernateException( "could not determine appropriate connection release mode [" + modeName + "]" );
+ }
+
+ private Object readResolve() {
+ return parse( name );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Criteria.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,338 +0,0 @@
-//$Id: Criteria.java 9116 2006-01-23 21:21:01Z steveebersole $
-package org.hibernate;
-
-import java.util.List;
-
-import org.hibernate.criterion.CriteriaSpecification;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Projection;
-import org.hibernate.transform.ResultTransformer;
-
-/**
- * <tt>Criteria</tt> is a simplified API for retrieving entities
- * by composing <tt>Criterion</tt> objects. This is a very
- * convenient approach for functionality like "search" screens
- * where there is a variable number of conditions to be placed
- * upon the result set.<br>
- * <br>
- * The <tt>Session</tt> is a factory for <tt>Criteria</tt>.
- * <tt>Criterion</tt> instances are usually obtained via
- * the factory methods on <tt>Restrictions</tt>. eg.
- * <pre>
- * List cats = session.createCriteria(Cat.class)
- * .add( Restrictions.like("name", "Iz%") )
- * .add( Restrictions.gt( "weight", new Float(minWeight) ) )
- * .addOrder( Order.asc("age") )
- * .list();
- * </pre>
- * You may navigate associations using <tt>createAlias()</tt> or
- * <tt>createCriteria()</tt>.
- * <pre>
- * List cats = session.createCriteria(Cat.class)
- * .createCriteria("kittens")
- * .add( Restrictions.like("name", "Iz%") )
- * .list();
- * </pre>
- * <pre>
- * List cats = session.createCriteria(Cat.class)
- * .createAlias("kittens", "kit")
- * .add( Restrictions.like("kit.name", "Iz%") )
- * .list();
- * </pre>
- * You may specify projection and aggregation using <tt>Projection</tt>
- * instances obtained via the factory methods on <tt>Projections</tt>.
- * <pre>
- * List cats = session.createCriteria(Cat.class)
- * .setProjection( Projections.projectionList()
- * .add( Projections.rowCount() )
- * .add( Projections.avg("weight") )
- * .add( Projections.max("weight") )
- * .add( Projections.min("weight") )
- * .add( Projections.groupProperty("color") )
- * )
- * .addOrder( Order.asc("color") )
- * .list();
- * </pre>
- *
- * @see Session#createCriteria(java.lang.Class)
- * @see org.hibernate.criterion.Restrictions
- * @see org.hibernate.criterion.Projections
- * @see org.hibernate.criterion.Order
- * @see org.hibernate.criterion.Criterion
- * @see org.hibernate.criterion.Projection
- * @see org.hibernate.criterion.DetachedCriteria a disconnected version of this API
- * @author Gavin King
- */
-public interface Criteria extends CriteriaSpecification {
-
- /**
- * Get the alias of the entity encapsulated by this criteria instance.
- *
- * @return The alias for the encapsulated entity.
- */
- public String getAlias();
-
- /**
- * Used to specify that the query results will be a projection (scalar in
- * nature). Implicitly specifies the {@link #PROJECTION} result transformer.
- * <p/>
- * The individual components contained within the given
- * {@link Projection projection} determines the overall "shape" of the
- * query result.
- *
- * @param projection The projection representing the overall "shape" of the
- * query results.
- * @return this (for method chaining)
- */
- public Criteria setProjection(Projection projection);
-
- /**
- * Add a {@link Criterion restriction} to constrain the results to be
- * retrieved.
- *
- * @param criterion The {@link Criterion criterion} object representing the
- * restriction to be applied.
- * @return this (for method chaining)
- */
- public Criteria add(Criterion criterion);
-
- /**
- * Add an {@link Order ordering} to the result set.
- *
- * @param order The {@link Order order} object representing an ordering
- * to be applied to the results.
- * @return this (for method chaining)
- */
- public Criteria addOrder(Order order);
-
- /**
- * Specify an association fetching strategy for an association or a
- * collection of values.
- *
- * @param associationPath a dot seperated property path
- * @param mode The fetch mode for the referenced association
- * @return this (for method chaining)
- */
- public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;
-
- /**
- * Set the lock mode of the current entity
- *
- * @param lockMode The lock mode to be applied
- * @return this (for method chaining)
- */
- public Criteria setLockMode(LockMode lockMode);
-
- /**
- * Set the lock mode of the aliased entity
- *
- * @param alias The previously assigned alias representing the entity to
- * which the given lock mode should apply.
- * @param lockMode The lock mode to be applied
- * @return this (for method chaining)
- */
- public Criteria setLockMode(String alias, LockMode lockMode);
-
- /**
- * Join an association, assigning an alias to the joined association.
- * <p/>
- * Functionally equivalent to {@link #createAlias(String, String, int)} using
- * {@link #INNER_JOIN} for the joinType.
- *
- * @param associationPath A dot-seperated property path
- * @param alias The alias to assign to the joined association (for later reference).
- * @return this (for method chaining)
- */
- public Criteria createAlias(String associationPath, String alias) throws HibernateException;
-
- /**
- * Join an association using the specified join-type, assigning an alias
- * to the joined association.
- * <p/>
- * The joinType is expected to be one of {@link #INNER_JOIN} (the default),
- * {@link #FULL_JOIN}, or {@link #LEFT_JOIN}.
- *
- * @param associationPath A dot-seperated property path
- * @param alias The alias to assign to the joined association (for later reference).
- * @param joinType The type of join to use.
- * @return this (for method chaining)
- */
- public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException;
-
- /**
- * Create a new <tt>Criteria</tt>, "rooted" at the associated entity.
- * <p/>
- * Functionally equivalent to {@link #createCriteria(String, int)} using
- * {@link #INNER_JOIN} for the joinType.
- *
- * @param associationPath A dot-seperated property path
- * @return the created "sub criteria"
- */
- public Criteria createCriteria(String associationPath) throws HibernateException;
-
- /**
- * Create a new <tt>Criteria</tt>, "rooted" at the associated entity, using the
- * specified join type.
- *
- * @param associationPath A dot-seperated property path
- * @param joinType The type of join to use.
- * @return the created "sub criteria"
- */
- public Criteria createCriteria(String associationPath, int joinType) throws HibernateException;
-
- /**
- * Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
- * assigning the given alias.
- * <p/>
- * Functionally equivalent to {@link #createCriteria(String, String, int)} using
- * {@link #INNER_JOIN} for the joinType.
- *
- * @param associationPath A dot-seperated property path
- * @param alias The alias to assign to the joined association (for later reference).
- * @return the created "sub criteria"
- */
- public Criteria createCriteria(String associationPath, String alias) throws HibernateException;
-
- /**
- * Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
- * assigning the given alias and using the specified join type.
- *
- * @param associationPath A dot-seperated property path
- * @param alias The alias to assign to the joined association (for later reference).
- * @param joinType The type of join to use.
- * @return the created "sub criteria"
- */
- public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException;
-
- /**
- * Set a strategy for handling the query results. This determines the
- * "shape" of the query result.
- *
- * @param resultTransformer The transformer to apply
- * @return this (for method chaining)
- *
- * @see #ROOT_ENTITY
- * @see #DISTINCT_ROOT_ENTITY
- * @see #ALIAS_TO_ENTITY_MAP
- * @see #PROJECTION
- */
- public Criteria setResultTransformer(ResultTransformer resultTransformer);
-
- /**
- * Set a limit upon the number of objects to be retrieved.
- *
- * @param maxResults the maximum number of results
- * @return this (for method chaining)
- */
- public Criteria setMaxResults(int maxResults);
-
- /**
- * Set the first result to be retrieved.
- *
- * @param firstResult the first result to retrieve, numbered from <tt>0</tt>
- * @return this (for method chaining)
- */
- public Criteria setFirstResult(int firstResult);
-
- /**
- * Set a fetch size for the underlying JDBC query.
- *
- * @param fetchSize the fetch size
- * @return this (for method chaining)
- *
- * @see java.sql.Statement#setFetchSize
- */
- public Criteria setFetchSize(int fetchSize);
-
- /**
- * Set a timeout for the underlying JDBC query.
- *
- * @param timeout The timeout value to apply.
- * @return this (for method chaining)
- *
- * @see java.sql.Statement#setQueryTimeout
- */
- public Criteria setTimeout(int timeout);
-
- /**
- * Enable caching of this query result, provided query caching is enabled
- * for the underlying session factory.
- *
- * @param cacheable Should the result be considered cacheable; default is
- * to not cache (false).
- * @return this (for method chaining)
- */
- public Criteria setCacheable(boolean cacheable);
-
- /**
- * Set the name of the cache region to use for query result caching.
- *
- * @param cacheRegion the name of a query cache region, or <tt>null</tt>
- * for the default query cache
- * @return this (for method chaining)
- *
- * @see #setCacheable
- */
- public Criteria setCacheRegion(String cacheRegion);
-
- /**
- * Add a comment to the generated SQL.
- *
- * @param comment a human-readable string
- * @return this (for method chaining)
- */
- public Criteria setComment(String comment);
-
- /**
- * Override the flush mode for this particular query.
- *
- * @param flushMode The flush mode to use.
- * @return this (for method chaining)
- */
- public Criteria setFlushMode(FlushMode flushMode);
-
- /**
- * Override the cache mode for this particular query.
- *
- * @param cacheMode The cache mode to use.
- * @return this (for method chaining)
- */
- public Criteria setCacheMode(CacheMode cacheMode);
-
- /**
- * Get the results.
- *
- * @return The list of matched query results.
- */
- public List list() throws HibernateException;
-
- /**
- * Get the results as an instance of {@link ScrollableResults}
- *
- * @return The {@link ScrollableResults} representing the matched
- * query results.
- */
- public ScrollableResults scroll() throws HibernateException;
-
- /**
- * Get the results as an instance of {@link ScrollableResults} based on the
- * given scroll mode.
- *
- * @param scrollMode Indicates the type of underlying database cursor to
- * request.
- * @return The {@link ScrollableResults} representing the matched
- * query results.
- */
- public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException;
-
- /**
- * Convenience method to return a single instance that matches
- * the query, or null if the query returns no results.
- *
- * @return the single result or <tt>null</tt>
- * @throws HibernateException if there is more than one matching result
- */
- public Object uniqueResult() throws HibernateException;
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Criteria.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Criteria.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,361 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.util.List;
+
+import org.hibernate.criterion.CriteriaSpecification;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projection;
+import org.hibernate.transform.ResultTransformer;
+
+/**
+ * <tt>Criteria</tt> is a simplified API for retrieving entities
+ * by composing <tt>Criterion</tt> objects. This is a very
+ * convenient approach for functionality like "search" screens
+ * where there is a variable number of conditions to be placed
+ * upon the result set.<br>
+ * <br>
+ * The <tt>Session</tt> is a factory for <tt>Criteria</tt>.
+ * <tt>Criterion</tt> instances are usually obtained via
+ * the factory methods on <tt>Restrictions</tt>. eg.
+ * <pre>
+ * List cats = session.createCriteria(Cat.class)
+ * .add( Restrictions.like("name", "Iz%") )
+ * .add( Restrictions.gt( "weight", new Float(minWeight) ) )
+ * .addOrder( Order.asc("age") )
+ * .list();
+ * </pre>
+ * You may navigate associations using <tt>createAlias()</tt> or
+ * <tt>createCriteria()</tt>.
+ * <pre>
+ * List cats = session.createCriteria(Cat.class)
+ * .createCriteria("kittens")
+ * .add( Restrictions.like("name", "Iz%") )
+ * .list();
+ * </pre>
+ * <pre>
+ * List cats = session.createCriteria(Cat.class)
+ * .createAlias("kittens", "kit")
+ * .add( Restrictions.like("kit.name", "Iz%") )
+ * .list();
+ * </pre>
+ * You may specify projection and aggregation using <tt>Projection</tt>
+ * instances obtained via the factory methods on <tt>Projections</tt>.
+ * <pre>
+ * List cats = session.createCriteria(Cat.class)
+ * .setProjection( Projections.projectionList()
+ * .add( Projections.rowCount() )
+ * .add( Projections.avg("weight") )
+ * .add( Projections.max("weight") )
+ * .add( Projections.min("weight") )
+ * .add( Projections.groupProperty("color") )
+ * )
+ * .addOrder( Order.asc("color") )
+ * .list();
+ * </pre>
+ *
+ * @see Session#createCriteria(java.lang.Class)
+ * @see org.hibernate.criterion.Restrictions
+ * @see org.hibernate.criterion.Projections
+ * @see org.hibernate.criterion.Order
+ * @see org.hibernate.criterion.Criterion
+ * @see org.hibernate.criterion.Projection
+ * @see org.hibernate.criterion.DetachedCriteria a disconnected version of this API
+ * @author Gavin King
+ */
+public interface Criteria extends CriteriaSpecification {
+
+ /**
+ * Get the alias of the entity encapsulated by this criteria instance.
+ *
+ * @return The alias for the encapsulated entity.
+ */
+ public String getAlias();
+
+ /**
+ * Used to specify that the query results will be a projection (scalar in
+ * nature). Implicitly specifies the {@link #PROJECTION} result transformer.
+ * <p/>
+ * The individual components contained within the given
+ * {@link Projection projection} determines the overall "shape" of the
+ * query result.
+ *
+ * @param projection The projection representing the overall "shape" of the
+ * query results.
+ * @return this (for method chaining)
+ */
+ public Criteria setProjection(Projection projection);
+
+ /**
+ * Add a {@link Criterion restriction} to constrain the results to be
+ * retrieved.
+ *
+ * @param criterion The {@link Criterion criterion} object representing the
+ * restriction to be applied.
+ * @return this (for method chaining)
+ */
+ public Criteria add(Criterion criterion);
+
+ /**
+ * Add an {@link Order ordering} to the result set.
+ *
+ * @param order The {@link Order order} object representing an ordering
+ * to be applied to the results.
+ * @return this (for method chaining)
+ */
+ public Criteria addOrder(Order order);
+
+ /**
+ * Specify an association fetching strategy for an association or a
+ * collection of values.
+ *
+ * @param associationPath a dot seperated property path
+ * @param mode The fetch mode for the referenced association
+ * @return this (for method chaining)
+ */
+ public Criteria setFetchMode(String associationPath, FetchMode mode) throws HibernateException;
+
+ /**
+ * Set the lock mode of the current entity
+ *
+ * @param lockMode The lock mode to be applied
+ * @return this (for method chaining)
+ */
+ public Criteria setLockMode(LockMode lockMode);
+
+ /**
+ * Set the lock mode of the aliased entity
+ *
+ * @param alias The previously assigned alias representing the entity to
+ * which the given lock mode should apply.
+ * @param lockMode The lock mode to be applied
+ * @return this (for method chaining)
+ */
+ public Criteria setLockMode(String alias, LockMode lockMode);
+
+ /**
+ * Join an association, assigning an alias to the joined association.
+ * <p/>
+ * Functionally equivalent to {@link #createAlias(String, String, int)} using
+ * {@link #INNER_JOIN} for the joinType.
+ *
+ * @param associationPath A dot-seperated property path
+ * @param alias The alias to assign to the joined association (for later reference).
+ * @return this (for method chaining)
+ */
+ public Criteria createAlias(String associationPath, String alias) throws HibernateException;
+
+ /**
+ * Join an association using the specified join-type, assigning an alias
+ * to the joined association.
+ * <p/>
+ * The joinType is expected to be one of {@link #INNER_JOIN} (the default),
+ * {@link #FULL_JOIN}, or {@link #LEFT_JOIN}.
+ *
+ * @param associationPath A dot-seperated property path
+ * @param alias The alias to assign to the joined association (for later reference).
+ * @param joinType The type of join to use.
+ * @return this (for method chaining)
+ */
+ public Criteria createAlias(String associationPath, String alias, int joinType) throws HibernateException;
+
+ /**
+ * Create a new <tt>Criteria</tt>, "rooted" at the associated entity.
+ * <p/>
+ * Functionally equivalent to {@link #createCriteria(String, int)} using
+ * {@link #INNER_JOIN} for the joinType.
+ *
+ * @param associationPath A dot-seperated property path
+ * @return the created "sub criteria"
+ */
+ public Criteria createCriteria(String associationPath) throws HibernateException;
+
+ /**
+ * Create a new <tt>Criteria</tt>, "rooted" at the associated entity, using the
+ * specified join type.
+ *
+ * @param associationPath A dot-seperated property path
+ * @param joinType The type of join to use.
+ * @return the created "sub criteria"
+ */
+ public Criteria createCriteria(String associationPath, int joinType) throws HibernateException;
+
+ /**
+ * Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
+ * assigning the given alias.
+ * <p/>
+ * Functionally equivalent to {@link #createCriteria(String, String, int)} using
+ * {@link #INNER_JOIN} for the joinType.
+ *
+ * @param associationPath A dot-seperated property path
+ * @param alias The alias to assign to the joined association (for later reference).
+ * @return the created "sub criteria"
+ */
+ public Criteria createCriteria(String associationPath, String alias) throws HibernateException;
+
+ /**
+ * Create a new <tt>Criteria</tt>, "rooted" at the associated entity,
+ * assigning the given alias and using the specified join type.
+ *
+ * @param associationPath A dot-seperated property path
+ * @param alias The alias to assign to the joined association (for later reference).
+ * @param joinType The type of join to use.
+ * @return the created "sub criteria"
+ */
+ public Criteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException;
+
+ /**
+ * Set a strategy for handling the query results. This determines the
+ * "shape" of the query result.
+ *
+ * @param resultTransformer The transformer to apply
+ * @return this (for method chaining)
+ *
+ * @see #ROOT_ENTITY
+ * @see #DISTINCT_ROOT_ENTITY
+ * @see #ALIAS_TO_ENTITY_MAP
+ * @see #PROJECTION
+ */
+ public Criteria setResultTransformer(ResultTransformer resultTransformer);
+
+ /**
+ * Set a limit upon the number of objects to be retrieved.
+ *
+ * @param maxResults the maximum number of results
+ * @return this (for method chaining)
+ */
+ public Criteria setMaxResults(int maxResults);
+
+ /**
+ * Set the first result to be retrieved.
+ *
+ * @param firstResult the first result to retrieve, numbered from <tt>0</tt>
+ * @return this (for method chaining)
+ */
+ public Criteria setFirstResult(int firstResult);
+
+ /**
+ * Set a fetch size for the underlying JDBC query.
+ *
+ * @param fetchSize the fetch size
+ * @return this (for method chaining)
+ *
+ * @see java.sql.Statement#setFetchSize
+ */
+ public Criteria setFetchSize(int fetchSize);
+
+ /**
+ * Set a timeout for the underlying JDBC query.
+ *
+ * @param timeout The timeout value to apply.
+ * @return this (for method chaining)
+ *
+ * @see java.sql.Statement#setQueryTimeout
+ */
+ public Criteria setTimeout(int timeout);
+
+ /**
+ * Enable caching of this query result, provided query caching is enabled
+ * for the underlying session factory.
+ *
+ * @param cacheable Should the result be considered cacheable; default is
+ * to not cache (false).
+ * @return this (for method chaining)
+ */
+ public Criteria setCacheable(boolean cacheable);
+
+ /**
+ * Set the name of the cache region to use for query result caching.
+ *
+ * @param cacheRegion the name of a query cache region, or <tt>null</tt>
+ * for the default query cache
+ * @return this (for method chaining)
+ *
+ * @see #setCacheable
+ */
+ public Criteria setCacheRegion(String cacheRegion);
+
+ /**
+ * Add a comment to the generated SQL.
+ *
+ * @param comment a human-readable string
+ * @return this (for method chaining)
+ */
+ public Criteria setComment(String comment);
+
+ /**
+ * Override the flush mode for this particular query.
+ *
+ * @param flushMode The flush mode to use.
+ * @return this (for method chaining)
+ */
+ public Criteria setFlushMode(FlushMode flushMode);
+
+ /**
+ * Override the cache mode for this particular query.
+ *
+ * @param cacheMode The cache mode to use.
+ * @return this (for method chaining)
+ */
+ public Criteria setCacheMode(CacheMode cacheMode);
+
+ /**
+ * Get the results.
+ *
+ * @return The list of matched query results.
+ */
+ public List list() throws HibernateException;
+
+ /**
+ * Get the results as an instance of {@link ScrollableResults}
+ *
+ * @return The {@link ScrollableResults} representing the matched
+ * query results.
+ */
+ public ScrollableResults scroll() throws HibernateException;
+
+ /**
+ * Get the results as an instance of {@link ScrollableResults} based on the
+ * given scroll mode.
+ *
+ * @param scrollMode Indicates the type of underlying database cursor to
+ * request.
+ * @return The {@link ScrollableResults} representing the matched
+ * query results.
+ */
+ public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException;
+
+ /**
+ * Convenience method to return a single instance that matches
+ * the query, or null if the query returns no results.
+ *
+ * @return the single result or <tt>null</tt>
+ * @throws HibernateException if there is more than one matching result
+ */
+ public Object uniqueResult() throws HibernateException;
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/DuplicateMappingException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,32 +0,0 @@
-package org.hibernate;
-
-/**
- * Raised whenever a duplicate for a certain type occurs.
- * Duplicate class, table, property name etc.
- *
- * @author Max Rydahl Andersen
- *
- */
-public class DuplicateMappingException extends MappingException {
-
- private final String name;
- private final String type;
-
- public DuplicateMappingException(String customMessage, String type, String name) {
- super(customMessage);
- this.type=type;
- this.name=name;
- }
-
- public DuplicateMappingException(String type, String name) {
- this("Duplicate " + type + " mapping " + name, type, name);
- }
-
- public String getType() {
- return type;
- }
-
- public String getName() {
- return name;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/DuplicateMappingException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/DuplicateMappingException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Raised whenever a duplicate for a certain type occurs.
+ * Duplicate class, table, property name etc.
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class DuplicateMappingException extends MappingException {
+
+ private final String name;
+ private final String type;
+
+ public DuplicateMappingException(String customMessage, String type, String name) {
+ super(customMessage);
+ this.type=type;
+ this.name=name;
+ }
+
+ public DuplicateMappingException(String type, String name) {
+ this("Duplicate " + type + " mapping " + name, type, name);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/EmptyInterceptor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,98 +0,0 @@
-//$Id: EmptyInterceptor.java 7859 2005-08-11 21:57:33Z oneovthafew $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-import org.hibernate.type.Type;
-
-/**
- * An interceptor that does nothing. May be used as a base class
- * for application-defined custom interceptors.
- *
- * @author Gavin King
- */
-public class EmptyInterceptor implements Interceptor, Serializable {
-
- public static final Interceptor INSTANCE = new EmptyInterceptor();
-
- protected EmptyInterceptor() {}
-
- public void onDelete(
- Object entity,
- Serializable id,
- Object[] state,
- String[] propertyNames,
- Type[] types) {}
-
- public boolean onFlushDirty(
- Object entity,
- Serializable id,
- Object[] currentState,
- Object[] previousState,
- String[] propertyNames,
- Type[] types) {
- return false;
- }
-
- public boolean onLoad(
- Object entity,
- Serializable id,
- Object[] state,
- String[] propertyNames,
- Type[] types) {
- return false;
- }
-
- public boolean onSave(
- Object entity,
- Serializable id,
- Object[] state,
- String[] propertyNames,
- Type[] types) {
- return false;
- }
-
- public void postFlush(Iterator entities) {}
- public void preFlush(Iterator entities) {}
-
- public Boolean isTransient(Object entity) {
- return null;
- }
-
- public Object instantiate(String entityName, EntityMode entityMode, Serializable id) {
- return null;
- }
-
- public int[] findDirty(Object entity,
- Serializable id,
- Object[] currentState,
- Object[] previousState,
- String[] propertyNames,
- Type[] types) {
- return null;
- }
-
- public String getEntityName(Object object) {
- return null;
- }
-
- public Object getEntity(String entityName, Serializable id) {
- return null;
- }
-
- public void afterTransactionBegin(Transaction tx) {}
- public void afterTransactionCompletion(Transaction tx) {}
- public void beforeTransactionCompletion(Transaction tx) {}
-
- public String onPrepareStatement(String sql) {
- return sql;
- }
-
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {}
-
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {}
-
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {}
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/EmptyInterceptor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EmptyInterceptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,121 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+import org.hibernate.type.Type;
+
+/**
+ * An interceptor that does nothing. May be used as a base class
+ * for application-defined custom interceptors.
+ *
+ * @author Gavin King
+ */
+public class EmptyInterceptor implements Interceptor, Serializable {
+
+ public static final Interceptor INSTANCE = new EmptyInterceptor();
+
+ protected EmptyInterceptor() {}
+
+ public void onDelete(
+ Object entity,
+ Serializable id,
+ Object[] state,
+ String[] propertyNames,
+ Type[] types) {}
+
+ public boolean onFlushDirty(
+ Object entity,
+ Serializable id,
+ Object[] currentState,
+ Object[] previousState,
+ String[] propertyNames,
+ Type[] types) {
+ return false;
+ }
+
+ public boolean onLoad(
+ Object entity,
+ Serializable id,
+ Object[] state,
+ String[] propertyNames,
+ Type[] types) {
+ return false;
+ }
+
+ public boolean onSave(
+ Object entity,
+ Serializable id,
+ Object[] state,
+ String[] propertyNames,
+ Type[] types) {
+ return false;
+ }
+
+ public void postFlush(Iterator entities) {}
+ public void preFlush(Iterator entities) {}
+
+ public Boolean isTransient(Object entity) {
+ return null;
+ }
+
+ public Object instantiate(String entityName, EntityMode entityMode, Serializable id) {
+ return null;
+ }
+
+ public int[] findDirty(Object entity,
+ Serializable id,
+ Object[] currentState,
+ Object[] previousState,
+ String[] propertyNames,
+ Type[] types) {
+ return null;
+ }
+
+ public String getEntityName(Object object) {
+ return null;
+ }
+
+ public Object getEntity(String entityName, Serializable id) {
+ return null;
+ }
+
+ public void afterTransactionBegin(Transaction tx) {}
+ public void afterTransactionCompletion(Transaction tx) {}
+ public void beforeTransactionCompletion(Transaction tx) {}
+
+ public String onPrepareStatement(String sql) {
+ return sql;
+ }
+
+ public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {}
+
+ public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {}
+
+ public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {}
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/EntityMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,49 +0,0 @@
-// $Id: EntityMode.java 8697 2005-11-29 14:29:24Z steveebersole $
-package org.hibernate;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.io.Serializable;
-
-/**
- * Defines the representation modes available for entities.
- *
- * @author Steve Ebersole
- */
-public class EntityMode implements Serializable {
-
- private static final Map INSTANCES = new HashMap();
-
- public static final EntityMode POJO = new EntityMode( "pojo" );
- public static final EntityMode DOM4J = new EntityMode( "dom4j" );
- public static final EntityMode MAP = new EntityMode( "dynamic-map" );
-
- static {
- INSTANCES.put( POJO.name, POJO );
- INSTANCES.put( DOM4J.name, DOM4J );
- INSTANCES.put( MAP.name, MAP );
- }
-
- private final String name;
-
- public EntityMode(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- private Object readResolve() {
- return INSTANCES.get( name );
- }
-
- public static EntityMode parse(String name) {
- EntityMode rtn = ( EntityMode ) INSTANCES.get( name );
- if ( rtn == null ) {
- // default is POJO
- rtn = POJO;
- }
- return rtn;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/EntityMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/EntityMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,72 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Serializable;
+
+/**
+ * Defines the representation modes available for entities.
+ *
+ * @author Steve Ebersole
+ */
+public class EntityMode implements Serializable {
+
+ private static final Map INSTANCES = new HashMap();
+
+ public static final EntityMode POJO = new EntityMode( "pojo" );
+ public static final EntityMode DOM4J = new EntityMode( "dom4j" );
+ public static final EntityMode MAP = new EntityMode( "dynamic-map" );
+
+ static {
+ INSTANCES.put( POJO.name, POJO );
+ INSTANCES.put( DOM4J.name, DOM4J );
+ INSTANCES.put( MAP.name, MAP );
+ }
+
+ private final String name;
+
+ public EntityMode(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get( name );
+ }
+
+ public static EntityMode parse(String name) {
+ EntityMode rtn = ( EntityMode ) INSTANCES.get( name );
+ if ( rtn == null ) {
+ // default is POJO
+ rtn = POJO;
+ }
+ return rtn;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/FetchMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,70 +0,0 @@
-//$Id: FetchMode.java 5060 2004-12-24 03:11:05Z oneovthafew $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents an association fetching strategy. This is used
- * together with the <tt>Criteria</tt> API to specify runtime
- * fetching strategies.<br>
- * <br>
- * For HQL queries, use the <tt>FETCH</tt> keyword instead.
- *
- * @see Criteria#setFetchMode(java.lang.String, FetchMode)
- * @author Gavin King
- */
-public final class FetchMode implements Serializable {
- private final String name;
- private static final Map INSTANCES = new HashMap();
-
- private FetchMode(String name) {
- this.name=name;
- }
- public String toString() {
- return name;
- }
- /**
- * Default to the setting configured in the mapping file.
- */
- public static final FetchMode DEFAULT = new FetchMode("DEFAULT");
-
- /**
- * Fetch using an outer join. Equivalent to <tt>fetch="join"</tt>.
- */
- public static final FetchMode JOIN = new FetchMode("JOIN");
- /**
- * Fetch eagerly, using a separate select. Equivalent to
- * <tt>fetch="select"</tt>.
- */
- public static final FetchMode SELECT = new FetchMode("SELECT");
-
- /**
- * Fetch lazily. Equivalent to <tt>outer-join="false"</tt>.
- * @deprecated use <tt>FetchMode.SELECT</tt>
- */
- public static final FetchMode LAZY = SELECT;
- /**
- * Fetch eagerly, using an outer join. Equivalent to
- * <tt>outer-join="true"</tt>.
- * @deprecated use <tt>FetchMode.JOIN</tt>
- */
- public static final FetchMode EAGER = JOIN;
-
- static {
- INSTANCES.put( JOIN.name, JOIN );
- INSTANCES.put( SELECT.name, SELECT );
- INSTANCES.put( DEFAULT.name, DEFAULT );
- }
-
- private Object readResolve() {
- return INSTANCES.get(name);
- }
-
-}
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/FetchMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FetchMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,93 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents an association fetching strategy. This is used
+ * together with the <tt>Criteria</tt> API to specify runtime
+ * fetching strategies.<br>
+ * <br>
+ * For HQL queries, use the <tt>FETCH</tt> keyword instead.
+ *
+ * @see Criteria#setFetchMode(java.lang.String, FetchMode)
+ * @author Gavin King
+ */
+public final class FetchMode implements Serializable {
+ private final String name;
+ private static final Map INSTANCES = new HashMap();
+
+ private FetchMode(String name) {
+ this.name=name;
+ }
+ public String toString() {
+ return name;
+ }
+ /**
+ * Default to the setting configured in the mapping file.
+ */
+ public static final FetchMode DEFAULT = new FetchMode("DEFAULT");
+
+ /**
+ * Fetch using an outer join. Equivalent to <tt>fetch="join"</tt>.
+ */
+ public static final FetchMode JOIN = new FetchMode("JOIN");
+ /**
+ * Fetch eagerly, using a separate select. Equivalent to
+ * <tt>fetch="select"</tt>.
+ */
+ public static final FetchMode SELECT = new FetchMode("SELECT");
+
+ /**
+ * Fetch lazily. Equivalent to <tt>outer-join="false"</tt>.
+ * @deprecated use <tt>FetchMode.SELECT</tt>
+ */
+ public static final FetchMode LAZY = SELECT;
+ /**
+ * Fetch eagerly, using an outer join. Equivalent to
+ * <tt>outer-join="true"</tt>.
+ * @deprecated use <tt>FetchMode.JOIN</tt>
+ */
+ public static final FetchMode EAGER = JOIN;
+
+ static {
+ INSTANCES.put( JOIN.name, JOIN );
+ INSTANCES.put( SELECT.name, SELECT );
+ INSTANCES.put( DEFAULT.name, DEFAULT );
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get(name);
+ }
+
+}
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Filter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,68 +0,0 @@
-// $Id: Filter.java 8754 2005-12-05 23:36:59Z steveebersole $
-package org.hibernate;
-
-import org.hibernate.engine.FilterDefinition;
-
-import java.util.Collection;
-
-/**
- * Type definition of Filter. Filter defines the user's view into enabled dynamic filters,
- * allowing them to set filter parameter values.
- *
- * @author Steve Ebersole
- */
-public interface Filter {
-
- /**
- * Get the name of this filter.
- *
- * @return This filter's name.
- */
- public String getName();
-
- /**
- * Get the filter definition containing additional information about the
- * filter (such as default-condition and expected parameter names/types).
- *
- * @return The filter definition
- */
- public FilterDefinition getFilterDefinition();
-
-
- /**
- * Set the named parameter's value for this filter.
- *
- * @param name The parameter's name.
- * @param value The value to be applied.
- * @return This FilterImpl instance (for method chaining).
- */
- public Filter setParameter(String name, Object value);
-
- /**
- * Set the named parameter's value list for this filter. Used
- * in conjunction with IN-style filter criteria.
- *
- * @param name The parameter's name.
- * @param values The values to be expanded into an SQL IN list.
- * @return This FilterImpl instance (for method chaining).
- */
- public Filter setParameterList(String name, Collection values);
-
- /**
- * Set the named parameter's value list for this filter. Used
- * in conjunction with IN-style filter criteria.
- *
- * @param name The parameter's name.
- * @param values The values to be expanded into an SQL IN list.
- * @return This FilterImpl instance (for method chaining).
- */
- public Filter setParameterList(String name, Object[] values);
-
- /**
- * Perform validation of the filter state. This is used to verify the
- * state of the filter after its enablement and before its use.
- *
- * @throws HibernateException If the state is not currently valid.
- */
- public void validate() throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Filter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Filter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,91 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.hibernate.engine.FilterDefinition;
+
+import java.util.Collection;
+
+/**
+ * Type definition of Filter. Filter defines the user's view into enabled dynamic filters,
+ * allowing them to set filter parameter values.
+ *
+ * @author Steve Ebersole
+ */
+public interface Filter {
+
+ /**
+ * Get the name of this filter.
+ *
+ * @return This filter's name.
+ */
+ public String getName();
+
+ /**
+ * Get the filter definition containing additional information about the
+ * filter (such as default-condition and expected parameter names/types).
+ *
+ * @return The filter definition
+ */
+ public FilterDefinition getFilterDefinition();
+
+
+ /**
+ * Set the named parameter's value for this filter.
+ *
+ * @param name The parameter's name.
+ * @param value The value to be applied.
+ * @return This FilterImpl instance (for method chaining).
+ */
+ public Filter setParameter(String name, Object value);
+
+ /**
+ * Set the named parameter's value list for this filter. Used
+ * in conjunction with IN-style filter criteria.
+ *
+ * @param name The parameter's name.
+ * @param values The values to be expanded into an SQL IN list.
+ * @return This FilterImpl instance (for method chaining).
+ */
+ public Filter setParameterList(String name, Collection values);
+
+ /**
+ * Set the named parameter's value list for this filter. Used
+ * in conjunction with IN-style filter criteria.
+ *
+ * @param name The parameter's name.
+ * @param values The values to be expanded into an SQL IN list.
+ * @return This FilterImpl instance (for method chaining).
+ */
+ public Filter setParameterList(String name, Object[] values);
+
+ /**
+ * Perform validation of the filter state. This is used to verify the
+ * state of the filter after its enablement and before its use.
+ *
+ * @throws HibernateException If the state is not currently valid.
+ */
+ public void validate() throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/FlushMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,92 +0,0 @@
-//$Id: FlushMode.java 10469 2006-09-08 12:23:18Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents a flushing strategy. The flush process synchronizes
- * database state with session state by detecting state changes
- * and executing SQL statements.
- *
- * @see Session#setFlushMode(FlushMode)
- * @see Query#setFlushMode(FlushMode)
- * @see Criteria#setFlushMode(FlushMode)
- *
- * @author Gavin King
- */
-public final class FlushMode implements Serializable {
- private static final Map INSTANCES = new HashMap();
-
- private final int level;
- private final String name;
-
- private FlushMode(int level, String name) {
- this.level = level;
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- /**
- * The {@link Session} is never flushed unless {@link Session#flush}
- * is explicitly called by the application. This mode is very
- * efficient for read only transactions.
- *
- * @deprecated use {@link #MANUAL} instead.
- */
- public static final FlushMode NEVER = new FlushMode( 0, "NEVER" );
-
- /**
- * The {@link Session} is only ever flushed when {@link Session#flush}
- * is explicitly called by the application. This mode is very
- * efficient for read only transactions.
- */
- public static final FlushMode MANUAL = new FlushMode( 0, "MANUAL" );
-
- /**
- * The {@link Session} is flushed when {@link Transaction#commit}
- * is called.
- */
- public static final FlushMode COMMIT = new FlushMode(5, "COMMIT");
-
- /**
- * The {@link Session} is sometimes flushed before query execution
- * in order to ensure that queries never return stale state. This
- * is the default flush mode.
- */
- public static final FlushMode AUTO = new FlushMode(10, "AUTO");
-
- /**
- * The {@link Session} is flushed before every query. This is
- * almost always unnecessary and inefficient.
- */
- public static final FlushMode ALWAYS = new FlushMode(20, "ALWAYS");
-
- public boolean lessThan(FlushMode other) {
- return this.level<other.level;
- }
-
- static {
- INSTANCES.put( NEVER.name, NEVER );
- INSTANCES.put( MANUAL.name, MANUAL );
- INSTANCES.put( AUTO.name, AUTO );
- INSTANCES.put( ALWAYS.name, ALWAYS );
- INSTANCES.put( COMMIT.name, COMMIT );
- }
-
- public static boolean isManualFlushMode(FlushMode mode) {
- return MANUAL.level == mode.level;
- }
-
- private Object readResolve() {
- return INSTANCES.get( name );
- }
-
- public static FlushMode parse(String name) {
- return ( FlushMode ) INSTANCES.get( name );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/FlushMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/FlushMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,115 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents a flushing strategy. The flush process synchronizes
+ * database state with session state by detecting state changes
+ * and executing SQL statements.
+ *
+ * @see Session#setFlushMode(FlushMode)
+ * @see Query#setFlushMode(FlushMode)
+ * @see Criteria#setFlushMode(FlushMode)
+ *
+ * @author Gavin King
+ */
+public final class FlushMode implements Serializable {
+ private static final Map INSTANCES = new HashMap();
+
+ private final int level;
+ private final String name;
+
+ private FlushMode(int level, String name) {
+ this.level = level;
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * The {@link Session} is never flushed unless {@link Session#flush}
+ * is explicitly called by the application. This mode is very
+ * efficient for read only transactions.
+ *
+ * @deprecated use {@link #MANUAL} instead.
+ */
+ public static final FlushMode NEVER = new FlushMode( 0, "NEVER" );
+
+ /**
+ * The {@link Session} is only ever flushed when {@link Session#flush}
+ * is explicitly called by the application. This mode is very
+ * efficient for read only transactions.
+ */
+ public static final FlushMode MANUAL = new FlushMode( 0, "MANUAL" );
+
+ /**
+ * The {@link Session} is flushed when {@link Transaction#commit}
+ * is called.
+ */
+ public static final FlushMode COMMIT = new FlushMode(5, "COMMIT");
+
+ /**
+ * The {@link Session} is sometimes flushed before query execution
+ * in order to ensure that queries never return stale state. This
+ * is the default flush mode.
+ */
+ public static final FlushMode AUTO = new FlushMode(10, "AUTO");
+
+ /**
+ * The {@link Session} is flushed before every query. This is
+ * almost always unnecessary and inefficient.
+ */
+ public static final FlushMode ALWAYS = new FlushMode(20, "ALWAYS");
+
+ public boolean lessThan(FlushMode other) {
+ return this.level<other.level;
+ }
+
+ static {
+ INSTANCES.put( NEVER.name, NEVER );
+ INSTANCES.put( MANUAL.name, MANUAL );
+ INSTANCES.put( AUTO.name, AUTO );
+ INSTANCES.put( ALWAYS.name, ALWAYS );
+ INSTANCES.put( COMMIT.name, COMMIT );
+ }
+
+ public static boolean isManualFlushMode(FlushMode mode) {
+ return MANUAL.level == mode.level;
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get( name );
+ }
+
+ public static FlushMode parse(String name) {
+ return ( FlushMode ) INSTANCES.get( name );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Hibernate.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,454 +0,0 @@
-//$Id: Hibernate.java 10009 2006-06-10 03:24:05Z epbernard $
-package org.hibernate;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Serializable;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.HibernateIterator;
-import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.intercept.FieldInterceptor;
-import org.hibernate.lob.BlobImpl;
-import org.hibernate.lob.ClobImpl;
-import org.hibernate.lob.SerializableBlob;
-import org.hibernate.lob.SerializableClob;
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.proxy.LazyInitializer;
-import org.hibernate.type.AnyType;
-import org.hibernate.type.BigDecimalType;
-import org.hibernate.type.BigIntegerType;
-import org.hibernate.type.BinaryType;
-import org.hibernate.type.BlobType;
-import org.hibernate.type.BooleanType;
-import org.hibernate.type.ByteType;
-import org.hibernate.type.CalendarDateType;
-import org.hibernate.type.CalendarType;
-import org.hibernate.type.CharacterType;
-import org.hibernate.type.ClassType;
-import org.hibernate.type.ClobType;
-import org.hibernate.type.CompositeCustomType;
-import org.hibernate.type.CurrencyType;
-import org.hibernate.type.CustomType;
-import org.hibernate.type.DateType;
-import org.hibernate.type.DoubleType;
-import org.hibernate.type.FloatType;
-import org.hibernate.type.IntegerType;
-import org.hibernate.type.LocaleType;
-import org.hibernate.type.LongType;
-import org.hibernate.type.ManyToOneType;
-import org.hibernate.type.NullableType;
-import org.hibernate.type.SerializableType;
-import org.hibernate.type.ShortType;
-import org.hibernate.type.StringType;
-import org.hibernate.type.TextType;
-import org.hibernate.type.TimeType;
-import org.hibernate.type.TimeZoneType;
-import org.hibernate.type.TimestampType;
-import org.hibernate.type.TrueFalseType;
-import org.hibernate.type.Type;
-import org.hibernate.type.YesNoType;
-import org.hibernate.type.CharArrayType;
-import org.hibernate.type.WrapperBinaryType;
-import org.hibernate.type.CharacterArrayType;
-import org.hibernate.usertype.CompositeUserType;
-
-/**
- * <ul>
- * <li>Provides access to the full range of Hibernate built-in types. <tt>Type</tt>
- * instances may be used to bind values to query parameters.
- * <li>A factory for new <tt>Blob</tt>s and <tt>Clob</tt>s.
- * <li>Defines static methods for manipulation of proxies.
- * </ul>
- *
- * @author Gavin King
- * @see java.sql.Clob
- * @see java.sql.Blob
- * @see org.hibernate.type.Type
- */
-
-public final class Hibernate {
-
- /**
- * Hibernate <tt>long</tt> type.
- */
- public static final NullableType LONG = new LongType();
- /**
- * Hibernate <tt>short</tt> type.
- */
- public static final NullableType SHORT = new ShortType();
- /**
- * Hibernate <tt>integer</tt> type.
- */
- public static final NullableType INTEGER = new IntegerType();
- /**
- * Hibernate <tt>byte</tt> type.
- */
- public static final NullableType BYTE = new ByteType();
- /**
- * Hibernate <tt>float</tt> type.
- */
- public static final NullableType FLOAT = new FloatType();
- /**
- * Hibernate <tt>double</tt> type.
- */
- public static final NullableType DOUBLE = new DoubleType();
- /**
- * Hibernate <tt>character</tt> type.
- */
- public static final NullableType CHARACTER = new CharacterType();
- /**
- * Hibernate <tt>string</tt> type.
- */
- public static final NullableType STRING = new StringType();
- /**
- * Hibernate <tt>time</tt> type.
- */
- public static final NullableType TIME = new TimeType();
- /**
- * Hibernate <tt>date</tt> type.
- */
- public static final NullableType DATE = new DateType();
- /**
- * Hibernate <tt>timestamp</tt> type.
- */
- public static final NullableType TIMESTAMP = new TimestampType();
- /**
- * Hibernate <tt>boolean</tt> type.
- */
- public static final NullableType BOOLEAN = new BooleanType();
- /**
- * Hibernate <tt>true_false</tt> type.
- */
- public static final NullableType TRUE_FALSE = new TrueFalseType();
- /**
- * Hibernate <tt>yes_no</tt> type.
- */
- public static final NullableType YES_NO = new YesNoType();
- /**
- * Hibernate <tt>big_decimal</tt> type.
- */
- public static final NullableType BIG_DECIMAL = new BigDecimalType();
- /**
- * Hibernate <tt>big_integer</tt> type.
- */
- public static final NullableType BIG_INTEGER = new BigIntegerType();
- /**
- * Hibernate <tt>binary</tt> type.
- */
- public static final NullableType BINARY = new BinaryType();
- /**
- * Hibernate <tt>wrapper-binary</tt> type.
- */
- public static final NullableType WRAPPER_BINARY = new WrapperBinaryType();
- /**
- * Hibernate char[] type.
- */
- public static final NullableType CHAR_ARRAY = new CharArrayType();
- /**
- * Hibernate Character[] type.
- */
- public static final NullableType CHARACTER_ARRAY = new CharacterArrayType();
- /**
- * Hibernate <tt>text</tt> type.
- */
- public static final NullableType TEXT = new TextType();
- /**
- * Hibernate <tt>blob</tt> type.
- */
- public static final Type BLOB = new BlobType();
- /**
- * Hibernate <tt>clob</tt> type.
- */
- public static final Type CLOB = new ClobType();
- /**
- * Hibernate <tt>calendar</tt> type.
- */
- public static final NullableType CALENDAR = new CalendarType();
- /**
- * Hibernate <tt>calendar_date</tt> type.
- */
- public static final NullableType CALENDAR_DATE = new CalendarDateType();
- /**
- * Hibernate <tt>locale</tt> type.
- */
- public static final NullableType LOCALE = new LocaleType();
- /**
- * Hibernate <tt>currency</tt> type.
- */
- public static final NullableType CURRENCY = new CurrencyType();
- /**
- * Hibernate <tt>timezone</tt> type.
- */
- public static final NullableType TIMEZONE = new TimeZoneType();
- /**
- * Hibernate <tt>class</tt> type.
- */
- public static final NullableType CLASS = new ClassType();
- /**
- * Hibernate <tt>serializable</tt> type.
- */
- public static final NullableType SERIALIZABLE = new SerializableType( Serializable.class );
- /**
- * Hibernate <tt>object</tt> type.
- */
- public static final Type OBJECT = new AnyType();
-
-
- /**
- * Cannot be instantiated.
- */
- private Hibernate() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * A Hibernate <tt>serializable</tt> type.
- */
- public static Type serializable(Class serializableClass) {
- return new SerializableType( serializableClass );
- }
-
- /**
- * A Hibernate <tt>any</tt> type.
- *
- * @param metaType a type mapping <tt>java.lang.Class</tt> to a single column
- * @param identifierType the entity identifier type
- * @return the Type
- */
- public static Type any(Type metaType, Type identifierType) {
- return new AnyType( metaType, identifierType );
- }
-
- /**
- * A Hibernate persistent object (entity) type.
- *
- * @param persistentClass a mapped entity class
- */
- public static Type entity(Class persistentClass) {
- // not really a many-to-one association *necessarily*
- return new ManyToOneType( persistentClass.getName() );
- }
-
- /**
- * A Hibernate persistent object (entity) type.
- *
- * @param entityName a mapped entity class
- */
- public static Type entity(String entityName) {
- // not really a many-to-one association *necessarily*
- return new ManyToOneType( entityName );
- }
-
- /**
- * A Hibernate custom type.
- *
- * @param userTypeClass a class that implements <tt>UserType</tt>
- */
- public static Type custom(Class userTypeClass) throws HibernateException {
- return custom( userTypeClass, null );
- }
-
- /**
- * A Hibernate parameterizable custom type.
- *
- * @param userTypeClass a class that implements <tt>UserType and ParameterizableType</tt>
- * @param parameterNames the names of the parameters passed to the type
- * @param parameterValues the values of the parameters passed to the type. They must match
- * up with the order and length of the parameterNames array.
- */
- public static Type custom(Class userTypeClass, String[] parameterNames, String[] parameterValues)
- throws HibernateException {
- Properties parameters = new Properties();
- for ( int i = 0; i < parameterNames.length; i++ ) {
- parameters.setProperty( parameterNames[i], parameterValues[i] );
- }
- return custom( userTypeClass, parameters );
- }
-
- /**
- * A Hibernate parameterizable custom type.
- *
- * @param userTypeClass a class that implements <tt>UserType and ParameterizableType</tt>
- * @param parameters the parameters as a collection of name/value pairs
- */
- public static Type custom(Class userTypeClass, Properties parameters)
- throws HibernateException {
- if ( CompositeUserType.class.isAssignableFrom( userTypeClass ) ) {
- CompositeCustomType type = new CompositeCustomType( userTypeClass, parameters );
- return type;
- }
- else {
- CustomType type = new CustomType( userTypeClass, parameters );
- return type;
- }
- }
-
- /**
- * Force initialization of a proxy or persistent collection.
- * <p/>
- * Note: This only ensures intialization of a proxy object or collection;
- * it is not guaranteed that the elements INSIDE the collection will be initialized/materialized.
- *
- * @param proxy a persistable object, proxy, persistent collection or <tt>null</tt>
- * @throws HibernateException if we can't initialize the proxy at this time, eg. the <tt>Session</tt> was closed
- */
- public static void initialize(Object proxy) throws HibernateException {
- if ( proxy == null ) {
- return;
- }
- else if ( proxy instanceof HibernateProxy ) {
- ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().initialize();
- }
- else if ( proxy instanceof PersistentCollection ) {
- ( ( PersistentCollection ) proxy ).forceInitialization();
- }
- }
-
- /**
- * Check if the proxy or persistent collection is initialized.
- *
- * @param proxy a persistable object, proxy, persistent collection or <tt>null</tt>
- * @return true if the argument is already initialized, or is not a proxy or collection
- */
- public static boolean isInitialized(Object proxy) {
- if ( proxy instanceof HibernateProxy ) {
- return !( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().isUninitialized();
- }
- else if ( proxy instanceof PersistentCollection ) {
- return ( ( PersistentCollection ) proxy ).wasInitialized();
- }
- else {
- return true;
- }
- }
-
- /**
- * Get the true, underlying class of a proxied persistent class. This operation
- * will initialize a proxy by side-effect.
- *
- * @param proxy a persistable object or proxy
- * @return the true class of the instance
- * @throws HibernateException
- */
- public static Class getClass(Object proxy) {
- if ( proxy instanceof HibernateProxy ) {
- return ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer()
- .getImplementation()
- .getClass();
- }
- else {
- return proxy.getClass();
- }
- }
-
- /**
- * Create a new <tt>Blob</tt>. The returned object will be initially immutable.
- *
- * @param bytes a byte array
- * @return the Blob
- */
- public static Blob createBlob(byte[] bytes) {
- return new SerializableBlob( new BlobImpl( bytes ) );
- }
-
- /**
- * Create a new <tt>Blob</tt>. The returned object will be initially immutable.
- *
- * @param stream a binary stream
- * @param length the number of bytes in the stream
- * @return the Blob
- */
- public static Blob createBlob(InputStream stream, int length) {
- return new SerializableBlob( new BlobImpl( stream, length ) );
- }
-
- /**
- * Create a new <tt>Blob</tt>. The returned object will be initially immutable.
- *
- * @param stream a binary stream
- * @return the Blob
- * @throws IOException
- */
- public static Blob createBlob(InputStream stream) throws IOException {
- return new SerializableBlob( new BlobImpl( stream, stream.available() ) );
- }
-
- /**
- * Create a new <tt>Clob</tt>. The returned object will be initially immutable.
- *
- * @param string a <tt>String</tt>
- */
- public static Clob createClob(String string) {
- return new SerializableClob( new ClobImpl( string ) );
- }
-
- /**
- * Create a new <tt>Clob</tt>. The returned object will be initially immutable.
- *
- * @param reader a character stream
- * @param length the number of characters in the stream
- */
- public static Clob createClob(Reader reader, int length) {
- return new SerializableClob( new ClobImpl( reader, length ) );
- }
-
- /**
- * Close an <tt>Iterator</tt> created by <tt>iterate()</tt> immediately,
- * instead of waiting until the session is closed or disconnected.
- *
- * @param iterator an <tt>Iterator</tt> created by <tt>iterate()</tt>
- * @throws HibernateException
- * @see org.hibernate.Query#iterate
- * @see Query#iterate()
- */
- public static void close(Iterator iterator) throws HibernateException {
- if ( iterator instanceof HibernateIterator ) {
- ( ( HibernateIterator ) iterator ).close();
- }
- else {
- throw new IllegalArgumentException( "not a Hibernate iterator" );
- }
- }
-
- /**
- * Check if the property is initialized. If the named property does not exist
- * or is not persistent, this method always returns <tt>true</tt>.
- *
- * @param proxy The potential proxy
- * @param propertyName the name of a persistent attribute of the object
- * @return true if the named property of the object is not listed as uninitialized
- * @return false if the object is an uninitialized proxy, or the named property is uninitialized
- */
- public static boolean isPropertyInitialized(Object proxy, String propertyName) {
-
- Object entity;
- if ( proxy instanceof HibernateProxy ) {
- LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
- if ( li.isUninitialized() ) {
- return false;
- }
- else {
- entity = li.getImplementation();
- }
- }
- else {
- entity = proxy;
- }
-
- if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
- FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
- return interceptor == null || interceptor.isInitialized( propertyName );
- }
- else {
- return true;
- }
-
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Hibernate.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Hibernate.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,477 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Serializable;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.HibernateIterator;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.intercept.FieldInterceptor;
+import org.hibernate.lob.BlobImpl;
+import org.hibernate.lob.ClobImpl;
+import org.hibernate.lob.SerializableBlob;
+import org.hibernate.lob.SerializableClob;
+import org.hibernate.proxy.HibernateProxy;
+import org.hibernate.proxy.LazyInitializer;
+import org.hibernate.type.AnyType;
+import org.hibernate.type.BigDecimalType;
+import org.hibernate.type.BigIntegerType;
+import org.hibernate.type.BinaryType;
+import org.hibernate.type.BlobType;
+import org.hibernate.type.BooleanType;
+import org.hibernate.type.ByteType;
+import org.hibernate.type.CalendarDateType;
+import org.hibernate.type.CalendarType;
+import org.hibernate.type.CharacterType;
+import org.hibernate.type.ClassType;
+import org.hibernate.type.ClobType;
+import org.hibernate.type.CompositeCustomType;
+import org.hibernate.type.CurrencyType;
+import org.hibernate.type.CustomType;
+import org.hibernate.type.DateType;
+import org.hibernate.type.DoubleType;
+import org.hibernate.type.FloatType;
+import org.hibernate.type.IntegerType;
+import org.hibernate.type.LocaleType;
+import org.hibernate.type.LongType;
+import org.hibernate.type.ManyToOneType;
+import org.hibernate.type.NullableType;
+import org.hibernate.type.SerializableType;
+import org.hibernate.type.ShortType;
+import org.hibernate.type.StringType;
+import org.hibernate.type.TextType;
+import org.hibernate.type.TimeType;
+import org.hibernate.type.TimeZoneType;
+import org.hibernate.type.TimestampType;
+import org.hibernate.type.TrueFalseType;
+import org.hibernate.type.Type;
+import org.hibernate.type.YesNoType;
+import org.hibernate.type.CharArrayType;
+import org.hibernate.type.WrapperBinaryType;
+import org.hibernate.type.CharacterArrayType;
+import org.hibernate.usertype.CompositeUserType;
+
+/**
+ * <ul>
+ * <li>Provides access to the full range of Hibernate built-in types. <tt>Type</tt>
+ * instances may be used to bind values to query parameters.
+ * <li>A factory for new <tt>Blob</tt>s and <tt>Clob</tt>s.
+ * <li>Defines static methods for manipulation of proxies.
+ * </ul>
+ *
+ * @author Gavin King
+ * @see java.sql.Clob
+ * @see java.sql.Blob
+ * @see org.hibernate.type.Type
+ */
+
+public final class Hibernate {
+
+ /**
+ * Hibernate <tt>long</tt> type.
+ */
+ public static final NullableType LONG = new LongType();
+ /**
+ * Hibernate <tt>short</tt> type.
+ */
+ public static final NullableType SHORT = new ShortType();
+ /**
+ * Hibernate <tt>integer</tt> type.
+ */
+ public static final NullableType INTEGER = new IntegerType();
+ /**
+ * Hibernate <tt>byte</tt> type.
+ */
+ public static final NullableType BYTE = new ByteType();
+ /**
+ * Hibernate <tt>float</tt> type.
+ */
+ public static final NullableType FLOAT = new FloatType();
+ /**
+ * Hibernate <tt>double</tt> type.
+ */
+ public static final NullableType DOUBLE = new DoubleType();
+ /**
+ * Hibernate <tt>character</tt> type.
+ */
+ public static final NullableType CHARACTER = new CharacterType();
+ /**
+ * Hibernate <tt>string</tt> type.
+ */
+ public static final NullableType STRING = new StringType();
+ /**
+ * Hibernate <tt>time</tt> type.
+ */
+ public static final NullableType TIME = new TimeType();
+ /**
+ * Hibernate <tt>date</tt> type.
+ */
+ public static final NullableType DATE = new DateType();
+ /**
+ * Hibernate <tt>timestamp</tt> type.
+ */
+ public static final NullableType TIMESTAMP = new TimestampType();
+ /**
+ * Hibernate <tt>boolean</tt> type.
+ */
+ public static final NullableType BOOLEAN = new BooleanType();
+ /**
+ * Hibernate <tt>true_false</tt> type.
+ */
+ public static final NullableType TRUE_FALSE = new TrueFalseType();
+ /**
+ * Hibernate <tt>yes_no</tt> type.
+ */
+ public static final NullableType YES_NO = new YesNoType();
+ /**
+ * Hibernate <tt>big_decimal</tt> type.
+ */
+ public static final NullableType BIG_DECIMAL = new BigDecimalType();
+ /**
+ * Hibernate <tt>big_integer</tt> type.
+ */
+ public static final NullableType BIG_INTEGER = new BigIntegerType();
+ /**
+ * Hibernate <tt>binary</tt> type.
+ */
+ public static final NullableType BINARY = new BinaryType();
+ /**
+ * Hibernate <tt>wrapper-binary</tt> type.
+ */
+ public static final NullableType WRAPPER_BINARY = new WrapperBinaryType();
+ /**
+ * Hibernate char[] type.
+ */
+ public static final NullableType CHAR_ARRAY = new CharArrayType();
+ /**
+ * Hibernate Character[] type.
+ */
+ public static final NullableType CHARACTER_ARRAY = new CharacterArrayType();
+ /**
+ * Hibernate <tt>text</tt> type.
+ */
+ public static final NullableType TEXT = new TextType();
+ /**
+ * Hibernate <tt>blob</tt> type.
+ */
+ public static final Type BLOB = new BlobType();
+ /**
+ * Hibernate <tt>clob</tt> type.
+ */
+ public static final Type CLOB = new ClobType();
+ /**
+ * Hibernate <tt>calendar</tt> type.
+ */
+ public static final NullableType CALENDAR = new CalendarType();
+ /**
+ * Hibernate <tt>calendar_date</tt> type.
+ */
+ public static final NullableType CALENDAR_DATE = new CalendarDateType();
+ /**
+ * Hibernate <tt>locale</tt> type.
+ */
+ public static final NullableType LOCALE = new LocaleType();
+ /**
+ * Hibernate <tt>currency</tt> type.
+ */
+ public static final NullableType CURRENCY = new CurrencyType();
+ /**
+ * Hibernate <tt>timezone</tt> type.
+ */
+ public static final NullableType TIMEZONE = new TimeZoneType();
+ /**
+ * Hibernate <tt>class</tt> type.
+ */
+ public static final NullableType CLASS = new ClassType();
+ /**
+ * Hibernate <tt>serializable</tt> type.
+ */
+ public static final NullableType SERIALIZABLE = new SerializableType( Serializable.class );
+ /**
+ * Hibernate <tt>object</tt> type.
+ */
+ public static final Type OBJECT = new AnyType();
+
+
+ /**
+ * Cannot be instantiated.
+ */
+ private Hibernate() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * A Hibernate <tt>serializable</tt> type.
+ */
+ public static Type serializable(Class serializableClass) {
+ return new SerializableType( serializableClass );
+ }
+
+ /**
+ * A Hibernate <tt>any</tt> type.
+ *
+ * @param metaType a type mapping <tt>java.lang.Class</tt> to a single column
+ * @param identifierType the entity identifier type
+ * @return the Type
+ */
+ public static Type any(Type metaType, Type identifierType) {
+ return new AnyType( metaType, identifierType );
+ }
+
+ /**
+ * A Hibernate persistent object (entity) type.
+ *
+ * @param persistentClass a mapped entity class
+ */
+ public static Type entity(Class persistentClass) {
+ // not really a many-to-one association *necessarily*
+ return new ManyToOneType( persistentClass.getName() );
+ }
+
+ /**
+ * A Hibernate persistent object (entity) type.
+ *
+ * @param entityName a mapped entity class
+ */
+ public static Type entity(String entityName) {
+ // not really a many-to-one association *necessarily*
+ return new ManyToOneType( entityName );
+ }
+
+ /**
+ * A Hibernate custom type.
+ *
+ * @param userTypeClass a class that implements <tt>UserType</tt>
+ */
+ public static Type custom(Class userTypeClass) throws HibernateException {
+ return custom( userTypeClass, null );
+ }
+
+ /**
+ * A Hibernate parameterizable custom type.
+ *
+ * @param userTypeClass a class that implements <tt>UserType and ParameterizableType</tt>
+ * @param parameterNames the names of the parameters passed to the type
+ * @param parameterValues the values of the parameters passed to the type. They must match
+ * up with the order and length of the parameterNames array.
+ */
+ public static Type custom(Class userTypeClass, String[] parameterNames, String[] parameterValues)
+ throws HibernateException {
+ Properties parameters = new Properties();
+ for ( int i = 0; i < parameterNames.length; i++ ) {
+ parameters.setProperty( parameterNames[i], parameterValues[i] );
+ }
+ return custom( userTypeClass, parameters );
+ }
+
+ /**
+ * A Hibernate parameterizable custom type.
+ *
+ * @param userTypeClass a class that implements <tt>UserType and ParameterizableType</tt>
+ * @param parameters the parameters as a collection of name/value pairs
+ */
+ public static Type custom(Class userTypeClass, Properties parameters)
+ throws HibernateException {
+ if ( CompositeUserType.class.isAssignableFrom( userTypeClass ) ) {
+ CompositeCustomType type = new CompositeCustomType( userTypeClass, parameters );
+ return type;
+ }
+ else {
+ CustomType type = new CustomType( userTypeClass, parameters );
+ return type;
+ }
+ }
+
+ /**
+ * Force initialization of a proxy or persistent collection.
+ * <p/>
+ * Note: This only ensures intialization of a proxy object or collection;
+ * it is not guaranteed that the elements INSIDE the collection will be initialized/materialized.
+ *
+ * @param proxy a persistable object, proxy, persistent collection or <tt>null</tt>
+ * @throws HibernateException if we can't initialize the proxy at this time, eg. the <tt>Session</tt> was closed
+ */
+ public static void initialize(Object proxy) throws HibernateException {
+ if ( proxy == null ) {
+ return;
+ }
+ else if ( proxy instanceof HibernateProxy ) {
+ ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().initialize();
+ }
+ else if ( proxy instanceof PersistentCollection ) {
+ ( ( PersistentCollection ) proxy ).forceInitialization();
+ }
+ }
+
+ /**
+ * Check if the proxy or persistent collection is initialized.
+ *
+ * @param proxy a persistable object, proxy, persistent collection or <tt>null</tt>
+ * @return true if the argument is already initialized, or is not a proxy or collection
+ */
+ public static boolean isInitialized(Object proxy) {
+ if ( proxy instanceof HibernateProxy ) {
+ return !( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().isUninitialized();
+ }
+ else if ( proxy instanceof PersistentCollection ) {
+ return ( ( PersistentCollection ) proxy ).wasInitialized();
+ }
+ else {
+ return true;
+ }
+ }
+
+ /**
+ * Get the true, underlying class of a proxied persistent class. This operation
+ * will initialize a proxy by side-effect.
+ *
+ * @param proxy a persistable object or proxy
+ * @return the true class of the instance
+ * @throws HibernateException
+ */
+ public static Class getClass(Object proxy) {
+ if ( proxy instanceof HibernateProxy ) {
+ return ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer()
+ .getImplementation()
+ .getClass();
+ }
+ else {
+ return proxy.getClass();
+ }
+ }
+
+ /**
+ * Create a new <tt>Blob</tt>. The returned object will be initially immutable.
+ *
+ * @param bytes a byte array
+ * @return the Blob
+ */
+ public static Blob createBlob(byte[] bytes) {
+ return new SerializableBlob( new BlobImpl( bytes ) );
+ }
+
+ /**
+ * Create a new <tt>Blob</tt>. The returned object will be initially immutable.
+ *
+ * @param stream a binary stream
+ * @param length the number of bytes in the stream
+ * @return the Blob
+ */
+ public static Blob createBlob(InputStream stream, int length) {
+ return new SerializableBlob( new BlobImpl( stream, length ) );
+ }
+
+ /**
+ * Create a new <tt>Blob</tt>. The returned object will be initially immutable.
+ *
+ * @param stream a binary stream
+ * @return the Blob
+ * @throws IOException
+ */
+ public static Blob createBlob(InputStream stream) throws IOException {
+ return new SerializableBlob( new BlobImpl( stream, stream.available() ) );
+ }
+
+ /**
+ * Create a new <tt>Clob</tt>. The returned object will be initially immutable.
+ *
+ * @param string a <tt>String</tt>
+ */
+ public static Clob createClob(String string) {
+ return new SerializableClob( new ClobImpl( string ) );
+ }
+
+ /**
+ * Create a new <tt>Clob</tt>. The returned object will be initially immutable.
+ *
+ * @param reader a character stream
+ * @param length the number of characters in the stream
+ */
+ public static Clob createClob(Reader reader, int length) {
+ return new SerializableClob( new ClobImpl( reader, length ) );
+ }
+
+ /**
+ * Close an <tt>Iterator</tt> created by <tt>iterate()</tt> immediately,
+ * instead of waiting until the session is closed or disconnected.
+ *
+ * @param iterator an <tt>Iterator</tt> created by <tt>iterate()</tt>
+ * @throws HibernateException
+ * @see org.hibernate.Query#iterate
+ * @see Query#iterate()
+ */
+ public static void close(Iterator iterator) throws HibernateException {
+ if ( iterator instanceof HibernateIterator ) {
+ ( ( HibernateIterator ) iterator ).close();
+ }
+ else {
+ throw new IllegalArgumentException( "not a Hibernate iterator" );
+ }
+ }
+
+ /**
+ * Check if the property is initialized. If the named property does not exist
+ * or is not persistent, this method always returns <tt>true</tt>.
+ *
+ * @param proxy The potential proxy
+ * @param propertyName the name of a persistent attribute of the object
+ * @return true if the named property of the object is not listed as uninitialized
+ * @return false if the object is an uninitialized proxy, or the named property is uninitialized
+ */
+ public static boolean isPropertyInitialized(Object proxy, String propertyName) {
+
+ Object entity;
+ if ( proxy instanceof HibernateProxy ) {
+ LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
+ if ( li.isUninitialized() ) {
+ return false;
+ }
+ else {
+ entity = li.getImplementation();
+ }
+ }
+ else {
+ entity = proxy;
+ }
+
+ if ( FieldInterceptionHelper.isInstrumented( entity ) ) {
+ FieldInterceptor interceptor = FieldInterceptionHelper.extractFieldInterceptor( entity );
+ return interceptor == null || interceptor.isInitialized( propertyName );
+ }
+ else {
+ return true;
+ }
+
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/HibernateException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,34 +0,0 @@
-//$Id: HibernateException.java 5683 2005-02-12 03:09:22Z oneovthafew $
-package org.hibernate;
-
-import org.hibernate.exception.NestableRuntimeException;
-
-/**
- * Any exception that occurs inside the persistence layer
- * or JDBC driver. <tt>SQLException</tt>s are always wrapped
- * by instances of <tt>JDBCException</tt>.
- *
- * @see JDBCException
- * @author Gavin King
- */
-
-public class HibernateException extends NestableRuntimeException {
-
- public HibernateException(Throwable root) {
- super(root);
- }
-
- public HibernateException(String string, Throwable root) {
- super(string, root);
- }
-
- public HibernateException(String s) {
- super(s);
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/HibernateException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/HibernateException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.hibernate.exception.NestableRuntimeException;
+
+/**
+ * Any exception that occurs inside the persistence layer
+ * or JDBC driver. <tt>SQLException</tt>s are always wrapped
+ * by instances of <tt>JDBCException</tt>.
+ *
+ * @see JDBCException
+ * @author Gavin King
+ */
+
+public class HibernateException extends NestableRuntimeException {
+
+ public HibernateException(Throwable root) {
+ super(root);
+ }
+
+ public HibernateException(String string, Throwable root) {
+ super(string, root);
+ }
+
+ public HibernateException(String s) {
+ super(s);
+ }
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/InstantiationException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,44 +0,0 @@
-//$Id: InstantiationException.java 6781 2005-05-14 17:27:57Z oneovthafew $
-package org.hibernate;
-
-/**
- * Thrown if Hibernate can't instantiate an entity or component
- * class at runtime.
- *
- * @author Gavin King
- */
-
-public class InstantiationException extends HibernateException {
-
- private final Class clazz;
-
- public InstantiationException(String s, Class clazz, Throwable root) {
- super(s, root);
- this.clazz = clazz;
- }
-
- public InstantiationException(String s, Class clazz) {
- super(s);
- this.clazz = clazz;
- }
-
- public InstantiationException(String s, Class clazz, Exception e) {
- super(s, e);
- this.clazz = clazz;
- }
-
- public Class getPersistentClass() {
- return clazz;
- }
-
- public String getMessage() {
- return super.getMessage() + clazz.getName();
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/InstantiationException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InstantiationException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown if Hibernate can't instantiate an entity or component
+ * class at runtime.
+ *
+ * @author Gavin King
+ */
+
+public class InstantiationException extends HibernateException {
+
+ private final Class clazz;
+
+ public InstantiationException(String s, Class clazz, Throwable root) {
+ super(s, root);
+ this.clazz = clazz;
+ }
+
+ public InstantiationException(String s, Class clazz) {
+ super(s);
+ this.clazz = clazz;
+ }
+
+ public InstantiationException(String s, Class clazz, Exception e) {
+ super(s, e);
+ this.clazz = clazz;
+ }
+
+ public Class getPersistentClass() {
+ return clazz;
+ }
+
+ public String getMessage() {
+ return super.getMessage() + clazz.getName();
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Interceptor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,155 +0,0 @@
-//$Id: Interceptor.java 7883 2005-08-12 20:03:07Z oneovthafew $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-import org.hibernate.type.Type;
-
-/**
- * Allows user code to inspect and/or change property values.
- * <br><br>
- * Inspection occurs before property values are written and after they are read
- * from the database.<br>
- * <br>
- * There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance
- * might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be
- * serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped
- * interceptors should implement <tt>readResolve()</tt>.<br>
- * <br>
- * The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to
- * be lazily initialized).<br>
- * <br>
- * Instead of implementing this interface directly, it is usually better to extend <tt>EmptyInterceptor</tt>
- * and override only the callback methods of interest.
- *
- * @see SessionFactory#openSession(Interceptor)
- * @see org.hibernate.cfg.Configuration#setInterceptor(Interceptor)
- * @see EmptyInterceptor
- * @author Gavin King
- */
-public interface Interceptor {
- /**
- * Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will
- * be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be
- * an empty uninitialized instance of the class.
- *
- * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way.
- */
- public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
- /**
- * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected
- * <tt>currentState</tt>, which will be propagated to both the database and the persistent object.
- * Note that not all flushes end in actual synchronization with the database, in which case the
- * new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to
- * the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>.
- *
- * @return <tt>true</tt> if the user modified the <tt>currentState</tt> in any way.
- */
- public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException;
- /**
- * Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for
- * the SQL <tt>INSERT</tt> and propagated to the persistent object.
- *
- * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way.
- */
- public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
- /**
- * Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>.
- */
- public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
- /**
- * Called before a collection is (re)created.
- */
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException;
- /**
- * Called before a collection is deleted.
- */
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException;
- /**
- * Called before a collection is updated.
- */
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
- /**
- * Called before a flush
- */
- public void preFlush(Iterator entities) throws CallbackException;
- /**
- * Called after a flush that actually ends in execution of the SQL statements required to synchronize
- * in-memory state with the database.
- */
- public void postFlush(Iterator entities) throws CallbackException;
- /**
- * Called to distinguish between transient and detached entities. The return value determines the
- * state of the entity with respect to the current session.
- * <ul>
- * <li><tt>Boolean.TRUE</tt> - the entity is transient
- * <li><tt>Boolean.FALSE</tt> - the entity is detached
- * <li><tt>null</tt> - Hibernate uses the <tt>unsaved-value</tt> mapping and other heuristics to
- * determine if the object is unsaved
- * </ul>
- * @param entity a transient or detached entity
- * @return Boolean or <tt>null</tt> to choose default behaviour
- */
- public Boolean isTransient(Object entity);
- /**
- * Called from <tt>flush()</tt>. The return value determines whether the entity is updated
- * <ul>
- * <li>an array of property indices - the entity is dirty
- * <li>an empty array - the entity is not dirty
- * <li><tt>null</tt> - use Hibernate's default dirty-checking algorithm
- * </ul>
- * @param entity a persistent entity
- * @return array of dirty property indices or <tt>null</tt> to choose default behaviour
- */
- public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types);
- /**
- * Instantiate the entity class. Return <tt>null</tt> to indicate that Hibernate should use
- * the default constructor of the class. The identifier property of the returned instance
- * should be initialized with the given identifier.
- *
- * @param entityName the name of the entity
- * @param entityMode The type of entity instance to be returned.
- * @param id the identifier of the new instance
- * @return an instance of the class, or <tt>null</tt> to choose default behaviour
- */
- public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException;
-
- /**
- * Get the entity name for a persistent or transient instance
- * @param object an entity instance
- * @return the name of the entity
- */
- public String getEntityName(Object object) throws CallbackException;
-
- /**
- * Get a fully loaded entity instance that is cached externally
- * @param entityName the name of the entity
- * @param id the instance identifier
- * @return a fully initialized entity
- * @throws CallbackException
- */
- public Object getEntity(String entityName, Serializable id) throws CallbackException;
-
- /**
- * Called when a Hibernate transaction is begun via the Hibernate <tt>Transaction</tt>
- * API. Will not be called if transactions are being controlled via some other
- * mechanism (CMT, for example).
- */
- public void afterTransactionBegin(Transaction tx);
- /**
- * Called before a transaction is committed (but not before rollback).
- */
- public void beforeTransactionCompletion(Transaction tx);
- /**
- * Called after a transaction is committed or rolled back.
- */
- public void afterTransactionCompletion(Transaction tx);
-
- /**
- * Called when sql string is being prepared.
- * @param sql sql to be prepared
- * @return original or modified sql
- */
- public String onPrepareStatement(String sql);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Interceptor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Interceptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,178 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+import org.hibernate.type.Type;
+
+/**
+ * Allows user code to inspect and/or change property values.
+ * <br><br>
+ * Inspection occurs before property values are written and after they are read
+ * from the database.<br>
+ * <br>
+ * There might be a single instance of <tt>Interceptor</tt> for a <tt>SessionFactory</tt>, or a new instance
+ * might be specified for each <tt>Session</tt>. Whichever approach is used, the interceptor must be
+ * serializable if the <tt>Session</tt> is to be serializable. This means that <tt>SessionFactory</tt>-scoped
+ * interceptors should implement <tt>readResolve()</tt>.<br>
+ * <br>
+ * The <tt>Session</tt> may not be invoked from a callback (nor may a callback cause a collection or proxy to
+ * be lazily initialized).<br>
+ * <br>
+ * Instead of implementing this interface directly, it is usually better to extend <tt>EmptyInterceptor</tt>
+ * and override only the callback methods of interest.
+ *
+ * @see SessionFactory#openSession(Interceptor)
+ * @see org.hibernate.cfg.Configuration#setInterceptor(Interceptor)
+ * @see EmptyInterceptor
+ * @author Gavin King
+ */
+public interface Interceptor {
+ /**
+ * Called just before an object is initialized. The interceptor may change the <tt>state</tt>, which will
+ * be propagated to the persistent object. Note that when this method is called, <tt>entity</tt> will be
+ * an empty uninitialized instance of the class.
+ *
+ * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way.
+ */
+ public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
+ /**
+ * Called when an object is detected to be dirty, during a flush. The interceptor may modify the detected
+ * <tt>currentState</tt>, which will be propagated to both the database and the persistent object.
+ * Note that not all flushes end in actual synchronization with the database, in which case the
+ * new <tt>currentState</tt> will be propagated to the object, but not necessarily (immediately) to
+ * the database. It is strongly recommended that the interceptor <b>not</b> modify the <tt>previousState</tt>.
+ *
+ * @return <tt>true</tt> if the user modified the <tt>currentState</tt> in any way.
+ */
+ public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException;
+ /**
+ * Called before an object is saved. The interceptor may modify the <tt>state</tt>, which will be used for
+ * the SQL <tt>INSERT</tt> and propagated to the persistent object.
+ *
+ * @return <tt>true</tt> if the user modified the <tt>state</tt> in any way.
+ */
+ public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
+ /**
+ * Called before an object is deleted. It is not recommended that the interceptor modify the <tt>state</tt>.
+ */
+ public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException;
+ /**
+ * Called before a collection is (re)created.
+ */
+ public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException;
+ /**
+ * Called before a collection is deleted.
+ */
+ public void onCollectionRemove(Object collection, Serializable key) throws CallbackException;
+ /**
+ * Called before a collection is updated.
+ */
+ public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
+ /**
+ * Called before a flush
+ */
+ public void preFlush(Iterator entities) throws CallbackException;
+ /**
+ * Called after a flush that actually ends in execution of the SQL statements required to synchronize
+ * in-memory state with the database.
+ */
+ public void postFlush(Iterator entities) throws CallbackException;
+ /**
+ * Called to distinguish between transient and detached entities. The return value determines the
+ * state of the entity with respect to the current session.
+ * <ul>
+ * <li><tt>Boolean.TRUE</tt> - the entity is transient
+ * <li><tt>Boolean.FALSE</tt> - the entity is detached
+ * <li><tt>null</tt> - Hibernate uses the <tt>unsaved-value</tt> mapping and other heuristics to
+ * determine if the object is unsaved
+ * </ul>
+ * @param entity a transient or detached entity
+ * @return Boolean or <tt>null</tt> to choose default behaviour
+ */
+ public Boolean isTransient(Object entity);
+ /**
+ * Called from <tt>flush()</tt>. The return value determines whether the entity is updated
+ * <ul>
+ * <li>an array of property indices - the entity is dirty
+ * <li>an empty array - the entity is not dirty
+ * <li><tt>null</tt> - use Hibernate's default dirty-checking algorithm
+ * </ul>
+ * @param entity a persistent entity
+ * @return array of dirty property indices or <tt>null</tt> to choose default behaviour
+ */
+ public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types);
+ /**
+ * Instantiate the entity class. Return <tt>null</tt> to indicate that Hibernate should use
+ * the default constructor of the class. The identifier property of the returned instance
+ * should be initialized with the given identifier.
+ *
+ * @param entityName the name of the entity
+ * @param entityMode The type of entity instance to be returned.
+ * @param id the identifier of the new instance
+ * @return an instance of the class, or <tt>null</tt> to choose default behaviour
+ */
+ public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException;
+
+ /**
+ * Get the entity name for a persistent or transient instance
+ * @param object an entity instance
+ * @return the name of the entity
+ */
+ public String getEntityName(Object object) throws CallbackException;
+
+ /**
+ * Get a fully loaded entity instance that is cached externally
+ * @param entityName the name of the entity
+ * @param id the instance identifier
+ * @return a fully initialized entity
+ * @throws CallbackException
+ */
+ public Object getEntity(String entityName, Serializable id) throws CallbackException;
+
+ /**
+ * Called when a Hibernate transaction is begun via the Hibernate <tt>Transaction</tt>
+ * API. Will not be called if transactions are being controlled via some other
+ * mechanism (CMT, for example).
+ */
+ public void afterTransactionBegin(Transaction tx);
+ /**
+ * Called before a transaction is committed (but not before rollback).
+ */
+ public void beforeTransactionCompletion(Transaction tx);
+ /**
+ * Called after a transaction is committed or rolled back.
+ */
+ public void afterTransactionCompletion(Transaction tx);
+
+ /**
+ * Called when sql string is being prepared.
+ * @param sql sql to be prepared
+ * @return original or modified sql
+ */
+ public String onPrepareStatement(String sql);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/InvalidMappingException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,42 +0,0 @@
-package org.hibernate;
-
-/**
- * Thrown when a mapping is found to be invalid.
- * Similar to MappingException, but this contains more info about the path and type of mapping (e.g. file, resource or url)
- *
- * @author Max Rydahl Andersen
- *
- */
-public class InvalidMappingException extends MappingException {
-
- private final String path;
- private final String type;
-
- public InvalidMappingException(String customMessage, String type, String path, Throwable cause) {
- super(customMessage, cause);
- this.type=type;
- this.path=path;
- }
-
- public InvalidMappingException(String customMessage, String type, String path) {
- super(customMessage);
- this.type=type;
- this.path=path;
- }
-
- public InvalidMappingException(String type, String path) {
- this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path);
- }
-
- public InvalidMappingException(String type, String path, Throwable cause) {
- this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path, cause);
- }
-
- public String getType() {
- return type;
- }
-
- public String getPath() {
- return path;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/InvalidMappingException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/InvalidMappingException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,66 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when a mapping is found to be invalid.
+ * Similar to MappingException, but this contains more info about the path and type of mapping (e.g. file, resource or url)
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class InvalidMappingException extends MappingException {
+
+ private final String path;
+ private final String type;
+
+ public InvalidMappingException(String customMessage, String type, String path, Throwable cause) {
+ super(customMessage, cause);
+ this.type=type;
+ this.path=path;
+ }
+
+ public InvalidMappingException(String customMessage, String type, String path) {
+ super(customMessage);
+ this.type=type;
+ this.path=path;
+ }
+
+ public InvalidMappingException(String type, String path) {
+ this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path);
+ }
+
+ public InvalidMappingException(String type, String path, Throwable cause) {
+ this("Could not parse mapping document from " + type + (path==null?"":" " + path), type, path, cause);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getPath() {
+ return path;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/JDBCException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,63 +0,0 @@
-//$Id: JDBCException.java 4626 2004-09-27 15:24:38Z oneovthafew $
-package org.hibernate;
-
-import java.sql.SQLException;
-
-
-/**
- * Wraps an <tt>SQLException</tt>. Indicates that an exception
- * occurred during a JDBC call.
- *
- * @see java.sql.SQLException
- * @author Gavin King
- */
-public class JDBCException extends HibernateException {
-
- private SQLException sqle;
- private String sql;
-
- public JDBCException(String string, SQLException root) {
- super(string, root);
- sqle=root;
- }
-
- public JDBCException(String string, SQLException root, String sql) {
- this(string, root);
- this.sql = sql;
- }
-
- /**
- * Get the SQLState of the underlying <tt>SQLException</tt>.
- * @see java.sql.SQLException
- * @return String
- */
- public String getSQLState() {
- return sqle.getSQLState();
- }
-
- /**
- * Get the <tt>errorCode</tt> of the underlying <tt>SQLException</tt>.
- * @see java.sql.SQLException
- * @return int the error code
- */
- public int getErrorCode() {
- return sqle.getErrorCode();
- }
-
- /**
- * Get the underlying <tt>SQLException</tt>.
- * @return SQLException
- */
- public SQLException getSQLException() {
- return sqle;
- }
-
- /**
- * Get the actual SQL statement that caused the exception
- * (may be null)
- */
- public String getSQL() {
- return sql;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/JDBCException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/JDBCException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.sql.SQLException;
+
+
+/**
+ * Wraps an <tt>SQLException</tt>. Indicates that an exception
+ * occurred during a JDBC call.
+ *
+ * @see java.sql.SQLException
+ * @author Gavin King
+ */
+public class JDBCException extends HibernateException {
+
+ private SQLException sqle;
+ private String sql;
+
+ public JDBCException(String string, SQLException root) {
+ super(string, root);
+ sqle=root;
+ }
+
+ public JDBCException(String string, SQLException root, String sql) {
+ this(string, root);
+ this.sql = sql;
+ }
+
+ /**
+ * Get the SQLState of the underlying <tt>SQLException</tt>.
+ * @see java.sql.SQLException
+ * @return String
+ */
+ public String getSQLState() {
+ return sqle.getSQLState();
+ }
+
+ /**
+ * Get the <tt>errorCode</tt> of the underlying <tt>SQLException</tt>.
+ * @see java.sql.SQLException
+ * @return int the error code
+ */
+ public int getErrorCode() {
+ return sqle.getErrorCode();
+ }
+
+ /**
+ * Get the underlying <tt>SQLException</tt>.
+ * @return SQLException
+ */
+ public SQLException getSQLException() {
+ return sqle;
+ }
+
+ /**
+ * Get the actual SQL statement that caused the exception
+ * (may be null)
+ */
+ public String getSQL() {
+ return sql;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/LazyInitializationException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,28 +0,0 @@
-//$Id: LazyInitializationException.java 4458 2004-08-29 09:59:17Z oneovthafew $
-package org.hibernate;
-
-import org.slf4j.LoggerFactory;
-
-/**
- * Indicates access to unfetched data outside of a session context.
- * For example, when an uninitialized proxy or collection is accessed
- * after the session was closed.
- *
- * @see Hibernate#initialize(java.lang.Object)
- * @see Hibernate#isInitialized(java.lang.Object)
- * @author Gavin King
- */
-public class LazyInitializationException extends HibernateException {
-
- public LazyInitializationException(String msg) {
- super(msg);
- LoggerFactory.getLogger( LazyInitializationException.class ).error( msg, this );
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/LazyInitializationException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LazyInitializationException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.slf4j.LoggerFactory;
+
+/**
+ * Indicates access to unfetched data outside of a session context.
+ * For example, when an uninitialized proxy or collection is accessed
+ * after the session was closed.
+ *
+ * @see Hibernate#initialize(java.lang.Object)
+ * @see Hibernate#isInitialized(java.lang.Object)
+ * @author Gavin King
+ */
+public class LazyInitializationException extends HibernateException {
+
+ public LazyInitializationException(String msg) {
+ super(msg);
+ LoggerFactory.getLogger( LazyInitializationException.class ).error( msg, this );
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/LockMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,106 +0,0 @@
-//$Id: LockMode.java 9581 2006-03-09 15:50:15Z epbernard $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Instances represent a lock mode for a row of a relational
- * database table. It is not intended that users spend much
- * time worrying about locking since Hibernate usually
- * obtains exactly the right lock level automatically.
- * Some "advanced" users may wish to explicitly specify lock
- * levels.
- *
- * @see Session#lock(Object,LockMode)
- * @author Gavin King
- */
-public final class LockMode implements Serializable {
- private final int level;
- private final String name;
- private static final Map INSTANCES = new HashMap();
-
- private LockMode(int level, String name) {
- this.level=level;
- this.name=name;
- }
- public String toString() {
- return name;
- }
- /**
- * Check if this lock mode is more restrictive than the given lock mode.
- *
- * @param mode LockMode to check
- * @return true if this lock mode is more restrictive than given lock mode
- */
- public boolean greaterThan(LockMode mode) {
- return level > mode.level;
- }
- /**
- * Check if this lock mode is less restrictive than the given lock mode.
- *
- * @param mode LockMode to check
- * @return true if this lock mode is less restrictive than given lock mode
- */
- public boolean lessThan(LockMode mode) {
- return level < mode.level;
- }
- /**
- * No lock required. If an object is requested with this lock
- * mode, a <tt>READ</tt> lock will be obtained if it is
- * necessary to actually read the state from the database,
- * rather than pull it from a cache.<br>
- * <br>
- * This is the "default" lock mode.
- */
- public static final LockMode NONE = new LockMode(0, "NONE");
- /**
- * A shared lock. Objects in this lock mode were read from
- * the database in the current transaction, rather than being
- * pulled from a cache.
- */
- public static final LockMode READ = new LockMode(5, "READ");
- /**
- * An upgrade lock. Objects loaded in this lock mode are
- * materialized using an SQL <tt>select ... for update</tt>.
- */
- public static final LockMode UPGRADE = new LockMode(10, "UPGRADE");
- /**
- * Attempt to obtain an upgrade lock, using an Oracle-style
- * <tt>select for update nowait</tt>. The semantics of
- * this lock mode, once obtained, are the same as
- * <tt>UPGRADE</tt>.
- */
- public static final LockMode UPGRADE_NOWAIT = new LockMode(10, "UPGRADE_NOWAIT");
- /**
- * A <tt>WRITE</tt> lock is obtained when an object is updated
- * or inserted. This lock mode is for internal use only and is
- * not a valid mode for <tt>load()</tt> or <tt>lock()</tt> (both
- * of which throw exceptions if WRITE is specified).
- */
- public static final LockMode WRITE = new LockMode(10, "WRITE");
-
- /**
- * Similiar to {@link #UPGRADE} except that, for versioned entities,
- * it results in a forced version increment.
- */
- public static final LockMode FORCE = new LockMode( 15, "FORCE" );
-
- static {
- INSTANCES.put( NONE.name, NONE );
- INSTANCES.put( READ.name, READ );
- INSTANCES.put( UPGRADE.name, UPGRADE );
- INSTANCES.put( UPGRADE_NOWAIT.name, UPGRADE_NOWAIT );
- INSTANCES.put( WRITE.name, WRITE );
- INSTANCES.put( FORCE.name, FORCE );
- }
-
- private Object readResolve() {
- return parse( name );
- }
-
- public static LockMode parse(String name) {
- return ( LockMode ) INSTANCES.get(name);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/LockMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/LockMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,129 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Instances represent a lock mode for a row of a relational
+ * database table. It is not intended that users spend much
+ * time worrying about locking since Hibernate usually
+ * obtains exactly the right lock level automatically.
+ * Some "advanced" users may wish to explicitly specify lock
+ * levels.
+ *
+ * @see Session#lock(Object,LockMode)
+ * @author Gavin King
+ */
+public final class LockMode implements Serializable {
+ private final int level;
+ private final String name;
+ private static final Map INSTANCES = new HashMap();
+
+ private LockMode(int level, String name) {
+ this.level=level;
+ this.name=name;
+ }
+ public String toString() {
+ return name;
+ }
+ /**
+ * Check if this lock mode is more restrictive than the given lock mode.
+ *
+ * @param mode LockMode to check
+ * @return true if this lock mode is more restrictive than given lock mode
+ */
+ public boolean greaterThan(LockMode mode) {
+ return level > mode.level;
+ }
+ /**
+ * Check if this lock mode is less restrictive than the given lock mode.
+ *
+ * @param mode LockMode to check
+ * @return true if this lock mode is less restrictive than given lock mode
+ */
+ public boolean lessThan(LockMode mode) {
+ return level < mode.level;
+ }
+ /**
+ * No lock required. If an object is requested with this lock
+ * mode, a <tt>READ</tt> lock will be obtained if it is
+ * necessary to actually read the state from the database,
+ * rather than pull it from a cache.<br>
+ * <br>
+ * This is the "default" lock mode.
+ */
+ public static final LockMode NONE = new LockMode(0, "NONE");
+ /**
+ * A shared lock. Objects in this lock mode were read from
+ * the database in the current transaction, rather than being
+ * pulled from a cache.
+ */
+ public static final LockMode READ = new LockMode(5, "READ");
+ /**
+ * An upgrade lock. Objects loaded in this lock mode are
+ * materialized using an SQL <tt>select ... for update</tt>.
+ */
+ public static final LockMode UPGRADE = new LockMode(10, "UPGRADE");
+ /**
+ * Attempt to obtain an upgrade lock, using an Oracle-style
+ * <tt>select for update nowait</tt>. The semantics of
+ * this lock mode, once obtained, are the same as
+ * <tt>UPGRADE</tt>.
+ */
+ public static final LockMode UPGRADE_NOWAIT = new LockMode(10, "UPGRADE_NOWAIT");
+ /**
+ * A <tt>WRITE</tt> lock is obtained when an object is updated
+ * or inserted. This lock mode is for internal use only and is
+ * not a valid mode for <tt>load()</tt> or <tt>lock()</tt> (both
+ * of which throw exceptions if WRITE is specified).
+ */
+ public static final LockMode WRITE = new LockMode(10, "WRITE");
+
+ /**
+ * Similiar to {@link #UPGRADE} except that, for versioned entities,
+ * it results in a forced version increment.
+ */
+ public static final LockMode FORCE = new LockMode( 15, "FORCE" );
+
+ static {
+ INSTANCES.put( NONE.name, NONE );
+ INSTANCES.put( READ.name, READ );
+ INSTANCES.put( UPGRADE.name, UPGRADE );
+ INSTANCES.put( UPGRADE_NOWAIT.name, UPGRADE_NOWAIT );
+ INSTANCES.put( WRITE.name, WRITE );
+ INSTANCES.put( FORCE.name, FORCE );
+ }
+
+ private Object readResolve() {
+ return parse( name );
+ }
+
+ public static LockMode parse(String name) {
+ return ( LockMode ) INSTANCES.get(name);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/MappingException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-//$Id: MappingException.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-/**
- * An exception that usually occurs at configuration time, rather
- * than runtime, as a result of something screwy in the O-R mappings.
- *
- * @author Gavin King
- */
-
-public class MappingException extends HibernateException {
-
- public MappingException(String msg, Throwable root) {
- super( msg, root );
- }
-
- public MappingException(Throwable root) {
- super(root);
- }
-
- public MappingException(String s) {
- super(s);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/MappingException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,54 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * An exception that usually occurs at configuration time, rather
+ * than runtime, as a result of something screwy in the O-R mappings.
+ *
+ * @author Gavin King
+ */
+
+public class MappingException extends HibernateException {
+
+ public MappingException(String msg, Throwable root) {
+ super( msg, root );
+ }
+
+ public MappingException(Throwable root) {
+ super(root);
+ }
+
+ public MappingException(String s) {
+ super(s);
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/MappingNotFoundException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,41 +0,0 @@
-package org.hibernate;
-
-/**
- * Thrown when a resource for a mapping could not be found.
- *
- * @author Max Rydahl Andersen
- *
- */
-public class MappingNotFoundException extends MappingException {
-
- private final String path;
- private final String type;
-
- public MappingNotFoundException(String customMessage, String type, String path, Throwable cause) {
- super(customMessage, cause);
- this.type=type;
- this.path=path;
- }
-
- public MappingNotFoundException(String customMessage, String type, String path) {
- super(customMessage);
- this.type=type;
- this.path=path;
- }
-
- public MappingNotFoundException(String type, String path) {
- this(type + ": " + path + " not found", type, path);
- }
-
- public MappingNotFoundException(String type, String path, Throwable cause) {
- this(type + ": " + path + " not found", type, path, cause);
- }
-
- public String getType() {
- return type;
- }
-
- public String getPath() {
- return path;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/MappingNotFoundException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/MappingNotFoundException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when a resource for a mapping could not be found.
+ *
+ * @author Max Rydahl Andersen
+ */
+public class MappingNotFoundException extends MappingException {
+
+ private final String path;
+ private final String type;
+
+ public MappingNotFoundException(String customMessage, String type, String path, Throwable cause) {
+ super(customMessage, cause);
+ this.type=type;
+ this.path=path;
+ }
+
+ public MappingNotFoundException(String customMessage, String type, String path) {
+ super(customMessage);
+ this.type=type;
+ this.path=path;
+ }
+
+ public MappingNotFoundException(String type, String path) {
+ this(type + ": " + path + " not found", type, path);
+ }
+
+ public MappingNotFoundException(String type, String path, Throwable cause) {
+ this(type + ": " + path + " not found", type, path, cause);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getPath() {
+ return path;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/NonUniqueObjectException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,44 +0,0 @@
-//$Id: NonUniqueObjectException.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-
-import org.hibernate.pretty.MessageHelper;
-
-/**
- * This exception is thrown when an operation would
- * break session-scoped identity. This occurs if the
- * user tries to associate two different instances of
- * the same Java class with a particular identifier,
- * in the scope of a single <tt>Session</tt>.
- *
- * @author Gavin King
- */
-public class NonUniqueObjectException extends HibernateException {
- private final Serializable identifier;
- private final String entityName;
-
- public NonUniqueObjectException(String message, Serializable id, String clazz) {
- super(message);
- this.entityName = clazz;
- this.identifier = id;
- }
-
- public NonUniqueObjectException(Serializable id, String clazz) {
- this("a different object with the same identifier value was already associated with the session", id, clazz);
- }
-
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getMessage() {
- return super.getMessage() + ": " +
- MessageHelper.infoString(entityName, identifier);
- }
-
- public String getEntityName() {
- return entityName;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/NonUniqueObjectException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+import org.hibernate.pretty.MessageHelper;
+
+/**
+ * This exception is thrown when an operation would
+ * break session-scoped identity. This occurs if the
+ * user tries to associate two different instances of
+ * the same Java class with a particular identifier,
+ * in the scope of a single <tt>Session</tt>.
+ *
+ * @author Gavin King
+ */
+public class NonUniqueObjectException extends HibernateException {
+ private final Serializable identifier;
+ private final String entityName;
+
+ public NonUniqueObjectException(String message, Serializable id, String clazz) {
+ super(message);
+ this.entityName = clazz;
+ this.identifier = id;
+ }
+
+ public NonUniqueObjectException(Serializable id, String clazz) {
+ this("a different object with the same identifier value was already associated with the session", id, clazz);
+ }
+
+ public Serializable getIdentifier() {
+ return identifier;
+ }
+
+ public String getMessage() {
+ return super.getMessage() + ": " +
+ MessageHelper.infoString(entityName, identifier);
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/NonUniqueResultException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,17 +0,0 @@
-//$Id: NonUniqueResultException.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-/**
- * Thrown when the application calls <tt>Query.uniqueResult()</tt> and
- * the query returned more than one result. Unlike all other Hibernate
- * exceptions, this one is recoverable!
- *
- * @author Gavin King
- */
-public class NonUniqueResultException extends HibernateException {
-
- public NonUniqueResultException(int resultCount) {
- super( "query did not return a unique result: " + resultCount );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/NonUniqueResultException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/NonUniqueResultException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when the application calls <tt>Query.uniqueResult()</tt> and
+ * the query returned more than one result. Unlike all other Hibernate
+ * exceptions, this one is recoverable!
+ *
+ * @author Gavin King
+ */
+public class NonUniqueResultException extends HibernateException {
+
+ public NonUniqueResultException(int resultCount) {
+ super( "query did not return a unique result: " + resultCount );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/ObjectDeletedException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,25 +0,0 @@
-//$Id: ObjectDeletedException.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-
-/**
- * Thrown when the user tries to do something illegal with a deleted
- * object.
- *
- * @author Gavin King
- */
-public class ObjectDeletedException extends UnresolvableObjectException {
-
- public ObjectDeletedException(String message, Serializable identifier, String clazz) {
- super(message, identifier, clazz);
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/ObjectDeletedException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectDeletedException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,48 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+/**
+ * Thrown when the user tries to do something illegal with a deleted
+ * object.
+ *
+ * @author Gavin King
+ */
+public class ObjectDeletedException extends UnresolvableObjectException {
+
+ public ObjectDeletedException(String message, Serializable identifier, String clazz) {
+ super(message, identifier, clazz);
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/ObjectNotFoundException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,24 +0,0 @@
-//$Id: ObjectNotFoundException.java 9855 2006-05-02 18:55:45Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-import java.io.Serializable;
-
-/**
- * Thrown when <tt>Session.load()</tt> fails to select a row with
- * the given primary key (identifier value). This exception might not
- * be thrown when <tt>load()</tt> is called, even if there was no
- * row on the database, because <tt>load()</tt> returns a proxy if
- * possible. Applications should use <tt>Session.get()</tt> to test if
- * a row exists in the database.<br>
- * <br>
- * Like all Hibernate exceptions, this exception is considered
- * unrecoverable.
- *
- * @author Gavin King
- */
-public class ObjectNotFoundException extends UnresolvableObjectException {
-
- public ObjectNotFoundException(Serializable identifier, String clazz) {
- super(identifier, clazz);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/ObjectNotFoundException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ObjectNotFoundException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+/**
+ * Thrown when <tt>Session.load()</tt> fails to select a row with
+ * the given primary key (identifier value). This exception might not
+ * be thrown when <tt>load()</tt> is called, even if there was no
+ * row on the database, because <tt>load()</tt> returns a proxy if
+ * possible. Applications should use <tt>Session.get()</tt> to test if
+ * a row exists in the database.<br>
+ * <br>
+ * Like all Hibernate exceptions, this exception is considered
+ * unrecoverable.
+ *
+ * @author Gavin King
+ */
+public class ObjectNotFoundException extends UnresolvableObjectException {
+
+ public ObjectNotFoundException(Serializable identifier, String clazz) {
+ super(identifier, clazz);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/PersistentObjectException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: PersistentObjectException.java 6877 2005-05-23 15:00:25Z oneovthafew $
-package org.hibernate;
-
-/**
- * Thrown when the user passes a persistent instance to a <tt>Session</tt>
- * method that expects a transient instance.
- *
- * @author Gavin King
- */
-public class PersistentObjectException extends HibernateException {
-
- public PersistentObjectException(String s) {
- super(s);
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/PersistentObjectException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PersistentObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when the user passes a persistent instance to a <tt>Session</tt>
+ * method that expects a transient instance.
+ *
+ * @author Gavin King
+ */
+public class PersistentObjectException extends HibernateException {
+
+ public PersistentObjectException(String s) {
+ super(s);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/PropertyAccessException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,50 +0,0 @@
-//$Id: PropertyAccessException.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * A problem occurred accessing a property of an instance of a
- * persistent class by reflection, or via CGLIB. There are a
- * number of possible underlying causes, including
- * <ul>
- * <li>failure of a security check
- * <li>an exception occurring inside the getter or setter method
- * <li>a nullable database column was mapped to a primitive-type property
- * <li>the Hibernate type was not castable to the property type (or vice-versa)
- * </ul>
- * @author Gavin King
- */
-public class PropertyAccessException extends HibernateException {
-
- private final Class persistentClass;
- private final String propertyName;
- private final boolean wasSetter;
-
- public PropertyAccessException(Throwable root, String s, boolean wasSetter, Class persistentClass, String propertyName) {
- super(s, root);
- this.persistentClass = persistentClass;
- this.wasSetter = wasSetter;
- this.propertyName = propertyName;
- }
-
- public Class getPersistentClass() {
- return persistentClass;
- }
-
- public String getPropertyName() {
- return propertyName;
- }
-
- public String getMessage() {
- return super.getMessage() +
- ( wasSetter ? " setter of " : " getter of ") +
- StringHelper.qualify( persistentClass.getName(), propertyName );
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/PropertyAccessException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyAccessException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,73 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * A problem occurred accessing a property of an instance of a
+ * persistent class by reflection, or via CGLIB. There are a
+ * number of possible underlying causes, including
+ * <ul>
+ * <li>failure of a security check
+ * <li>an exception occurring inside the getter or setter method
+ * <li>a nullable database column was mapped to a primitive-type property
+ * <li>the Hibernate type was not castable to the property type (or vice-versa)
+ * </ul>
+ * @author Gavin King
+ */
+public class PropertyAccessException extends HibernateException {
+
+ private final Class persistentClass;
+ private final String propertyName;
+ private final boolean wasSetter;
+
+ public PropertyAccessException(Throwable root, String s, boolean wasSetter, Class persistentClass, String propertyName) {
+ super(s, root);
+ this.persistentClass = persistentClass;
+ this.wasSetter = wasSetter;
+ this.propertyName = propertyName;
+ }
+
+ public Class getPersistentClass() {
+ return persistentClass;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public String getMessage() {
+ return super.getMessage() +
+ ( wasSetter ? " setter of " : " getter of ") +
+ StringHelper.qualify( persistentClass.getName(), propertyName );
+ }
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/PropertyNotFoundException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-//$Id: PropertyNotFoundException.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-/**
- * Indicates that an expected getter or setter method could not be
- * found on a class.
- *
- * @author Gavin King
- */
-public class PropertyNotFoundException extends MappingException {
-
- public PropertyNotFoundException(String s) {
- super(s);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/PropertyNotFoundException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyNotFoundException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,39 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Indicates that an expected getter or setter method could not be
+ * found on a class.
+ *
+ * @author Gavin King
+ */
+public class PropertyNotFoundException extends MappingException {
+
+ public PropertyNotFoundException(String s) {
+ super(s);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/PropertyValueException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,56 +0,0 @@
-//$Id: PropertyValueException.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate;
-
-import org.hibernate.util.StringHelper;
-
-/**
- * Thrown when the (illegal) value of a property can not be persisted.
- * There are two main causes:
- * <ul>
- * <li>a property declared <tt>not-null="true"</tt> is null
- * <li>an association references an unsaved transient instance
- * </ul>
- * @author Gavin King
- */
-public class PropertyValueException extends HibernateException {
-
- private final String entityName;
- private final String propertyName;
-
- public PropertyValueException(String s, String entityName, String propertyName) {
- super(s);
- this.entityName = entityName;
- this.propertyName = propertyName;
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public String getPropertyName() {
- return propertyName;
- }
-
- public String getMessage() {
- return super.getMessage() + ": " +
- StringHelper.qualify(entityName, propertyName);
- }
-
- /**
- * Return a well formed property path.
- * Basicaly, it will return parent.child
- *
- * @param parent parent in path
- * @param child child in path
- * @return parent-child path
- */
- public static String buildPropertyPath(String parent, String child) {
- return new StringBuffer(parent).append('.').append(child).toString();
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/PropertyValueException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/PropertyValueException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,79 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.hibernate.util.StringHelper;
+
+/**
+ * Thrown when the (illegal) value of a property can not be persisted.
+ * There are two main causes:
+ * <ul>
+ * <li>a property declared <tt>not-null="true"</tt> is null
+ * <li>an association references an unsaved transient instance
+ * </ul>
+ * @author Gavin King
+ */
+public class PropertyValueException extends HibernateException {
+
+ private final String entityName;
+ private final String propertyName;
+
+ public PropertyValueException(String s, String entityName, String propertyName) {
+ super(s);
+ this.entityName = entityName;
+ this.propertyName = propertyName;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public String getMessage() {
+ return super.getMessage() + ": " +
+ StringHelper.qualify(entityName, propertyName);
+ }
+
+ /**
+ * Return a well formed property path.
+ * Basicaly, it will return parent.child
+ *
+ * @param parent parent in path
+ * @param child child in path
+ * @return parent-child path
+ */
+ public static String buildPropertyPath(String parent, String child) {
+ return new StringBuffer(parent).append('.').append(child).toString();
+ }
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Query.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,386 +0,0 @@
-//$Id: Query.java 10591 2006-10-17 08:57:26Z max.andersen(a)jboss.com $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.hibernate.transform.ResultTransformer;
-import org.hibernate.type.Type;
-
-/**
- * An object-oriented representation of a Hibernate query. A <tt>Query</tt>
- * instance is obtained by calling <tt>Session.createQuery()</tt>. This
- * interface exposes some extra functionality beyond that provided by
- * <tt>Session.iterate()</tt> and <tt>Session.find()</tt>:
- * <ul>
- * <li>a particular page of the result set may be selected by calling <tt>
- * setMaxResults(), setFirstResult()</tt>
- * <li>named query parameters may be used
- * <li>the results may be returned as an instance of <tt>ScrollableResults</tt>
- * </ul>
- * <br>
- * Named query parameters are tokens of the form <tt>:name</tt> in the
- * query string. A value is bound to the <tt>integer</tt> parameter
- * <tt>:foo</tt> by calling<br>
- * <br>
- * <tt>setParameter("foo", foo, Hibernate.INTEGER);</tt><br>
- * <br>
- * for example. A name may appear multiple times in the query string.<br>
- * <br>
- * JDBC-style <tt>?</tt> parameters are also supported. To bind a
- * value to a JDBC-style parameter use a set method that accepts an
- * <tt>int</tt> positional argument (numbered from zero, contrary
- * to JDBC).<br>
- * <br>
- * You may not mix and match JDBC-style parameters and named parameters
- * in the same query.<br>
- * <br>
- * Queries are executed by calling <tt>list()</tt>, <tt>scroll()</tt> or
- * <tt>iterate()</tt>. A query may be re-executed by subsequent invocations.
- * Its lifespan is, however, bounded by the lifespan of the <tt>Session</tt>
- * that created it.<br>
- * <br>
- * Implementors are not intended to be threadsafe.
- *
- * @see org.hibernate.Session#createQuery(java.lang.String)
- * @see org.hibernate.ScrollableResults
- * @author Gavin King
- */
-public interface Query {
- /**
- * Get the query string.
- *
- * @return the query string
- */
- public String getQueryString();
- /**
- * Return the Hibernate types of the query result set.
- * @return an array of types
- */
- public Type[] getReturnTypes() throws HibernateException;
- /**
- * Return the HQL select clause aliases (if any)
- * @return an array of aliases as strings
- */
- public String[] getReturnAliases() throws HibernateException;
- /**
- * Return the names of all named parameters of the query.
- * @return the parameter names, in no particular order
- */
- public String[] getNamedParameters() throws HibernateException;
- /**
- * Return the query results as an <tt>Iterator</tt>. If the query
- * contains multiple results pre row, the results are returned in
- * an instance of <tt>Object[]</tt>.<br>
- * <br>
- * Entities returned as results are initialized on demand. The first
- * SQL query returns identifiers only.<br>
- *
- * @return the result iterator
- * @throws HibernateException
- */
- public Iterator iterate() throws HibernateException;
- /**
- * Return the query results as <tt>ScrollableResults</tt>. The
- * scrollability of the returned results depends upon JDBC driver
- * support for scrollable <tt>ResultSet</tt>s.<br>
- *
- * @see ScrollableResults
- * @return the result iterator
- * @throws HibernateException
- */
- public ScrollableResults scroll() throws HibernateException;
- /**
- * Return the query results as <tt>ScrollableResults</tt>. The
- * scrollability of the returned results depends upon JDBC driver
- * support for scrollable <tt>ResultSet</tt>s.<br>
- *
- * @see ScrollableResults
- * @see ScrollMode
- * @return the result iterator
- * @throws HibernateException
- */
- public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException;
- /**
- * Return the query results as a <tt>List</tt>. If the query contains
- * multiple results pre row, the results are returned in an instance
- * of <tt>Object[]</tt>.
- *
- * @return the result list
- * @throws HibernateException
- */
- public List list() throws HibernateException;
- /**
- * Convenience method to return a single instance that matches
- * the query, or null if the query returns no results.
- *
- * @return the single result or <tt>null</tt>
- * @throws NonUniqueResultException if there is more than one matching result
- */
- public Object uniqueResult() throws HibernateException;
-
- /**
- * Execute the update or delete statement.
- * </p>
- * The semantics are compliant with the ejb3 Query.executeUpdate()
- * method.
- *
- * @return The number of entities updated or deleted.
- * @throws HibernateException
- */
- public int executeUpdate() throws HibernateException;
-
- /**
- * Set the maximum number of rows to retrieve. If not set,
- * there is no limit to the number of rows retrieved.
- * @param maxResults the maximum number of rows
- */
- public Query setMaxResults(int maxResults);
- /**
- * Set the first row to retrieve. If not set, rows will be
- * retrieved beginnning from row <tt>0</tt>.
- * @param firstResult a row number, numbered from <tt>0</tt>
- */
- public Query setFirstResult(int firstResult);
-
- /**
- * Entities retrieved by this query will be loaded in
- * a read-only mode where Hibernate will never dirty-check
- * them or make changes persistent.
- *
- */
- public Query setReadOnly(boolean readOnly);
-
- /**
- * Enable caching of this query result set.
- * @param cacheable Should the query results be cacheable?
- */
- public Query setCacheable(boolean cacheable);
-
- /**
- * Set the name of the cache region.
- * @param cacheRegion the name of a query cache region, or <tt>null</tt>
- * for the default query cache
- */
- public Query setCacheRegion(String cacheRegion);
-
- /**
- * Set a timeout for the underlying JDBC query.
- * @param timeout the timeout in seconds
- */
- public Query setTimeout(int timeout);
- /**
- * Set a fetch size for the underlying JDBC query.
- * @param fetchSize the fetch size
- */
- public Query setFetchSize(int fetchSize);
-
- /**
- * Set the lockmode for the objects idententified by the
- * given alias that appears in the <tt>FROM</tt> clause.
- * @param alias a query alias, or <tt>this</tt> for a collection filter
- */
- public Query setLockMode(String alias, LockMode lockMode);
-
- /**
- * Add a comment to the generated SQL.
- * @param comment a human-readable string
- */
- public Query setComment(String comment);
-
- /**
- * Override the current session flush mode, just for
- * this query.
- * @see org.hibernate.FlushMode
- */
- public Query setFlushMode(FlushMode flushMode);
-
- /**
- * Override the current session cache mode, just for
- * this query.
- * @see org.hibernate.CacheMode
- */
- public Query setCacheMode(CacheMode cacheMode);
-
- /**
- * Bind a value to a JDBC-style query parameter.
- * @param position the position of the parameter in the query
- * string, numbered from <tt>0</tt>.
- * @param val the possibly-null parameter value
- * @param type the Hibernate type
- */
- public Query setParameter(int position, Object val, Type type);
- /**
- * Bind a value to a named query parameter.
- * @param name the name of the parameter
- * @param val the possibly-null parameter value
- * @param type the Hibernate type
- */
- public Query setParameter(String name, Object val, Type type);
-
- /**
- * Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is
- * first detected via the usage/position in the query and if not sufficient secondly
- * guessed from the class of the given object.
- * @param position the position of the parameter in the query
- * string, numbered from <tt>0</tt>.
- * @param val the non-null parameter value
- * @throws org.hibernate.HibernateException if no type could be determined
- */
- public Query setParameter(int position, Object val) throws HibernateException;
- /**
- * Bind a value to a named query parameter. The Hibernate type of the parameter is
- * first detected via the usage/position in the query and if not sufficient secondly
- * guessed from the class of the given object.
- * @param name the name of the parameter
- * @param val the non-null parameter value
- * @throws org.hibernate.HibernateException if no type could be determined
- */
- public Query setParameter(String name, Object val) throws HibernateException;
-
- /**
- * Bind values and types to positional parameters.
- */
- public Query setParameters(Object[] values, Type[] types) throws HibernateException;
-
- /**
- * Bind multiple values to a named query parameter. This is useful for binding
- * a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
- * @param name the name of the parameter
- * @param vals a collection of values to list
- * @param type the Hibernate type of the values
- */
- public Query setParameterList(String name, Collection vals, Type type) throws HibernateException;
-
- /**
- * Bind multiple values to a named query parameter. The Hibernate type of the parameter is
- * first detected via the usage/position in the query and if not sufficient secondly
- * guessed from the class of the first object in the collection. This is useful for binding a list of values
- * to an expression such as <tt>foo.bar in (:value_list)</tt>.
- * @param name the name of the parameter
- * @param vals a collection of values to list
- */
- public Query setParameterList(String name, Collection vals) throws HibernateException;
-
- /**
- * Bind multiple values to a named query parameter. This is useful for binding
- * a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
- * @param name the name of the parameter
- * @param vals a collection of values to list
- * @param type the Hibernate type of the values
- */
- public Query setParameterList(String name, Object[] vals, Type type) throws HibernateException;
-
- /**
- * Bind multiple values to a named query parameter. The Hibernate type of the parameter is
- * first detected via the usage/position in the query and if not sufficient secondly
- * guessed from the class of the first object in the array. This is useful for binding a list of values
- * to an expression such as <tt>foo.bar in (:value_list)</tt>.
- * @param name the name of the parameter
- * @param vals a collection of values to list
- */
- public Query setParameterList(String name, Object[] vals) throws HibernateException;
-
- /**
- * Bind the property values of the given bean to named parameters of the query,
- * matching property names with parameter names and mapping property types to
- * Hibernate types using hueristics.
- * @param bean any JavaBean or POJO
- */
- public Query setProperties(Object bean) throws HibernateException;
-
- /**
- * Bind the values of the given Map for each named parameters of the query,
- * matching key names with parameter names and mapping value types to
- * Hibernate types using hueristics.
- * @param bean a java.util.Map
- */
- public Query setProperties(Map bean) throws HibernateException;
-
- public Query setString(int position, String val);
- public Query setCharacter(int position, char val);
- public Query setBoolean(int position, boolean val);
- public Query setByte(int position, byte val);
- public Query setShort(int position, short val);
- public Query setInteger(int position, int val);
- public Query setLong(int position, long val);
- public Query setFloat(int position, float val);
- public Query setDouble(int position, double val);
- public Query setBinary(int position, byte[] val);
- public Query setText(int position, String val);
- public Query setSerializable(int position, Serializable val);
- public Query setLocale(int position, Locale locale);
- public Query setBigDecimal(int position, BigDecimal number);
- public Query setBigInteger(int position, BigInteger number);
-
- public Query setDate(int position, Date date);
- public Query setTime(int position, Date date);
- public Query setTimestamp(int position, Date date);
-
- public Query setCalendar(int position, Calendar calendar);
- public Query setCalendarDate(int position, Calendar calendar);
-
- public Query setString(String name, String val);
- public Query setCharacter(String name, char val);
- public Query setBoolean(String name, boolean val);
- public Query setByte(String name, byte val);
- public Query setShort(String name, short val);
- public Query setInteger(String name, int val);
- public Query setLong(String name, long val);
- public Query setFloat(String name, float val);
- public Query setDouble(String name, double val);
- public Query setBinary(String name, byte[] val);
- public Query setText(String name, String val);
- public Query setSerializable(String name, Serializable val);
- public Query setLocale(String name, Locale locale);
- public Query setBigDecimal(String name, BigDecimal number);
- public Query setBigInteger(String name, BigInteger number);
-
- public Query setDate(String name, Date date);
- public Query setTime(String name, Date date);
- public Query setTimestamp(String name, Date date);
-
- public Query setCalendar(String name, Calendar calendar);
- public Query setCalendarDate(String name, Calendar calendar);
-
- /**
- * Bind an instance of a mapped persistent class to a JDBC-style query parameter.
- * @param position the position of the parameter in the query
- * string, numbered from <tt>0</tt>.
- * @param val a non-null instance of a persistent class
- */
- public Query setEntity(int position, Object val); // use setParameter for null values
-
- /**
- * Bind an instance of a mapped persistent class to a named query parameter.
- * @param name the name of the parameter
- * @param val a non-null instance of a persistent class
- */
- public Query setEntity(String name, Object val); // use setParameter for null values
-
-
- /**
- * Set a strategy for handling the query results. This can be used to change
- * "shape" of the query result.
- *
- * @param transformer The transformer to apply
- * @return this (for method chaining)
- */
- public Query setResultTransformer(ResultTransformer transformer);
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Query.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Query.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,409 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.hibernate.transform.ResultTransformer;
+import org.hibernate.type.Type;
+
+/**
+ * An object-oriented representation of a Hibernate query. A <tt>Query</tt>
+ * instance is obtained by calling <tt>Session.createQuery()</tt>. This
+ * interface exposes some extra functionality beyond that provided by
+ * <tt>Session.iterate()</tt> and <tt>Session.find()</tt>:
+ * <ul>
+ * <li>a particular page of the result set may be selected by calling <tt>
+ * setMaxResults(), setFirstResult()</tt>
+ * <li>named query parameters may be used
+ * <li>the results may be returned as an instance of <tt>ScrollableResults</tt>
+ * </ul>
+ * <br>
+ * Named query parameters are tokens of the form <tt>:name</tt> in the
+ * query string. A value is bound to the <tt>integer</tt> parameter
+ * <tt>:foo</tt> by calling<br>
+ * <br>
+ * <tt>setParameter("foo", foo, Hibernate.INTEGER);</tt><br>
+ * <br>
+ * for example. A name may appear multiple times in the query string.<br>
+ * <br>
+ * JDBC-style <tt>?</tt> parameters are also supported. To bind a
+ * value to a JDBC-style parameter use a set method that accepts an
+ * <tt>int</tt> positional argument (numbered from zero, contrary
+ * to JDBC).<br>
+ * <br>
+ * You may not mix and match JDBC-style parameters and named parameters
+ * in the same query.<br>
+ * <br>
+ * Queries are executed by calling <tt>list()</tt>, <tt>scroll()</tt> or
+ * <tt>iterate()</tt>. A query may be re-executed by subsequent invocations.
+ * Its lifespan is, however, bounded by the lifespan of the <tt>Session</tt>
+ * that created it.<br>
+ * <br>
+ * Implementors are not intended to be threadsafe.
+ *
+ * @see org.hibernate.Session#createQuery(java.lang.String)
+ * @see org.hibernate.ScrollableResults
+ * @author Gavin King
+ */
+public interface Query {
+ /**
+ * Get the query string.
+ *
+ * @return the query string
+ */
+ public String getQueryString();
+ /**
+ * Return the Hibernate types of the query result set.
+ * @return an array of types
+ */
+ public Type[] getReturnTypes() throws HibernateException;
+ /**
+ * Return the HQL select clause aliases (if any)
+ * @return an array of aliases as strings
+ */
+ public String[] getReturnAliases() throws HibernateException;
+ /**
+ * Return the names of all named parameters of the query.
+ * @return the parameter names, in no particular order
+ */
+ public String[] getNamedParameters() throws HibernateException;
+ /**
+ * Return the query results as an <tt>Iterator</tt>. If the query
+ * contains multiple results pre row, the results are returned in
+ * an instance of <tt>Object[]</tt>.<br>
+ * <br>
+ * Entities returned as results are initialized on demand. The first
+ * SQL query returns identifiers only.<br>
+ *
+ * @return the result iterator
+ * @throws HibernateException
+ */
+ public Iterator iterate() throws HibernateException;
+ /**
+ * Return the query results as <tt>ScrollableResults</tt>. The
+ * scrollability of the returned results depends upon JDBC driver
+ * support for scrollable <tt>ResultSet</tt>s.<br>
+ *
+ * @see ScrollableResults
+ * @return the result iterator
+ * @throws HibernateException
+ */
+ public ScrollableResults scroll() throws HibernateException;
+ /**
+ * Return the query results as <tt>ScrollableResults</tt>. The
+ * scrollability of the returned results depends upon JDBC driver
+ * support for scrollable <tt>ResultSet</tt>s.<br>
+ *
+ * @see ScrollableResults
+ * @see ScrollMode
+ * @return the result iterator
+ * @throws HibernateException
+ */
+ public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException;
+ /**
+ * Return the query results as a <tt>List</tt>. If the query contains
+ * multiple results pre row, the results are returned in an instance
+ * of <tt>Object[]</tt>.
+ *
+ * @return the result list
+ * @throws HibernateException
+ */
+ public List list() throws HibernateException;
+ /**
+ * Convenience method to return a single instance that matches
+ * the query, or null if the query returns no results.
+ *
+ * @return the single result or <tt>null</tt>
+ * @throws NonUniqueResultException if there is more than one matching result
+ */
+ public Object uniqueResult() throws HibernateException;
+
+ /**
+ * Execute the update or delete statement.
+ * </p>
+ * The semantics are compliant with the ejb3 Query.executeUpdate()
+ * method.
+ *
+ * @return The number of entities updated or deleted.
+ * @throws HibernateException
+ */
+ public int executeUpdate() throws HibernateException;
+
+ /**
+ * Set the maximum number of rows to retrieve. If not set,
+ * there is no limit to the number of rows retrieved.
+ * @param maxResults the maximum number of rows
+ */
+ public Query setMaxResults(int maxResults);
+ /**
+ * Set the first row to retrieve. If not set, rows will be
+ * retrieved beginnning from row <tt>0</tt>.
+ * @param firstResult a row number, numbered from <tt>0</tt>
+ */
+ public Query setFirstResult(int firstResult);
+
+ /**
+ * Entities retrieved by this query will be loaded in
+ * a read-only mode where Hibernate will never dirty-check
+ * them or make changes persistent.
+ *
+ */
+ public Query setReadOnly(boolean readOnly);
+
+ /**
+ * Enable caching of this query result set.
+ * @param cacheable Should the query results be cacheable?
+ */
+ public Query setCacheable(boolean cacheable);
+
+ /**
+ * Set the name of the cache region.
+ * @param cacheRegion the name of a query cache region, or <tt>null</tt>
+ * for the default query cache
+ */
+ public Query setCacheRegion(String cacheRegion);
+
+ /**
+ * Set a timeout for the underlying JDBC query.
+ * @param timeout the timeout in seconds
+ */
+ public Query setTimeout(int timeout);
+ /**
+ * Set a fetch size for the underlying JDBC query.
+ * @param fetchSize the fetch size
+ */
+ public Query setFetchSize(int fetchSize);
+
+ /**
+ * Set the lockmode for the objects idententified by the
+ * given alias that appears in the <tt>FROM</tt> clause.
+ * @param alias a query alias, or <tt>this</tt> for a collection filter
+ */
+ public Query setLockMode(String alias, LockMode lockMode);
+
+ /**
+ * Add a comment to the generated SQL.
+ * @param comment a human-readable string
+ */
+ public Query setComment(String comment);
+
+ /**
+ * Override the current session flush mode, just for
+ * this query.
+ * @see org.hibernate.FlushMode
+ */
+ public Query setFlushMode(FlushMode flushMode);
+
+ /**
+ * Override the current session cache mode, just for
+ * this query.
+ * @see org.hibernate.CacheMode
+ */
+ public Query setCacheMode(CacheMode cacheMode);
+
+ /**
+ * Bind a value to a JDBC-style query parameter.
+ * @param position the position of the parameter in the query
+ * string, numbered from <tt>0</tt>.
+ * @param val the possibly-null parameter value
+ * @param type the Hibernate type
+ */
+ public Query setParameter(int position, Object val, Type type);
+ /**
+ * Bind a value to a named query parameter.
+ * @param name the name of the parameter
+ * @param val the possibly-null parameter value
+ * @param type the Hibernate type
+ */
+ public Query setParameter(String name, Object val, Type type);
+
+ /**
+ * Bind a value to a JDBC-style query parameter. The Hibernate type of the parameter is
+ * first detected via the usage/position in the query and if not sufficient secondly
+ * guessed from the class of the given object.
+ * @param position the position of the parameter in the query
+ * string, numbered from <tt>0</tt>.
+ * @param val the non-null parameter value
+ * @throws org.hibernate.HibernateException if no type could be determined
+ */
+ public Query setParameter(int position, Object val) throws HibernateException;
+ /**
+ * Bind a value to a named query parameter. The Hibernate type of the parameter is
+ * first detected via the usage/position in the query and if not sufficient secondly
+ * guessed from the class of the given object.
+ * @param name the name of the parameter
+ * @param val the non-null parameter value
+ * @throws org.hibernate.HibernateException if no type could be determined
+ */
+ public Query setParameter(String name, Object val) throws HibernateException;
+
+ /**
+ * Bind values and types to positional parameters.
+ */
+ public Query setParameters(Object[] values, Type[] types) throws HibernateException;
+
+ /**
+ * Bind multiple values to a named query parameter. This is useful for binding
+ * a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
+ * @param name the name of the parameter
+ * @param vals a collection of values to list
+ * @param type the Hibernate type of the values
+ */
+ public Query setParameterList(String name, Collection vals, Type type) throws HibernateException;
+
+ /**
+ * Bind multiple values to a named query parameter. The Hibernate type of the parameter is
+ * first detected via the usage/position in the query and if not sufficient secondly
+ * guessed from the class of the first object in the collection. This is useful for binding a list of values
+ * to an expression such as <tt>foo.bar in (:value_list)</tt>.
+ * @param name the name of the parameter
+ * @param vals a collection of values to list
+ */
+ public Query setParameterList(String name, Collection vals) throws HibernateException;
+
+ /**
+ * Bind multiple values to a named query parameter. This is useful for binding
+ * a list of values to an expression such as <tt>foo.bar in (:value_list)</tt>.
+ * @param name the name of the parameter
+ * @param vals a collection of values to list
+ * @param type the Hibernate type of the values
+ */
+ public Query setParameterList(String name, Object[] vals, Type type) throws HibernateException;
+
+ /**
+ * Bind multiple values to a named query parameter. The Hibernate type of the parameter is
+ * first detected via the usage/position in the query and if not sufficient secondly
+ * guessed from the class of the first object in the array. This is useful for binding a list of values
+ * to an expression such as <tt>foo.bar in (:value_list)</tt>.
+ * @param name the name of the parameter
+ * @param vals a collection of values to list
+ */
+ public Query setParameterList(String name, Object[] vals) throws HibernateException;
+
+ /**
+ * Bind the property values of the given bean to named parameters of the query,
+ * matching property names with parameter names and mapping property types to
+ * Hibernate types using hueristics.
+ * @param bean any JavaBean or POJO
+ */
+ public Query setProperties(Object bean) throws HibernateException;
+
+ /**
+ * Bind the values of the given Map for each named parameters of the query,
+ * matching key names with parameter names and mapping value types to
+ * Hibernate types using hueristics.
+ * @param bean a java.util.Map
+ */
+ public Query setProperties(Map bean) throws HibernateException;
+
+ public Query setString(int position, String val);
+ public Query setCharacter(int position, char val);
+ public Query setBoolean(int position, boolean val);
+ public Query setByte(int position, byte val);
+ public Query setShort(int position, short val);
+ public Query setInteger(int position, int val);
+ public Query setLong(int position, long val);
+ public Query setFloat(int position, float val);
+ public Query setDouble(int position, double val);
+ public Query setBinary(int position, byte[] val);
+ public Query setText(int position, String val);
+ public Query setSerializable(int position, Serializable val);
+ public Query setLocale(int position, Locale locale);
+ public Query setBigDecimal(int position, BigDecimal number);
+ public Query setBigInteger(int position, BigInteger number);
+
+ public Query setDate(int position, Date date);
+ public Query setTime(int position, Date date);
+ public Query setTimestamp(int position, Date date);
+
+ public Query setCalendar(int position, Calendar calendar);
+ public Query setCalendarDate(int position, Calendar calendar);
+
+ public Query setString(String name, String val);
+ public Query setCharacter(String name, char val);
+ public Query setBoolean(String name, boolean val);
+ public Query setByte(String name, byte val);
+ public Query setShort(String name, short val);
+ public Query setInteger(String name, int val);
+ public Query setLong(String name, long val);
+ public Query setFloat(String name, float val);
+ public Query setDouble(String name, double val);
+ public Query setBinary(String name, byte[] val);
+ public Query setText(String name, String val);
+ public Query setSerializable(String name, Serializable val);
+ public Query setLocale(String name, Locale locale);
+ public Query setBigDecimal(String name, BigDecimal number);
+ public Query setBigInteger(String name, BigInteger number);
+
+ public Query setDate(String name, Date date);
+ public Query setTime(String name, Date date);
+ public Query setTimestamp(String name, Date date);
+
+ public Query setCalendar(String name, Calendar calendar);
+ public Query setCalendarDate(String name, Calendar calendar);
+
+ /**
+ * Bind an instance of a mapped persistent class to a JDBC-style query parameter.
+ * @param position the position of the parameter in the query
+ * string, numbered from <tt>0</tt>.
+ * @param val a non-null instance of a persistent class
+ */
+ public Query setEntity(int position, Object val); // use setParameter for null values
+
+ /**
+ * Bind an instance of a mapped persistent class to a named query parameter.
+ * @param name the name of the parameter
+ * @param val a non-null instance of a persistent class
+ */
+ public Query setEntity(String name, Object val); // use setParameter for null values
+
+
+ /**
+ * Set a strategy for handling the query results. This can be used to change
+ * "shape" of the query result.
+ *
+ * @param transformer The transformer to apply
+ * @return this (for method chaining)
+ */
+ public Query setResultTransformer(ResultTransformer transformer);
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/QueryException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,48 +0,0 @@
-//$Id: QueryException.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate;
-
-/**
- * A problem occurred translating a Hibernate query to SQL
- * due to invalid query syntax, etc.
- */
-public class QueryException extends HibernateException {
-
- private String queryString;
-
- public QueryException(String message) {
- super(message);
- }
- public QueryException(String message, Throwable e) {
- super(message, e);
- }
-
- public QueryException(String message, String queryString) {
- super(message);
- this.queryString = queryString;
- }
-
- public QueryException(Exception e) {
- super(e);
- }
- public String getQueryString() {
- return queryString;
- }
-
- public void setQueryString(String queryString) {
- this.queryString = queryString;
- }
-
- public String getMessage() {
- String msg = super.getMessage();
- if ( queryString!=null ) msg += " [" + queryString + ']';
- return msg;
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/QueryException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,71 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * A problem occurred translating a Hibernate query to SQL
+ * due to invalid query syntax, etc.
+ */
+public class QueryException extends HibernateException {
+
+ private String queryString;
+
+ public QueryException(String message) {
+ super(message);
+ }
+ public QueryException(String message, Throwable e) {
+ super(message, e);
+ }
+
+ public QueryException(String message, String queryString) {
+ super(message);
+ this.queryString = queryString;
+ }
+
+ public QueryException(Exception e) {
+ super(e);
+ }
+ public String getQueryString() {
+ return queryString;
+ }
+
+ public void setQueryString(String queryString) {
+ this.queryString = queryString;
+ }
+
+ public String getMessage() {
+ String msg = super.getMessage();
+ if ( queryString!=null ) msg += " [" + queryString + ']';
+ return msg;
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/QueryParameterException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,26 +0,0 @@
-//$Id: $
-package org.hibernate;
-
-/**
- * Parameter invalid or not found in the query
- *
- * @author Emmanuel Bernard
- */
-public class QueryParameterException extends QueryException {
-
- public QueryParameterException(Exception e) {
- super( e );
- }
-
- public QueryParameterException(String message) {
- super( message );
- }
-
- public QueryParameterException(String message, Throwable e) {
- super( message, e );
- }
-
- public QueryParameterException(String message, String queryString) {
- super( message, queryString );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/QueryParameterException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/QueryParameterException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Parameter invalid or not found in the query
+ *
+ * @author Emmanuel Bernard
+ */
+public class QueryParameterException extends QueryException {
+
+ public QueryParameterException(Exception e) {
+ super( e );
+ }
+
+ public QueryParameterException(String message) {
+ super( message );
+ }
+
+ public QueryParameterException(String message, Throwable e) {
+ super( message, e );
+ }
+
+ public QueryParameterException(String message, String queryString) {
+ super( message, queryString );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/ReplicationMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,78 +0,0 @@
-//$Id: ReplicationMode.java 5060 2004-12-24 03:11:05Z oneovthafew $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.type.VersionType;
-
-/**
- * Represents a replication strategy.
- *
- * @see Session#replicate(Object, ReplicationMode)
- * @author Gavin King
- */
-public abstract class ReplicationMode implements Serializable {
- private final String name;
- private static final Map INSTANCES = new HashMap();
-
- public ReplicationMode(String name) {
- this.name=name;
- }
- public String toString() {
- return name;
- }
- public abstract boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType);
- /**
- * Throw an exception when a row already exists.
- */
- public static final ReplicationMode EXCEPTION = new ReplicationMode("EXCEPTION") {
- public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
- throw new AssertionFailure("should not be called");
- }
- };
- /**
- * Ignore replicated entities when a row already exists.
- */
- public static final ReplicationMode IGNORE = new ReplicationMode("IGNORE") {
- public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
- return false;
- }
- };
- /**
- * Overwrite existing rows when a row already exists.
- */
- public static final ReplicationMode OVERWRITE = new ReplicationMode("OVERWRITE") {
- public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
- return true;
- }
- };
- /**
- * When a row already exists, choose the latest version.
- */
- public static final ReplicationMode LATEST_VERSION = new ReplicationMode("LATEST_VERSION") {
- public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
- if (versionType==null) return true; //always overwrite nonversioned data
- return versionType.getComparator().compare(currentVersion, newVersion) <= 0;
- }
- };
-
- static {
- INSTANCES.put( LATEST_VERSION.name, LATEST_VERSION );
- INSTANCES.put( IGNORE.name, IGNORE );
- INSTANCES.put( OVERWRITE.name, OVERWRITE );
- INSTANCES.put( EXCEPTION.name, EXCEPTION );
- }
-
- private Object readResolve() {
- return INSTANCES.get(name);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/ReplicationMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ReplicationMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.type.VersionType;
+
+/**
+ * Represents a replication strategy.
+ *
+ * @see Session#replicate(Object, ReplicationMode)
+ * @author Gavin King
+ */
+public abstract class ReplicationMode implements Serializable {
+ private final String name;
+ private static final Map INSTANCES = new HashMap();
+
+ public ReplicationMode(String name) {
+ this.name=name;
+ }
+ public String toString() {
+ return name;
+ }
+ public abstract boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType);
+ /**
+ * Throw an exception when a row already exists.
+ */
+ public static final ReplicationMode EXCEPTION = new ReplicationMode("EXCEPTION") {
+ public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
+ throw new AssertionFailure("should not be called");
+ }
+ };
+ /**
+ * Ignore replicated entities when a row already exists.
+ */
+ public static final ReplicationMode IGNORE = new ReplicationMode("IGNORE") {
+ public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
+ return false;
+ }
+ };
+ /**
+ * Overwrite existing rows when a row already exists.
+ */
+ public static final ReplicationMode OVERWRITE = new ReplicationMode("OVERWRITE") {
+ public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
+ return true;
+ }
+ };
+ /**
+ * When a row already exists, choose the latest version.
+ */
+ public static final ReplicationMode LATEST_VERSION = new ReplicationMode("LATEST_VERSION") {
+ public boolean shouldOverwriteCurrentVersion(Object entity, Object currentVersion, Object newVersion, VersionType versionType) {
+ if (versionType==null) return true; //always overwrite nonversioned data
+ return versionType.getComparator().compare(currentVersion, newVersion) <= 0;
+ }
+ };
+
+ static {
+ INSTANCES.put( LATEST_VERSION.name, LATEST_VERSION );
+ INSTANCES.put( IGNORE.name, IGNORE );
+ INSTANCES.put( OVERWRITE.name, OVERWRITE );
+ INSTANCES.put( EXCEPTION.name, EXCEPTION );
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get(name);
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/SQLQuery.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,93 +0,0 @@
-//$Id: SQLQuery.java 10845 2006-11-18 04:20:30Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-import org.hibernate.type.Type;
-
-/**
- * Allows the user to declare the types and select list injection
- * points of all entities returned by the query. Also allows
- * declaration of the type and column alias of any scalar results
- * of the query.
- *
- * @author Gavin King
- */
-public interface SQLQuery extends Query {
- /**
- * Declare a "root" entity, without specifying an alias
- */
- public SQLQuery addEntity(String entityName);
- /**
- * Declare a "root" entity
- */
- public SQLQuery addEntity(String alias, String entityName);
- /**
- * Declare a "root" entity, specifying a lock mode
- */
- public SQLQuery addEntity(String alias, String entityName, LockMode lockMode);
- /**
- * Declare a "root" entity, without specifying an alias
- */
- public SQLQuery addEntity(Class entityClass);
- /**
- * Declare a "root" entity
- */
- public SQLQuery addEntity(String alias, Class entityClass);
- /**
- * Declare a "root" entity, specifying a lock mode
- */
- public SQLQuery addEntity(String alias, Class entityClass, LockMode lockMode);
-
- /**
- * Declare a "joined" entity
- */
- public SQLQuery addJoin(String alias, String path);
- /**
- * Declare a "joined" entity, specifying a lock mode
- */
- public SQLQuery addJoin(String alias, String path, LockMode lockMode);
-
- /**
- * Declare a scalar query result
- */
- public SQLQuery addScalar(String columnAlias, Type type);
-
- /**
- * Declare a scalar query. Hibernate will attempt to automatically detect the underlying type.
- */
- public SQLQuery addScalar(String columnAlias);
-
- /**
- * Use a predefined named ResultSetMapping
- */
- public SQLQuery setResultSetMapping(String name);
-
- /**
- * Adds a query space for auto-flush synchronization.
- *
- * @param querySpace The query space to be auto-flushed for this query.
- * @return this, for method chaning
- */
- public SQLQuery addSynchronizedQuerySpace(String querySpace);
-
- /**
- * Adds an entity name or auto-flush synchronization.
- *
- * @param entityName The name of the entity upon whose defined
- * query spaces we should additionally synchronize.
- * @return this, for method chaning
- * @throws MappingException Indicates the given entity name could not be
- * resolved.
- */
- public SQLQuery addSynchronizedEntityName(String entityName) throws MappingException;
-
- /**
- * Adds an entity name or auto-flush synchronization.
- *
- * @param entityClass The class of the entity upon whose defined
- * query spaces we should additionally synchronize.
- * @return this, for method chaning
- * @throws MappingException Indicates the given entity class could not be
- * resolved.
- */
- public SQLQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/SQLQuery.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SQLQuery.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,116 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import org.hibernate.type.Type;
+
+/**
+ * Allows the user to declare the types and select list injection
+ * points of all entities returned by the query. Also allows
+ * declaration of the type and column alias of any scalar results
+ * of the query.
+ *
+ * @author Gavin King
+ */
+public interface SQLQuery extends Query {
+ /**
+ * Declare a "root" entity, without specifying an alias
+ */
+ public SQLQuery addEntity(String entityName);
+ /**
+ * Declare a "root" entity
+ */
+ public SQLQuery addEntity(String alias, String entityName);
+ /**
+ * Declare a "root" entity, specifying a lock mode
+ */
+ public SQLQuery addEntity(String alias, String entityName, LockMode lockMode);
+ /**
+ * Declare a "root" entity, without specifying an alias
+ */
+ public SQLQuery addEntity(Class entityClass);
+ /**
+ * Declare a "root" entity
+ */
+ public SQLQuery addEntity(String alias, Class entityClass);
+ /**
+ * Declare a "root" entity, specifying a lock mode
+ */
+ public SQLQuery addEntity(String alias, Class entityClass, LockMode lockMode);
+
+ /**
+ * Declare a "joined" entity
+ */
+ public SQLQuery addJoin(String alias, String path);
+ /**
+ * Declare a "joined" entity, specifying a lock mode
+ */
+ public SQLQuery addJoin(String alias, String path, LockMode lockMode);
+
+ /**
+ * Declare a scalar query result
+ */
+ public SQLQuery addScalar(String columnAlias, Type type);
+
+ /**
+ * Declare a scalar query. Hibernate will attempt to automatically detect the underlying type.
+ */
+ public SQLQuery addScalar(String columnAlias);
+
+ /**
+ * Use a predefined named ResultSetMapping
+ */
+ public SQLQuery setResultSetMapping(String name);
+
+ /**
+ * Adds a query space for auto-flush synchronization.
+ *
+ * @param querySpace The query space to be auto-flushed for this query.
+ * @return this, for method chaning
+ */
+ public SQLQuery addSynchronizedQuerySpace(String querySpace);
+
+ /**
+ * Adds an entity name or auto-flush synchronization.
+ *
+ * @param entityName The name of the entity upon whose defined
+ * query spaces we should additionally synchronize.
+ * @return this, for method chaning
+ * @throws MappingException Indicates the given entity name could not be
+ * resolved.
+ */
+ public SQLQuery addSynchronizedEntityName(String entityName) throws MappingException;
+
+ /**
+ * Adds an entity name or auto-flush synchronization.
+ *
+ * @param entityClass The class of the entity upon whose defined
+ * query spaces we should additionally synchronize.
+ * @return this, for method chaning
+ * @throws MappingException Indicates the given entity class could not be
+ * resolved.
+ */
+ public SQLQuery addSynchronizedEntityClass(Class entityClass) throws MappingException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/ScrollMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,74 +0,0 @@
-//$Id: ScrollMode.java 4369 2004-08-18 00:28:43Z oneovthafew $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Specifies the type of JDBC scrollable result set to use
- * underneath a <tt>ScrollableResults</tt>
- *
- * @see Query#scroll(ScrollMode)
- * @see ScrollableResults
- * @author Gavin King
- */
-public final class ScrollMode implements Serializable {
- private final int resultSetType;
- private final String name;
- private static final Map INSTANCES = new HashMap();
-
- private ScrollMode(int level, String name) {
- this.resultSetType=level;
- this.name=name;
- }
-
- public String toString() {
- return name;
- }
-
- /**
- * @return the JDBC result set type code
- */
- public int toResultSetType() {
- return resultSetType;
- }
-
- /**
- * @see java.sql.ResultSet.TYPE_FORWARD_ONLY
- */
- public static final ScrollMode FORWARD_ONLY = new ScrollMode(ResultSet.TYPE_FORWARD_ONLY, "FORWARD_ONLY");
- /**
- * @see java.sql.ResultSet.TYPE_SCROLL_SENSITIVE
- */
- public static final ScrollMode SCROLL_SENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_SENSITIVE, "SCROLL_SENSITIVE");
- /**
- * Note that since the Hibernate session acts as a cache, you
- * might need to expicitly evict objects, if you need to see
- * changes made by other transactions.
- * @see java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE
- */
- public static final ScrollMode SCROLL_INSENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_INSENSITIVE, "SCROLL_INSENSITIVE");
-
- public boolean lessThan(ScrollMode other) {
- return this.resultSetType<other.resultSetType;
- }
-
- static {
- INSTANCES.put( FORWARD_ONLY.name, FORWARD_ONLY );
- INSTANCES.put( SCROLL_INSENSITIVE.name, SCROLL_INSENSITIVE );
- INSTANCES.put( SCROLL_SENSITIVE.name, SCROLL_SENSITIVE );
- }
-
- private Object readResolve() {
- return INSTANCES.get(name);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/ScrollMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,97 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Specifies the type of JDBC scrollable result set to use
+ * underneath a <tt>ScrollableResults</tt>
+ *
+ * @see Query#scroll(ScrollMode)
+ * @see ScrollableResults
+ * @author Gavin King
+ */
+public final class ScrollMode implements Serializable {
+ private final int resultSetType;
+ private final String name;
+ private static final Map INSTANCES = new HashMap();
+
+ private ScrollMode(int level, String name) {
+ this.resultSetType=level;
+ this.name=name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * @return the JDBC result set type code
+ */
+ public int toResultSetType() {
+ return resultSetType;
+ }
+
+ /**
+ * @see java.sql.ResultSet.TYPE_FORWARD_ONLY
+ */
+ public static final ScrollMode FORWARD_ONLY = new ScrollMode(ResultSet.TYPE_FORWARD_ONLY, "FORWARD_ONLY");
+ /**
+ * @see java.sql.ResultSet.TYPE_SCROLL_SENSITIVE
+ */
+ public static final ScrollMode SCROLL_SENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_SENSITIVE, "SCROLL_SENSITIVE");
+ /**
+ * Note that since the Hibernate session acts as a cache, you
+ * might need to expicitly evict objects, if you need to see
+ * changes made by other transactions.
+ * @see java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE
+ */
+ public static final ScrollMode SCROLL_INSENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_INSENSITIVE, "SCROLL_INSENSITIVE");
+
+ public boolean lessThan(ScrollMode other) {
+ return this.resultSetType<other.resultSetType;
+ }
+
+ static {
+ INSTANCES.put( FORWARD_ONLY.name, FORWARD_ONLY );
+ INSTANCES.put( SCROLL_INSENSITIVE.name, SCROLL_INSENSITIVE );
+ INSTANCES.put( SCROLL_SENSITIVE.name, SCROLL_SENSITIVE );
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get(name);
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/ScrollableResults.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,204 +0,0 @@
-//$Id: ScrollableResults.java 6411 2005-04-13 07:37:50Z oneovthafew $
-package org.hibernate;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-import org.hibernate.type.Type;
-
-/**
- * A result iterator that allows moving around within the results
- * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt>
- * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/
- * <tt>ResultSet</tt> pattern and the semantics of methods of this interface
- * are similar to the similarly named methods on <tt>ResultSet</tt>.<br>
- * <br>
- * Contrary to JDBC, columns of results are numbered from zero.
- *
- * @see Query#scroll()
- * @author Gavin King
- */
-public interface ScrollableResults {
- /**
- * Advance to the next result
- * @return <tt>true</tt> if there is another result
- */
- public boolean next() throws HibernateException;
- /**
- * Retreat to the previous result
- * @return <tt>true</tt> if there is a previous result
- */
- public boolean previous() throws HibernateException;
- /**
- * Scroll an arbitrary number of locations
- * @param i a positive (forward) or negative (backward) number of rows
- * @return <tt>true</tt> if there is a result at the new location
- */
- public boolean scroll(int i) throws HibernateException;
- /**
- * Go to the last result
- * @return <tt>true</tt> if there are any results
- */
- public boolean last() throws HibernateException;
- /**
- * Go to the first result
- * @return <tt>true</tt> if there are any results
- */
- public boolean first() throws HibernateException;
- /**
- * Go to a location just before first result (this is the initial location)
- */
- public void beforeFirst() throws HibernateException;
- /**
- * Go to a location just after the last result
- */
- public void afterLast() throws HibernateException;
- /**
- * Is this the first result?
- *
- * @return <tt>true</tt> if this is the first row of results
- * @throws HibernateException
- */
- public boolean isFirst() throws HibernateException;
- /**
- * Is this the last result?
- *
- * @return <tt>true</tt> if this is the last row of results
- * @throws HibernateException
- */
- public boolean isLast() throws HibernateException;
- /**
- * Release resources immediately.
- */
- public void close() throws HibernateException;
- /**
- * Get the current row of results
- * @return an object or array
- */
- public Object[] get() throws HibernateException;
- /**
- * Get the <tt>i</tt>th object in the current row of results, without
- * initializing any other results in the row. This method may be used
- * safely, regardless of the type of the column (ie. even for scalar
- * results).
- * @param i the column, numbered from zero
- * @return an object of any Hibernate type or <tt>null</tt>
- */
- public Object get(int i) throws HibernateException;
-
- /**
- * Get the type of the <tt>i</tt>th column of results
- * @param i the column, numbered from zero
- * @return the Hibernate type
- */
- public Type getType(int i);
-
- /**
- * Convenience method to read an <tt>integer</tt>
- */
- public Integer getInteger(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>long</tt>
- */
- public Long getLong(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>float</tt>
- */
- public Float getFloat(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>boolean</tt>
- */
- public Boolean getBoolean(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>double</tt>
- */
- public Double getDouble(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>short</tt>
- */
- public Short getShort(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>byte</tt>
- */
- public Byte getByte(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>character</tt>
- */
- public Character getCharacter(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>binary</tt>
- */
- public byte[] getBinary(int col) throws HibernateException;
- /**
- * Convenience method to read <tt>text</tt>
- */
- public String getText(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>blob</tt>
- */
- public Blob getBlob(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>clob</tt>
- */
- public Clob getClob(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>string</tt>
- */
- public String getString(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>big_decimal</tt>
- */
- public BigDecimal getBigDecimal(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>big_integer</tt>
- */
- public BigInteger getBigInteger(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>date</tt>, <tt>time</tt> or <tt>timestamp</tt>
- */
- public Date getDate(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>locale</tt>
- */
- public Locale getLocale(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>calendar</tt> or <tt>calendar_date</tt>
- */
- public Calendar getCalendar(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>currency</tt>
- */
- //public Currency getCurrency(int col) throws HibernateException;
- /**
- * Convenience method to read a <tt>timezone</tt>
- */
- public TimeZone getTimeZone(int col) throws HibernateException;
- /**
- * Get the current location in the result set. The first
- * row is number <tt>0</tt>, contrary to JDBC.
- * @return the row number, numbered from <tt>0</tt>, or <tt>-1</tt> if
- * there is no current row
- */
- public int getRowNumber() throws HibernateException;
- /**
- * Set the current location in the result set, numbered from either the
- * first row (row number <tt>0</tt>), or the last row (row
- * number <tt>-1</tt>).
- * @param rowNumber the row number, numbered from the last row, in the
- * case of a negative row number
- * @return true if there is a row at that row number
- */
- public boolean setRowNumber(int rowNumber) throws HibernateException;
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/ScrollableResults.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/ScrollableResults.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,227 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.hibernate.type.Type;
+
+/**
+ * A result iterator that allows moving around within the results
+ * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt>
+ * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/
+ * <tt>ResultSet</tt> pattern and the semantics of methods of this interface
+ * are similar to the similarly named methods on <tt>ResultSet</tt>.<br>
+ * <br>
+ * Contrary to JDBC, columns of results are numbered from zero.
+ *
+ * @see Query#scroll()
+ * @author Gavin King
+ */
+public interface ScrollableResults {
+ /**
+ * Advance to the next result
+ * @return <tt>true</tt> if there is another result
+ */
+ public boolean next() throws HibernateException;
+ /**
+ * Retreat to the previous result
+ * @return <tt>true</tt> if there is a previous result
+ */
+ public boolean previous() throws HibernateException;
+ /**
+ * Scroll an arbitrary number of locations
+ * @param i a positive (forward) or negative (backward) number of rows
+ * @return <tt>true</tt> if there is a result at the new location
+ */
+ public boolean scroll(int i) throws HibernateException;
+ /**
+ * Go to the last result
+ * @return <tt>true</tt> if there are any results
+ */
+ public boolean last() throws HibernateException;
+ /**
+ * Go to the first result
+ * @return <tt>true</tt> if there are any results
+ */
+ public boolean first() throws HibernateException;
+ /**
+ * Go to a location just before first result (this is the initial location)
+ */
+ public void beforeFirst() throws HibernateException;
+ /**
+ * Go to a location just after the last result
+ */
+ public void afterLast() throws HibernateException;
+ /**
+ * Is this the first result?
+ *
+ * @return <tt>true</tt> if this is the first row of results
+ * @throws HibernateException
+ */
+ public boolean isFirst() throws HibernateException;
+ /**
+ * Is this the last result?
+ *
+ * @return <tt>true</tt> if this is the last row of results
+ * @throws HibernateException
+ */
+ public boolean isLast() throws HibernateException;
+ /**
+ * Release resources immediately.
+ */
+ public void close() throws HibernateException;
+ /**
+ * Get the current row of results
+ * @return an object or array
+ */
+ public Object[] get() throws HibernateException;
+ /**
+ * Get the <tt>i</tt>th object in the current row of results, without
+ * initializing any other results in the row. This method may be used
+ * safely, regardless of the type of the column (ie. even for scalar
+ * results).
+ * @param i the column, numbered from zero
+ * @return an object of any Hibernate type or <tt>null</tt>
+ */
+ public Object get(int i) throws HibernateException;
+
+ /**
+ * Get the type of the <tt>i</tt>th column of results
+ * @param i the column, numbered from zero
+ * @return the Hibernate type
+ */
+ public Type getType(int i);
+
+ /**
+ * Convenience method to read an <tt>integer</tt>
+ */
+ public Integer getInteger(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>long</tt>
+ */
+ public Long getLong(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>float</tt>
+ */
+ public Float getFloat(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>boolean</tt>
+ */
+ public Boolean getBoolean(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>double</tt>
+ */
+ public Double getDouble(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>short</tt>
+ */
+ public Short getShort(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>byte</tt>
+ */
+ public Byte getByte(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>character</tt>
+ */
+ public Character getCharacter(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>binary</tt>
+ */
+ public byte[] getBinary(int col) throws HibernateException;
+ /**
+ * Convenience method to read <tt>text</tt>
+ */
+ public String getText(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>blob</tt>
+ */
+ public Blob getBlob(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>clob</tt>
+ */
+ public Clob getClob(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>string</tt>
+ */
+ public String getString(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>big_decimal</tt>
+ */
+ public BigDecimal getBigDecimal(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>big_integer</tt>
+ */
+ public BigInteger getBigInteger(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>date</tt>, <tt>time</tt> or <tt>timestamp</tt>
+ */
+ public Date getDate(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>locale</tt>
+ */
+ public Locale getLocale(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>calendar</tt> or <tt>calendar_date</tt>
+ */
+ public Calendar getCalendar(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>currency</tt>
+ */
+ //public Currency getCurrency(int col) throws HibernateException;
+ /**
+ * Convenience method to read a <tt>timezone</tt>
+ */
+ public TimeZone getTimeZone(int col) throws HibernateException;
+ /**
+ * Get the current location in the result set. The first
+ * row is number <tt>0</tt>, contrary to JDBC.
+ * @return the row number, numbered from <tt>0</tt>, or <tt>-1</tt> if
+ * there is no current row
+ */
+ public int getRowNumber() throws HibernateException;
+ /**
+ * Set the current location in the result set, numbered from either the
+ * first row (row number <tt>0</tt>), or the last row (row
+ * number <tt>-1</tt>).
+ * @param rowNumber the row number, numbered from the last row, in the
+ * case of a negative row number
+ * @return true if there is a row at that row number
+ */
+ public boolean setRowNumber(int rowNumber) throws HibernateException;
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Session.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,793 +0,0 @@
-//$Id: Session.java 11494 2007-05-09 02:00:16Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.sql.Connection;
-
-import org.hibernate.jdbc.Work;
-import org.hibernate.stat.SessionStatistics;
-
-/**
- * The main runtime interface between a Java application and Hibernate. This is the
- * central API class abstracting the notion of a persistence service.<br>
- * <br>
- * The lifecycle of a <tt>Session</tt> is bounded by the beginning and end of a logical
- * transaction. (Long transactions might span several database transactions.)<br>
- * <br>
- * The main function of the <tt>Session</tt> is to offer create, read and delete operations
- * for instances of mapped entity classes. Instances may exist in one of three states:<br>
- * <br>
- * <i>transient:</i> never persistent, not associated with any <tt>Session</tt><br>
- * <i>persistent:</i> associated with a unique <tt>Session</tt><br>
- * <i>detached:</i> previously persistent, not associated with any <tt>Session</tt><br>
- * <br>
- * Transient instances may be made persistent by calling <tt>save()</tt>,
- * <tt>persist()</tt> or <tt>saveOrUpdate()</tt>. Persistent instances may be made transient
- * by calling<tt> delete()</tt>. Any instance returned by a <tt>get()</tt> or
- * <tt>load()</tt> method is persistent. Detached instances may be made persistent
- * by calling <tt>update()</tt>, <tt>saveOrUpdate()</tt>, <tt>lock()</tt> or <tt>replicate()</tt>.
- * The state of a transient or detached instance may also be made persistent as a new
- * persistent instance by calling <tt>merge()</tt>.<br>
- * <br>
- * <tt>save()</tt> and <tt>persist()</tt> result in an SQL <tt>INSERT</tt>, <tt>delete()</tt>
- * in an SQL <tt>DELETE</tt> and <tt>update()</tt> or <tt>merge()</tt> in an SQL <tt>UPDATE</tt>.
- * Changes to <i>persistent</i> instances are detected at flush time and also result in an SQL
- * <tt>UPDATE</tt>. <tt>saveOrUpdate()</tt> and <tt>replicate()</tt> result in either an
- * <tt>INSERT</tt> or an <tt>UPDATE</tt>.<br>
- * <br>
- * It is not intended that implementors be threadsafe. Instead each thread/transaction
- * should obtain its own instance from a <tt>SessionFactory</tt>.<br>
- * <br>
- * A <tt>Session</tt> instance is serializable if its persistent classes are serializable.<br>
- * <br>
- * A typical transaction should use the following idiom:
- * <pre>
- * Session sess = factory.openSession();
- * Transaction tx;
- * try {
- * tx = sess.beginTransaction();
- * //do some work
- * ...
- * tx.commit();
- * }
- * catch (Exception e) {
- * if (tx!=null) tx.rollback();
- * throw e;
- * }
- * finally {
- * sess.close();
- * }
- * </pre>
- * <br>
- * If the <tt>Session</tt> throws an exception, the transaction must be rolled back
- * and the session discarded. The internal state of the <tt>Session</tt> might not
- * be consistent with the database after the exception occurs.
- *
- * @see SessionFactory
- * @author Gavin King
- */
-public interface Session extends Serializable {
-
- /**
- * Retrieve the entity mode in effect for this session.
- *
- * @return The entity mode for this session.
- */
- public EntityMode getEntityMode();
-
- /**
- * Starts a new Session with the given entity mode in effect. This secondary
- * Session inherits the connection, transaction, and other context
- * information from the primary Session. It doesn't need to be flushed
- * or closed by the developer.
- *
- * @param entityMode The entity mode to use for the new session.
- * @return The new session
- */
- public Session getSession(EntityMode entityMode);
-
- /**
- * Force this session to flush. Must be called at the end of a
- * unit of work, before commiting the transaction and closing the
- * session (depending on {@link #setFlushMode flush-mode},
- * {@link Transaction#commit()} calls this method).
- * <p/>
- * <i>Flushing</i> is the process of synchronizing the underlying persistent
- * store with persistable state held in memory.
- *
- * @throws HibernateException Indicates problems flushing the session or
- * talking to the database.
- */
- public void flush() throws HibernateException;
-
- /**
- * Set the flush mode for this session.
- * <p/>
- * The flush mode determines the points at which the session is flushed.
- * <i>Flushing</i> is the process of synchronizing the underlying persistent
- * store with persistable state held in memory.
- * <p/>
- * For a logically "read only" session, it is reasonable to set the session's
- * flush mode to {@link FlushMode#MANUAL} at the start of the session (in
- * order to achieve some extra performance).
- *
- * @param flushMode the new flush mode
- * @see FlushMode
- */
- public void setFlushMode(FlushMode flushMode);
-
- /**
- * Get the current flush mode for this session.
- *
- * @return The flush mode
- */
- public FlushMode getFlushMode();
-
- /**
- * Set the cache mode.
- * <p/>
- * Cache mode determines the manner in which this session can interact with
- * the second level cache.
- *
- * @param cacheMode The new cache mode.
- */
- public void setCacheMode(CacheMode cacheMode);
-
- /**
- * Get the current cache mode.
- *
- * @return The current cache mode.
- */
- public CacheMode getCacheMode();
-
- /**
- * Get the session factory which created this session.
- *
- * @return The session factory.
- * @see SessionFactory
-
- */
- public SessionFactory getSessionFactory();
-
- /**
- * Get the JDBC connection of this Session.<br>
- * <br>
- * If the session is using aggressive collection release (as in a
- * CMT environment), it is the application's responsibility to
- * close the connection returned by this call. Otherwise, the
- * application should not close the connection.
- *
- * @return the JDBC connection in use by the <tt>Session</tt>
- * @throws HibernateException if the <tt>Session</tt> is disconnected
- * @deprecated (scheduled for removal in 4.x). Replacement depends on need; for doing direct JDBC stuff use
- * {@link #doWork}; for opening a 'temporary Session' use (TBD).
- */
- public Connection connection() throws HibernateException;
-
- /**
- * End the session by releasing the JDBC connection and cleaning up. It is
- * not strictly necessary to close the session but you must at least
- * {@link #disconnect()} it.
- *
- * @return the connection provided by the application or null.
- * @throws HibernateException Indicates problems cleaning up.
- */
- public Connection close() throws HibernateException;
-
- /**
- * Cancel the execution of the current query.
- * <p/>
- * This is the sole method on session which may be safely called from
- * another thread.
- *
- * @throws HibernateException There was a problem canceling the query
- */
- public void cancelQuery() throws HibernateException;
-
- /**
- * Check if the session is still open.
- *
- * @return boolean
- */
- public boolean isOpen();
-
- /**
- * Check if the session is currently connected.
- *
- * @return boolean
- */
- public boolean isConnected();
-
- /**
- * Does this session contain any changes which must be synchronized with
- * the database? In other words, would any DML operations be executed if
- * we flushed this session?
- *
- * @return True if the session contains pending changes; false otherwise.
- * @throws HibernateException could not perform dirtying checking
- */
- public boolean isDirty() throws HibernateException;
-
- /**
- * Return the identifier value of the given entity as associated with this
- * session. An exception is thrown if the given entity instance is transient
- * or detached in relation to this session.
- *
- * @param object a persistent instance
- * @return the identifier
- * @throws TransientObjectException if the instance is transient or associated with
- * a different session
- */
- public Serializable getIdentifier(Object object) throws HibernateException;
-
- /**
- * Check if this instance is associated with this <tt>Session</tt>.
- *
- * @param object an instance of a persistent class
- * @return true if the given instance is associated with this <tt>Session</tt>
- */
- public boolean contains(Object object);
-
- /**
- * Remove this instance from the session cache. Changes to the instance will
- * not be synchronized with the database. This operation cascades to associated
- * instances if the association is mapped with <tt>cascade="evict"</tt>.
- *
- * @param object a persistent instance
- * @throws HibernateException
- */
- public void evict(Object object) throws HibernateException;
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * obtaining the specified lock mode, assuming the instance exists.
- *
- * @param theClass a persistent class
- * @param id a valid identifier of an existing persistent instance of the class
- * @param lockMode the lock level
- * @return the persistent instance or proxy
- * @throws HibernateException
- */
- public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException;
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * obtaining the specified lock mode, assuming the instance exists.
- *
- * @param entityName a persistent class
- * @param id a valid identifier of an existing persistent instance of the class
- * @param lockMode the lock level
- * @return the persistent instance or proxy
- * @throws HibernateException
- */
- public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * assuming that the instance exists. This method might return a proxied instance that
- * is initialized on-demand, when a non-identifier method is accessed.
- * <br><br>
- * You should not use this method to determine if an instance exists (use <tt>get()</tt>
- * instead). Use this only to retrieve an instance that you assume exists, where non-existence
- * would be an actual error.
- *
- * @param theClass a persistent class
- * @param id a valid identifier of an existing persistent instance of the class
- * @return the persistent instance or proxy
- * @throws HibernateException
- */
- public Object load(Class theClass, Serializable id) throws HibernateException;
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * assuming that the instance exists. This method might return a proxied instance that
- * is initialized on-demand, when a non-identifier method is accessed.
- * <br><br>
- * You should not use this method to determine if an instance exists (use <tt>get()</tt>
- * instead). Use this only to retrieve an instance that you assume exists, where non-existence
- * would be an actual error.
- *
- * @param entityName a persistent class
- * @param id a valid identifier of an existing persistent instance of the class
- * @return the persistent instance or proxy
- * @throws HibernateException
- */
- public Object load(String entityName, Serializable id) throws HibernateException;
-
- /**
- * Read the persistent state associated with the given identifier into the given transient
- * instance.
- *
- * @param object an "empty" instance of the persistent class
- * @param id a valid identifier of an existing persistent instance of the class
- * @throws HibernateException
- */
- public void load(Object object, Serializable id) throws HibernateException;
-
- /**
- * Persist the state of the given detached instance, reusing the current
- * identifier value. This operation cascades to associated instances if
- * the association is mapped with <tt>cascade="replicate"</tt>.
- *
- * @param object a detached instance of a persistent class
- */
- public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException;
-
- /**
- * Persist the state of the given detached instance, reusing the current
- * identifier value. This operation cascades to associated instances if
- * the association is mapped with <tt>cascade="replicate"</tt>.
- *
- * @param object a detached instance of a persistent class
- */
- public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException;
-
- /**
- * Persist the given transient instance, first assigning a generated identifier. (Or
- * using the current value of the identifier property if the <tt>assigned</tt>
- * generator is used.) This operation cascades to associated instances if the
- * association is mapped with <tt>cascade="save-update"</tt>.
- *
- * @param object a transient instance of a persistent class
- * @return the generated identifier
- * @throws HibernateException
- */
- public Serializable save(Object object) throws HibernateException;
-
- /**
- * Persist the given transient instance, first assigning a generated identifier. (Or
- * using the current value of the identifier property if the <tt>assigned</tt>
- * generator is used.) This operation cascades to associated instances if the
- * association is mapped with <tt>cascade="save-update"</tt>.
- *
- * @param object a transient instance of a persistent class
- * @return the generated identifier
- * @throws HibernateException
- */
- public Serializable save(String entityName, Object object) throws HibernateException;
-
- /**
- * Either {@link #save(Object)} or {@link #update(Object)} the given
- * instance, depending upon resolution of the unsaved-value checks (see the
- * manual for discussion of unsaved-value checking).
- * <p/>
- * This operation cascades to associated instances if the association is mapped
- * with <tt>cascade="save-update"</tt>.
- *
- * @see Session#save(java.lang.Object)
- * @see Session#update(Object object)
- * @param object a transient or detached instance containing new or updated state
- * @throws HibernateException
- */
- public void saveOrUpdate(Object object) throws HibernateException;
-
- /**
- * Either {@link #save(String, Object)} or {@link #update(String, Object)}
- * the given instance, depending upon resolution of the unsaved-value checks
- * (see the manual for discussion of unsaved-value checking).
- * <p/>
- * This operation cascades to associated instances if the association is mapped
- * with <tt>cascade="save-update"</tt>.
- *
- * @see Session#save(String,Object)
- * @see Session#update(String,Object)
- * @param object a transient or detached instance containing new or updated state
- * @throws HibernateException
- */
- public void saveOrUpdate(String entityName, Object object) throws HibernateException;
-
- /**
- * Update the persistent instance with the identifier of the given detached
- * instance. If there is a persistent instance with the same identifier,
- * an exception is thrown. This operation cascades to associated instances
- * if the association is mapped with <tt>cascade="save-update"</tt>.
- *
- * @param object a detached instance containing updated state
- * @throws HibernateException
- */
- public void update(Object object) throws HibernateException;
-
- /**
- * Update the persistent instance with the identifier of the given detached
- * instance. If there is a persistent instance with the same identifier,
- * an exception is thrown. This operation cascades to associated instances
- * if the association is mapped with <tt>cascade="save-update"</tt>.
- *
- * @param object a detached instance containing updated state
- * @throws HibernateException
- */
- public void update(String entityName, Object object) throws HibernateException;
-
- /**
- * Copy the state of the given object onto the persistent object with the same
- * identifier. If there is no persistent instance currently associated with
- * the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved, save a copy of and return it as a newly persistent
- * instance. The given instance does not become associated with the session.
- * This operation cascades to associated instances if the association is mapped
- * with <tt>cascade="merge"</tt>.<br>
- * <br>
- * The semantics of this method are defined by JSR-220.
- *
- * @param object a detached instance with state to be copied
- * @return an updated persistent instance
- */
- public Object merge(Object object) throws HibernateException;
-
- /**
- * Copy the state of the given object onto the persistent object with the same
- * identifier. If there is no persistent instance currently associated with
- * the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved, save a copy of and return it as a newly persistent
- * instance. The given instance does not become associated with the session.
- * This operation cascades to associated instances if the association is mapped
- * with <tt>cascade="merge"</tt>.<br>
- * <br>
- * The semantics of this method are defined by JSR-220.
- *
- * @param object a detached instance with state to be copied
- * @return an updated persistent instance
- */
- public Object merge(String entityName, Object object) throws HibernateException;
-
- /**
- * Make a transient instance persistent. This operation cascades to associated
- * instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
- * <br>
- * The semantics of this method are defined by JSR-220.
- *
- * @param object a transient instance to be made persistent
- */
- public void persist(Object object) throws HibernateException;
- /**
- * Make a transient instance persistent. This operation cascades to associated
- * instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
- * <br>
- * The semantics of this method are defined by JSR-220.
- *
- * @param object a transient instance to be made persistent
- */
- public void persist(String entityName, Object object) throws HibernateException;
-
- /**
- * Remove a persistent instance from the datastore. The argument may be
- * an instance associated with the receiving <tt>Session</tt> or a transient
- * instance with an identifier associated with existing persistent state.
- * This operation cascades to associated instances if the association is mapped
- * with <tt>cascade="delete"</tt>.
- *
- * @param object the instance to be removed
- * @throws HibernateException
- */
- public void delete(Object object) throws HibernateException;
-
- /**
- * Remove a persistent instance from the datastore. The <b>object</b> argument may be
- * an instance associated with the receiving <tt>Session</tt> or a transient
- * instance with an identifier associated with existing persistent state.
- * This operation cascades to associated instances if the association is mapped
- * with <tt>cascade="delete"</tt>.
- *
- * @param entityName The entity name for the instance to be removed.
- * @param object the instance to be removed
- * @throws HibernateException
- */
- public void delete(String entityName, Object object) throws HibernateException;
-
- /**
- * Obtain the specified lock level upon the given object. This may be used to
- * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
- * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
- * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
- * instances if the association is mapped with <tt>cascade="lock"</tt>.
- *
- * @param object a persistent or transient instance
- * @param lockMode the lock level
- * @throws HibernateException
- */
- public void lock(Object object, LockMode lockMode) throws HibernateException;
-
- /**
- * Obtain the specified lock level upon the given object. This may be used to
- * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
- * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
- * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
- * instances if the association is mapped with <tt>cascade="lock"</tt>.
- *
- * @param object a persistent or transient instance
- * @param lockMode the lock level
- * @throws HibernateException
- */
- public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException;
-
- /**
- * Re-read the state of the given instance from the underlying database. It is
- * inadvisable to use this to implement long-running sessions that span many
- * business tasks. This method is, however, useful in certain special circumstances.
- * For example
- * <ul>
- * <li>where a database trigger alters the object state upon insert or update
- * <li>after executing direct SQL (eg. a mass update) in the same session
- * <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
- * </ul>
- *
- * @param object a persistent or detached instance
- * @throws HibernateException
- */
- public void refresh(Object object) throws HibernateException;
-
- /**
- * Re-read the state of the given instance from the underlying database, with
- * the given <tt>LockMode</tt>. It is inadvisable to use this to implement
- * long-running sessions that span many business tasks. This method is, however,
- * useful in certain special circumstances.
- *
- * @param object a persistent or detached instance
- * @param lockMode the lock mode to use
- * @throws HibernateException
- */
- public void refresh(Object object, LockMode lockMode) throws HibernateException;
-
- /**
- * Determine the current lock mode of the given object.
- *
- * @param object a persistent instance
- * @return the current lock mode
- * @throws HibernateException
- */
- public LockMode getCurrentLockMode(Object object) throws HibernateException;
-
- /**
- * Begin a unit of work and return the associated <tt>Transaction</tt> object.
- * If a new underlying transaction is required, begin the transaction. Otherwise
- * continue the new work in the context of the existing underlying transaction.
- * The class of the returned <tt>Transaction</tt> object is determined by the
- * property <tt>hibernate.transaction_factory</tt>.
- *
- * @return a Transaction instance
- * @throws HibernateException
- * @see Transaction
- */
- public Transaction beginTransaction() throws HibernateException;
-
- /**
- * Get the <tt>Transaction</tt> instance associated with this session.
- * The class of the returned <tt>Transaction</tt> object is determined by the
- * property <tt>hibernate.transaction_factory</tt>.
- *
- * @return a Transaction instance
- * @throws HibernateException
- * @see Transaction
- */
- public Transaction getTransaction();
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity class,
- * or a superclass of an entity class.
- *
- * @param persistentClass a class, which is persistent, or has persistent subclasses
- * @return Criteria
- */
- public Criteria createCriteria(Class persistentClass);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity class,
- * or a superclass of an entity class, with the given alias.
- *
- * @param persistentClass a class, which is persistent, or has persistent subclasses
- * @return Criteria
- */
- public Criteria createCriteria(Class persistentClass, String alias);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity name.
- *
- * @param entityName
- * @return Criteria
- */
- public Criteria createCriteria(String entityName);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity name,
- * with the given alias.
- *
- * @param entityName
- * @return Criteria
- */
- public Criteria createCriteria(String entityName, String alias);
-
- /**
- * Create a new instance of <tt>Query</tt> for the given HQL query string.
- *
- * @param queryString a HQL query
- * @return Query
- * @throws HibernateException
- */
- public Query createQuery(String queryString) throws HibernateException;
-
- /**
- * Create a new instance of <tt>SQLQuery</tt> for the given SQL query string.
- *
- * @param queryString a SQL query
- * @return SQLQuery
- * @throws HibernateException
- */
- public SQLQuery createSQLQuery(String queryString) throws HibernateException;
-
- /**
- * Create a new instance of <tt>Query</tt> for the given collection and filter string.
- *
- * @param collection a persistent collection
- * @param queryString a Hibernate query
- * @return Query
- * @throws HibernateException
- */
- public Query createFilter(Object collection, String queryString) throws HibernateException;
-
- /**
- * Obtain an instance of <tt>Query</tt> for a named query string defined in the
- * mapping file.
- *
- * @param queryName the name of a query defined externally
- * @return Query
- * @throws HibernateException
- */
- public Query getNamedQuery(String queryName) throws HibernateException;
-
- /**
- * Completely clear the session. Evict all loaded instances and cancel all pending
- * saves, updates and deletions. Do not close open iterators or instances of
- * <tt>ScrollableResults</tt>.
- */
- public void clear();
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
- * Obtain the specified lock mode if the instance exists.
- *
- * @param clazz a persistent class
- * @param id an identifier
- * @return a persistent instance or null
- * @throws HibernateException
- */
- public Object get(Class clazz, Serializable id) throws HibernateException;
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
- * Obtain the specified lock mode if the instance exists.
- *
- * @param clazz a persistent class
- * @param id an identifier
- * @param lockMode the lock mode
- * @return a persistent instance or null
- * @throws HibernateException
- */
- public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException;
-
- /**
- * Return the persistent instance of the given named entity with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
- *
- * @param entityName the entity name
- * @param id an identifier
- * @return a persistent instance or null
- * @throws HibernateException
- */
- public Object get(String entityName, Serializable id) throws HibernateException;
-
- /**
- * Return the persistent instance of the given entity class with the given identifier,
- * or null if there is no such persistent instance. (If the instance is already associated
- * with the session, return that instance. This method never returns an uninitialized instance.)
- * Obtain the specified lock mode if the instance exists.
- *
- * @param entityName the entity name
- * @param id an identifier
- * @param lockMode the lock mode
- * @return a persistent instance or null
- * @throws HibernateException
- */
- public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
-
-
- /**
- * Return the entity name for a persistent entity
- *
- * @param object a persistent entity
- * @return the entity name
- * @throws HibernateException
- */
- public String getEntityName(Object object) throws HibernateException;
-
- /**
- * Enable the named filter for this current session.
- *
- * @param filterName The name of the filter to be enabled.
- * @return The Filter instance representing the enabled fiter.
- */
- public Filter enableFilter(String filterName);
-
- /**
- * Retrieve a currently enabled filter by name.
- *
- * @param filterName The name of the filter to be retrieved.
- * @return The Filter instance representing the enabled fiter.
- */
- public Filter getEnabledFilter(String filterName);
-
- /**
- * Disable the named filter for the current session.
- *
- * @param filterName The name of the filter to be disabled.
- */
- public void disableFilter(String filterName);
-
- /**
- * Get the statistics for this session.
- */
- public SessionStatistics getStatistics();
-
- /**
- * Set an unmodified persistent object to read only mode, or a read only
- * object to modifiable mode. In read only mode, no snapshot is maintained
- * and the instance is never dirty checked.
- *
- * @see Query#setReadOnly(boolean)
- */
- public void setReadOnly(Object entity, boolean readOnly);
-
- /**
- * Controller for allowing users to perform JDBC related work using the Connection
- * managed by this Session.
- *
- * @param work The work to be performed.
- * @throws HibernateException Generally indicates wrapped {@link java.sql.SQLException}
- */
- public void doWork(Work work) throws HibernateException;
-
-
- /**
- * Disconnect the <tt>Session</tt> from the current JDBC connection. If
- * the connection was obtained by Hibernate close it and return it to
- * the connection pool; otherwise, return it to the application.
- * <p/>
- * This is used by applications which supply JDBC connections to Hibernate
- * and which require long-sessions (or long-conversations)
- * <p/>
- * Note that disconnect() called on a session where the connection was
- * retrieved by Hibernate through its configured
- * {@link org.hibernate.connection.ConnectionProvider} has no effect,
- * provided {@link ConnectionReleaseMode#ON_CLOSE} is not in effect.
- *
- * @return the application-supplied connection or <tt>null</tt>
- * @see #reconnect(Connection)
- * @see #reconnect()
- */
- Connection disconnect() throws HibernateException;
-
- /**
- * Obtain a new JDBC connection. This is used by applications which
- * require long transactions and do not supply connections to the
- * session.
- *
- * @see #disconnect()
- * @deprecated Manual reconnection is only needed in the case of
- * application-supplied connections, in which case the
- * {@link #reconnect(java.sql.Connection)} for should be used.
- */
- void reconnect() throws HibernateException;
-
- /**
- * Reconnect to the given JDBC connection. This is used by applications
- * which require long transactions and use application-supplied connections.
- *
- * @param connection a JDBC connection
- * @see #disconnect()
- */
- void reconnect(Connection connection) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Session.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Session.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,816 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.sql.Connection;
+
+import org.hibernate.jdbc.Work;
+import org.hibernate.stat.SessionStatistics;
+
+/**
+ * The main runtime interface between a Java application and Hibernate. This is the
+ * central API class abstracting the notion of a persistence service.<br>
+ * <br>
+ * The lifecycle of a <tt>Session</tt> is bounded by the beginning and end of a logical
+ * transaction. (Long transactions might span several database transactions.)<br>
+ * <br>
+ * The main function of the <tt>Session</tt> is to offer create, read and delete operations
+ * for instances of mapped entity classes. Instances may exist in one of three states:<br>
+ * <br>
+ * <i>transient:</i> never persistent, not associated with any <tt>Session</tt><br>
+ * <i>persistent:</i> associated with a unique <tt>Session</tt><br>
+ * <i>detached:</i> previously persistent, not associated with any <tt>Session</tt><br>
+ * <br>
+ * Transient instances may be made persistent by calling <tt>save()</tt>,
+ * <tt>persist()</tt> or <tt>saveOrUpdate()</tt>. Persistent instances may be made transient
+ * by calling<tt> delete()</tt>. Any instance returned by a <tt>get()</tt> or
+ * <tt>load()</tt> method is persistent. Detached instances may be made persistent
+ * by calling <tt>update()</tt>, <tt>saveOrUpdate()</tt>, <tt>lock()</tt> or <tt>replicate()</tt>.
+ * The state of a transient or detached instance may also be made persistent as a new
+ * persistent instance by calling <tt>merge()</tt>.<br>
+ * <br>
+ * <tt>save()</tt> and <tt>persist()</tt> result in an SQL <tt>INSERT</tt>, <tt>delete()</tt>
+ * in an SQL <tt>DELETE</tt> and <tt>update()</tt> or <tt>merge()</tt> in an SQL <tt>UPDATE</tt>.
+ * Changes to <i>persistent</i> instances are detected at flush time and also result in an SQL
+ * <tt>UPDATE</tt>. <tt>saveOrUpdate()</tt> and <tt>replicate()</tt> result in either an
+ * <tt>INSERT</tt> or an <tt>UPDATE</tt>.<br>
+ * <br>
+ * It is not intended that implementors be threadsafe. Instead each thread/transaction
+ * should obtain its own instance from a <tt>SessionFactory</tt>.<br>
+ * <br>
+ * A <tt>Session</tt> instance is serializable if its persistent classes are serializable.<br>
+ * <br>
+ * A typical transaction should use the following idiom:
+ * <pre>
+ * Session sess = factory.openSession();
+ * Transaction tx;
+ * try {
+ * tx = sess.beginTransaction();
+ * //do some work
+ * ...
+ * tx.commit();
+ * }
+ * catch (Exception e) {
+ * if (tx!=null) tx.rollback();
+ * throw e;
+ * }
+ * finally {
+ * sess.close();
+ * }
+ * </pre>
+ * <br>
+ * If the <tt>Session</tt> throws an exception, the transaction must be rolled back
+ * and the session discarded. The internal state of the <tt>Session</tt> might not
+ * be consistent with the database after the exception occurs.
+ *
+ * @see SessionFactory
+ * @author Gavin King
+ */
+public interface Session extends Serializable {
+
+ /**
+ * Retrieve the entity mode in effect for this session.
+ *
+ * @return The entity mode for this session.
+ */
+ public EntityMode getEntityMode();
+
+ /**
+ * Starts a new Session with the given entity mode in effect. This secondary
+ * Session inherits the connection, transaction, and other context
+ * information from the primary Session. It doesn't need to be flushed
+ * or closed by the developer.
+ *
+ * @param entityMode The entity mode to use for the new session.
+ * @return The new session
+ */
+ public Session getSession(EntityMode entityMode);
+
+ /**
+ * Force this session to flush. Must be called at the end of a
+ * unit of work, before commiting the transaction and closing the
+ * session (depending on {@link #setFlushMode flush-mode},
+ * {@link Transaction#commit()} calls this method).
+ * <p/>
+ * <i>Flushing</i> is the process of synchronizing the underlying persistent
+ * store with persistable state held in memory.
+ *
+ * @throws HibernateException Indicates problems flushing the session or
+ * talking to the database.
+ */
+ public void flush() throws HibernateException;
+
+ /**
+ * Set the flush mode for this session.
+ * <p/>
+ * The flush mode determines the points at which the session is flushed.
+ * <i>Flushing</i> is the process of synchronizing the underlying persistent
+ * store with persistable state held in memory.
+ * <p/>
+ * For a logically "read only" session, it is reasonable to set the session's
+ * flush mode to {@link FlushMode#MANUAL} at the start of the session (in
+ * order to achieve some extra performance).
+ *
+ * @param flushMode the new flush mode
+ * @see FlushMode
+ */
+ public void setFlushMode(FlushMode flushMode);
+
+ /**
+ * Get the current flush mode for this session.
+ *
+ * @return The flush mode
+ */
+ public FlushMode getFlushMode();
+
+ /**
+ * Set the cache mode.
+ * <p/>
+ * Cache mode determines the manner in which this session can interact with
+ * the second level cache.
+ *
+ * @param cacheMode The new cache mode.
+ */
+ public void setCacheMode(CacheMode cacheMode);
+
+ /**
+ * Get the current cache mode.
+ *
+ * @return The current cache mode.
+ */
+ public CacheMode getCacheMode();
+
+ /**
+ * Get the session factory which created this session.
+ *
+ * @return The session factory.
+ * @see SessionFactory
+
+ */
+ public SessionFactory getSessionFactory();
+
+ /**
+ * Get the JDBC connection of this Session.<br>
+ * <br>
+ * If the session is using aggressive collection release (as in a
+ * CMT environment), it is the application's responsibility to
+ * close the connection returned by this call. Otherwise, the
+ * application should not close the connection.
+ *
+ * @return the JDBC connection in use by the <tt>Session</tt>
+ * @throws HibernateException if the <tt>Session</tt> is disconnected
+ * @deprecated (scheduled for removal in 4.x). Replacement depends on need; for doing direct JDBC stuff use
+ * {@link #doWork}; for opening a 'temporary Session' use (TBD).
+ */
+ public Connection connection() throws HibernateException;
+
+ /**
+ * End the session by releasing the JDBC connection and cleaning up. It is
+ * not strictly necessary to close the session but you must at least
+ * {@link #disconnect()} it.
+ *
+ * @return the connection provided by the application or null.
+ * @throws HibernateException Indicates problems cleaning up.
+ */
+ public Connection close() throws HibernateException;
+
+ /**
+ * Cancel the execution of the current query.
+ * <p/>
+ * This is the sole method on session which may be safely called from
+ * another thread.
+ *
+ * @throws HibernateException There was a problem canceling the query
+ */
+ public void cancelQuery() throws HibernateException;
+
+ /**
+ * Check if the session is still open.
+ *
+ * @return boolean
+ */
+ public boolean isOpen();
+
+ /**
+ * Check if the session is currently connected.
+ *
+ * @return boolean
+ */
+ public boolean isConnected();
+
+ /**
+ * Does this session contain any changes which must be synchronized with
+ * the database? In other words, would any DML operations be executed if
+ * we flushed this session?
+ *
+ * @return True if the session contains pending changes; false otherwise.
+ * @throws HibernateException could not perform dirtying checking
+ */
+ public boolean isDirty() throws HibernateException;
+
+ /**
+ * Return the identifier value of the given entity as associated with this
+ * session. An exception is thrown if the given entity instance is transient
+ * or detached in relation to this session.
+ *
+ * @param object a persistent instance
+ * @return the identifier
+ * @throws TransientObjectException if the instance is transient or associated with
+ * a different session
+ */
+ public Serializable getIdentifier(Object object) throws HibernateException;
+
+ /**
+ * Check if this instance is associated with this <tt>Session</tt>.
+ *
+ * @param object an instance of a persistent class
+ * @return true if the given instance is associated with this <tt>Session</tt>
+ */
+ public boolean contains(Object object);
+
+ /**
+ * Remove this instance from the session cache. Changes to the instance will
+ * not be synchronized with the database. This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="evict"</tt>.
+ *
+ * @param object a persistent instance
+ * @throws HibernateException
+ */
+ public void evict(Object object) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * obtaining the specified lock mode, assuming the instance exists.
+ *
+ * @param theClass a persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @param lockMode the lock level
+ * @return the persistent instance or proxy
+ * @throws HibernateException
+ */
+ public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * obtaining the specified lock mode, assuming the instance exists.
+ *
+ * @param entityName a persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @param lockMode the lock level
+ * @return the persistent instance or proxy
+ * @throws HibernateException
+ */
+ public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * assuming that the instance exists. This method might return a proxied instance that
+ * is initialized on-demand, when a non-identifier method is accessed.
+ * <br><br>
+ * You should not use this method to determine if an instance exists (use <tt>get()</tt>
+ * instead). Use this only to retrieve an instance that you assume exists, where non-existence
+ * would be an actual error.
+ *
+ * @param theClass a persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @return the persistent instance or proxy
+ * @throws HibernateException
+ */
+ public Object load(Class theClass, Serializable id) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * assuming that the instance exists. This method might return a proxied instance that
+ * is initialized on-demand, when a non-identifier method is accessed.
+ * <br><br>
+ * You should not use this method to determine if an instance exists (use <tt>get()</tt>
+ * instead). Use this only to retrieve an instance that you assume exists, where non-existence
+ * would be an actual error.
+ *
+ * @param entityName a persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @return the persistent instance or proxy
+ * @throws HibernateException
+ */
+ public Object load(String entityName, Serializable id) throws HibernateException;
+
+ /**
+ * Read the persistent state associated with the given identifier into the given transient
+ * instance.
+ *
+ * @param object an "empty" instance of the persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @throws HibernateException
+ */
+ public void load(Object object, Serializable id) throws HibernateException;
+
+ /**
+ * Persist the state of the given detached instance, reusing the current
+ * identifier value. This operation cascades to associated instances if
+ * the association is mapped with <tt>cascade="replicate"</tt>.
+ *
+ * @param object a detached instance of a persistent class
+ */
+ public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException;
+
+ /**
+ * Persist the state of the given detached instance, reusing the current
+ * identifier value. This operation cascades to associated instances if
+ * the association is mapped with <tt>cascade="replicate"</tt>.
+ *
+ * @param object a detached instance of a persistent class
+ */
+ public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException;
+
+ /**
+ * Persist the given transient instance, first assigning a generated identifier. (Or
+ * using the current value of the identifier property if the <tt>assigned</tt>
+ * generator is used.) This operation cascades to associated instances if the
+ * association is mapped with <tt>cascade="save-update"</tt>.
+ *
+ * @param object a transient instance of a persistent class
+ * @return the generated identifier
+ * @throws HibernateException
+ */
+ public Serializable save(Object object) throws HibernateException;
+
+ /**
+ * Persist the given transient instance, first assigning a generated identifier. (Or
+ * using the current value of the identifier property if the <tt>assigned</tt>
+ * generator is used.) This operation cascades to associated instances if the
+ * association is mapped with <tt>cascade="save-update"</tt>.
+ *
+ * @param object a transient instance of a persistent class
+ * @return the generated identifier
+ * @throws HibernateException
+ */
+ public Serializable save(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Either {@link #save(Object)} or {@link #update(Object)} the given
+ * instance, depending upon resolution of the unsaved-value checks (see the
+ * manual for discussion of unsaved-value checking).
+ * <p/>
+ * This operation cascades to associated instances if the association is mapped
+ * with <tt>cascade="save-update"</tt>.
+ *
+ * @see Session#save(java.lang.Object)
+ * @see Session#update(Object object)
+ * @param object a transient or detached instance containing new or updated state
+ * @throws HibernateException
+ */
+ public void saveOrUpdate(Object object) throws HibernateException;
+
+ /**
+ * Either {@link #save(String, Object)} or {@link #update(String, Object)}
+ * the given instance, depending upon resolution of the unsaved-value checks
+ * (see the manual for discussion of unsaved-value checking).
+ * <p/>
+ * This operation cascades to associated instances if the association is mapped
+ * with <tt>cascade="save-update"</tt>.
+ *
+ * @see Session#save(String,Object)
+ * @see Session#update(String,Object)
+ * @param object a transient or detached instance containing new or updated state
+ * @throws HibernateException
+ */
+ public void saveOrUpdate(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Update the persistent instance with the identifier of the given detached
+ * instance. If there is a persistent instance with the same identifier,
+ * an exception is thrown. This operation cascades to associated instances
+ * if the association is mapped with <tt>cascade="save-update"</tt>.
+ *
+ * @param object a detached instance containing updated state
+ * @throws HibernateException
+ */
+ public void update(Object object) throws HibernateException;
+
+ /**
+ * Update the persistent instance with the identifier of the given detached
+ * instance. If there is a persistent instance with the same identifier,
+ * an exception is thrown. This operation cascades to associated instances
+ * if the association is mapped with <tt>cascade="save-update"</tt>.
+ *
+ * @param object a detached instance containing updated state
+ * @throws HibernateException
+ */
+ public void update(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Copy the state of the given object onto the persistent object with the same
+ * identifier. If there is no persistent instance currently associated with
+ * the session, it will be loaded. Return the persistent instance. If the
+ * given instance is unsaved, save a copy of and return it as a newly persistent
+ * instance. The given instance does not become associated with the session.
+ * This operation cascades to associated instances if the association is mapped
+ * with <tt>cascade="merge"</tt>.<br>
+ * <br>
+ * The semantics of this method are defined by JSR-220.
+ *
+ * @param object a detached instance with state to be copied
+ * @return an updated persistent instance
+ */
+ public Object merge(Object object) throws HibernateException;
+
+ /**
+ * Copy the state of the given object onto the persistent object with the same
+ * identifier. If there is no persistent instance currently associated with
+ * the session, it will be loaded. Return the persistent instance. If the
+ * given instance is unsaved, save a copy of and return it as a newly persistent
+ * instance. The given instance does not become associated with the session.
+ * This operation cascades to associated instances if the association is mapped
+ * with <tt>cascade="merge"</tt>.<br>
+ * <br>
+ * The semantics of this method are defined by JSR-220.
+ *
+ * @param object a detached instance with state to be copied
+ * @return an updated persistent instance
+ */
+ public Object merge(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Make a transient instance persistent. This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
+ * <br>
+ * The semantics of this method are defined by JSR-220.
+ *
+ * @param object a transient instance to be made persistent
+ */
+ public void persist(Object object) throws HibernateException;
+ /**
+ * Make a transient instance persistent. This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="persist"</tt>.<br>
+ * <br>
+ * The semantics of this method are defined by JSR-220.
+ *
+ * @param object a transient instance to be made persistent
+ */
+ public void persist(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Remove a persistent instance from the datastore. The argument may be
+ * an instance associated with the receiving <tt>Session</tt> or a transient
+ * instance with an identifier associated with existing persistent state.
+ * This operation cascades to associated instances if the association is mapped
+ * with <tt>cascade="delete"</tt>.
+ *
+ * @param object the instance to be removed
+ * @throws HibernateException
+ */
+ public void delete(Object object) throws HibernateException;
+
+ /**
+ * Remove a persistent instance from the datastore. The <b>object</b> argument may be
+ * an instance associated with the receiving <tt>Session</tt> or a transient
+ * instance with an identifier associated with existing persistent state.
+ * This operation cascades to associated instances if the association is mapped
+ * with <tt>cascade="delete"</tt>.
+ *
+ * @param entityName The entity name for the instance to be removed.
+ * @param object the instance to be removed
+ * @throws HibernateException
+ */
+ public void delete(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Obtain the specified lock level upon the given object. This may be used to
+ * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
+ * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="lock"</tt>.
+ *
+ * @param object a persistent or transient instance
+ * @param lockMode the lock level
+ * @throws HibernateException
+ */
+ public void lock(Object object, LockMode lockMode) throws HibernateException;
+
+ /**
+ * Obtain the specified lock level upon the given object. This may be used to
+ * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
+ * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="lock"</tt>.
+ *
+ * @param object a persistent or transient instance
+ * @param lockMode the lock level
+ * @throws HibernateException
+ */
+ public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException;
+
+ /**
+ * Re-read the state of the given instance from the underlying database. It is
+ * inadvisable to use this to implement long-running sessions that span many
+ * business tasks. This method is, however, useful in certain special circumstances.
+ * For example
+ * <ul>
+ * <li>where a database trigger alters the object state upon insert or update
+ * <li>after executing direct SQL (eg. a mass update) in the same session
+ * <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt>
+ * </ul>
+ *
+ * @param object a persistent or detached instance
+ * @throws HibernateException
+ */
+ public void refresh(Object object) throws HibernateException;
+
+ /**
+ * Re-read the state of the given instance from the underlying database, with
+ * the given <tt>LockMode</tt>. It is inadvisable to use this to implement
+ * long-running sessions that span many business tasks. This method is, however,
+ * useful in certain special circumstances.
+ *
+ * @param object a persistent or detached instance
+ * @param lockMode the lock mode to use
+ * @throws HibernateException
+ */
+ public void refresh(Object object, LockMode lockMode) throws HibernateException;
+
+ /**
+ * Determine the current lock mode of the given object.
+ *
+ * @param object a persistent instance
+ * @return the current lock mode
+ * @throws HibernateException
+ */
+ public LockMode getCurrentLockMode(Object object) throws HibernateException;
+
+ /**
+ * Begin a unit of work and return the associated <tt>Transaction</tt> object.
+ * If a new underlying transaction is required, begin the transaction. Otherwise
+ * continue the new work in the context of the existing underlying transaction.
+ * The class of the returned <tt>Transaction</tt> object is determined by the
+ * property <tt>hibernate.transaction_factory</tt>.
+ *
+ * @return a Transaction instance
+ * @throws HibernateException
+ * @see Transaction
+ */
+ public Transaction beginTransaction() throws HibernateException;
+
+ /**
+ * Get the <tt>Transaction</tt> instance associated with this session.
+ * The class of the returned <tt>Transaction</tt> object is determined by the
+ * property <tt>hibernate.transaction_factory</tt>.
+ *
+ * @return a Transaction instance
+ * @throws HibernateException
+ * @see Transaction
+ */
+ public Transaction getTransaction();
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity class,
+ * or a superclass of an entity class.
+ *
+ * @param persistentClass a class, which is persistent, or has persistent subclasses
+ * @return Criteria
+ */
+ public Criteria createCriteria(Class persistentClass);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity class,
+ * or a superclass of an entity class, with the given alias.
+ *
+ * @param persistentClass a class, which is persistent, or has persistent subclasses
+ * @return Criteria
+ */
+ public Criteria createCriteria(Class persistentClass, String alias);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity name.
+ *
+ * @param entityName
+ * @return Criteria
+ */
+ public Criteria createCriteria(String entityName);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity name,
+ * with the given alias.
+ *
+ * @param entityName
+ * @return Criteria
+ */
+ public Criteria createCriteria(String entityName, String alias);
+
+ /**
+ * Create a new instance of <tt>Query</tt> for the given HQL query string.
+ *
+ * @param queryString a HQL query
+ * @return Query
+ * @throws HibernateException
+ */
+ public Query createQuery(String queryString) throws HibernateException;
+
+ /**
+ * Create a new instance of <tt>SQLQuery</tt> for the given SQL query string.
+ *
+ * @param queryString a SQL query
+ * @return SQLQuery
+ * @throws HibernateException
+ */
+ public SQLQuery createSQLQuery(String queryString) throws HibernateException;
+
+ /**
+ * Create a new instance of <tt>Query</tt> for the given collection and filter string.
+ *
+ * @param collection a persistent collection
+ * @param queryString a Hibernate query
+ * @return Query
+ * @throws HibernateException
+ */
+ public Query createFilter(Object collection, String queryString) throws HibernateException;
+
+ /**
+ * Obtain an instance of <tt>Query</tt> for a named query string defined in the
+ * mapping file.
+ *
+ * @param queryName the name of a query defined externally
+ * @return Query
+ * @throws HibernateException
+ */
+ public Query getNamedQuery(String queryName) throws HibernateException;
+
+ /**
+ * Completely clear the session. Evict all loaded instances and cancel all pending
+ * saves, updates and deletions. Do not close open iterators or instances of
+ * <tt>ScrollableResults</tt>.
+ */
+ public void clear();
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * or null if there is no such persistent instance. (If the instance is already associated
+ * with the session, return that instance. This method never returns an uninitialized instance.)
+ * Obtain the specified lock mode if the instance exists.
+ *
+ * @param clazz a persistent class
+ * @param id an identifier
+ * @return a persistent instance or null
+ * @throws HibernateException
+ */
+ public Object get(Class clazz, Serializable id) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * or null if there is no such persistent instance. (If the instance is already associated
+ * with the session, return that instance. This method never returns an uninitialized instance.)
+ * Obtain the specified lock mode if the instance exists.
+ *
+ * @param clazz a persistent class
+ * @param id an identifier
+ * @param lockMode the lock mode
+ * @return a persistent instance or null
+ * @throws HibernateException
+ */
+ public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given named entity with the given identifier,
+ * or null if there is no such persistent instance. (If the instance is already associated
+ * with the session, return that instance. This method never returns an uninitialized instance.)
+ *
+ * @param entityName the entity name
+ * @param id an identifier
+ * @return a persistent instance or null
+ * @throws HibernateException
+ */
+ public Object get(String entityName, Serializable id) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * or null if there is no such persistent instance. (If the instance is already associated
+ * with the session, return that instance. This method never returns an uninitialized instance.)
+ * Obtain the specified lock mode if the instance exists.
+ *
+ * @param entityName the entity name
+ * @param id an identifier
+ * @param lockMode the lock mode
+ * @return a persistent instance or null
+ * @throws HibernateException
+ */
+ public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
+
+
+ /**
+ * Return the entity name for a persistent entity
+ *
+ * @param object a persistent entity
+ * @return the entity name
+ * @throws HibernateException
+ */
+ public String getEntityName(Object object) throws HibernateException;
+
+ /**
+ * Enable the named filter for this current session.
+ *
+ * @param filterName The name of the filter to be enabled.
+ * @return The Filter instance representing the enabled fiter.
+ */
+ public Filter enableFilter(String filterName);
+
+ /**
+ * Retrieve a currently enabled filter by name.
+ *
+ * @param filterName The name of the filter to be retrieved.
+ * @return The Filter instance representing the enabled fiter.
+ */
+ public Filter getEnabledFilter(String filterName);
+
+ /**
+ * Disable the named filter for the current session.
+ *
+ * @param filterName The name of the filter to be disabled.
+ */
+ public void disableFilter(String filterName);
+
+ /**
+ * Get the statistics for this session.
+ */
+ public SessionStatistics getStatistics();
+
+ /**
+ * Set an unmodified persistent object to read only mode, or a read only
+ * object to modifiable mode. In read only mode, no snapshot is maintained
+ * and the instance is never dirty checked.
+ *
+ * @see Query#setReadOnly(boolean)
+ */
+ public void setReadOnly(Object entity, boolean readOnly);
+
+ /**
+ * Controller for allowing users to perform JDBC related work using the Connection
+ * managed by this Session.
+ *
+ * @param work The work to be performed.
+ * @throws HibernateException Generally indicates wrapped {@link java.sql.SQLException}
+ */
+ public void doWork(Work work) throws HibernateException;
+
+
+ /**
+ * Disconnect the <tt>Session</tt> from the current JDBC connection. If
+ * the connection was obtained by Hibernate close it and return it to
+ * the connection pool; otherwise, return it to the application.
+ * <p/>
+ * This is used by applications which supply JDBC connections to Hibernate
+ * and which require long-sessions (or long-conversations)
+ * <p/>
+ * Note that disconnect() called on a session where the connection was
+ * retrieved by Hibernate through its configured
+ * {@link org.hibernate.connection.ConnectionProvider} has no effect,
+ * provided {@link ConnectionReleaseMode#ON_CLOSE} is not in effect.
+ *
+ * @return the application-supplied connection or <tt>null</tt>
+ * @see #reconnect(Connection)
+ * @see #reconnect()
+ */
+ Connection disconnect() throws HibernateException;
+
+ /**
+ * Obtain a new JDBC connection. This is used by applications which
+ * require long transactions and do not supply connections to the
+ * session.
+ *
+ * @see #disconnect()
+ * @deprecated Manual reconnection is only needed in the case of
+ * application-supplied connections, in which case the
+ * {@link #reconnect(java.sql.Connection)} for should be used.
+ */
+ void reconnect() throws HibernateException;
+
+ /**
+ * Reconnect to the given JDBC connection. This is used by applications
+ * which require long transactions and use application-supplied connections.
+ *
+ * @param connection a JDBC connection
+ * @see #disconnect()
+ */
+ void reconnect(Connection connection) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/SessionException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-//$Id: SessionException.java 9024 2006-01-11 22:38:24Z steveebersole $
-package org.hibernate;
-
-/**
- * Thrown when the user calls a method of a {@link Session} that is in an
- * inappropropriate state for the given call (for example, the the session
- * is closed or disconnected).
- *
- * @author Gavin King
- */
-public class SessionException extends HibernateException {
-
- /**
- * Constructs a new SessionException with the given message.
- *
- * @param message The message indicating the specific problem.
- */
- public SessionException(String message) {
- super( message );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/SessionException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when the user calls a method of a {@link Session} that is in an
+ * inappropropriate state for the given call (for example, the the session
+ * is closed or disconnected).
+ *
+ * @author Gavin King
+ */
+public class SessionException extends HibernateException {
+
+ /**
+ * Constructs a new SessionException with the given message.
+ *
+ * @param message The message indicating the specific problem.
+ */
+ public SessionException(String message) {
+ super( message );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/SessionFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,224 +0,0 @@
-//$Id: SessionFactory.java 8754 2005-12-05 23:36:59Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.Referenceable;
-
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.metadata.CollectionMetadata;
-import org.hibernate.stat.Statistics;
-import org.hibernate.engine.FilterDefinition;
-
-/**
- * Creates <tt>Session</tt>s. Usually an application has a single <tt>SessionFactory</tt>.
- * Threads servicing client requests obtain <tt>Session</tt>s from the factory.<br>
- * <br>
- * Implementors must be threadsafe.<br>
- * <br>
- * <tt>SessionFactory</tt>s are immutable. The behaviour of a <tt>SessionFactory</tt> is
- * controlled by properties supplied at configuration time. These properties are defined
- * on <tt>Environment</tt>.
- *
- * @see Session
- * @see org.hibernate.cfg.Environment
- * @see org.hibernate.cfg.Configuration
- * @see org.hibernate.connection.ConnectionProvider
- * @see org.hibernate.transaction.TransactionFactory
- * @author Gavin King
- */
-public interface SessionFactory extends Referenceable, Serializable {
-
- /**
- * Open a <tt>Session</tt> on the given connection.
- * <p>
- * Note that the second-level cache will be disabled if you
- * supply a JDBC connection. Hibernate will not be able to track
- * any statements you might have executed in the same transaction.
- * Consider implementing your own <tt>ConnectionProvider</tt>.
- *
- * @param connection a connection provided by the application.
- * @return Session
- */
- public org.hibernate.classic.Session openSession(Connection connection);
-
- /**
- * Create database connection and open a <tt>Session</tt> on it, specifying an
- * interceptor.
- *
- * @param interceptor a session-scoped interceptor
- * @return Session
- * @throws HibernateException
- */
- public org.hibernate.classic.Session openSession(Interceptor interceptor) throws HibernateException;
-
- /**
- * Open a <tt>Session</tt> on the given connection, specifying an interceptor.
- * <p>
- * Note that the second-level cache will be disabled if you
- * supply a JDBC connection. Hibernate will not be able to track
- * any statements you might have executed in the same transaction.
- * Consider implementing your own <tt>ConnectionProvider</tt>.
- *
- * @param connection a connection provided by the application.
- * @param interceptor a session-scoped interceptor
- * @return Session
- */
- public org.hibernate.classic.Session openSession(Connection connection, Interceptor interceptor);
-
- /**
- * Create database connection and open a <tt>Session</tt> on it.
- *
- * @return Session
- * @throws HibernateException
- */
- public org.hibernate.classic.Session openSession() throws HibernateException;
-
- /**
- * Obtains the current session. The definition of what exactly "current"
- * means controlled by the {@link org.hibernate.context.CurrentSessionContext} impl configured
- * for use.
- * <p/>
- * Note that for backwards compatibility, if a {@link org.hibernate.context.CurrentSessionContext}
- * is not configured but a JTA {@link org.hibernate.transaction.TransactionManagerLookup}
- * is configured this will default to the {@link org.hibernate.context.JTASessionContext}
- * impl.
- *
- * @return The current session.
- * @throws HibernateException Indicates an issue locating a suitable current session.
- */
- public org.hibernate.classic.Session getCurrentSession() throws HibernateException;
-
- /**
- * Get the <tt>ClassMetadata</tt> associated with the given entity class
- *
- * @see org.hibernate.metadata.ClassMetadata
- */
- public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException;
-
- /**
- * Get the <tt>ClassMetadata</tt> associated with the given entity name
- *
- * @see org.hibernate.metadata.ClassMetadata
- * @since 3.0
- */
- public ClassMetadata getClassMetadata(String entityName) throws HibernateException;
-
- /**
- * Get the <tt>CollectionMetadata</tt> associated with the named collection role
- *
- * @see org.hibernate.metadata.CollectionMetadata
- */
- public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException;
-
-
- /**
- * Get all <tt>ClassMetadata</tt> as a <tt>Map</tt> from entityname <tt>String</tt>
- * to metadata object
- *
- * @see org.hibernate.metadata.ClassMetadata
- * @return a map from <tt>String</tt> an entity name to <tt>ClassMetaData</tt>
- * @since 3.0 changed key from <tt>Class</tt> to <tt>String</tt>
- */
- public Map getAllClassMetadata() throws HibernateException;
-
- /**
- * Get all <tt>CollectionMetadata</tt> as a <tt>Map</tt> from role name
- * to metadata object
- *
- * @see org.hibernate.metadata.CollectionMetadata
- * @return a map from <tt>String</tt> to <tt>CollectionMetadata</tt>
- */
- public Map getAllCollectionMetadata() throws HibernateException;
-
- /**
- * Get the statistics for this session factory
- */
- public Statistics getStatistics();
-
- /**
- * Destroy this <tt>SessionFactory</tt> and release all resources (caches,
- * connection pools, etc). It is the responsibility of the application
- * to ensure that there are no open <tt>Session</tt>s before calling
- * <tt>close()</tt>.
- */
- public void close() throws HibernateException;
-
- /**
- * Was this <tt>SessionFactory</tt> already closed?
- */
- public boolean isClosed();
-
- /**
- * Evict all entries from the second-level cache. This method occurs outside
- * of any transaction; it performs an immediate "hard" remove, so does not respect
- * any transaction isolation semantics of the usage strategy. Use with care.
- */
- public void evict(Class persistentClass) throws HibernateException;
- /**
- * Evict an entry from the second-level cache. This method occurs outside
- * of any transaction; it performs an immediate "hard" remove, so does not respect
- * any transaction isolation semantics of the usage strategy. Use with care.
- */
- public void evict(Class persistentClass, Serializable id) throws HibernateException;
- /**
- * Evict all entries from the second-level cache. This method occurs outside
- * of any transaction; it performs an immediate "hard" remove, so does not respect
- * any transaction isolation semantics of the usage strategy. Use with care.
- */
- public void evictEntity(String entityName) throws HibernateException;
- /**
- * Evict an entry from the second-level cache. This method occurs outside
- * of any transaction; it performs an immediate "hard" remove, so does not respect
- * any transaction isolation semantics of the usage strategy. Use with care.
- */
- public void evictEntity(String entityName, Serializable id) throws HibernateException;
- /**
- * Evict all entries from the second-level cache. This method occurs outside
- * of any transaction; it performs an immediate "hard" remove, so does not respect
- * any transaction isolation semantics of the usage strategy. Use with care.
- */
- public void evictCollection(String roleName) throws HibernateException;
- /**
- * Evict an entry from the second-level cache. This method occurs outside
- * of any transaction; it performs an immediate "hard" remove, so does not respect
- * any transaction isolation semantics of the usage strategy. Use with care.
- */
- public void evictCollection(String roleName, Serializable id) throws HibernateException;
-
- /**
- * Evict any query result sets cached in the default query cache region.
- */
- public void evictQueries() throws HibernateException;
- /**
- * Evict any query result sets cached in the named query cache region.
- */
- public void evictQueries(String cacheRegion) throws HibernateException;
- /**
- * Get a new stateless session.
- */
- public StatelessSession openStatelessSession();
- /**
- * Get a new stateless session for the given JDBC connection.
- */
- public StatelessSession openStatelessSession(Connection connection);
-
- /**
- * Obtain a set of the names of all filters defined on this SessionFactory.
- *
- * @return The set of filter names.
- */
- public Set getDefinedFilterNames();
-
- /**
- * Obtain the definition of a filter by name.
- *
- * @param filterName The name of the filter for which to obtain the definition.
- * @return The filter definition.
- * @throws HibernateException If no filter defined with the given name.
- */
- public FilterDefinition getFilterDefinition(String filterName) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/SessionFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,247 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Referenceable;
+
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.metadata.CollectionMetadata;
+import org.hibernate.stat.Statistics;
+import org.hibernate.engine.FilterDefinition;
+
+/**
+ * Creates <tt>Session</tt>s. Usually an application has a single <tt>SessionFactory</tt>.
+ * Threads servicing client requests obtain <tt>Session</tt>s from the factory.<br>
+ * <br>
+ * Implementors must be threadsafe.<br>
+ * <br>
+ * <tt>SessionFactory</tt>s are immutable. The behaviour of a <tt>SessionFactory</tt> is
+ * controlled by properties supplied at configuration time. These properties are defined
+ * on <tt>Environment</tt>.
+ *
+ * @see Session
+ * @see org.hibernate.cfg.Environment
+ * @see org.hibernate.cfg.Configuration
+ * @see org.hibernate.connection.ConnectionProvider
+ * @see org.hibernate.transaction.TransactionFactory
+ * @author Gavin King
+ */
+public interface SessionFactory extends Referenceable, Serializable {
+
+ /**
+ * Open a <tt>Session</tt> on the given connection.
+ * <p>
+ * Note that the second-level cache will be disabled if you
+ * supply a JDBC connection. Hibernate will not be able to track
+ * any statements you might have executed in the same transaction.
+ * Consider implementing your own <tt>ConnectionProvider</tt>.
+ *
+ * @param connection a connection provided by the application.
+ * @return Session
+ */
+ public org.hibernate.classic.Session openSession(Connection connection);
+
+ /**
+ * Create database connection and open a <tt>Session</tt> on it, specifying an
+ * interceptor.
+ *
+ * @param interceptor a session-scoped interceptor
+ * @return Session
+ * @throws HibernateException
+ */
+ public org.hibernate.classic.Session openSession(Interceptor interceptor) throws HibernateException;
+
+ /**
+ * Open a <tt>Session</tt> on the given connection, specifying an interceptor.
+ * <p>
+ * Note that the second-level cache will be disabled if you
+ * supply a JDBC connection. Hibernate will not be able to track
+ * any statements you might have executed in the same transaction.
+ * Consider implementing your own <tt>ConnectionProvider</tt>.
+ *
+ * @param connection a connection provided by the application.
+ * @param interceptor a session-scoped interceptor
+ * @return Session
+ */
+ public org.hibernate.classic.Session openSession(Connection connection, Interceptor interceptor);
+
+ /**
+ * Create database connection and open a <tt>Session</tt> on it.
+ *
+ * @return Session
+ * @throws HibernateException
+ */
+ public org.hibernate.classic.Session openSession() throws HibernateException;
+
+ /**
+ * Obtains the current session. The definition of what exactly "current"
+ * means controlled by the {@link org.hibernate.context.CurrentSessionContext} impl configured
+ * for use.
+ * <p/>
+ * Note that for backwards compatibility, if a {@link org.hibernate.context.CurrentSessionContext}
+ * is not configured but a JTA {@link org.hibernate.transaction.TransactionManagerLookup}
+ * is configured this will default to the {@link org.hibernate.context.JTASessionContext}
+ * impl.
+ *
+ * @return The current session.
+ * @throws HibernateException Indicates an issue locating a suitable current session.
+ */
+ public org.hibernate.classic.Session getCurrentSession() throws HibernateException;
+
+ /**
+ * Get the <tt>ClassMetadata</tt> associated with the given entity class
+ *
+ * @see org.hibernate.metadata.ClassMetadata
+ */
+ public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException;
+
+ /**
+ * Get the <tt>ClassMetadata</tt> associated with the given entity name
+ *
+ * @see org.hibernate.metadata.ClassMetadata
+ * @since 3.0
+ */
+ public ClassMetadata getClassMetadata(String entityName) throws HibernateException;
+
+ /**
+ * Get the <tt>CollectionMetadata</tt> associated with the named collection role
+ *
+ * @see org.hibernate.metadata.CollectionMetadata
+ */
+ public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException;
+
+
+ /**
+ * Get all <tt>ClassMetadata</tt> as a <tt>Map</tt> from entityname <tt>String</tt>
+ * to metadata object
+ *
+ * @see org.hibernate.metadata.ClassMetadata
+ * @return a map from <tt>String</tt> an entity name to <tt>ClassMetaData</tt>
+ * @since 3.0 changed key from <tt>Class</tt> to <tt>String</tt>
+ */
+ public Map getAllClassMetadata() throws HibernateException;
+
+ /**
+ * Get all <tt>CollectionMetadata</tt> as a <tt>Map</tt> from role name
+ * to metadata object
+ *
+ * @see org.hibernate.metadata.CollectionMetadata
+ * @return a map from <tt>String</tt> to <tt>CollectionMetadata</tt>
+ */
+ public Map getAllCollectionMetadata() throws HibernateException;
+
+ /**
+ * Get the statistics for this session factory
+ */
+ public Statistics getStatistics();
+
+ /**
+ * Destroy this <tt>SessionFactory</tt> and release all resources (caches,
+ * connection pools, etc). It is the responsibility of the application
+ * to ensure that there are no open <tt>Session</tt>s before calling
+ * <tt>close()</tt>.
+ */
+ public void close() throws HibernateException;
+
+ /**
+ * Was this <tt>SessionFactory</tt> already closed?
+ */
+ public boolean isClosed();
+
+ /**
+ * Evict all entries from the second-level cache. This method occurs outside
+ * of any transaction; it performs an immediate "hard" remove, so does not respect
+ * any transaction isolation semantics of the usage strategy. Use with care.
+ */
+ public void evict(Class persistentClass) throws HibernateException;
+ /**
+ * Evict an entry from the second-level cache. This method occurs outside
+ * of any transaction; it performs an immediate "hard" remove, so does not respect
+ * any transaction isolation semantics of the usage strategy. Use with care.
+ */
+ public void evict(Class persistentClass, Serializable id) throws HibernateException;
+ /**
+ * Evict all entries from the second-level cache. This method occurs outside
+ * of any transaction; it performs an immediate "hard" remove, so does not respect
+ * any transaction isolation semantics of the usage strategy. Use with care.
+ */
+ public void evictEntity(String entityName) throws HibernateException;
+ /**
+ * Evict an entry from the second-level cache. This method occurs outside
+ * of any transaction; it performs an immediate "hard" remove, so does not respect
+ * any transaction isolation semantics of the usage strategy. Use with care.
+ */
+ public void evictEntity(String entityName, Serializable id) throws HibernateException;
+ /**
+ * Evict all entries from the second-level cache. This method occurs outside
+ * of any transaction; it performs an immediate "hard" remove, so does not respect
+ * any transaction isolation semantics of the usage strategy. Use with care.
+ */
+ public void evictCollection(String roleName) throws HibernateException;
+ /**
+ * Evict an entry from the second-level cache. This method occurs outside
+ * of any transaction; it performs an immediate "hard" remove, so does not respect
+ * any transaction isolation semantics of the usage strategy. Use with care.
+ */
+ public void evictCollection(String roleName, Serializable id) throws HibernateException;
+
+ /**
+ * Evict any query result sets cached in the default query cache region.
+ */
+ public void evictQueries() throws HibernateException;
+ /**
+ * Evict any query result sets cached in the named query cache region.
+ */
+ public void evictQueries(String cacheRegion) throws HibernateException;
+ /**
+ * Get a new stateless session.
+ */
+ public StatelessSession openStatelessSession();
+ /**
+ * Get a new stateless session for the given JDBC connection.
+ */
+ public StatelessSession openStatelessSession(Connection connection);
+
+ /**
+ * Obtain a set of the names of all filters defined on this SessionFactory.
+ *
+ * @return The set of filter names.
+ */
+ public Set getDefinedFilterNames();
+
+ /**
+ * Obtain the definition of a filter by name.
+ *
+ * @param filterName The name of the filter for which to obtain the definition.
+ * @return The filter definition.
+ * @throws HibernateException If no filter defined with the given name.
+ */
+ public FilterDefinition getFilterDefinition(String filterName) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/SessionFactoryObserver.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,48 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate;
-
-import java.io.Serializable;
-
-/**
- * Allows reaction to basic {@link SessionFactory} occurrences.
- *
- * @author Steve Ebersole
- */
-public interface SessionFactoryObserver extends Serializable {
- /**
- * Callback to indicate that the given factory has been created and is now ready for use.
- *
- * @param factory The factory initialized.
- */
- public void sessionFactoryCreated(SessionFactory factory);
-
- /**
- * Callback to indicate that the given factory has been closed. Care should be taken
- * in how (if at all) the passed factory reference is used since it is closed.
- *
- * @param factory The factory closed.
- */
- public void sessionFactoryClosed(SessionFactory factory);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/SessionFactoryObserver.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/SessionFactoryObserver.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+/**
+ * Allows reaction to basic {@link SessionFactory} occurrences.
+ *
+ * @author Steve Ebersole
+ */
+public interface SessionFactoryObserver extends Serializable {
+ /**
+ * Callback to indicate that the given factory has been created and is now ready for use.
+ *
+ * @param factory The factory initialized.
+ */
+ public void sessionFactoryCreated(SessionFactory factory);
+
+ /**
+ * Callback to indicate that the given factory has been closed. Care should be taken
+ * in how (if at all) the passed factory reference is used since it is closed.
+ *
+ * @param factory The factory closed.
+ */
+ public void sessionFactoryClosed(SessionFactory factory);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/StaleObjectStateException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: StaleObjectStateException.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-
-import org.hibernate.pretty.MessageHelper;
-
-/**
- * A <tt>StaleStateException</tt> that carries information
- * about a particular entity instance that was the source
- * of the failure.
- *
- * @author Gavin King
- */
-public class StaleObjectStateException extends StaleStateException {
- private final String entityName;
- private final Serializable identifier;
-
- public StaleObjectStateException(String persistentClass, Serializable identifier) {
- super("Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)");
- this.entityName = persistentClass;
- this.identifier = identifier;
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getMessage() {
- return super.getMessage() + ": " +
- MessageHelper.infoString(entityName, identifier);
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/StaleObjectStateException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleObjectStateException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+import org.hibernate.pretty.MessageHelper;
+
+/**
+ * A <tt>StaleStateException</tt> that carries information
+ * about a particular entity instance that was the source
+ * of the failure.
+ *
+ * @author Gavin King
+ */
+public class StaleObjectStateException extends StaleStateException {
+ private final String entityName;
+ private final Serializable identifier;
+
+ public StaleObjectStateException(String persistentClass, Serializable identifier) {
+ super("Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)");
+ this.entityName = persistentClass;
+ this.identifier = identifier;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public Serializable getIdentifier() {
+ return identifier;
+ }
+
+ public String getMessage() {
+ return super.getMessage() + ": " +
+ MessageHelper.infoString(entityName, identifier);
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/StaleStateException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: StaleStateException.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate;
-
-/**
- * Thrown when a version number or timestamp check failed, indicating that the
- * <tt>Session</tt> contained stale data (when using long transactions
- * with versioning). Also occurs if we try delete or update a row that does
- * not exist.<br>
- * <br>
- * Note that this exception often indicates that the user failed to specify the
- * correct <tt>unsaved-value</tt> strategy for a class!
- *
- * @see StaleObjectStateException
- * @author Gavin King
- */
-public class StaleStateException extends HibernateException {
-
- public StaleStateException(String s) {
- super(s);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/StaleStateException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StaleStateException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when a version number or timestamp check failed, indicating that the
+ * <tt>Session</tt> contained stale data (when using long transactions
+ * with versioning). Also occurs if we try delete or update a row that does
+ * not exist.<br>
+ * <br>
+ * Note that this exception often indicates that the user failed to specify the
+ * correct <tt>unsaved-value</tt> strategy for a class!
+ *
+ * @see StaleObjectStateException
+ * @author Gavin King
+ */
+public class StaleStateException extends HibernateException {
+
+ public StaleStateException(String s) {
+ super(s);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/StatelessSession.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,217 +0,0 @@
-//$Id: StatelessSession.java 9705 2006-03-28 19:59:31Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-import java.io.Serializable;
-import java.sql.Connection;
-
-/**
- * A command-oriented API for performing bulk operations
- * against a database.<br>
- * <br>
- * A stateless session does not implement a first-level cache nor
- * interact with any second-level cache, nor does it implement
- * transactional write-behind or automatic dirty checking, nor do
- * operations cascade to associated instances. Collections are
- * ignored by a stateless session. Operations performed via a
- * stateless session bypass Hibernate's event model and
- * interceptors. Stateless sessions are vulnerable to data
- * aliasing effects, due to the lack of a first-level cache.<br>
- * <br>
- * For certain kinds of transactions, a stateless session may
- * perform slightly faster than a stateful session.
- *
- * @author Gavin King
- */
-public interface StatelessSession extends Serializable {
- /**
- * Close the stateless session and release the JDBC connection.
- */
- public void close();
-
- /**
- * Insert a row.
- *
- * @param entity a new transient instance
- */
- public Serializable insert(Object entity);
-
- /**
- * Insert a row.
- *
- * @param entityName The entityName for the entity to be inserted
- * @param entity a new transient instance
- * @return the identifier of the instance
- */
- public Serializable insert(String entityName, Object entity);
-
- /**
- * Update a row.
- *
- * @param entity a detached entity instance
- */
- public void update(Object entity);
-
- /**
- * Update a row.
- *
- * @param entityName The entityName for the entity to be updated
- * @param entity a detached entity instance
- */
- public void update(String entityName, Object entity);
-
- /**
- * Delete a row.
- *
- * @param entity a detached entity instance
- */
- public void delete(Object entity);
-
- /**
- * Delete a row.
- *
- * @param entityName The entityName for the entity to be deleted
- * @param entity a detached entity instance
- */
- public void delete(String entityName, Object entity);
-
- /**
- * Retrieve a row.
- *
- * @return a detached entity instance
- */
- public Object get(String entityName, Serializable id);
-
- /**
- * Retrieve a row.
- *
- * @return a detached entity instance
- */
- public Object get(Class entityClass, Serializable id);
-
- /**
- * Retrieve a row, obtaining the specified lock mode.
- *
- * @return a detached entity instance
- */
- public Object get(String entityName, Serializable id, LockMode lockMode);
-
- /**
- * Retrieve a row, obtaining the specified lock mode.
- *
- * @return a detached entity instance
- */
- public Object get(Class entityClass, Serializable id, LockMode lockMode);
-
- /**
- * Refresh the entity instance state from the database.
- *
- * @param entity The entity to be refreshed.
- */
- public void refresh(Object entity);
-
- /**
- * Refresh the entity instance state from the database.
- *
- * @param entityName The entityName for the entity to be refreshed.
- * @param entity The entity to be refreshed.
- */
- public void refresh(String entityName, Object entity);
-
- /**
- * Refresh the entity instance state from the database.
- *
- * @param entity The entity to be refreshed.
- * @param lockMode The LockMode to be applied.
- */
- public void refresh(Object entity, LockMode lockMode);
-
- /**
- * Refresh the entity instance state from the database.
- *
- * @param entityName The entityName for the entity to be refreshed.
- * @param entity The entity to be refreshed.
- * @param lockMode The LockMode to be applied.
- */
- public void refresh(String entityName, Object entity, LockMode lockMode);
-
- /**
- * Create a new instance of <tt>Query</tt> for the given HQL query string.
- * Entities returned by the query are detached.
- */
- public Query createQuery(String queryString);
-
- /**
- * Obtain an instance of <tt>Query</tt> for a named query string defined in
- * the mapping file. Entities returned by the query are detached.
- */
- public Query getNamedQuery(String queryName);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity class,
- * or a superclass of an entity class. Entities returned by the query are
- * detached.
- *
- * @param persistentClass a class, which is persistent, or has persistent subclasses
- * @return Criteria
- */
- public Criteria createCriteria(Class persistentClass);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity class,
- * or a superclass of an entity class, with the given alias.
- * Entities returned by the query are detached.
- *
- * @param persistentClass a class, which is persistent, or has persistent subclasses
- * @return Criteria
- */
- public Criteria createCriteria(Class persistentClass, String alias);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity name.
- * Entities returned by the query are detached.
- *
- * @param entityName
- * @return Criteria
- */
- public Criteria createCriteria(String entityName);
-
- /**
- * Create a new <tt>Criteria</tt> instance, for the given entity name,
- * with the given alias. Entities returned by the query are detached.
- *
- * @param entityName
- * @return Criteria
- */
- public Criteria createCriteria(String entityName, String alias);
-
- /**
- * Create a new instance of <tt>SQLQuery</tt> for the given SQL query string.
- * Entities returned by the query are detached.
- *
- * @param queryString a SQL query
- * @return SQLQuery
- * @throws HibernateException
- */
- public SQLQuery createSQLQuery(String queryString) throws HibernateException;
-
- /**
- * Begin a Hibernate transaction.
- */
- public Transaction beginTransaction();
-
- /**
- * Get the current Hibernate transaction.
- */
- public Transaction getTransaction();
-
- /**
- * Returns the current JDBC connection associated with this
- * instance.<br>
- * <br>
- * If the session is using aggressive connection release (as in a
- * CMT environment), it is the application's responsibility to
- * close the connection returned by this call. Otherwise, the
- * application should not close the connection.
- */
- public Connection connection();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/StatelessSession.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/StatelessSession.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,240 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+import java.sql.Connection;
+
+/**
+ * A command-oriented API for performing bulk operations
+ * against a database.<br>
+ * <br>
+ * A stateless session does not implement a first-level cache nor
+ * interact with any second-level cache, nor does it implement
+ * transactional write-behind or automatic dirty checking, nor do
+ * operations cascade to associated instances. Collections are
+ * ignored by a stateless session. Operations performed via a
+ * stateless session bypass Hibernate's event model and
+ * interceptors. Stateless sessions are vulnerable to data
+ * aliasing effects, due to the lack of a first-level cache.<br>
+ * <br>
+ * For certain kinds of transactions, a stateless session may
+ * perform slightly faster than a stateful session.
+ *
+ * @author Gavin King
+ */
+public interface StatelessSession extends Serializable {
+ /**
+ * Close the stateless session and release the JDBC connection.
+ */
+ public void close();
+
+ /**
+ * Insert a row.
+ *
+ * @param entity a new transient instance
+ */
+ public Serializable insert(Object entity);
+
+ /**
+ * Insert a row.
+ *
+ * @param entityName The entityName for the entity to be inserted
+ * @param entity a new transient instance
+ * @return the identifier of the instance
+ */
+ public Serializable insert(String entityName, Object entity);
+
+ /**
+ * Update a row.
+ *
+ * @param entity a detached entity instance
+ */
+ public void update(Object entity);
+
+ /**
+ * Update a row.
+ *
+ * @param entityName The entityName for the entity to be updated
+ * @param entity a detached entity instance
+ */
+ public void update(String entityName, Object entity);
+
+ /**
+ * Delete a row.
+ *
+ * @param entity a detached entity instance
+ */
+ public void delete(Object entity);
+
+ /**
+ * Delete a row.
+ *
+ * @param entityName The entityName for the entity to be deleted
+ * @param entity a detached entity instance
+ */
+ public void delete(String entityName, Object entity);
+
+ /**
+ * Retrieve a row.
+ *
+ * @return a detached entity instance
+ */
+ public Object get(String entityName, Serializable id);
+
+ /**
+ * Retrieve a row.
+ *
+ * @return a detached entity instance
+ */
+ public Object get(Class entityClass, Serializable id);
+
+ /**
+ * Retrieve a row, obtaining the specified lock mode.
+ *
+ * @return a detached entity instance
+ */
+ public Object get(String entityName, Serializable id, LockMode lockMode);
+
+ /**
+ * Retrieve a row, obtaining the specified lock mode.
+ *
+ * @return a detached entity instance
+ */
+ public Object get(Class entityClass, Serializable id, LockMode lockMode);
+
+ /**
+ * Refresh the entity instance state from the database.
+ *
+ * @param entity The entity to be refreshed.
+ */
+ public void refresh(Object entity);
+
+ /**
+ * Refresh the entity instance state from the database.
+ *
+ * @param entityName The entityName for the entity to be refreshed.
+ * @param entity The entity to be refreshed.
+ */
+ public void refresh(String entityName, Object entity);
+
+ /**
+ * Refresh the entity instance state from the database.
+ *
+ * @param entity The entity to be refreshed.
+ * @param lockMode The LockMode to be applied.
+ */
+ public void refresh(Object entity, LockMode lockMode);
+
+ /**
+ * Refresh the entity instance state from the database.
+ *
+ * @param entityName The entityName for the entity to be refreshed.
+ * @param entity The entity to be refreshed.
+ * @param lockMode The LockMode to be applied.
+ */
+ public void refresh(String entityName, Object entity, LockMode lockMode);
+
+ /**
+ * Create a new instance of <tt>Query</tt> for the given HQL query string.
+ * Entities returned by the query are detached.
+ */
+ public Query createQuery(String queryString);
+
+ /**
+ * Obtain an instance of <tt>Query</tt> for a named query string defined in
+ * the mapping file. Entities returned by the query are detached.
+ */
+ public Query getNamedQuery(String queryName);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity class,
+ * or a superclass of an entity class. Entities returned by the query are
+ * detached.
+ *
+ * @param persistentClass a class, which is persistent, or has persistent subclasses
+ * @return Criteria
+ */
+ public Criteria createCriteria(Class persistentClass);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity class,
+ * or a superclass of an entity class, with the given alias.
+ * Entities returned by the query are detached.
+ *
+ * @param persistentClass a class, which is persistent, or has persistent subclasses
+ * @return Criteria
+ */
+ public Criteria createCriteria(Class persistentClass, String alias);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity name.
+ * Entities returned by the query are detached.
+ *
+ * @param entityName
+ * @return Criteria
+ */
+ public Criteria createCriteria(String entityName);
+
+ /**
+ * Create a new <tt>Criteria</tt> instance, for the given entity name,
+ * with the given alias. Entities returned by the query are detached.
+ *
+ * @param entityName
+ * @return Criteria
+ */
+ public Criteria createCriteria(String entityName, String alias);
+
+ /**
+ * Create a new instance of <tt>SQLQuery</tt> for the given SQL query string.
+ * Entities returned by the query are detached.
+ *
+ * @param queryString a SQL query
+ * @return SQLQuery
+ * @throws HibernateException
+ */
+ public SQLQuery createSQLQuery(String queryString) throws HibernateException;
+
+ /**
+ * Begin a Hibernate transaction.
+ */
+ public Transaction beginTransaction();
+
+ /**
+ * Get the current Hibernate transaction.
+ */
+ public Transaction getTransaction();
+
+ /**
+ * Returns the current JDBC connection associated with this
+ * instance.<br>
+ * <br>
+ * If the session is using aggressive connection release (as in a
+ * CMT environment), it is the application's responsibility to
+ * close the connection returned by this call. Otherwise, the
+ * application should not close the connection.
+ */
+ public Connection connection();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Transaction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,105 +0,0 @@
-//$Id: Transaction.java 9595 2006-03-10 18:14:21Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-import javax.transaction.Synchronization;
-
-/**
- * Allows the application to define units of work, while
- * maintaining abstraction from the underlying transaction
- * implementation (eg. JTA, JDBC).<br>
- * <br>
- * A transaction is associated with a <tt>Session</tt> and is
- * usually instantiated by a call to <tt>Session.beginTransaction()</tt>.
- * A single session might span multiple transactions since
- * the notion of a session (a conversation between the application
- * and the datastore) is of coarser granularity than the notion of
- * a transaction. However, it is intended that there be at most one
- * uncommitted <tt>Transaction</tt> associated with a particular
- * <tt>Session</tt> at any time.<br>
- * <br>
- * Implementors are not intended to be threadsafe.
- *
- * @see Session#beginTransaction()
- * @see org.hibernate.transaction.TransactionFactory
- * @author Anton van Straaten
- */
-public interface Transaction {
-
- /**
- * Begin a new transaction.
- */
- public void begin() throws HibernateException;
-
- /**
- * Flush the associated <tt>Session</tt> and end the unit of work (unless
- * we are in {@link FlushMode#MANUAL}.
- * </p>
- * This method will commit the underlying transaction if and only
- * if the underlying transaction was initiated by this object.
- *
- * @throws HibernateException
- */
- public void commit() throws HibernateException;
-
- /**
- * Force the underlying transaction to roll back.
- *
- * @throws HibernateException
- */
- public void rollback() throws HibernateException;
-
- /**
- * Was this transaction rolled back or set to rollback only?
- * <p/>
- * This only accounts for actions initiated from this local transaction.
- * If, for example, the underlying transaction is forced to rollback via
- * some other means, this method still reports false because the rollback
- * was not initiated from here.
- *
- * @return boolean True if the transaction was rolled back via this
- * local transaction; false otherwise.
- * @throws HibernateException
- */
- public boolean wasRolledBack() throws HibernateException;
-
- /**
- * Check if this transaction was successfully committed.
- * <p/>
- * This method could return <tt>false</tt> even after successful invocation
- * of {@link #commit}. As an example, JTA based strategies no-op on
- * {@link #commit} calls if they did not start the transaction; in that case,
- * they also report {@link #wasCommitted} as false.
- *
- * @return boolean True if the transaction was (unequivocally) committed
- * via this local transaction; false otherwise.
- * @throws HibernateException
- */
- public boolean wasCommitted() throws HibernateException;
-
- /**
- * Is this transaction still active?
- * <p/>
- * Again, this only returns information in relation to the
- * local transaction, not the actual underlying transaction.
- *
- * @return boolean Treu if this local transaction is still active.
- */
- public boolean isActive() throws HibernateException;
-
- /**
- * Register a user synchronization callback for this transaction.
- *
- * @param synchronization The Synchronization callback to register.
- * @throws HibernateException
- */
- public void registerSynchronization(Synchronization synchronization)
- throws HibernateException;
-
- /**
- * Set the transaction timeout for any transaction started by
- * a subsequent call to <tt>begin()</tt> on this instance.
- *
- * @param seconds The number of seconds before a timeout.
- */
- public void setTimeout(int seconds);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/Transaction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/Transaction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,128 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Allows the application to define units of work, while
+ * maintaining abstraction from the underlying transaction
+ * implementation (eg. JTA, JDBC).<br>
+ * <br>
+ * A transaction is associated with a <tt>Session</tt> and is
+ * usually instantiated by a call to <tt>Session.beginTransaction()</tt>.
+ * A single session might span multiple transactions since
+ * the notion of a session (a conversation between the application
+ * and the datastore) is of coarser granularity than the notion of
+ * a transaction. However, it is intended that there be at most one
+ * uncommitted <tt>Transaction</tt> associated with a particular
+ * <tt>Session</tt> at any time.<br>
+ * <br>
+ * Implementors are not intended to be threadsafe.
+ *
+ * @see Session#beginTransaction()
+ * @see org.hibernate.transaction.TransactionFactory
+ * @author Anton van Straaten
+ */
+public interface Transaction {
+
+ /**
+ * Begin a new transaction.
+ */
+ public void begin() throws HibernateException;
+
+ /**
+ * Flush the associated <tt>Session</tt> and end the unit of work (unless
+ * we are in {@link FlushMode#MANUAL}.
+ * </p>
+ * This method will commit the underlying transaction if and only
+ * if the underlying transaction was initiated by this object.
+ *
+ * @throws HibernateException
+ */
+ public void commit() throws HibernateException;
+
+ /**
+ * Force the underlying transaction to roll back.
+ *
+ * @throws HibernateException
+ */
+ public void rollback() throws HibernateException;
+
+ /**
+ * Was this transaction rolled back or set to rollback only?
+ * <p/>
+ * This only accounts for actions initiated from this local transaction.
+ * If, for example, the underlying transaction is forced to rollback via
+ * some other means, this method still reports false because the rollback
+ * was not initiated from here.
+ *
+ * @return boolean True if the transaction was rolled back via this
+ * local transaction; false otherwise.
+ * @throws HibernateException
+ */
+ public boolean wasRolledBack() throws HibernateException;
+
+ /**
+ * Check if this transaction was successfully committed.
+ * <p/>
+ * This method could return <tt>false</tt> even after successful invocation
+ * of {@link #commit}. As an example, JTA based strategies no-op on
+ * {@link #commit} calls if they did not start the transaction; in that case,
+ * they also report {@link #wasCommitted} as false.
+ *
+ * @return boolean True if the transaction was (unequivocally) committed
+ * via this local transaction; false otherwise.
+ * @throws HibernateException
+ */
+ public boolean wasCommitted() throws HibernateException;
+
+ /**
+ * Is this transaction still active?
+ * <p/>
+ * Again, this only returns information in relation to the
+ * local transaction, not the actual underlying transaction.
+ *
+ * @return boolean Treu if this local transaction is still active.
+ */
+ public boolean isActive() throws HibernateException;
+
+ /**
+ * Register a user synchronization callback for this transaction.
+ *
+ * @param synchronization The Synchronization callback to register.
+ * @throws HibernateException
+ */
+ public void registerSynchronization(Synchronization synchronization)
+ throws HibernateException;
+
+ /**
+ * Set the transaction timeout for any transaction started by
+ * a subsequent call to <tt>begin()</tt> on this instance.
+ *
+ * @param seconds The number of seconds before a timeout.
+ */
+ public void setTimeout(int seconds);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/TransactionException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-//$Id: TransactionException.java 10312 2006-08-23 12:43:54Z steve.ebersole(a)jboss.com $
-package org.hibernate;
-
-/**
- * Indicates that a transaction could not be begun, committed
- * or rolled back.
- *
- * @see Transaction
- * @author Anton van Straaten
- */
-
-public class TransactionException extends HibernateException {
-
- public TransactionException(String message, Throwable root) {
- super(message,root);
- }
-
- public TransactionException(String message) {
- super(message);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/TransactionException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransactionException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Indicates that a transaction could not be begun, committed
+ * or rolled back.
+ *
+ * @see Transaction
+ * @author Anton van Straaten
+ */
+
+public class TransactionException extends HibernateException {
+
+ public TransactionException(String message, Throwable root) {
+ super(message,root);
+ }
+
+ public TransactionException(String message) {
+ super(message);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/TransientObjectException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,23 +0,0 @@
-//$Id: TransientObjectException.java 6877 2005-05-23 15:00:25Z oneovthafew $
-package org.hibernate;
-
-/**
- * Thrown when the user passes a transient instance to a <tt>Session</tt>
- * method that expects a persistent instance.
- *
- * @author Gavin King
- */
-
-public class TransientObjectException extends HibernateException {
-
- public TransientObjectException(String s) {
- super(s);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/TransientObjectException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TransientObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Thrown when the user passes a transient instance to a <tt>Session</tt>
+ * method that expects a persistent instance.
+ *
+ * @author Gavin King
+ */
+
+public class TransientObjectException extends HibernateException {
+
+ public TransientObjectException(String s) {
+ super(s);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/TypeMismatchException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: $
-package org.hibernate;
-
-/**
- * Used when a user provided type does not match the expected one
- *
- * @author Emmanuel Bernard
- */
-public class TypeMismatchException extends HibernateException {
- public TypeMismatchException(Throwable root) {
- super( root );
- }
-
- public TypeMismatchException(String s) {
- super( s );
- }
-
- public TypeMismatchException(String string, Throwable root) {
- super( string, root );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/TypeMismatchException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/TypeMismatchException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Used when a user provided type does not match the expected one
+ *
+ * @author Emmanuel Bernard
+ */
+public class TypeMismatchException extends HibernateException {
+ public TypeMismatchException(Throwable root) {
+ super( root );
+ }
+
+ public TypeMismatchException(String s) {
+ super( s );
+ }
+
+ public TypeMismatchException(String string, Throwable root) {
+ super( string, root );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/UnresolvableObjectException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,52 +0,0 @@
-//$Id: UnresolvableObjectException.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-
-import org.hibernate.pretty.MessageHelper;
-
-/**
- * Thrown when Hibernate could not resolve an object by id, especially when
- * loading an association.
- *
- * @author Gavin King
- */
-public class UnresolvableObjectException extends HibernateException {
-
- private final Serializable identifier;
- private final String entityName;
-
- public UnresolvableObjectException(Serializable identifier, String clazz) {
- this("No row with the given identifier exists", identifier, clazz);
- }
- UnresolvableObjectException(String message, Serializable identifier, String clazz) {
- super(message);
- this.identifier = identifier;
- this.entityName = clazz;
- }
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getMessage() {
- return super.getMessage() + ": " +
- MessageHelper.infoString(entityName, identifier);
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public static void throwIfNull(Object o, Serializable id, String clazz)
- throws UnresolvableObjectException {
- if (o==null) throw new UnresolvableObjectException(id, clazz);
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/UnresolvableObjectException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/UnresolvableObjectException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,75 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+import org.hibernate.pretty.MessageHelper;
+
+/**
+ * Thrown when Hibernate could not resolve an object by id, especially when
+ * loading an association.
+ *
+ * @author Gavin King
+ */
+public class UnresolvableObjectException extends HibernateException {
+
+ private final Serializable identifier;
+ private final String entityName;
+
+ public UnresolvableObjectException(Serializable identifier, String clazz) {
+ this("No row with the given identifier exists", identifier, clazz);
+ }
+ UnresolvableObjectException(String message, Serializable identifier, String clazz) {
+ super(message);
+ this.identifier = identifier;
+ this.entityName = clazz;
+ }
+ public Serializable getIdentifier() {
+ return identifier;
+ }
+
+ public String getMessage() {
+ return super.getMessage() + ": " +
+ MessageHelper.infoString(entityName, identifier);
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public static void throwIfNull(Object o, Serializable id, String clazz)
+ throws UnresolvableObjectException {
+ if (o==null) throw new UnresolvableObjectException(id, clazz);
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/WrongClassException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,47 +0,0 @@
-//$Id: WrongClassException.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate;
-
-import java.io.Serializable;
-
-/**
- * Thrown when <tt>Session.load()</tt> selects a row with
- * the given primary key (identifier value) but the row's
- * discriminator value specifies a subclass that is not
- * assignable to the class requested by the user.
- *
- * @author Gavin King
- */
-public class WrongClassException extends HibernateException {
-
- private final Serializable identifier;
- private final String entityName;
-
- public WrongClassException(String msg, Serializable identifier, String clazz) {
- super(msg);
- this.identifier = identifier;
- this.entityName = clazz;
- }
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getMessage() {
- return "Object with id: " +
- identifier +
- " was not of the specified subclass: " +
- entityName +
- " (" + super.getMessage() + ")" ;
- }
-
- public String getEntityName() {
- return entityName;
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/WrongClassException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/WrongClassException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,70 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+import java.io.Serializable;
+
+/**
+ * Thrown when <tt>Session.load()</tt> selects a row with
+ * the given primary key (identifier value) but the row's
+ * discriminator value specifies a subclass that is not
+ * assignable to the class requested by the user.
+ *
+ * @author Gavin King
+ */
+public class WrongClassException extends HibernateException {
+
+ private final Serializable identifier;
+ private final String entityName;
+
+ public WrongClassException(String msg, Serializable identifier, String clazz) {
+ super(msg);
+ this.identifier = identifier;
+ this.entityName = clazz;
+ }
+ public Serializable getIdentifier() {
+ return identifier;
+ }
+
+ public String getMessage() {
+ return "Object with id: " +
+ identifier +
+ " was not of the specified subclass: " +
+ entityName +
+ " (" + super.getMessage() + ")" ;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,146 +0,0 @@
-// $Id: BulkOperationCleanupAction.java 9897 2006-05-05 20:50:27Z max.andersen(a)jboss.com $
-package org.hibernate.action;
-
-import org.hibernate.HibernateException;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.persister.entity.Queryable;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.ArrayList;
-
-/**
- * Implementation of BulkOperationCleanupAction.
- *
- * @author Steve Ebersole
- */
-public class BulkOperationCleanupAction implements Executable, Serializable {
-
- private final SessionImplementor session;
-
- private final Set affectedEntityNames = new HashSet();
- private final Set affectedCollectionRoles = new HashSet();
- private final Serializable[] spaces;
-
- public BulkOperationCleanupAction(SessionImplementor session, Queryable[] affectedQueryables) {
- this.session = session;
- // TODO : probably better to calculate these and pass them in, as it'll be more performant
- ArrayList tmpSpaces = new ArrayList();
- for ( int i = 0; i < affectedQueryables.length; i++ ) {
- if ( affectedQueryables[i].hasCache() ) {
- affectedEntityNames.add( affectedQueryables[i].getEntityName() );
- }
- Set roles = session.getFactory().getCollectionRolesByEntityParticipant( affectedQueryables[i].getEntityName() );
- if ( roles != null ) {
- affectedCollectionRoles.addAll( roles );
- }
- for ( int y = 0; y < affectedQueryables[i].getQuerySpaces().length; y++ ) {
- tmpSpaces.add( affectedQueryables[i].getQuerySpaces()[y] );
- }
- }
- this.spaces = new Serializable[ tmpSpaces.size() ];
- for ( int i = 0; i < tmpSpaces.size(); i++ ) {
- this.spaces[i] = ( Serializable ) tmpSpaces.get( i );
- }
- }
-
- /** Create an action that will evict collection and entity regions based on queryspaces (table names).
- * TODO: cache the autodetected information and pass it in instead.
- **/
- public BulkOperationCleanupAction(SessionImplementor session, Set querySpaces) {
- this.session = session;
-
- Set tmpSpaces = new HashSet(querySpaces);
- SessionFactoryImplementor factory = session.getFactory();
- Iterator iterator = factory.getAllClassMetadata().entrySet().iterator();
- while ( iterator.hasNext() ) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String entityName = (String) entry.getKey();
- EntityPersister persister = factory.getEntityPersister( entityName );
- Serializable[] entitySpaces = persister.getQuerySpaces();
-
- if (affectedEntity( querySpaces, entitySpaces )) {
- if ( persister.hasCache() ) {
- affectedEntityNames.add( persister.getEntityName() );
- }
- Set roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
- if ( roles != null ) {
- affectedCollectionRoles.addAll( roles );
- }
- for ( int y = 0; y < entitySpaces.length; y++ ) {
- tmpSpaces.add( entitySpaces[y] );
- }
- }
-
- }
- this.spaces = (Serializable[]) tmpSpaces.toArray( new Serializable[tmpSpaces.size()] );
- }
-
-
- /** returns true if no queryspaces or if there are a match */
- private boolean affectedEntity(Set querySpaces, Serializable[] entitySpaces) {
- if(querySpaces==null || querySpaces.isEmpty()) {
- return true;
- }
-
- for ( int i = 0; i < entitySpaces.length; i++ ) {
- if ( querySpaces.contains( entitySpaces[i] ) ) {
- return true;
- }
- }
- return false;
- }
-
- public void init() {
- evictEntityRegions();
- evictCollectionRegions();
- }
-
- public boolean hasAfterTransactionCompletion() {
- return true;
- }
-
- public void afterTransactionCompletion(boolean success) throws HibernateException {
- evictEntityRegions();
- evictCollectionRegions();
- }
-
- public Serializable[] getPropertySpaces() {
- return spaces;
- }
-
- public void beforeExecutions() throws HibernateException {
- // nothing to do
- }
-
- public void execute() throws HibernateException {
- // nothing to do
- }
-
- private void evictEntityRegions() {
- if ( affectedEntityNames != null ) {
- Iterator itr = affectedEntityNames.iterator();
- while ( itr.hasNext() ) {
- final String entityName = ( String ) itr.next();
- session.getFactory().evictEntity( entityName );
- }
- }
- }
-
- private void evictCollectionRegions() {
- if ( affectedCollectionRoles != null ) {
- Iterator itr = affectedCollectionRoles.iterator();
- while ( itr.hasNext() ) {
- final String roleName = ( String ) itr.next();
- session.getFactory().evictCollection( roleName );
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/BulkOperationCleanupAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,167 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.HibernateException;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.ArrayList;
+
+/**
+ * Implementation of BulkOperationCleanupAction.
+ *
+ * @author Steve Ebersole
+ */
+public class BulkOperationCleanupAction implements Executable, Serializable {
+
+ private final SessionImplementor session;
+
+ private final Set affectedEntityNames = new HashSet();
+ private final Set affectedCollectionRoles = new HashSet();
+ private final Serializable[] spaces;
+
+ public BulkOperationCleanupAction(SessionImplementor session, Queryable[] affectedQueryables) {
+ this.session = session;
+ // TODO : probably better to calculate these and pass them in, as it'll be more performant
+ ArrayList tmpSpaces = new ArrayList();
+ for ( int i = 0; i < affectedQueryables.length; i++ ) {
+ if ( affectedQueryables[i].hasCache() ) {
+ affectedEntityNames.add( affectedQueryables[i].getEntityName() );
+ }
+ Set roles = session.getFactory().getCollectionRolesByEntityParticipant( affectedQueryables[i].getEntityName() );
+ if ( roles != null ) {
+ affectedCollectionRoles.addAll( roles );
+ }
+ for ( int y = 0; y < affectedQueryables[i].getQuerySpaces().length; y++ ) {
+ tmpSpaces.add( affectedQueryables[i].getQuerySpaces()[y] );
+ }
+ }
+ this.spaces = new Serializable[ tmpSpaces.size() ];
+ for ( int i = 0; i < tmpSpaces.size(); i++ ) {
+ this.spaces[i] = ( Serializable ) tmpSpaces.get( i );
+ }
+ }
+
+ /** Create an action that will evict collection and entity regions based on queryspaces (table names).
+ * TODO: cache the autodetected information and pass it in instead.
+ **/
+ public BulkOperationCleanupAction(SessionImplementor session, Set querySpaces) {
+ this.session = session;
+
+ Set tmpSpaces = new HashSet(querySpaces);
+ SessionFactoryImplementor factory = session.getFactory();
+ Iterator iterator = factory.getAllClassMetadata().entrySet().iterator();
+ while ( iterator.hasNext() ) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+ String entityName = (String) entry.getKey();
+ EntityPersister persister = factory.getEntityPersister( entityName );
+ Serializable[] entitySpaces = persister.getQuerySpaces();
+
+ if (affectedEntity( querySpaces, entitySpaces )) {
+ if ( persister.hasCache() ) {
+ affectedEntityNames.add( persister.getEntityName() );
+ }
+ Set roles = session.getFactory().getCollectionRolesByEntityParticipant( persister.getEntityName() );
+ if ( roles != null ) {
+ affectedCollectionRoles.addAll( roles );
+ }
+ for ( int y = 0; y < entitySpaces.length; y++ ) {
+ tmpSpaces.add( entitySpaces[y] );
+ }
+ }
+
+ }
+ this.spaces = (Serializable[]) tmpSpaces.toArray( new Serializable[tmpSpaces.size()] );
+ }
+
+
+ /** returns true if no queryspaces or if there are a match */
+ private boolean affectedEntity(Set querySpaces, Serializable[] entitySpaces) {
+ if(querySpaces==null || querySpaces.isEmpty()) {
+ return true;
+ }
+
+ for ( int i = 0; i < entitySpaces.length; i++ ) {
+ if ( querySpaces.contains( entitySpaces[i] ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void init() {
+ evictEntityRegions();
+ evictCollectionRegions();
+ }
+
+ public boolean hasAfterTransactionCompletion() {
+ return true;
+ }
+
+ public void afterTransactionCompletion(boolean success) throws HibernateException {
+ evictEntityRegions();
+ evictCollectionRegions();
+ }
+
+ public Serializable[] getPropertySpaces() {
+ return spaces;
+ }
+
+ public void beforeExecutions() throws HibernateException {
+ // nothing to do
+ }
+
+ public void execute() throws HibernateException {
+ // nothing to do
+ }
+
+ private void evictEntityRegions() {
+ if ( affectedEntityNames != null ) {
+ Iterator itr = affectedEntityNames.iterator();
+ while ( itr.hasNext() ) {
+ final String entityName = ( String ) itr.next();
+ session.getFactory().evictEntity( entityName );
+ }
+ }
+ }
+
+ private void evictCollectionRegions() {
+ if ( affectedCollectionRoles != null ) {
+ Iterator itr = affectedCollectionRoles.iterator();
+ while ( itr.hasNext() ) {
+ final String roleName = ( String ) itr.next();
+ session.getFactory().evictCollection( roleName );
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,150 +0,0 @@
-//$Id: CollectionAction.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.action;
-
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.util.StringHelper;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-
-/**
- * Any action relating to insert/update/delete of a collection
- * @author Gavin King
- */
-public abstract class CollectionAction implements Executable, Serializable, Comparable {
-
- private transient CollectionPersister persister;
- private final Serializable key;
- private Serializable finalKey;
- private final SessionImplementor session;
- private SoftLock lock;
- private final String collectionRole;
- private final PersistentCollection collection;
-
- public CollectionAction(
- final CollectionPersister persister,
- final PersistentCollection collection,
- final Serializable key,
- final SessionImplementor session) throws CacheException {
- this.persister = persister;
- this.session = session;
- this.key = key;
- this.collectionRole = persister.getRole();
- this.collection = collection;
- }
-
- protected PersistentCollection getCollection() {
- return collection;
- }
-
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- ois.defaultReadObject();
- persister = session.getFactory().getCollectionPersister( collectionRole );
- }
-
- public void afterTransactionCompletion(boolean success) throws CacheException {
- if ( persister.hasCache() ) {
- final CacheKey ck = new CacheKey(
- key,
- persister.getKeyType(),
- persister.getRole(),
- session.getEntityMode(),
- session.getFactory()
- );
- persister.getCacheAccessStrategy().unlockItem( ck, lock );
- }
- }
-
- public boolean hasAfterTransactionCompletion() {
- return persister.hasCache();
- }
-
- public Serializable[] getPropertySpaces() {
- return persister.getCollectionSpaces();
- }
-
- protected final CollectionPersister getPersister() {
- return persister;
- }
-
- protected final Serializable getKey() {
- finalKey = key;
- if ( key instanceof DelayedPostInsertIdentifier ) {
- // need to look it up from the persistence-context
- finalKey = session.getPersistenceContext().getEntry( collection.getOwner() ).getId();
- if ( finalKey == key ) {
- // we may be screwed here since the collection action is about to execute
- // and we do not know the final owner key value
- }
- }
- return finalKey;
- }
-
- protected final SessionImplementor getSession() {
- return session;
- }
-
- public final void beforeExecutions() throws CacheException {
- // we need to obtain the lock before any actions are
- // executed, since this may be an inverse="true"
- // bidirectional association and it is one of the
- // earlier entity actions which actually updates
- // the database (this action is resposible for
- // second-level cache invalidation only)
- if ( persister.hasCache() ) {
- final CacheKey ck = new CacheKey(
- key,
- persister.getKeyType(),
- persister.getRole(),
- session.getEntityMode(),
- session.getFactory()
- );
- lock = persister.getCacheAccessStrategy().lockItem( ck, null );
- }
- }
-
- protected final void evict() throws CacheException {
- if ( persister.hasCache() ) {
- CacheKey ck = new CacheKey(
- key,
- persister.getKeyType(),
- persister.getRole(),
- session.getEntityMode(),
- session.getFactory()
- );
- persister.getCacheAccessStrategy().remove( ck );
- }
- }
-
- public String toString() {
- return StringHelper.unqualify( getClass().getName() ) +
- MessageHelper.infoString( collectionRole, key );
- }
-
- public int compareTo(Object other) {
- CollectionAction action = ( CollectionAction ) other;
- //sort first by role name
- int roleComparison = collectionRole.compareTo( action.collectionRole );
- if ( roleComparison != 0 ) {
- return roleComparison;
- }
- else {
- //then by fk
- return persister.getKeyType()
- .compare( key, action.key, session.getEntityMode() );
- }
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/CollectionAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,173 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.util.StringHelper;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Any action relating to insert/update/delete of a collection
+ * @author Gavin King
+ */
+public abstract class CollectionAction implements Executable, Serializable, Comparable {
+
+ private transient CollectionPersister persister;
+ private final Serializable key;
+ private Serializable finalKey;
+ private final SessionImplementor session;
+ private SoftLock lock;
+ private final String collectionRole;
+ private final PersistentCollection collection;
+
+ public CollectionAction(
+ final CollectionPersister persister,
+ final PersistentCollection collection,
+ final Serializable key,
+ final SessionImplementor session) throws CacheException {
+ this.persister = persister;
+ this.session = session;
+ this.key = key;
+ this.collectionRole = persister.getRole();
+ this.collection = collection;
+ }
+
+ protected PersistentCollection getCollection() {
+ return collection;
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ois.defaultReadObject();
+ persister = session.getFactory().getCollectionPersister( collectionRole );
+ }
+
+ public void afterTransactionCompletion(boolean success) throws CacheException {
+ if ( persister.hasCache() ) {
+ final CacheKey ck = new CacheKey(
+ key,
+ persister.getKeyType(),
+ persister.getRole(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ persister.getCacheAccessStrategy().unlockItem( ck, lock );
+ }
+ }
+
+ public boolean hasAfterTransactionCompletion() {
+ return persister.hasCache();
+ }
+
+ public Serializable[] getPropertySpaces() {
+ return persister.getCollectionSpaces();
+ }
+
+ protected final CollectionPersister getPersister() {
+ return persister;
+ }
+
+ protected final Serializable getKey() {
+ finalKey = key;
+ if ( key instanceof DelayedPostInsertIdentifier ) {
+ // need to look it up from the persistence-context
+ finalKey = session.getPersistenceContext().getEntry( collection.getOwner() ).getId();
+ if ( finalKey == key ) {
+ // we may be screwed here since the collection action is about to execute
+ // and we do not know the final owner key value
+ }
+ }
+ return finalKey;
+ }
+
+ protected final SessionImplementor getSession() {
+ return session;
+ }
+
+ public final void beforeExecutions() throws CacheException {
+ // we need to obtain the lock before any actions are
+ // executed, since this may be an inverse="true"
+ // bidirectional association and it is one of the
+ // earlier entity actions which actually updates
+ // the database (this action is resposible for
+ // second-level cache invalidation only)
+ if ( persister.hasCache() ) {
+ final CacheKey ck = new CacheKey(
+ key,
+ persister.getKeyType(),
+ persister.getRole(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ lock = persister.getCacheAccessStrategy().lockItem( ck, null );
+ }
+ }
+
+ protected final void evict() throws CacheException {
+ if ( persister.hasCache() ) {
+ CacheKey ck = new CacheKey(
+ key,
+ persister.getKeyType(),
+ persister.getRole(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ persister.getCacheAccessStrategy().remove( ck );
+ }
+ }
+
+ public String toString() {
+ return StringHelper.unqualify( getClass().getName() ) +
+ MessageHelper.infoString( collectionRole, key );
+ }
+
+ public int compareTo(Object other) {
+ CollectionAction action = ( CollectionAction ) other;
+ //sort first by role name
+ int roleComparison = collectionRole.compareTo( action.collectionRole );
+ if ( roleComparison != 0 ) {
+ return roleComparison;
+ }
+ else {
+ //then by fk
+ return persister.getKeyType()
+ .compare( key, action.key, session.getEntityMode() );
+ }
+ }
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,81 +0,0 @@
-//$Id: CollectionRecreateAction.java 7147 2005-06-15 13:20:13Z oneovthafew $
-package org.hibernate.action;
-
-import org.hibernate.HibernateException;
-import org.hibernate.event.PostCollectionRecreateEventListener;
-import org.hibernate.event.PostCollectionRecreateEvent;
-import org.hibernate.event.EventSource;
-import org.hibernate.event.PreCollectionRecreateEvent;
-import org.hibernate.event.PreCollectionRecreateEventListener;
-import org.hibernate.cache.CacheException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-
-import java.io.Serializable;
-
-public final class CollectionRecreateAction extends CollectionAction {
-
- public CollectionRecreateAction(
- final PersistentCollection collection,
- final CollectionPersister persister,
- final Serializable id,
- final SessionImplementor session)
- throws CacheException {
- super( persister, collection, id, session );
- }
-
- public void execute() throws HibernateException {
- // this method is called when a new non-null collection is persisted
- // or when an existing (non-null) collection is moved to a new owner
- final PersistentCollection collection = getCollection();
-
- preRecreate();
-
- getPersister().recreate( collection, getKey(), getSession() );
-
- getSession().getPersistenceContext()
- .getCollectionEntry(collection)
- .afterAction(collection);
-
- evict();
-
- postRecreate();
-
- if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
- getSession().getFactory().getStatisticsImplementor()
- .recreateCollection( getPersister().getRole() );
- }
- }
-
- private void preRecreate() {
- PreCollectionRecreateEventListener[] preListeners = getSession().getListeners()
- .getPreCollectionRecreateEventListeners();
- if (preListeners.length > 0) {
- PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(
- getPersister(), getCollection(), ( EventSource ) getSession() );
- for ( int i = 0; i < preListeners.length; i++ ) {
- preListeners[i].onPreRecreateCollection( preEvent );
- }
- }
- }
-
- private void postRecreate() {
- PostCollectionRecreateEventListener[] postListeners = getSession().getListeners()
- .getPostCollectionRecreateEventListeners();
- if (postListeners.length > 0) {
- PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
- getPersister(), getCollection(), ( EventSource ) getSession() );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostRecreateCollection( postEvent );
- }
- }
- }
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRecreateAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,104 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.HibernateException;
+import org.hibernate.event.PostCollectionRecreateEventListener;
+import org.hibernate.event.PostCollectionRecreateEvent;
+import org.hibernate.event.EventSource;
+import org.hibernate.event.PreCollectionRecreateEvent;
+import org.hibernate.event.PreCollectionRecreateEventListener;
+import org.hibernate.cache.CacheException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+
+import java.io.Serializable;
+
+public final class CollectionRecreateAction extends CollectionAction {
+
+ public CollectionRecreateAction(
+ final PersistentCollection collection,
+ final CollectionPersister persister,
+ final Serializable id,
+ final SessionImplementor session)
+ throws CacheException {
+ super( persister, collection, id, session );
+ }
+
+ public void execute() throws HibernateException {
+ // this method is called when a new non-null collection is persisted
+ // or when an existing (non-null) collection is moved to a new owner
+ final PersistentCollection collection = getCollection();
+
+ preRecreate();
+
+ getPersister().recreate( collection, getKey(), getSession() );
+
+ getSession().getPersistenceContext()
+ .getCollectionEntry(collection)
+ .afterAction(collection);
+
+ evict();
+
+ postRecreate();
+
+ if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
+ getSession().getFactory().getStatisticsImplementor()
+ .recreateCollection( getPersister().getRole() );
+ }
+ }
+
+ private void preRecreate() {
+ PreCollectionRecreateEventListener[] preListeners = getSession().getListeners()
+ .getPreCollectionRecreateEventListeners();
+ if (preListeners.length > 0) {
+ PreCollectionRecreateEvent preEvent = new PreCollectionRecreateEvent(
+ getPersister(), getCollection(), ( EventSource ) getSession() );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ preListeners[i].onPreRecreateCollection( preEvent );
+ }
+ }
+ }
+
+ private void postRecreate() {
+ PostCollectionRecreateEventListener[] postListeners = getSession().getListeners()
+ .getPostCollectionRecreateEventListeners();
+ if (postListeners.length > 0) {
+ PostCollectionRecreateEvent postEvent = new PostCollectionRecreateEvent(
+ getPersister(), getCollection(), ( EventSource ) getSession() );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostRecreateCollection( postEvent );
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,127 +0,0 @@
-//$Id: CollectionRemoveAction.java 7147 2005-06-15 13:20:13Z oneovthafew $
-package org.hibernate.action;
-
-import org.hibernate.HibernateException;
-import org.hibernate.AssertionFailure;
-import org.hibernate.event.PostCollectionRemoveEvent;
-import org.hibernate.event.PreCollectionRemoveEvent;
-import org.hibernate.event.PreCollectionRemoveEventListener;
-import org.hibernate.event.EventSource;
-import org.hibernate.event.PostCollectionRemoveEventListener;
-import org.hibernate.cache.CacheException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-
-import java.io.Serializable;
-
-public final class CollectionRemoveAction extends CollectionAction {
-
- private boolean emptySnapshot;
- private final Object affectedOwner;
-
- /**
- * Removes a persistent collection from its loaded owner.
- *
- * Use this constructor when the collection is non-null.
- *
- * @param collection The collection to to remove; must be non-null
- * @param persister The collection's persister
- * @param id The collection key
- * @param emptySnapshot Indicates if the snapshot is empty
- * @param session The session
- * @throws AssertionFailure if collection is null.
- */
- public CollectionRemoveAction(
- final PersistentCollection collection,
- final CollectionPersister persister,
- final Serializable id,
- final boolean emptySnapshot,
- final SessionImplementor session)
- throws CacheException {
- super( persister, collection, id, session );
- if (collection == null) { throw new AssertionFailure("collection == null"); }
- this.emptySnapshot = emptySnapshot;
- // the loaded owner will be set to null after the collection is removed,
- // so capture its value as the affected owner so it is accessible to
- // both pre- and post- events
- this.affectedOwner = session.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
- }
-
- /**
- * Removes a persistent collection from a specified owner.
- *
- * Use this constructor when the collection to be removed has not been loaded.
- *
- * @param affectedOwner The collection's owner; must be non-null
- * @param persister The collection's persister
- * @param id The collection key
- * @param emptySnapshot Indicates if the snapshot is empty
- * @param session The session
- * @throws AssertionFailure if affectedOwner is null.
- */
- public CollectionRemoveAction(
- final Object affectedOwner,
- final CollectionPersister persister,
- final Serializable id,
- final boolean emptySnapshot,
- final SessionImplementor session)
- throws CacheException {
- super( persister, null, id, session );
- if (affectedOwner == null) { throw new AssertionFailure("affectedOwner == null"); }
- this.emptySnapshot = emptySnapshot;
- this.affectedOwner = affectedOwner;
- }
-
- public void execute() throws HibernateException {
- preRemove();
-
- if ( !emptySnapshot ) {
- // an existing collection that was either non-empty or uninitialized
- // is replaced by null or a different collection
- // (if the collection is uninitialized, hibernate has no way of
- // knowing if the collection is actually empty without querying the db)
- getPersister().remove( getKey(), getSession() );
- }
-
- final PersistentCollection collection = getCollection();
- if (collection!=null) {
- getSession().getPersistenceContext()
- .getCollectionEntry(collection)
- .afterAction(collection);
- }
-
- evict();
-
- postRemove();
-
- if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
- getSession().getFactory().getStatisticsImplementor()
- .removeCollection( getPersister().getRole() );
- }
- }
-
- private void preRemove() {
- PreCollectionRemoveEventListener[] preListeners = getSession().getListeners()
- .getPreCollectionRemoveEventListeners();
- if (preListeners.length>0) {
- PreCollectionRemoveEvent preEvent = new PreCollectionRemoveEvent(
- getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
- for ( int i = 0; i < preListeners.length; i++ ) {
- preListeners[i].onPreRemoveCollection(preEvent);
- }
- }
- }
-
- private void postRemove() {
- PostCollectionRemoveEventListener[] postListeners = getSession().getListeners()
- .getPostCollectionRemoveEventListeners();
- if (postListeners.length>0) {
- PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
- getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostRemoveCollection(postEvent);
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionRemoveAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,150 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.HibernateException;
+import org.hibernate.AssertionFailure;
+import org.hibernate.event.PostCollectionRemoveEvent;
+import org.hibernate.event.PreCollectionRemoveEvent;
+import org.hibernate.event.PreCollectionRemoveEventListener;
+import org.hibernate.event.EventSource;
+import org.hibernate.event.PostCollectionRemoveEventListener;
+import org.hibernate.cache.CacheException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+
+import java.io.Serializable;
+
+public final class CollectionRemoveAction extends CollectionAction {
+
+ private boolean emptySnapshot;
+ private final Object affectedOwner;
+
+ /**
+ * Removes a persistent collection from its loaded owner.
+ *
+ * Use this constructor when the collection is non-null.
+ *
+ * @param collection The collection to to remove; must be non-null
+ * @param persister The collection's persister
+ * @param id The collection key
+ * @param emptySnapshot Indicates if the snapshot is empty
+ * @param session The session
+ * @throws AssertionFailure if collection is null.
+ */
+ public CollectionRemoveAction(
+ final PersistentCollection collection,
+ final CollectionPersister persister,
+ final Serializable id,
+ final boolean emptySnapshot,
+ final SessionImplementor session)
+ throws CacheException {
+ super( persister, collection, id, session );
+ if (collection == null) { throw new AssertionFailure("collection == null"); }
+ this.emptySnapshot = emptySnapshot;
+ // the loaded owner will be set to null after the collection is removed,
+ // so capture its value as the affected owner so it is accessible to
+ // both pre- and post- events
+ this.affectedOwner = session.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
+ }
+
+ /**
+ * Removes a persistent collection from a specified owner.
+ *
+ * Use this constructor when the collection to be removed has not been loaded.
+ *
+ * @param affectedOwner The collection's owner; must be non-null
+ * @param persister The collection's persister
+ * @param id The collection key
+ * @param emptySnapshot Indicates if the snapshot is empty
+ * @param session The session
+ * @throws AssertionFailure if affectedOwner is null.
+ */
+ public CollectionRemoveAction(
+ final Object affectedOwner,
+ final CollectionPersister persister,
+ final Serializable id,
+ final boolean emptySnapshot,
+ final SessionImplementor session)
+ throws CacheException {
+ super( persister, null, id, session );
+ if (affectedOwner == null) { throw new AssertionFailure("affectedOwner == null"); }
+ this.emptySnapshot = emptySnapshot;
+ this.affectedOwner = affectedOwner;
+ }
+
+ public void execute() throws HibernateException {
+ preRemove();
+
+ if ( !emptySnapshot ) {
+ // an existing collection that was either non-empty or uninitialized
+ // is replaced by null or a different collection
+ // (if the collection is uninitialized, hibernate has no way of
+ // knowing if the collection is actually empty without querying the db)
+ getPersister().remove( getKey(), getSession() );
+ }
+
+ final PersistentCollection collection = getCollection();
+ if (collection!=null) {
+ getSession().getPersistenceContext()
+ .getCollectionEntry(collection)
+ .afterAction(collection);
+ }
+
+ evict();
+
+ postRemove();
+
+ if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
+ getSession().getFactory().getStatisticsImplementor()
+ .removeCollection( getPersister().getRole() );
+ }
+ }
+
+ private void preRemove() {
+ PreCollectionRemoveEventListener[] preListeners = getSession().getListeners()
+ .getPreCollectionRemoveEventListeners();
+ if (preListeners.length>0) {
+ PreCollectionRemoveEvent preEvent = new PreCollectionRemoveEvent(
+ getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ preListeners[i].onPreRemoveCollection(preEvent);
+ }
+ }
+ }
+
+ private void postRemove() {
+ PostCollectionRemoveEventListener[] postListeners = getSession().getListeners()
+ .getPostCollectionRemoveEventListeners();
+ if (postListeners.length>0) {
+ PostCollectionRemoveEvent postEvent = new PostCollectionRemoveEvent(
+ getPersister(), getCollection(), ( EventSource ) getSession(), affectedOwner );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostRemoveCollection(postEvent);
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,110 +0,0 @@
-//$Id: CollectionUpdateAction.java 7631 2005-07-24 21:26:21Z oneovthafew $
-package org.hibernate.action;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.event.PostCollectionUpdateEvent;
-import org.hibernate.event.PreCollectionUpdateEvent;
-import org.hibernate.event.PreCollectionUpdateEventListener;
-import org.hibernate.event.EventSource;
-import org.hibernate.event.PostCollectionUpdateEventListener;
-import org.hibernate.cache.CacheException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-
-import java.io.Serializable;
-
-public final class CollectionUpdateAction extends CollectionAction {
-
- private final boolean emptySnapshot;
-
- public CollectionUpdateAction(
- final PersistentCollection collection,
- final CollectionPersister persister,
- final Serializable id,
- final boolean emptySnapshot,
- final SessionImplementor session)
- throws CacheException {
- super( persister, collection, id, session );
- this.emptySnapshot = emptySnapshot;
- }
-
- public void execute() throws HibernateException {
- final Serializable id = getKey();
- final SessionImplementor session = getSession();
- final CollectionPersister persister = getPersister();
- final PersistentCollection collection = getCollection();
- boolean affectedByFilters = persister.isAffectedByEnabledFilters(session);
-
- preUpdate();
-
- if ( !collection.wasInitialized() ) {
- if ( !collection.hasQueuedOperations() ) throw new AssertionFailure( "no queued adds" );
- //do nothing - we only need to notify the cache...
- }
- else if ( !affectedByFilters && collection.empty() ) {
- if ( !emptySnapshot ) persister.remove( id, session );
- }
- else if ( collection.needsRecreate(persister) ) {
- if (affectedByFilters) {
- throw new HibernateException(
- "cannot recreate collection while filter is enabled: " +
- MessageHelper.collectionInfoString( persister, id, persister.getFactory() )
- );
- }
- if ( !emptySnapshot ) persister.remove( id, session );
- persister.recreate( collection, id, session );
- }
- else {
- persister.deleteRows( collection, id, session );
- persister.updateRows( collection, id, session );
- persister.insertRows( collection, id, session );
- }
-
- getSession().getPersistenceContext()
- .getCollectionEntry(collection)
- .afterAction(collection);
-
- evict();
-
- postUpdate();
-
- if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
- getSession().getFactory().getStatisticsImplementor().
- updateCollection( getPersister().getRole() );
- }
- }
-
- private void preUpdate() {
- PreCollectionUpdateEventListener[] preListeners = getSession().getListeners()
- .getPreCollectionUpdateEventListeners();
- if (preListeners.length > 0) {
- PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(
- getPersister(), getCollection(), ( EventSource ) getSession() );
- for ( int i = 0; i < preListeners.length; i++ ) {
- preListeners[i].onPreUpdateCollection( preEvent );
- }
- }
- }
-
- private void postUpdate() {
- PostCollectionUpdateEventListener[] postListeners = getSession().getListeners()
- .getPostCollectionUpdateEventListeners();
- if (postListeners.length > 0) {
- PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(
- getPersister(), getCollection(), ( EventSource ) getSession() );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostUpdateCollection( postEvent );
- }
- }
- }
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/CollectionUpdateAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,133 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.event.PostCollectionUpdateEvent;
+import org.hibernate.event.PreCollectionUpdateEvent;
+import org.hibernate.event.PreCollectionUpdateEventListener;
+import org.hibernate.event.EventSource;
+import org.hibernate.event.PostCollectionUpdateEventListener;
+import org.hibernate.cache.CacheException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+
+import java.io.Serializable;
+
+public final class CollectionUpdateAction extends CollectionAction {
+
+ private final boolean emptySnapshot;
+
+ public CollectionUpdateAction(
+ final PersistentCollection collection,
+ final CollectionPersister persister,
+ final Serializable id,
+ final boolean emptySnapshot,
+ final SessionImplementor session)
+ throws CacheException {
+ super( persister, collection, id, session );
+ this.emptySnapshot = emptySnapshot;
+ }
+
+ public void execute() throws HibernateException {
+ final Serializable id = getKey();
+ final SessionImplementor session = getSession();
+ final CollectionPersister persister = getPersister();
+ final PersistentCollection collection = getCollection();
+ boolean affectedByFilters = persister.isAffectedByEnabledFilters(session);
+
+ preUpdate();
+
+ if ( !collection.wasInitialized() ) {
+ if ( !collection.hasQueuedOperations() ) throw new AssertionFailure( "no queued adds" );
+ //do nothing - we only need to notify the cache...
+ }
+ else if ( !affectedByFilters && collection.empty() ) {
+ if ( !emptySnapshot ) persister.remove( id, session );
+ }
+ else if ( collection.needsRecreate(persister) ) {
+ if (affectedByFilters) {
+ throw new HibernateException(
+ "cannot recreate collection while filter is enabled: " +
+ MessageHelper.collectionInfoString( persister, id, persister.getFactory() )
+ );
+ }
+ if ( !emptySnapshot ) persister.remove( id, session );
+ persister.recreate( collection, id, session );
+ }
+ else {
+ persister.deleteRows( collection, id, session );
+ persister.updateRows( collection, id, session );
+ persister.insertRows( collection, id, session );
+ }
+
+ getSession().getPersistenceContext()
+ .getCollectionEntry(collection)
+ .afterAction(collection);
+
+ evict();
+
+ postUpdate();
+
+ if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
+ getSession().getFactory().getStatisticsImplementor().
+ updateCollection( getPersister().getRole() );
+ }
+ }
+
+ private void preUpdate() {
+ PreCollectionUpdateEventListener[] preListeners = getSession().getListeners()
+ .getPreCollectionUpdateEventListeners();
+ if (preListeners.length > 0) {
+ PreCollectionUpdateEvent preEvent = new PreCollectionUpdateEvent(
+ getPersister(), getCollection(), ( EventSource ) getSession() );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ preListeners[i].onPreUpdateCollection( preEvent );
+ }
+ }
+ }
+
+ private void postUpdate() {
+ PostCollectionUpdateEventListener[] postListeners = getSession().getListeners()
+ .getPostCollectionUpdateEventListeners();
+ if (postListeners.length > 0) {
+ PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(
+ getPersister(), getCollection(), ( EventSource ) getSession() );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostUpdateCollection( postEvent );
+ }
+ }
+ }
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,49 +0,0 @@
-package org.hibernate.action;
-
-import java.io.Serializable;
-
-/**
- * Acts as a stand-in for an entity identifier which is supposed to be
- * generated on insert (like an IDENTITY column) where the insert needed to
- * be delayed because we were outside a transaction when the persist
- * occurred (save currently still performs the insert).
- * <p/>
- * The stand-in is only used within the {@link org.hibernate.engine.PersistenceContext}
- * in order to distinguish one instance from another; it is never injected into
- * the entity instance or returned to the client...
- *
- * @author Steve Ebersole
- */
-public class DelayedPostInsertIdentifier implements Serializable {
- private static long SEQUENCE = 0;
- private final long sequence;
-
- public DelayedPostInsertIdentifier() {
- synchronized( DelayedPostInsertIdentifier.class ) {
- if ( SEQUENCE == Long.MAX_VALUE ) {
- SEQUENCE = 0;
- }
- this.sequence = SEQUENCE++;
- }
- }
-
- public boolean equals(Object o) {
- if ( this == o ) {
- return true;
- }
- if ( o == null || getClass() != o.getClass() ) {
- return false;
- }
- final DelayedPostInsertIdentifier that = ( DelayedPostInsertIdentifier ) o;
- return sequence == that.sequence;
- }
-
- public int hashCode() {
- return ( int ) ( sequence ^ ( sequence >>> 32 ) );
- }
-
- public String toString() {
- return "<delayed:" + sequence + ">";
-
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/DelayedPostInsertIdentifier.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,73 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import java.io.Serializable;
+
+/**
+ * Acts as a stand-in for an entity identifier which is supposed to be
+ * generated on insert (like an IDENTITY column) where the insert needed to
+ * be delayed because we were outside a transaction when the persist
+ * occurred (save currently still performs the insert).
+ * <p/>
+ * The stand-in is only used within the {@link org.hibernate.engine.PersistenceContext}
+ * in order to distinguish one instance from another; it is never injected into
+ * the entity instance or returned to the client...
+ *
+ * @author Steve Ebersole
+ */
+public class DelayedPostInsertIdentifier implements Serializable {
+ private static long SEQUENCE = 0;
+ private final long sequence;
+
+ public DelayedPostInsertIdentifier() {
+ synchronized( DelayedPostInsertIdentifier.class ) {
+ if ( SEQUENCE == Long.MAX_VALUE ) {
+ SEQUENCE = 0;
+ }
+ this.sequence = SEQUENCE++;
+ }
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+ final DelayedPostInsertIdentifier that = ( DelayedPostInsertIdentifier ) o;
+ return sequence == that.sequence;
+ }
+
+ public int hashCode() {
+ return ( int ) ( sequence ^ ( sequence >>> 32 ) );
+ }
+
+ public String toString() {
+ return "<delayed:" + sequence + ">";
+
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,136 +0,0 @@
-//$Id: EntityAction.java 11402 2007-04-11 14:24:35Z steve.ebersole(a)jboss.com $
-package org.hibernate.action;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.util.StringHelper;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-
-/**
- * Base class for actions relating to insert/update/delete of an entity
- * instance.
- *
- * @author Gavin King
- */
-public abstract class EntityAction implements Executable, Serializable, Comparable {
-
- private final String entityName;
- private final Serializable id;
- private final Object instance;
- private final SessionImplementor session;
-
- private transient EntityPersister persister;
-
- /**
- * Instantiate an action.
- *
- * @param session The session from which this action is coming.
- * @param id The id of the entity
- * @param instance The entiyt instance
- * @param persister The entity persister
- */
- protected EntityAction(SessionImplementor session, Serializable id, Object instance, EntityPersister persister) {
- this.entityName = persister.getEntityName();
- this.id = id;
- this.instance = instance;
- this.session = session;
- this.persister = persister;
- }
-
- protected abstract boolean hasPostCommitEventListeners();
-
- /**
- * entity name accessor
- *
- * @return The entity name
- */
- public String getEntityName() {
- return entityName;
- }
-
- /**
- * entity id accessor
- *
- * @return The entity id
- */
- public final Serializable getId() {
- if ( id instanceof DelayedPostInsertIdentifier ) {
- return session.getPersistenceContext().getEntry( instance ).getId();
- }
- return id;
- }
-
- /**
- * entity instance accessor
- *
- * @return The entity instance
- */
- public final Object getInstance() {
- return instance;
- }
-
- /**
- * originating session accessor
- *
- * @return The session from which this action originated.
- */
- public final SessionImplementor getSession() {
- return session;
- }
-
- /**
- * entity persister accessor
- *
- * @return The entity persister
- */
- public final EntityPersister getPersister() {
- return persister;
- }
-
- public final Serializable[] getPropertySpaces() {
- return persister.getPropertySpaces();
- }
-
- public void beforeExecutions() {
- throw new AssertionFailure( "beforeExecutions() called for non-collection action" );
- }
-
- public boolean hasAfterTransactionCompletion() {
- return persister.hasCache() || hasPostCommitEventListeners();
- }
-
- public String toString() {
- return StringHelper.unqualify( getClass().getName() ) + MessageHelper.infoString( entityName, id );
- }
-
- public int compareTo(Object other) {
- EntityAction action = ( EntityAction ) other;
- //sort first by entity name
- int roleComparison = entityName.compareTo( action.entityName );
- if ( roleComparison != 0 ) {
- return roleComparison;
- }
- else {
- //then by id
- return persister.getIdentifierType().compare( id, action.id, session.getEntityMode() );
- }
- }
-
- /**
- * Serialization...
- *
- * @param ois Thed object stream
- * @throws IOException Problem performing the default stream reading
- * @throws ClassNotFoundException Problem performing the default stream reading
- */
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- ois.defaultReadObject();
- persister = session.getFactory().getEntityPersister( entityName );
- }
-}
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/EntityAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,159 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.util.StringHelper;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Base class for actions relating to insert/update/delete of an entity
+ * instance.
+ *
+ * @author Gavin King
+ */
+public abstract class EntityAction implements Executable, Serializable, Comparable {
+
+ private final String entityName;
+ private final Serializable id;
+ private final Object instance;
+ private final SessionImplementor session;
+
+ private transient EntityPersister persister;
+
+ /**
+ * Instantiate an action.
+ *
+ * @param session The session from which this action is coming.
+ * @param id The id of the entity
+ * @param instance The entiyt instance
+ * @param persister The entity persister
+ */
+ protected EntityAction(SessionImplementor session, Serializable id, Object instance, EntityPersister persister) {
+ this.entityName = persister.getEntityName();
+ this.id = id;
+ this.instance = instance;
+ this.session = session;
+ this.persister = persister;
+ }
+
+ protected abstract boolean hasPostCommitEventListeners();
+
+ /**
+ * entity name accessor
+ *
+ * @return The entity name
+ */
+ public String getEntityName() {
+ return entityName;
+ }
+
+ /**
+ * entity id accessor
+ *
+ * @return The entity id
+ */
+ public final Serializable getId() {
+ if ( id instanceof DelayedPostInsertIdentifier ) {
+ return session.getPersistenceContext().getEntry( instance ).getId();
+ }
+ return id;
+ }
+
+ /**
+ * entity instance accessor
+ *
+ * @return The entity instance
+ */
+ public final Object getInstance() {
+ return instance;
+ }
+
+ /**
+ * originating session accessor
+ *
+ * @return The session from which this action originated.
+ */
+ public final SessionImplementor getSession() {
+ return session;
+ }
+
+ /**
+ * entity persister accessor
+ *
+ * @return The entity persister
+ */
+ public final EntityPersister getPersister() {
+ return persister;
+ }
+
+ public final Serializable[] getPropertySpaces() {
+ return persister.getPropertySpaces();
+ }
+
+ public void beforeExecutions() {
+ throw new AssertionFailure( "beforeExecutions() called for non-collection action" );
+ }
+
+ public boolean hasAfterTransactionCompletion() {
+ return persister.hasCache() || hasPostCommitEventListeners();
+ }
+
+ public String toString() {
+ return StringHelper.unqualify( getClass().getName() ) + MessageHelper.infoString( entityName, id );
+ }
+
+ public int compareTo(Object other) {
+ EntityAction action = ( EntityAction ) other;
+ //sort first by entity name
+ int roleComparison = entityName.compareTo( action.entityName );
+ if ( roleComparison != 0 ) {
+ return roleComparison;
+ }
+ else {
+ //then by id
+ return persister.getIdentifierType().compare( id, action.id, session.getEntityMode() );
+ }
+ }
+
+ /**
+ * Serialization...
+ *
+ * @param ois Thed object stream
+ * @throws IOException Problem performing the default stream reading
+ * @throws ClassNotFoundException Problem performing the default stream reading
+ */
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ois.defaultReadObject();
+ persister = session.getFactory().getEntityPersister( entityName );
+ }
+}
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,174 +0,0 @@
-//$Id: EntityDeleteAction.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.action;
-
-import java.io.Serializable;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.engine.EntityKey;
-import org.hibernate.engine.PersistenceContext;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.event.PostDeleteEvent;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PreDeleteEvent;
-import org.hibernate.event.PreDeleteEventListener;
-import org.hibernate.event.EventSource;
-import org.hibernate.persister.entity.EntityPersister;
-
-public final class EntityDeleteAction extends EntityAction {
-
- private final Object version;
- private SoftLock lock;
- private final boolean isCascadeDeleteEnabled;
- private final Object[] state;
-
- public EntityDeleteAction(
- final Serializable id,
- final Object[] state,
- final Object version,
- final Object instance,
- final EntityPersister persister,
- final boolean isCascadeDeleteEnabled,
- final SessionImplementor session) {
- super( session, id, instance, persister );
- this.version = version;
- this.isCascadeDeleteEnabled = isCascadeDeleteEnabled;
- this.state = state;
- }
-
- public void execute() throws HibernateException {
- Serializable id = getId();
- EntityPersister persister = getPersister();
- SessionImplementor session = getSession();
- Object instance = getInstance();
-
- boolean veto = preDelete();
-
- Object version = this.version;
- if ( persister.isVersionPropertyGenerated() ) {
- // we need to grab the version value from the entity, otherwise
- // we have issues with generated-version entities that may have
- // multiple actions queued during the same flush
- version = persister.getVersion( instance, session.getEntityMode() );
- }
-
- final CacheKey ck;
- if ( persister.hasCache() ) {
- ck = new CacheKey(
- id,
- persister.getIdentifierType(),
- persister.getRootEntityName(),
- session.getEntityMode(),
- session.getFactory()
- );
- lock = persister.getCacheAccessStrategy().lockItem( ck, version );
- }
- else {
- ck = null;
- }
-
- if ( !isCascadeDeleteEnabled && !veto ) {
- persister.delete( id, version, instance, session );
- }
-
- //postDelete:
- // After actually deleting a row, record the fact that the instance no longer
- // exists on the database (needed for identity-column key generation), and
- // remove it from the session cache
- final PersistenceContext persistenceContext = session.getPersistenceContext();
- EntityEntry entry = persistenceContext.removeEntry( instance );
- if ( entry == null ) {
- throw new AssertionFailure( "possible nonthreadsafe access to session" );
- }
- entry.postDelete();
-
- EntityKey key = new EntityKey( entry.getId(), entry.getPersister(), session.getEntityMode() );
- persistenceContext.removeEntity(key);
- persistenceContext.removeProxy(key);
-
- if ( persister.hasCache() ) persister.getCacheAccessStrategy().remove( ck );
-
- postDelete();
-
- if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
- getSession().getFactory().getStatisticsImplementor()
- .deleteEntity( getPersister().getEntityName() );
- }
- }
-
- private boolean preDelete() {
- PreDeleteEventListener[] preListeners = getSession().getListeners()
- .getPreDeleteEventListeners();
- boolean veto = false;
- if (preListeners.length>0) {
- PreDeleteEvent preEvent = new PreDeleteEvent( getInstance(), getId(), state, getPersister() );
- for ( int i = 0; i < preListeners.length; i++ ) {
- veto = preListeners[i].onPreDelete(preEvent) || veto;
- }
- }
- return veto;
- }
-
- private void postDelete() {
- PostDeleteEventListener[] postListeners = getSession().getListeners()
- .getPostDeleteEventListeners();
- if (postListeners.length>0) {
- PostDeleteEvent postEvent = new PostDeleteEvent(
- getInstance(),
- getId(),
- state,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostDelete(postEvent);
- }
- }
- }
-
- private void postCommitDelete() {
- PostDeleteEventListener[] postListeners = getSession().getListeners()
- .getPostCommitDeleteEventListeners();
- if (postListeners.length>0) {
- PostDeleteEvent postEvent = new PostDeleteEvent(
- getInstance(),
- getId(),
- state,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostDelete(postEvent);
- }
- }
- }
-
- public void afterTransactionCompletion(boolean success) throws HibernateException {
- if ( getPersister().hasCache() ) {
- final CacheKey ck = new CacheKey(
- getId(),
- getPersister().getIdentifierType(),
- getPersister().getRootEntityName(),
- getSession().getEntityMode(),
- getSession().getFactory()
- );
- getPersister().getCacheAccessStrategy().unlockItem( ck, lock );
- }
- postCommitDelete();
- }
-
- protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitDeleteEventListeners().length>0;
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/EntityDeleteAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityDeleteAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,197 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import java.io.Serializable;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.engine.EntityEntry;
+import org.hibernate.engine.EntityKey;
+import org.hibernate.engine.PersistenceContext;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.event.PostDeleteEvent;
+import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PreDeleteEvent;
+import org.hibernate.event.PreDeleteEventListener;
+import org.hibernate.event.EventSource;
+import org.hibernate.persister.entity.EntityPersister;
+
+public final class EntityDeleteAction extends EntityAction {
+
+ private final Object version;
+ private SoftLock lock;
+ private final boolean isCascadeDeleteEnabled;
+ private final Object[] state;
+
+ public EntityDeleteAction(
+ final Serializable id,
+ final Object[] state,
+ final Object version,
+ final Object instance,
+ final EntityPersister persister,
+ final boolean isCascadeDeleteEnabled,
+ final SessionImplementor session) {
+ super( session, id, instance, persister );
+ this.version = version;
+ this.isCascadeDeleteEnabled = isCascadeDeleteEnabled;
+ this.state = state;
+ }
+
+ public void execute() throws HibernateException {
+ Serializable id = getId();
+ EntityPersister persister = getPersister();
+ SessionImplementor session = getSession();
+ Object instance = getInstance();
+
+ boolean veto = preDelete();
+
+ Object version = this.version;
+ if ( persister.isVersionPropertyGenerated() ) {
+ // we need to grab the version value from the entity, otherwise
+ // we have issues with generated-version entities that may have
+ // multiple actions queued during the same flush
+ version = persister.getVersion( instance, session.getEntityMode() );
+ }
+
+ final CacheKey ck;
+ if ( persister.hasCache() ) {
+ ck = new CacheKey(
+ id,
+ persister.getIdentifierType(),
+ persister.getRootEntityName(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ lock = persister.getCacheAccessStrategy().lockItem( ck, version );
+ }
+ else {
+ ck = null;
+ }
+
+ if ( !isCascadeDeleteEnabled && !veto ) {
+ persister.delete( id, version, instance, session );
+ }
+
+ //postDelete:
+ // After actually deleting a row, record the fact that the instance no longer
+ // exists on the database (needed for identity-column key generation), and
+ // remove it from the session cache
+ final PersistenceContext persistenceContext = session.getPersistenceContext();
+ EntityEntry entry = persistenceContext.removeEntry( instance );
+ if ( entry == null ) {
+ throw new AssertionFailure( "possible nonthreadsafe access to session" );
+ }
+ entry.postDelete();
+
+ EntityKey key = new EntityKey( entry.getId(), entry.getPersister(), session.getEntityMode() );
+ persistenceContext.removeEntity(key);
+ persistenceContext.removeProxy(key);
+
+ if ( persister.hasCache() ) persister.getCacheAccessStrategy().remove( ck );
+
+ postDelete();
+
+ if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
+ getSession().getFactory().getStatisticsImplementor()
+ .deleteEntity( getPersister().getEntityName() );
+ }
+ }
+
+ private boolean preDelete() {
+ PreDeleteEventListener[] preListeners = getSession().getListeners()
+ .getPreDeleteEventListeners();
+ boolean veto = false;
+ if (preListeners.length>0) {
+ PreDeleteEvent preEvent = new PreDeleteEvent( getInstance(), getId(), state, getPersister() );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ veto = preListeners[i].onPreDelete(preEvent) || veto;
+ }
+ }
+ return veto;
+ }
+
+ private void postDelete() {
+ PostDeleteEventListener[] postListeners = getSession().getListeners()
+ .getPostDeleteEventListeners();
+ if (postListeners.length>0) {
+ PostDeleteEvent postEvent = new PostDeleteEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostDelete(postEvent);
+ }
+ }
+ }
+
+ private void postCommitDelete() {
+ PostDeleteEventListener[] postListeners = getSession().getListeners()
+ .getPostCommitDeleteEventListeners();
+ if (postListeners.length>0) {
+ PostDeleteEvent postEvent = new PostDeleteEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostDelete(postEvent);
+ }
+ }
+ }
+
+ public void afterTransactionCompletion(boolean success) throws HibernateException {
+ if ( getPersister().hasCache() ) {
+ final CacheKey ck = new CacheKey(
+ getId(),
+ getPersister().getIdentifierType(),
+ getPersister().getRootEntityName(),
+ getSession().getEntityMode(),
+ getSession().getFactory()
+ );
+ getPersister().getCacheAccessStrategy().unlockItem( ck, lock );
+ }
+ postCommitDelete();
+ }
+
+ protected boolean hasPostCommitEventListeners() {
+ return getSession().getListeners().getPostCommitDeleteEventListeners().length>0;
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,159 +0,0 @@
-//$Id: EntityIdentityInsertAction.java 10680 2006-11-01 22:53:30Z epbernard $
-package org.hibernate.action;
-
-import java.io.Serializable;
-
-import org.hibernate.HibernateException;
-import org.hibernate.AssertionFailure;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.EntityKey;
-import org.hibernate.event.PostInsertEvent;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PreInsertEvent;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.EventSource;
-import org.hibernate.persister.entity.EntityPersister;
-
-public final class EntityIdentityInsertAction extends EntityAction {
- private final Object[] state;
- private final boolean isDelayed;
- private final EntityKey delayedEntityKey;
- //private CacheEntry cacheEntry;
- private Serializable generatedId;
-
- public EntityIdentityInsertAction(
- Object[] state,
- Object instance,
- EntityPersister persister,
- SessionImplementor session,
- boolean isDelayed) throws HibernateException {
- super( session, null, instance, persister );
- this.state = state;
- this.isDelayed = isDelayed;
- delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
- }
-
- public void execute() throws HibernateException {
-
- final EntityPersister persister = getPersister();
- final SessionImplementor session = getSession();
- final Object instance = getInstance();
-
- boolean veto = preInsert();
-
- // Don't need to lock the cache here, since if someone
- // else inserted the same pk first, the insert would fail
-
- if ( !veto ) {
- generatedId = persister.insert( state, instance, session );
- if ( persister.hasInsertGeneratedProperties() ) {
- persister.processInsertGeneratedProperties( generatedId, instance, state, session );
- }
- //need to do that here rather than in the save event listener to let
- //the post insert events to have a id-filled entity when IDENTITY is used (EJB3)
- persister.setIdentifier( instance, generatedId, session.getEntityMode() );
- }
-
-
- //TODO: this bit actually has to be called after all cascades!
- // but since identity insert is called *synchronously*,
- // instead of asynchronously as other actions, it isn't
- /*if ( persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
- cacheEntry = new CacheEntry(object, persister, session);
- persister.getCache().insert(generatedId, cacheEntry);
- }*/
-
- postInsert();
-
- if ( session.getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
- session.getFactory().getStatisticsImplementor()
- .insertEntity( getPersister().getEntityName() );
- }
-
- }
-
- private void postInsert() {
- if ( isDelayed ) {
- getSession().getPersistenceContext().replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
- }
- PostInsertEventListener[] postListeners = getSession().getListeners()
- .getPostInsertEventListeners();
- if (postListeners.length>0) {
- PostInsertEvent postEvent = new PostInsertEvent(
- getInstance(),
- generatedId,
- state,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostInsert(postEvent);
- }
- }
- }
-
- private void postCommitInsert() {
- PostInsertEventListener[] postListeners = getSession().getListeners()
- .getPostCommitInsertEventListeners();
- if (postListeners.length>0) {
- PostInsertEvent postEvent = new PostInsertEvent(
- getInstance(),
- generatedId,
- state,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostInsert(postEvent);
- }
- }
- }
-
- private boolean preInsert() {
- PreInsertEventListener[] preListeners = getSession().getListeners()
- .getPreInsertEventListeners();
- boolean veto = false;
- if (preListeners.length>0) {
- PreInsertEvent preEvent = new PreInsertEvent( getInstance(), null, state, getPersister(), getSession() );
- for ( int i = 0; i < preListeners.length; i++ ) {
- veto = preListeners[i].onPreInsert(preEvent) || veto;
- }
- }
- return veto;
- }
-
- //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
- public void afterTransactionCompletion(boolean success) throws HibernateException {
- //TODO: reenable if we also fix the above todo
- /*EntityPersister persister = getEntityPersister();
- if ( success && persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
- persister.getCache().afterInsert( getGeneratedId(), cacheEntry );
- }*/
- postCommitInsert();
- }
-
- public boolean hasAfterTransactionCompletion() {
- //TODO: simply remove this override
- // if we fix the above todos
- return hasPostCommitEventListeners();
- }
-
- protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
- }
-
- public final Serializable getGeneratedId() {
- return generatedId;
- }
-
- public EntityKey getDelayedEntityKey() {
- return delayedEntityKey;
- }
-
- private synchronized EntityKey generateDelayedEntityKey() {
- if ( !isDelayed ) {
- throw new AssertionFailure( "cannot request delayed entity-key for non-delayed post-insert-id generation" );
- }
- return new EntityKey( new DelayedPostInsertIdentifier(), getPersister(), getSession().getEntityMode() );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityIdentityInsertAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,182 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import java.io.Serializable;
+
+import org.hibernate.HibernateException;
+import org.hibernate.AssertionFailure;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.EntityKey;
+import org.hibernate.event.PostInsertEvent;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.event.PreInsertEvent;
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.EventSource;
+import org.hibernate.persister.entity.EntityPersister;
+
+public final class EntityIdentityInsertAction extends EntityAction {
+ private final Object[] state;
+ private final boolean isDelayed;
+ private final EntityKey delayedEntityKey;
+ //private CacheEntry cacheEntry;
+ private Serializable generatedId;
+
+ public EntityIdentityInsertAction(
+ Object[] state,
+ Object instance,
+ EntityPersister persister,
+ SessionImplementor session,
+ boolean isDelayed) throws HibernateException {
+ super( session, null, instance, persister );
+ this.state = state;
+ this.isDelayed = isDelayed;
+ delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
+ }
+
+ public void execute() throws HibernateException {
+
+ final EntityPersister persister = getPersister();
+ final SessionImplementor session = getSession();
+ final Object instance = getInstance();
+
+ boolean veto = preInsert();
+
+ // Don't need to lock the cache here, since if someone
+ // else inserted the same pk first, the insert would fail
+
+ if ( !veto ) {
+ generatedId = persister.insert( state, instance, session );
+ if ( persister.hasInsertGeneratedProperties() ) {
+ persister.processInsertGeneratedProperties( generatedId, instance, state, session );
+ }
+ //need to do that here rather than in the save event listener to let
+ //the post insert events to have a id-filled entity when IDENTITY is used (EJB3)
+ persister.setIdentifier( instance, generatedId, session.getEntityMode() );
+ }
+
+
+ //TODO: this bit actually has to be called after all cascades!
+ // but since identity insert is called *synchronously*,
+ // instead of asynchronously as other actions, it isn't
+ /*if ( persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
+ cacheEntry = new CacheEntry(object, persister, session);
+ persister.getCache().insert(generatedId, cacheEntry);
+ }*/
+
+ postInsert();
+
+ if ( session.getFactory().getStatistics().isStatisticsEnabled() && !veto ) {
+ session.getFactory().getStatisticsImplementor()
+ .insertEntity( getPersister().getEntityName() );
+ }
+
+ }
+
+ private void postInsert() {
+ if ( isDelayed ) {
+ getSession().getPersistenceContext().replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
+ }
+ PostInsertEventListener[] postListeners = getSession().getListeners()
+ .getPostInsertEventListeners();
+ if (postListeners.length>0) {
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ generatedId,
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostInsert(postEvent);
+ }
+ }
+ }
+
+ private void postCommitInsert() {
+ PostInsertEventListener[] postListeners = getSession().getListeners()
+ .getPostCommitInsertEventListeners();
+ if (postListeners.length>0) {
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ generatedId,
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostInsert(postEvent);
+ }
+ }
+ }
+
+ private boolean preInsert() {
+ PreInsertEventListener[] preListeners = getSession().getListeners()
+ .getPreInsertEventListeners();
+ boolean veto = false;
+ if (preListeners.length>0) {
+ PreInsertEvent preEvent = new PreInsertEvent( getInstance(), null, state, getPersister(), getSession() );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ veto = preListeners[i].onPreInsert(preEvent) || veto;
+ }
+ }
+ return veto;
+ }
+
+ //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
+ public void afterTransactionCompletion(boolean success) throws HibernateException {
+ //TODO: reenable if we also fix the above todo
+ /*EntityPersister persister = getEntityPersister();
+ if ( success && persister.hasCache() && !persister.isCacheInvalidationRequired() ) {
+ persister.getCache().afterInsert( getGeneratedId(), cacheEntry );
+ }*/
+ postCommitInsert();
+ }
+
+ public boolean hasAfterTransactionCompletion() {
+ //TODO: simply remove this override
+ // if we fix the above todos
+ return hasPostCommitEventListeners();
+ }
+
+ protected boolean hasPostCommitEventListeners() {
+ return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
+ }
+
+ public final Serializable getGeneratedId() {
+ return generatedId;
+ }
+
+ public EntityKey getDelayedEntityKey() {
+ return delayedEntityKey;
+ }
+
+ private synchronized EntityKey generateDelayedEntityKey() {
+ if ( !isDelayed ) {
+ throw new AssertionFailure( "cannot request delayed entity-key for non-delayed post-insert-id generation" );
+ }
+ return new EntityKey( new DelayedPostInsertIdentifier(), getPersister(), getSession().getEntityMode() );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,199 +0,0 @@
-//$Id: EntityInsertAction.java 11402 2007-04-11 14:24:35Z steve.ebersole(a)jboss.com $
-package org.hibernate.action;
-
-import java.io.Serializable;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.cache.entry.CacheEntry;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.Versioning;
-import org.hibernate.event.PostInsertEvent;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PreInsertEvent;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.EventSource;
-import org.hibernate.persister.entity.EntityPersister;
-
-public final class EntityInsertAction extends EntityAction {
-
- private Object[] state;
- private Object version;
- private Object cacheEntry;
-
- public EntityInsertAction(
- Serializable id,
- Object[] state,
- Object instance,
- Object version,
- EntityPersister persister,
- SessionImplementor session) throws HibernateException {
- super( session, id, instance, persister );
- this.state = state;
- this.version = version;
- }
-
- public Object[] getState() {
- return state;
- }
-
- public void execute() throws HibernateException {
- EntityPersister persister = getPersister();
- SessionImplementor session = getSession();
- Object instance = getInstance();
- Serializable id = getId();
-
- boolean veto = preInsert();
-
- // Don't need to lock the cache here, since if someone
- // else inserted the same pk first, the insert would fail
-
- if ( !veto ) {
-
- persister.insert( id, state, instance, session );
-
- EntityEntry entry = session.getPersistenceContext().getEntry( instance );
- if ( entry == null ) {
- throw new AssertionFailure( "possible nonthreadsafe access to session" );
- }
-
- entry.postInsert();
-
- if ( persister.hasInsertGeneratedProperties() ) {
- persister.processInsertGeneratedProperties( id, instance, state, session );
- if ( persister.isVersionPropertyGenerated() ) {
- version = Versioning.getVersion(state, persister);
- }
- entry.postUpdate(instance, state, version);
- }
-
- }
-
- final SessionFactoryImplementor factory = getSession().getFactory();
-
- if ( isCachePutEnabled( persister, session ) ) {
-
- CacheEntry ce = new CacheEntry(
- state,
- persister,
- persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
- version,
- session,
- instance
- );
-
- cacheEntry = persister.getCacheEntryStructure().structure(ce);
- final CacheKey ck = new CacheKey(
- id,
- persister.getIdentifierType(),
- persister.getRootEntityName(),
- session.getEntityMode(),
- session.getFactory()
- );
-// boolean put = persister.getCache().insert(ck, cacheEntry);
- boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
-
- if ( put && factory.getStatistics().isStatisticsEnabled() ) {
- factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
- }
-
- }
-
- postInsert();
-
- if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
- factory.getStatisticsImplementor()
- .insertEntity( getPersister().getEntityName() );
- }
-
- }
-
- private void postInsert() {
- PostInsertEventListener[] postListeners = getSession().getListeners()
- .getPostInsertEventListeners();
- if ( postListeners.length > 0 ) {
- PostInsertEvent postEvent = new PostInsertEvent(
- getInstance(),
- getId(),
- state,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostInsert(postEvent);
- }
- }
- }
-
- private void postCommitInsert() {
- PostInsertEventListener[] postListeners = getSession().getListeners()
- .getPostCommitInsertEventListeners();
- if ( postListeners.length > 0 ) {
- PostInsertEvent postEvent = new PostInsertEvent(
- getInstance(),
- getId(),
- state,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostInsert(postEvent);
- }
- }
- }
-
- private boolean preInsert() {
- PreInsertEventListener[] preListeners = getSession().getListeners()
- .getPreInsertEventListeners();
- boolean veto = false;
- if (preListeners.length>0) {
- PreInsertEvent preEvent = new PreInsertEvent( getInstance(), getId(), state, getPersister(), getSession() );
- for ( int i = 0; i < preListeners.length; i++ ) {
- veto = preListeners[i].onPreInsert(preEvent) || veto;
- }
- }
- return veto;
- }
-
- //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
- public void afterTransactionCompletion(boolean success) throws HibernateException {
- EntityPersister persister = getPersister();
- if ( success && isCachePutEnabled( persister, getSession() ) ) {
- final CacheKey ck = new CacheKey(
- getId(),
- persister.getIdentifierType(),
- persister.getRootEntityName(),
- getSession().getEntityMode(),
- getSession().getFactory()
- );
- boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version );
-
- if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
- getSession().getFactory().getStatisticsImplementor()
- .secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
- }
- }
- postCommitInsert();
- }
-
- protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
- }
-
- private boolean isCachePutEnabled(EntityPersister persister, SessionImplementor session) {
- return persister.hasCache() &&
- !persister.isCacheInvalidationRequired() &&
- session.getCacheMode().isPutEnabled();
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/EntityInsertAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityInsertAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,222 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import java.io.Serializable;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.cache.entry.CacheEntry;
+import org.hibernate.engine.EntityEntry;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.Versioning;
+import org.hibernate.event.PostInsertEvent;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.event.PreInsertEvent;
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.EventSource;
+import org.hibernate.persister.entity.EntityPersister;
+
+public final class EntityInsertAction extends EntityAction {
+
+ private Object[] state;
+ private Object version;
+ private Object cacheEntry;
+
+ public EntityInsertAction(
+ Serializable id,
+ Object[] state,
+ Object instance,
+ Object version,
+ EntityPersister persister,
+ SessionImplementor session) throws HibernateException {
+ super( session, id, instance, persister );
+ this.state = state;
+ this.version = version;
+ }
+
+ public Object[] getState() {
+ return state;
+ }
+
+ public void execute() throws HibernateException {
+ EntityPersister persister = getPersister();
+ SessionImplementor session = getSession();
+ Object instance = getInstance();
+ Serializable id = getId();
+
+ boolean veto = preInsert();
+
+ // Don't need to lock the cache here, since if someone
+ // else inserted the same pk first, the insert would fail
+
+ if ( !veto ) {
+
+ persister.insert( id, state, instance, session );
+
+ EntityEntry entry = session.getPersistenceContext().getEntry( instance );
+ if ( entry == null ) {
+ throw new AssertionFailure( "possible nonthreadsafe access to session" );
+ }
+
+ entry.postInsert();
+
+ if ( persister.hasInsertGeneratedProperties() ) {
+ persister.processInsertGeneratedProperties( id, instance, state, session );
+ if ( persister.isVersionPropertyGenerated() ) {
+ version = Versioning.getVersion(state, persister);
+ }
+ entry.postUpdate(instance, state, version);
+ }
+
+ }
+
+ final SessionFactoryImplementor factory = getSession().getFactory();
+
+ if ( isCachePutEnabled( persister, session ) ) {
+
+ CacheEntry ce = new CacheEntry(
+ state,
+ persister,
+ persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
+ version,
+ session,
+ instance
+ );
+
+ cacheEntry = persister.getCacheEntryStructure().structure(ce);
+ final CacheKey ck = new CacheKey(
+ id,
+ persister.getIdentifierType(),
+ persister.getRootEntityName(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+// boolean put = persister.getCache().insert(ck, cacheEntry);
+ boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
+
+ if ( put && factory.getStatistics().isStatisticsEnabled() ) {
+ factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
+ }
+
+ }
+
+ postInsert();
+
+ if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
+ factory.getStatisticsImplementor()
+ .insertEntity( getPersister().getEntityName() );
+ }
+
+ }
+
+ private void postInsert() {
+ PostInsertEventListener[] postListeners = getSession().getListeners()
+ .getPostInsertEventListeners();
+ if ( postListeners.length > 0 ) {
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostInsert(postEvent);
+ }
+ }
+ }
+
+ private void postCommitInsert() {
+ PostInsertEventListener[] postListeners = getSession().getListeners()
+ .getPostCommitInsertEventListeners();
+ if ( postListeners.length > 0 ) {
+ PostInsertEvent postEvent = new PostInsertEvent(
+ getInstance(),
+ getId(),
+ state,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostInsert(postEvent);
+ }
+ }
+ }
+
+ private boolean preInsert() {
+ PreInsertEventListener[] preListeners = getSession().getListeners()
+ .getPreInsertEventListeners();
+ boolean veto = false;
+ if (preListeners.length>0) {
+ PreInsertEvent preEvent = new PreInsertEvent( getInstance(), getId(), state, getPersister(), getSession() );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ veto = preListeners[i].onPreInsert(preEvent) || veto;
+ }
+ }
+ return veto;
+ }
+
+ //Make 100% certain that this is called before any subsequent ScheduledUpdate.afterTransactionCompletion()!!
+ public void afterTransactionCompletion(boolean success) throws HibernateException {
+ EntityPersister persister = getPersister();
+ if ( success && isCachePutEnabled( persister, getSession() ) ) {
+ final CacheKey ck = new CacheKey(
+ getId(),
+ persister.getIdentifierType(),
+ persister.getRootEntityName(),
+ getSession().getEntityMode(),
+ getSession().getFactory()
+ );
+ boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version );
+
+ if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
+ getSession().getFactory().getStatisticsImplementor()
+ .secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
+ }
+ }
+ postCommitInsert();
+ }
+
+ protected boolean hasPostCommitEventListeners() {
+ return getSession().getListeners().getPostCommitInsertEventListeners().length>0;
+ }
+
+ private boolean isCachePutEnabled(EntityPersister persister, SessionImplementor session) {
+ return persister.hasCache() &&
+ !persister.isCacheInvalidationRequired() &&
+ session.getCacheMode().isPutEnabled();
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,257 +0,0 @@
-//$Id: EntityUpdateAction.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.action;
-
-import java.io.Serializable;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cache.entry.CacheEntry;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.Status;
-import org.hibernate.engine.Versioning;
-import org.hibernate.event.PostUpdateEvent;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PreUpdateEvent;
-import org.hibernate.event.PreUpdateEventListener;
-import org.hibernate.event.EventSource;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.TypeFactory;
-
-public final class EntityUpdateAction extends EntityAction {
-
- private final Object[] state;
- private final Object[] previousState;
- private final Object previousVersion;
- private Object nextVersion;
- private final int[] dirtyFields;
- private final boolean hasDirtyCollection;
- private final Object rowId;
- private Object cacheEntry;
- private SoftLock lock;
-
- public EntityUpdateAction(
- final Serializable id,
- final Object[] state,
- final int[] dirtyProperties,
- final boolean hasDirtyCollection,
- final Object[] previousState,
- final Object previousVersion,
- final Object nextVersion,
- final Object instance,
- final Object rowId,
- final EntityPersister persister,
- final SessionImplementor session) throws HibernateException {
- super( session, id, instance, persister );
- this.state = state;
- this.previousState = previousState;
- this.previousVersion = previousVersion;
- this.nextVersion = nextVersion;
- this.dirtyFields = dirtyProperties;
- this.hasDirtyCollection = hasDirtyCollection;
- this.rowId = rowId;
- }
-
- public void execute() throws HibernateException {
- Serializable id = getId();
- EntityPersister persister = getPersister();
- SessionImplementor session = getSession();
- Object instance = getInstance();
-
- boolean veto = preUpdate();
-
- final SessionFactoryImplementor factory = getSession().getFactory();
- Object previousVersion = this.previousVersion;
- if ( persister.isVersionPropertyGenerated() ) {
- // we need to grab the version value from the entity, otherwise
- // we have issues with generated-version entities that may have
- // multiple actions queued during the same flush
- previousVersion = persister.getVersion( instance, session.getEntityMode() );
- }
-
- final CacheKey ck;
- if ( persister.hasCache() ) {
- ck = new CacheKey(
- id,
- persister.getIdentifierType(),
- persister.getRootEntityName(),
- session.getEntityMode(),
- session.getFactory()
- );
- lock = persister.getCacheAccessStrategy().lockItem( ck, previousVersion );
- }
- else {
- ck = null;
- }
-
- if ( !veto ) {
- persister.update(
- id,
- state,
- dirtyFields,
- hasDirtyCollection,
- previousState,
- previousVersion,
- instance,
- rowId,
- session
- );
- }
-
- EntityEntry entry = getSession().getPersistenceContext().getEntry( instance );
- if ( entry == null ) {
- throw new AssertionFailure( "possible nonthreadsafe access to session" );
- }
-
- if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) {
- // get the updated snapshot of the entity state by cloning current state;
- // it is safe to copy in place, since by this time no-one else (should have)
- // has a reference to the array
- TypeFactory.deepCopy(
- state,
- persister.getPropertyTypes(),
- persister.getPropertyCheckability(),
- state,
- session
- );
- if ( persister.hasUpdateGeneratedProperties() ) {
- // this entity defines proeprty generation, so process those generated
- // values...
- persister.processUpdateGeneratedProperties( id, instance, state, session );
- if ( persister.isVersionPropertyGenerated() ) {
- nextVersion = Versioning.getVersion( state, persister );
- }
- }
- // have the entity entry perform post-update processing, passing it the
- // update state and the new version (if one).
- entry.postUpdate( instance, state, nextVersion );
- }
-
- if ( persister.hasCache() ) {
- if ( persister.isCacheInvalidationRequired() || entry.getStatus()!=Status.MANAGED ) {
- persister.getCacheAccessStrategy().remove( ck );
- }
- else {
- //TODO: inefficient if that cache is just going to ignore the updated state!
- CacheEntry ce = new CacheEntry(
- state,
- persister,
- persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
- nextVersion,
- getSession(),
- instance
- );
- cacheEntry = persister.getCacheEntryStructure().structure( ce );
- boolean put = persister.getCacheAccessStrategy().update( ck, cacheEntry, nextVersion, previousVersion );
- if ( put && factory.getStatistics().isStatisticsEnabled() ) {
- factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
- }
- }
- }
-
- postUpdate();
-
- if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
- factory.getStatisticsImplementor()
- .updateEntity( getPersister().getEntityName() );
- }
- }
-
- private void postUpdate() {
- PostUpdateEventListener[] postListeners = getSession().getListeners()
- .getPostUpdateEventListeners();
- if (postListeners.length>0) {
- PostUpdateEvent postEvent = new PostUpdateEvent(
- getInstance(),
- getId(),
- state,
- previousState,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostUpdate(postEvent);
- }
- }
- }
-
- private void postCommitUpdate() {
- PostUpdateEventListener[] postListeners = getSession().getListeners()
- .getPostCommitUpdateEventListeners();
- if (postListeners.length>0) {
- PostUpdateEvent postEvent = new PostUpdateEvent(
- getInstance(),
- getId(),
- state,
- previousState,
- getPersister(),
- (EventSource) getSession()
- );
- for ( int i = 0; i < postListeners.length; i++ ) {
- postListeners[i].onPostUpdate(postEvent);
- }
- }
- }
-
- private boolean preUpdate() {
- PreUpdateEventListener[] preListeners = getSession().getListeners()
- .getPreUpdateEventListeners();
- boolean veto = false;
- if (preListeners.length>0) {
- PreUpdateEvent preEvent = new PreUpdateEvent(
- getInstance(),
- getId(),
- state,
- previousState,
- getPersister(),
- getSession()
- );
- for ( int i = 0; i < preListeners.length; i++ ) {
- veto = preListeners[i].onPreUpdate(preEvent) || veto;
- }
- }
- return veto;
- }
-
- public void afterTransactionCompletion(boolean success) throws CacheException {
- EntityPersister persister = getPersister();
- if ( persister.hasCache() ) {
-
- final CacheKey ck = new CacheKey(
- getId(),
- persister.getIdentifierType(),
- persister.getRootEntityName(),
- getSession().getEntityMode(),
- getSession().getFactory()
- );
-
- if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) {
- boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock );
-
- if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
- getSession().getFactory().getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
- }
- }
- else {
- persister.getCacheAccessStrategy().unlockItem( ck, lock );
- }
- }
- postCommitUpdate();
- }
-
- protected boolean hasPostCommitEventListeners() {
- return getSession().getListeners().getPostCommitUpdateEventListeners().length>0;
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/EntityUpdateAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/EntityUpdateAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,280 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import java.io.Serializable;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.entry.CacheEntry;
+import org.hibernate.engine.EntityEntry;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.Status;
+import org.hibernate.engine.Versioning;
+import org.hibernate.event.PostUpdateEvent;
+import org.hibernate.event.PostUpdateEventListener;
+import org.hibernate.event.PreUpdateEvent;
+import org.hibernate.event.PreUpdateEventListener;
+import org.hibernate.event.EventSource;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.TypeFactory;
+
+public final class EntityUpdateAction extends EntityAction {
+
+ private final Object[] state;
+ private final Object[] previousState;
+ private final Object previousVersion;
+ private Object nextVersion;
+ private final int[] dirtyFields;
+ private final boolean hasDirtyCollection;
+ private final Object rowId;
+ private Object cacheEntry;
+ private SoftLock lock;
+
+ public EntityUpdateAction(
+ final Serializable id,
+ final Object[] state,
+ final int[] dirtyProperties,
+ final boolean hasDirtyCollection,
+ final Object[] previousState,
+ final Object previousVersion,
+ final Object nextVersion,
+ final Object instance,
+ final Object rowId,
+ final EntityPersister persister,
+ final SessionImplementor session) throws HibernateException {
+ super( session, id, instance, persister );
+ this.state = state;
+ this.previousState = previousState;
+ this.previousVersion = previousVersion;
+ this.nextVersion = nextVersion;
+ this.dirtyFields = dirtyProperties;
+ this.hasDirtyCollection = hasDirtyCollection;
+ this.rowId = rowId;
+ }
+
+ public void execute() throws HibernateException {
+ Serializable id = getId();
+ EntityPersister persister = getPersister();
+ SessionImplementor session = getSession();
+ Object instance = getInstance();
+
+ boolean veto = preUpdate();
+
+ final SessionFactoryImplementor factory = getSession().getFactory();
+ Object previousVersion = this.previousVersion;
+ if ( persister.isVersionPropertyGenerated() ) {
+ // we need to grab the version value from the entity, otherwise
+ // we have issues with generated-version entities that may have
+ // multiple actions queued during the same flush
+ previousVersion = persister.getVersion( instance, session.getEntityMode() );
+ }
+
+ final CacheKey ck;
+ if ( persister.hasCache() ) {
+ ck = new CacheKey(
+ id,
+ persister.getIdentifierType(),
+ persister.getRootEntityName(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ lock = persister.getCacheAccessStrategy().lockItem( ck, previousVersion );
+ }
+ else {
+ ck = null;
+ }
+
+ if ( !veto ) {
+ persister.update(
+ id,
+ state,
+ dirtyFields,
+ hasDirtyCollection,
+ previousState,
+ previousVersion,
+ instance,
+ rowId,
+ session
+ );
+ }
+
+ EntityEntry entry = getSession().getPersistenceContext().getEntry( instance );
+ if ( entry == null ) {
+ throw new AssertionFailure( "possible nonthreadsafe access to session" );
+ }
+
+ if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) {
+ // get the updated snapshot of the entity state by cloning current state;
+ // it is safe to copy in place, since by this time no-one else (should have)
+ // has a reference to the array
+ TypeFactory.deepCopy(
+ state,
+ persister.getPropertyTypes(),
+ persister.getPropertyCheckability(),
+ state,
+ session
+ );
+ if ( persister.hasUpdateGeneratedProperties() ) {
+ // this entity defines proeprty generation, so process those generated
+ // values...
+ persister.processUpdateGeneratedProperties( id, instance, state, session );
+ if ( persister.isVersionPropertyGenerated() ) {
+ nextVersion = Versioning.getVersion( state, persister );
+ }
+ }
+ // have the entity entry perform post-update processing, passing it the
+ // update state and the new version (if one).
+ entry.postUpdate( instance, state, nextVersion );
+ }
+
+ if ( persister.hasCache() ) {
+ if ( persister.isCacheInvalidationRequired() || entry.getStatus()!=Status.MANAGED ) {
+ persister.getCacheAccessStrategy().remove( ck );
+ }
+ else {
+ //TODO: inefficient if that cache is just going to ignore the updated state!
+ CacheEntry ce = new CacheEntry(
+ state,
+ persister,
+ persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
+ nextVersion,
+ getSession(),
+ instance
+ );
+ cacheEntry = persister.getCacheEntryStructure().structure( ce );
+ boolean put = persister.getCacheAccessStrategy().update( ck, cacheEntry, nextVersion, previousVersion );
+ if ( put && factory.getStatistics().isStatisticsEnabled() ) {
+ factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
+ }
+ }
+ }
+
+ postUpdate();
+
+ if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
+ factory.getStatisticsImplementor()
+ .updateEntity( getPersister().getEntityName() );
+ }
+ }
+
+ private void postUpdate() {
+ PostUpdateEventListener[] postListeners = getSession().getListeners()
+ .getPostUpdateEventListeners();
+ if (postListeners.length>0) {
+ PostUpdateEvent postEvent = new PostUpdateEvent(
+ getInstance(),
+ getId(),
+ state,
+ previousState,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostUpdate(postEvent);
+ }
+ }
+ }
+
+ private void postCommitUpdate() {
+ PostUpdateEventListener[] postListeners = getSession().getListeners()
+ .getPostCommitUpdateEventListeners();
+ if (postListeners.length>0) {
+ PostUpdateEvent postEvent = new PostUpdateEvent(
+ getInstance(),
+ getId(),
+ state,
+ previousState,
+ getPersister(),
+ (EventSource) getSession()
+ );
+ for ( int i = 0; i < postListeners.length; i++ ) {
+ postListeners[i].onPostUpdate(postEvent);
+ }
+ }
+ }
+
+ private boolean preUpdate() {
+ PreUpdateEventListener[] preListeners = getSession().getListeners()
+ .getPreUpdateEventListeners();
+ boolean veto = false;
+ if (preListeners.length>0) {
+ PreUpdateEvent preEvent = new PreUpdateEvent(
+ getInstance(),
+ getId(),
+ state,
+ previousState,
+ getPersister(),
+ getSession()
+ );
+ for ( int i = 0; i < preListeners.length; i++ ) {
+ veto = preListeners[i].onPreUpdate(preEvent) || veto;
+ }
+ }
+ return veto;
+ }
+
+ public void afterTransactionCompletion(boolean success) throws CacheException {
+ EntityPersister persister = getPersister();
+ if ( persister.hasCache() ) {
+
+ final CacheKey ck = new CacheKey(
+ getId(),
+ persister.getIdentifierType(),
+ persister.getRootEntityName(),
+ getSession().getEntityMode(),
+ getSession().getFactory()
+ );
+
+ if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) {
+ boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock );
+
+ if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
+ getSession().getFactory().getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
+ }
+ }
+ else {
+ persister.getCacheAccessStrategy().unlockItem( ck, lock );
+ }
+ }
+ postCommitUpdate();
+ }
+
+ protected boolean hasPostCommitEventListeners() {
+ return getSession().getListeners().getPostCommitUpdateEventListeners().length>0;
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/Executable.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,39 +0,0 @@
-//$Id: Executable.java 6607 2005-04-29 15:26:11Z oneovthafew $
-package org.hibernate.action;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * An operation which may be scheduled for later execution.
- * Usually, the operation is a database insert/update/delete,
- * together with required second-level cache management.
- *
- * @author Gavin King
- */
-public interface Executable {
- /**
- * Called before executing any actions
- */
- public void beforeExecutions() throws HibernateException;
- /**
- * Execute this action
- */
- public void execute() throws HibernateException;
- /**
- * Do we need to retain this instance until after the
- * transaction completes?
- * @return false if this class defines a no-op
- * <tt>hasAfterTransactionCompletion()</tt>
- */
- public boolean hasAfterTransactionCompletion();
- /**
- * Called after the transaction completes
- */
- public void afterTransactionCompletion(boolean success) throws HibernateException;
- /**
- * What spaces (tables) are affected by this action?
- */
- public Serializable[] getPropertySpaces();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/Executable.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/Executable.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,62 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.action;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * An operation which may be scheduled for later execution.
+ * Usually, the operation is a database insert/update/delete,
+ * together with required second-level cache management.
+ *
+ * @author Gavin King
+ */
+public interface Executable {
+ /**
+ * Called before executing any actions
+ */
+ public void beforeExecutions() throws HibernateException;
+ /**
+ * Execute this action
+ */
+ public void execute() throws HibernateException;
+ /**
+ * Do we need to retain this instance until after the
+ * transaction completes?
+ * @return false if this class defines a no-op
+ * <tt>hasAfterTransactionCompletion()</tt>
+ */
+ public boolean hasAfterTransactionCompletion();
+ /**
+ * Called after the transaction completes
+ */
+ public void afterTransactionCompletion(boolean success) throws HibernateException;
+ /**
+ * What spaces (tables) are affected by this action?
+ */
+ public Serializable[] getPropertySpaces();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/action/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-<p>
- This package defines "actions" that are scheduled for
- asycnchronous execution by the event listeners.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/action/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/action/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,35 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head>
+</head>
+<body>
+<p>
+ This package defines "actions" that are scheduled for
+ asycnchronous execution by the event listeners.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: $
-package org.hibernate.bytecode;
-
-import org.hibernate.bytecode.util.ClassFilter;
-import org.hibernate.bytecode.util.FieldFilter;
-
-import java.security.ProtectionDomain;
-
-/**
- * @author Emmanuel Bernard
- * @author Steve Ebersole
- */
-public abstract class AbstractClassTransformerImpl implements ClassTransformer {
-
- protected final ClassFilter classFilter;
- protected final FieldFilter fieldFilter;
-
- protected AbstractClassTransformerImpl(ClassFilter classFilter, FieldFilter fieldFilter) {
- this.classFilter = classFilter;
- this.fieldFilter = fieldFilter;
- }
-
- public byte[] transform(
- ClassLoader loader,
- String className,
- Class classBeingRedefined,
- ProtectionDomain protectionDomain,
- byte[] classfileBuffer) {
- // to be safe...
- className = className.replace( '/', '.' );
- if ( classFilter.shouldInstrumentClass( className ) ) {
- return doTransform( loader, className, classBeingRedefined, protectionDomain, classfileBuffer );
- }
- else {
- return classfileBuffer;
- }
- }
-
- protected abstract byte[] doTransform(
- ClassLoader loader,
- String className,
- Class classBeingRedefined,
- ProtectionDomain protectionDomain,
- byte[] classfileBuffer);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/AbstractClassTransformerImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,70 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+import org.hibernate.bytecode.util.ClassFilter;
+import org.hibernate.bytecode.util.FieldFilter;
+
+import java.security.ProtectionDomain;
+
+/**
+ * Basic implementation of the {@link ClassTransformer} contract.
+ *
+ * @author Emmanuel Bernard
+ * @author Steve Ebersole
+ */
+public abstract class AbstractClassTransformerImpl implements ClassTransformer {
+
+ protected final ClassFilter classFilter;
+ protected final FieldFilter fieldFilter;
+
+ protected AbstractClassTransformerImpl(ClassFilter classFilter, FieldFilter fieldFilter) {
+ this.classFilter = classFilter;
+ this.fieldFilter = fieldFilter;
+ }
+
+ public byte[] transform(
+ ClassLoader loader,
+ String className,
+ Class classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer) {
+ // to be safe...
+ className = className.replace( '/', '.' );
+ if ( classFilter.shouldInstrumentClass( className ) ) {
+ return doTransform( loader, className, classBeingRedefined, protectionDomain, classfileBuffer );
+ }
+ else {
+ return classfileBuffer;
+ }
+ }
+
+ protected abstract byte[] doTransform(
+ ClassLoader loader,
+ String className,
+ Class classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-package org.hibernate.bytecode;
-
-/**
- * A proxy factory for "basic proxy" generation
- *
- * @author Steve Ebersole
- */
-public interface BasicProxyFactory {
- public Object getProxy();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BasicProxyFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,39 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+/**
+ * A proxy factory for "basic proxy" generation
+ *
+ * @author Steve Ebersole
+ */
+public interface BasicProxyFactory {
+ /**
+ * Get a proxy reference.
+ *
+ * @return A proxy reference.
+ */
+ public Object getProxy();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,49 +0,0 @@
-package org.hibernate.bytecode;
-
-import org.hibernate.bytecode.util.ClassFilter;
-import org.hibernate.bytecode.util.FieldFilter;
-
-/**
- * Contract for providers of bytecode services to Hibernate.
- * <p/>
- * Bytecode requirements break down into basically 3 areas<ol>
- * <li>proxy generation (both for runtime-lazy-loading and basic proxy generation)
- * {@link #getProxyFactoryFactory()}
- * <li>bean relection optimization {@link #getReflectionOptimizer}
- * <li>field-access instumentation {@link #getTransformer}
- * </ol>
- *
- * @author Steve Ebersole
- */
-public interface BytecodeProvider {
- /**
- * Retrieve the specific factory for this provider capable of
- * generating run-time proxies for lazy-loading purposes.
- *
- * @return The provider specifc factory.
- */
- public ProxyFactoryFactory getProxyFactoryFactory();
-
- /**
- * Retrieve the ReflectionOptimizer delegate for this provider
- * capable of generating reflection optimization components.
- *
- * @param clazz The class to be reflected upon.
- * @param getterNames Names of all property getters to be accessed via reflection.
- * @param setterNames Names of all property setters to be accessed via reflection.
- * @param types The types of all properties to be accessed.
- * @return The reflection optimization delegate.
- */
- public ReflectionOptimizer getReflectionOptimizer(Class clazz, String[] getterNames, String[] setterNames, Class[] types);
-
- /**
- * Generate a ClassTransformer capable of performing bytecode manipulation.
- *
- * @param classFilter filter used to limit which classes are to be instrumented
- * via this ClassTransformer.
- * @param fieldFilter filter used to limit which fields are to be instrumented
- * via this ClassTransformer.
- * @return The appropriate ClassTransformer.
- */
- public ClassTransformer getTransformer(ClassFilter classFilter, FieldFilter fieldFilter);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/BytecodeProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,73 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+import org.hibernate.bytecode.util.ClassFilter;
+import org.hibernate.bytecode.util.FieldFilter;
+
+/**
+ * Contract for providers of bytecode services to Hibernate.
+ * <p/>
+ * Bytecode requirements break down into basically 3 areas<ol>
+ * <li>proxy generation (both for runtime-lazy-loading and basic proxy generation)
+ * {@link #getProxyFactoryFactory()}
+ * <li>bean relection optimization {@link #getReflectionOptimizer}
+ * <li>field-access instumentation {@link #getTransformer}
+ * </ol>
+ *
+ * @author Steve Ebersole
+ */
+public interface BytecodeProvider {
+ /**
+ * Retrieve the specific factory for this provider capable of
+ * generating run-time proxies for lazy-loading purposes.
+ *
+ * @return The provider specifc factory.
+ */
+ public ProxyFactoryFactory getProxyFactoryFactory();
+
+ /**
+ * Retrieve the ReflectionOptimizer delegate for this provider
+ * capable of generating reflection optimization components.
+ *
+ * @param clazz The class to be reflected upon.
+ * @param getterNames Names of all property getters to be accessed via reflection.
+ * @param setterNames Names of all property setters to be accessed via reflection.
+ * @param types The types of all properties to be accessed.
+ * @return The reflection optimization delegate.
+ */
+ public ReflectionOptimizer getReflectionOptimizer(Class clazz, String[] getterNames, String[] setterNames, Class[] types);
+
+ /**
+ * Generate a ClassTransformer capable of performing bytecode manipulation.
+ *
+ * @param classFilter filter used to limit which classes are to be instrumented
+ * via this ClassTransformer.
+ * @param fieldFilter filter used to limit which fields are to be instrumented
+ * via this ClassTransformer.
+ * @return The appropriate ClassTransformer.
+ */
+ public ClassTransformer getTransformer(ClassFilter classFilter, FieldFilter fieldFilter);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,34 +0,0 @@
-//$Id: $
-package org.hibernate.bytecode;
-
-import java.security.ProtectionDomain;
-
-/**
- * A persistence provider provides an instance of this interface
- * to the PersistenceUnitInfo.addTransformer method.
- * The supplied transformer instance will get called to transform
- * entity class files when they are loaded and redefined. The transformation
- * occurs before the class is defined by the JVM
- *
- *
- * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
- * @author Emmanuel Bernard
- */
-public interface ClassTransformer
-{
- /**
- * Invoked when a class is being loaded or redefined to add hooks for persistence bytecode manipulation
- *
- * @param loader the defining class loaderof the class being transformed. It may be null if using bootstrap loader
- * @param classname The name of the class being transformed
- * @param classBeingRedefined If an already loaded class is being redefined, then pass this as a parameter
- * @param protectionDomain ProtectionDomain of the class being (re)-defined
- * @param classfileBuffer The input byte buffer in class file format
- * @return A well-formed class file that can be loaded
- */
- public byte[] transform(ClassLoader loader,
- String classname,
- Class classBeingRedefined,
- ProtectionDomain protectionDomain,
- byte[] classfileBuffer);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ClassTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+import java.security.ProtectionDomain;
+
+/**
+ * A persistence provider provides an instance of this interface
+ * to the PersistenceUnitInfo.addTransformer method.
+ * The supplied transformer instance will get called to transform
+ * entity class files when they are loaded and redefined. The transformation
+ * occurs before the class is defined by the JVM
+ *
+ *
+ * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
+ * @author Emmanuel Bernard
+ */
+public interface ClassTransformer
+{
+ /**
+ * Invoked when a class is being loaded or redefined to add hooks for persistence bytecode manipulation
+ *
+ * @param loader the defining class loaderof the class being transformed. It may be null if using bootstrap loader
+ * @param classname The name of the class being transformed
+ * @param classBeingRedefined If an already loaded class is being redefined, then pass this as a parameter
+ * @param protectionDomain ProtectionDomain of the class being (re)-defined
+ * @param classfileBuffer The input byte buffer in class file format
+ * @return A well-formed class file that can be loaded
+ */
+ public byte[] transform(ClassLoader loader,
+ String classname,
+ Class classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,54 +0,0 @@
-package org.hibernate.bytecode;
-
-import org.hibernate.bytecode.util.ByteCodeHelper;
-
-import java.io.InputStream;
-
-/**
- * A specialized classloader which performs bytecode enhancement on class
- * definitions as they are loaded into the classloader scope.
- *
- * @author Emmanuel Bernard
- * @author Steve Ebersole
- */
-public class InstrumentedClassLoader extends ClassLoader {
-
- private ClassTransformer classTransformer;
-
- public InstrumentedClassLoader(ClassLoader parent, ClassTransformer classTransformer) {
- super( parent );
- this.classTransformer = classTransformer;
- }
-
- public Class loadClass(String name) throws ClassNotFoundException {
- if ( name.startsWith( "java." ) || classTransformer == null ) {
- return getParent().loadClass( name );
- }
-
- Class c = findLoadedClass( name );
- if ( c != null ) {
- return c;
- }
-
- InputStream is = this.getResourceAsStream( name.replace( '.', '/' ) + ".class" );
- if ( is == null ) {
- throw new ClassNotFoundException( name + " not found" );
- }
-
- try {
- byte[] originalBytecode = ByteCodeHelper.readByteCode( is );
- byte[] transformedBytecode = classTransformer.transform( getParent(), name, null, null, originalBytecode );
- if ( originalBytecode == transformedBytecode ) {
- // no transformations took place, so handle it as we would a
- // non-instrumented class
- return getParent().loadClass( name );
- }
- else {
- return defineClass( name, transformedBytecode, 0, transformedBytecode.length );
- }
- }
- catch( Throwable t ) {
- throw new ClassNotFoundException( name + " not found", t );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/InstrumentedClassLoader.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+import org.hibernate.bytecode.util.ByteCodeHelper;
+
+import java.io.InputStream;
+
+/**
+ * A specialized classloader which performs bytecode enhancement on class
+ * definitions as they are loaded into the classloader scope.
+ *
+ * @author Emmanuel Bernard
+ * @author Steve Ebersole
+ */
+public class InstrumentedClassLoader extends ClassLoader {
+
+ private ClassTransformer classTransformer;
+
+ public InstrumentedClassLoader(ClassLoader parent, ClassTransformer classTransformer) {
+ super( parent );
+ this.classTransformer = classTransformer;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ if ( name.startsWith( "java." ) || classTransformer == null ) {
+ return getParent().loadClass( name );
+ }
+
+ Class c = findLoadedClass( name );
+ if ( c != null ) {
+ return c;
+ }
+
+ InputStream is = this.getResourceAsStream( name.replace( '.', '/' ) + ".class" );
+ if ( is == null ) {
+ throw new ClassNotFoundException( name + " not found" );
+ }
+
+ try {
+ byte[] originalBytecode = ByteCodeHelper.readByteCode( is );
+ byte[] transformedBytecode = classTransformer.transform( getParent(), name, null, null, originalBytecode );
+ if ( originalBytecode == transformedBytecode ) {
+ // no transformations took place, so handle it as we would a
+ // non-instrumented class
+ return getParent().loadClass( name );
+ }
+ else {
+ return defineClass( name, transformedBytecode, 0, transformedBytecode.length );
+ }
+ }
+ catch( Throwable t ) {
+ throw new ClassNotFoundException( name + " not found", t );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,37 +0,0 @@
-package org.hibernate.bytecode;
-
-import org.hibernate.proxy.ProxyFactory;
-
-/**
- * An interface for factories of {@link ProxyFactory proxy factory} instances.
- * <p/>
- * Currently used to abstract from the tupizer whether we are using CGLIB or
- * Javassist for lazy proxy generation.
- *
- * @author Steve Ebersole
- */
-public interface ProxyFactoryFactory {
- /**
- * Build a proxy factory specifically for handling runtime
- * lazy loading.
- *
- * @return The lazy-load proxy factory.
- */
- public ProxyFactory buildProxyFactory();
-
- /**
- * Build a proxy factory for basic proxy concerns. The return
- * should be capable of properly handling newInstance() calls.
- * <p/>
- * Should build basic proxies essentially equivalent to JDK proxies in
- * terms of capabilities, but should be able to deal with abstract super
- * classes in addition to proxy interfaces.
- * <p/>
- * Must pass in either superClass or interfaces (or both).
- *
- * @param superClass The abstract super class (or null if none).
- * @param interfaces Interfaces to be proxied (or null if none).
- * @return The proxy class
- */
- public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ProxyFactoryFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+import org.hibernate.proxy.ProxyFactory;
+
+/**
+ * An interface for factories of {@link ProxyFactory proxy factory} instances.
+ * <p/>
+ * Currently used to abstract from the tupizer whether we are using CGLIB or
+ * Javassist for lazy proxy generation.
+ *
+ * @author Steve Ebersole
+ */
+public interface ProxyFactoryFactory {
+ /**
+ * Build a proxy factory specifically for handling runtime
+ * lazy loading.
+ *
+ * @return The lazy-load proxy factory.
+ */
+ public ProxyFactory buildProxyFactory();
+
+ /**
+ * Build a proxy factory for basic proxy concerns. The return
+ * should be capable of properly handling newInstance() calls.
+ * <p/>
+ * Should build basic proxies essentially equivalent to JDK proxies in
+ * terms of capabilities, but should be able to deal with abstract super
+ * classes in addition to proxy interfaces.
+ * <p/>
+ * Must pass in either superClass or interfaces (or both).
+ *
+ * @param superClass The abstract super class (or null if none).
+ * @param interfaces Interfaces to be proxied (or null if none).
+ * @return The proxy class
+ */
+ public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,35 +0,0 @@
-package org.hibernate.bytecode;
-
-/**
- * Represents reflection optimization for a particular class.
- *
- * @author Steve Ebersole
- */
-public interface ReflectionOptimizer {
-
- public InstantiationOptimizer getInstantiationOptimizer();
- public AccessOptimizer getAccessOptimizer();
-
- /**
- * Represents optimized entity instantiation.
- */
- public static interface InstantiationOptimizer {
- /**
- * Perform instantiation of an instance of the underlying class.
- *
- * @return The new instance.
- */
- public Object newInstance();
- }
-
- /**
- * Represents optimized entity property access.
- *
- * @author Steve Ebersole
- */
- public interface AccessOptimizer {
- public String[] getPropertyNames();
- public Object[] getPropertyValues(Object object);
- public void setPropertyValues(Object object, Object[] values);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/ReflectionOptimizer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode;
+
+/**
+ * Represents reflection optimization for a particular class.
+ *
+ * @author Steve Ebersole
+ */
+public interface ReflectionOptimizer {
+
+ public InstantiationOptimizer getInstantiationOptimizer();
+ public AccessOptimizer getAccessOptimizer();
+
+ /**
+ * Represents optimized entity instantiation.
+ */
+ public static interface InstantiationOptimizer {
+ /**
+ * Perform instantiation of an instance of the underlying class.
+ *
+ * @return The new instance.
+ */
+ public Object newInstance();
+ }
+
+ /**
+ * Represents optimized entity property access.
+ *
+ * @author Steve Ebersole
+ */
+ public interface AccessOptimizer {
+ public String[] getPropertyNames();
+ public Object[] getPropertyValues(Object object);
+ public void setPropertyValues(Object object, Object[] values);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,101 +0,0 @@
-package org.hibernate.bytecode.cglib;
-
-import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.PropertyAccessException;
-import org.hibernate.repackage.cglib.beans.BulkBean;
-import org.hibernate.repackage.cglib.beans.BulkBeanException;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-/**
- * The {@link ReflectionOptimizer.AccessOptimizer} implementation for CGLIB
- * which simply acts as an adpater to the {@link BulkBean} class.
- *
- * @author Steve Ebersole
- */
-public class AccessOptimizerAdapter implements ReflectionOptimizer.AccessOptimizer, Serializable {
-
- public static final String PROPERTY_GET_EXCEPTION =
- "exception getting property value with CGLIB (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
-
- public static final String PROPERTY_SET_EXCEPTION =
- "exception setting property value with CGLIB (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
-
- private Class mappedClass;
- private BulkBean bulkBean;
-
- public AccessOptimizerAdapter(BulkBean bulkBean, Class mappedClass) {
- this.bulkBean = bulkBean;
- this.mappedClass = mappedClass;
- }
-
- public String[] getPropertyNames() {
- return bulkBean.getGetters();
- }
-
- public Object[] getPropertyValues(Object object) {
- try {
- return bulkBean.getPropertyValues( object );
- }
- catch ( Throwable t ) {
- throw new PropertyAccessException(
- t,
- PROPERTY_GET_EXCEPTION,
- false,
- mappedClass,
- getterName( t, bulkBean )
- );
- }
- }
-
- public void setPropertyValues(Object object, Object[] values) {
- try {
- bulkBean.setPropertyValues( object, values );
- }
- catch ( Throwable t ) {
- throw new PropertyAccessException(
- t,
- PROPERTY_SET_EXCEPTION,
- true,
- mappedClass,
- setterName( t, bulkBean )
- );
- }
- }
-
- private static String setterName(Throwable t, BulkBean optimizer) {
- if ( t instanceof BulkBeanException ) {
- return optimizer.getSetters()[( ( BulkBeanException ) t ).getIndex()];
- }
- else {
- return "?";
- }
- }
-
- private static String getterName(Throwable t, BulkBean optimizer) {
- if ( t instanceof BulkBeanException ) {
- return optimizer.getGetters()[( ( BulkBeanException ) t ).getIndex()];
- }
- else {
- return "?";
- }
- }
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.writeObject( mappedClass );
- out.writeObject( bulkBean.getGetters() );
- out.writeObject( bulkBean.getSetters() );
- out.writeObject( bulkBean.getPropertyTypes() );
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- Class beanClass = ( Class ) in.readObject();
- String[] getters = ( String[] ) in.readObject();
- String[] setters = ( String[] ) in.readObject();
- Class[] types = ( Class[] ) in.readObject();
- bulkBean = BulkBean.create( beanClass, getters, setters, types );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/AccessOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,125 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.cglib;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.PropertyAccessException;
+import org.hibernate.repackage.cglib.beans.BulkBean;
+import org.hibernate.repackage.cglib.beans.BulkBeanException;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * The {@link ReflectionOptimizer.AccessOptimizer} implementation for CGLIB
+ * which simply acts as an adpater to the {@link BulkBean} class.
+ *
+ * @author Steve Ebersole
+ */
+public class AccessOptimizerAdapter implements ReflectionOptimizer.AccessOptimizer, Serializable {
+
+ public static final String PROPERTY_GET_EXCEPTION =
+ "exception getting property value with CGLIB (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
+
+ public static final String PROPERTY_SET_EXCEPTION =
+ "exception setting property value with CGLIB (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
+
+ private Class mappedClass;
+ private BulkBean bulkBean;
+
+ public AccessOptimizerAdapter(BulkBean bulkBean, Class mappedClass) {
+ this.bulkBean = bulkBean;
+ this.mappedClass = mappedClass;
+ }
+
+ public String[] getPropertyNames() {
+ return bulkBean.getGetters();
+ }
+
+ public Object[] getPropertyValues(Object object) {
+ try {
+ return bulkBean.getPropertyValues( object );
+ }
+ catch ( Throwable t ) {
+ throw new PropertyAccessException(
+ t,
+ PROPERTY_GET_EXCEPTION,
+ false,
+ mappedClass,
+ getterName( t, bulkBean )
+ );
+ }
+ }
+
+ public void setPropertyValues(Object object, Object[] values) {
+ try {
+ bulkBean.setPropertyValues( object, values );
+ }
+ catch ( Throwable t ) {
+ throw new PropertyAccessException(
+ t,
+ PROPERTY_SET_EXCEPTION,
+ true,
+ mappedClass,
+ setterName( t, bulkBean )
+ );
+ }
+ }
+
+ private static String setterName(Throwable t, BulkBean optimizer) {
+ if ( t instanceof BulkBeanException ) {
+ return optimizer.getSetters()[( ( BulkBeanException ) t ).getIndex()];
+ }
+ else {
+ return "?";
+ }
+ }
+
+ private static String getterName(Throwable t, BulkBean optimizer) {
+ if ( t instanceof BulkBeanException ) {
+ return optimizer.getGetters()[( ( BulkBeanException ) t ).getIndex()];
+ }
+ else {
+ return "?";
+ }
+ }
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ out.writeObject( mappedClass );
+ out.writeObject( bulkBean.getGetters() );
+ out.writeObject( bulkBean.getSetters() );
+ out.writeObject( bulkBean.getPropertyTypes() );
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ Class beanClass = ( Class ) in.readObject();
+ String[] getters = ( String[] ) in.readObject();
+ String[] setters = ( String[] ) in.readObject();
+ Class[] types = ( Class[] ) in.readObject();
+ bulkBean = BulkBean.create( beanClass, getters, setters, types );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,89 +0,0 @@
-package org.hibernate.bytecode.cglib;
-
-import java.lang.reflect.Modifier;
-
-import org.hibernate.repackage.cglib.beans.BulkBean;
-import org.hibernate.repackage.cglib.beans.BulkBeanException;
-import org.hibernate.repackage.cglib.reflect.FastClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.bytecode.BytecodeProvider;
-import org.hibernate.bytecode.ProxyFactoryFactory;
-import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.bytecode.util.FieldFilter;
-import org.hibernate.util.StringHelper;
-
-/**
- * Bytecode provider implementation for CGLIB.
- *
- * @author Steve Ebersole
- */
-public class BytecodeProviderImpl implements BytecodeProvider {
-
- private static final Logger log = LoggerFactory.getLogger( BytecodeProviderImpl.class );
-
- public BytecodeProviderImpl() {
- log.warn( "The CGLIB BytecodeProvider impl is considered deprecated and not recommended for use" );
- }
-
- public ProxyFactoryFactory getProxyFactoryFactory() {
- return new ProxyFactoryFactoryImpl();
- }
-
- public ReflectionOptimizer getReflectionOptimizer(
- Class clazz,
- String[] getterNames,
- String[] setterNames,
- Class[] types) {
- FastClass fastClass;
- BulkBean bulkBean;
- try {
- fastClass = FastClass.create( clazz );
- bulkBean = BulkBean.create( clazz, getterNames, setterNames, types );
- if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
- if ( fastClass == null ) {
- bulkBean = null;
- }
- else {
- //test out the optimizer:
- Object instance = fastClass.newInstance();
- bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) );
- }
- }
- }
- catch( Throwable t ) {
- fastClass = null;
- bulkBean = null;
- String message = "reflection optimizer disabled for: " +
- clazz.getName() +
- " [" +
- StringHelper.unqualify( t.getClass().getName() ) +
- ": " +
- t.getMessage();
-
- if (t instanceof BulkBeanException ) {
- int index = ( (BulkBeanException) t ).getIndex();
- if (index >= 0) {
- message += " (property " + setterNames[index] + ")";
- }
- }
-
- log.debug( message );
- }
-
- if ( fastClass != null && bulkBean != null ) {
- return new ReflectionOptimizerImpl(
- new InstantiationOptimizerAdapter( fastClass ),
- new AccessOptimizerAdapter( bulkBean, clazz )
- );
- }
- else {
- return null;
- }
- }
-
- public org.hibernate.bytecode.ClassTransformer getTransformer(org.hibernate.bytecode.util.ClassFilter classFilter, FieldFilter fieldFilter) {
- return new CglibClassTransformer( classFilter, fieldFilter );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/BytecodeProviderImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,113 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.cglib;
+
+import java.lang.reflect.Modifier;
+
+import org.hibernate.repackage.cglib.beans.BulkBean;
+import org.hibernate.repackage.cglib.beans.BulkBeanException;
+import org.hibernate.repackage.cglib.reflect.FastClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.bytecode.BytecodeProvider;
+import org.hibernate.bytecode.ProxyFactoryFactory;
+import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.bytecode.util.FieldFilter;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bytecode provider implementation for CGLIB.
+ *
+ * @author Steve Ebersole
+ */
+public class BytecodeProviderImpl implements BytecodeProvider {
+
+ private static final Logger log = LoggerFactory.getLogger( BytecodeProviderImpl.class );
+
+ public BytecodeProviderImpl() {
+ log.warn( "The CGLIB BytecodeProvider impl is considered deprecated and not recommended for use" );
+ }
+
+ public ProxyFactoryFactory getProxyFactoryFactory() {
+ return new ProxyFactoryFactoryImpl();
+ }
+
+ public ReflectionOptimizer getReflectionOptimizer(
+ Class clazz,
+ String[] getterNames,
+ String[] setterNames,
+ Class[] types) {
+ FastClass fastClass;
+ BulkBean bulkBean;
+ try {
+ fastClass = FastClass.create( clazz );
+ bulkBean = BulkBean.create( clazz, getterNames, setterNames, types );
+ if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
+ if ( fastClass == null ) {
+ bulkBean = null;
+ }
+ else {
+ //test out the optimizer:
+ Object instance = fastClass.newInstance();
+ bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) );
+ }
+ }
+ }
+ catch( Throwable t ) {
+ fastClass = null;
+ bulkBean = null;
+ String message = "reflection optimizer disabled for: " +
+ clazz.getName() +
+ " [" +
+ StringHelper.unqualify( t.getClass().getName() ) +
+ ": " +
+ t.getMessage();
+
+ if (t instanceof BulkBeanException ) {
+ int index = ( (BulkBeanException) t ).getIndex();
+ if (index >= 0) {
+ message += " (property " + setterNames[index] + ")";
+ }
+ }
+
+ log.debug( message );
+ }
+
+ if ( fastClass != null && bulkBean != null ) {
+ return new ReflectionOptimizerImpl(
+ new InstantiationOptimizerAdapter( fastClass ),
+ new AccessOptimizerAdapter( bulkBean, clazz )
+ );
+ }
+ else {
+ return null;
+ }
+ }
+
+ public org.hibernate.bytecode.ClassTransformer getTransformer(org.hibernate.bytecode.util.ClassFilter classFilter, FieldFilter fieldFilter) {
+ return new CglibClassTransformer( classFilter, fieldFilter );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,120 +0,0 @@
-//$Id: $
-package org.hibernate.bytecode.cglib;
-
-import java.security.ProtectionDomain;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-
-import org.hibernate.repackage.cglib.transform.ClassTransformer;
-import org.hibernate.repackage.cglib.transform.TransformingClassGenerator;
-import org.hibernate.repackage.cglib.transform.ClassReaderGenerator;
-import org.hibernate.repackage.cglib.transform.impl.InterceptFieldEnabled;
-import org.hibernate.repackage.cglib.transform.impl.InterceptFieldFilter;
-import org.hibernate.repackage.cglib.transform.impl.InterceptFieldTransformer;
-import org.hibernate.repackage.cglib.core.ClassNameReader;
-import org.hibernate.repackage.cglib.core.DebuggingClassWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.bytecode.AbstractClassTransformerImpl;
-import org.hibernate.bytecode.util.FieldFilter;
-import org.hibernate.bytecode.util.ClassFilter;
-import org.hibernate.HibernateException;
-import org.hibernate.repackage.cglib.asm.Attribute;
-import org.hibernate.repackage.cglib.asm.Type;
-import org.hibernate.repackage.cglib.asm.ClassReader;
-import org.hibernate.repackage.cglib.asm.ClassWriter;
-import org.hibernate.repackage.cglib.asm.attrs.Attributes;
-
-/**
- * Enhance the classes allowing them to implements InterceptFieldEnabled
- * This interface is then used by Hibernate for some optimizations.
- *
- * @author Emmanuel Bernard
- */
-public class CglibClassTransformer extends AbstractClassTransformerImpl {
-
- private static Logger log = LoggerFactory.getLogger( CglibClassTransformer.class.getName() );
-
- public CglibClassTransformer(ClassFilter classFilter, FieldFilter fieldFilter) {
- super( classFilter, fieldFilter );
- }
-
- protected byte[] doTransform(
- ClassLoader loader,
- String className,
- Class classBeingRedefined,
- ProtectionDomain protectionDomain,
- byte[] classfileBuffer) {
- ClassReader reader;
- try {
- reader = new ClassReader( new ByteArrayInputStream( classfileBuffer ) );
- }
- catch (IOException e) {
- log.error( "Unable to read class", e );
- throw new HibernateException( "Unable to read class: " + e.getMessage() );
- }
-
- String[] names = ClassNameReader.getClassInfo( reader );
- ClassWriter w = new DebuggingClassWriter( true );
- ClassTransformer t = getClassTransformer( names );
- if ( t != null ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "Enhancing " + className );
- }
- ByteArrayOutputStream out;
- byte[] result;
- try {
- reader = new ClassReader( new ByteArrayInputStream( classfileBuffer ) );
- new TransformingClassGenerator(
- new ClassReaderGenerator( reader, attributes(), skipDebug() ), t
- ).generateClass( w );
- out = new ByteArrayOutputStream();
- out.write( w.toByteArray() );
- result = out.toByteArray();
- out.close();
- }
- catch (Exception e) {
- log.error( "Unable to transform class", e );
- throw new HibernateException( "Unable to transform class: " + e.getMessage() );
- }
- return result;
- }
- return classfileBuffer;
- }
-
-
- private Attribute[] attributes() {
- return Attributes.getDefaultAttributes();
- }
-
- private boolean skipDebug() {
- return false;
- }
-
- private ClassTransformer getClassTransformer(final String[] classInfo) {
- if ( isAlreadyInstrumented( classInfo ) ) {
- return null;
- }
- return new InterceptFieldTransformer(
- new InterceptFieldFilter() {
- public boolean acceptRead(Type owner, String name) {
- return fieldFilter.shouldTransformFieldAccess( classInfo[0], owner.getClassName(), name );
- }
-
- public boolean acceptWrite(Type owner, String name) {
- return fieldFilter.shouldTransformFieldAccess( classInfo[0], owner.getClassName(), name );
- }
- }
- );
- }
-
- private boolean isAlreadyInstrumented(String[] classInfo) {
- for ( int i = 1; i < classInfo.length; i++ ) {
- if ( InterceptFieldEnabled.class.getName().equals( classInfo[i] ) ) {
- return true;
- }
- }
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/CglibClassTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,143 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.cglib;
+
+import java.security.ProtectionDomain;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+
+import org.hibernate.repackage.cglib.transform.ClassTransformer;
+import org.hibernate.repackage.cglib.transform.TransformingClassGenerator;
+import org.hibernate.repackage.cglib.transform.ClassReaderGenerator;
+import org.hibernate.repackage.cglib.transform.impl.InterceptFieldEnabled;
+import org.hibernate.repackage.cglib.transform.impl.InterceptFieldFilter;
+import org.hibernate.repackage.cglib.transform.impl.InterceptFieldTransformer;
+import org.hibernate.repackage.cglib.core.ClassNameReader;
+import org.hibernate.repackage.cglib.core.DebuggingClassWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.bytecode.AbstractClassTransformerImpl;
+import org.hibernate.bytecode.util.FieldFilter;
+import org.hibernate.bytecode.util.ClassFilter;
+import org.hibernate.HibernateException;
+import org.hibernate.repackage.cglib.asm.Attribute;
+import org.hibernate.repackage.cglib.asm.Type;
+import org.hibernate.repackage.cglib.asm.ClassReader;
+import org.hibernate.repackage.cglib.asm.ClassWriter;
+import org.hibernate.repackage.cglib.asm.attrs.Attributes;
+
+/**
+ * Enhance the classes allowing them to implements InterceptFieldEnabled
+ * This interface is then used by Hibernate for some optimizations.
+ *
+ * @author Emmanuel Bernard
+ */
+public class CglibClassTransformer extends AbstractClassTransformerImpl {
+
+ private static Logger log = LoggerFactory.getLogger( CglibClassTransformer.class.getName() );
+
+ public CglibClassTransformer(ClassFilter classFilter, FieldFilter fieldFilter) {
+ super( classFilter, fieldFilter );
+ }
+
+ protected byte[] doTransform(
+ ClassLoader loader,
+ String className,
+ Class classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer) {
+ ClassReader reader;
+ try {
+ reader = new ClassReader( new ByteArrayInputStream( classfileBuffer ) );
+ }
+ catch (IOException e) {
+ log.error( "Unable to read class", e );
+ throw new HibernateException( "Unable to read class: " + e.getMessage() );
+ }
+
+ String[] names = ClassNameReader.getClassInfo( reader );
+ ClassWriter w = new DebuggingClassWriter( true );
+ ClassTransformer t = getClassTransformer( names );
+ if ( t != null ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Enhancing " + className );
+ }
+ ByteArrayOutputStream out;
+ byte[] result;
+ try {
+ reader = new ClassReader( new ByteArrayInputStream( classfileBuffer ) );
+ new TransformingClassGenerator(
+ new ClassReaderGenerator( reader, attributes(), skipDebug() ), t
+ ).generateClass( w );
+ out = new ByteArrayOutputStream();
+ out.write( w.toByteArray() );
+ result = out.toByteArray();
+ out.close();
+ }
+ catch (Exception e) {
+ log.error( "Unable to transform class", e );
+ throw new HibernateException( "Unable to transform class: " + e.getMessage() );
+ }
+ return result;
+ }
+ return classfileBuffer;
+ }
+
+
+ private Attribute[] attributes() {
+ return Attributes.getDefaultAttributes();
+ }
+
+ private boolean skipDebug() {
+ return false;
+ }
+
+ private ClassTransformer getClassTransformer(final String[] classInfo) {
+ if ( isAlreadyInstrumented( classInfo ) ) {
+ return null;
+ }
+ return new InterceptFieldTransformer(
+ new InterceptFieldFilter() {
+ public boolean acceptRead(Type owner, String name) {
+ return fieldFilter.shouldTransformFieldAccess( classInfo[0], owner.getClassName(), name );
+ }
+
+ public boolean acceptWrite(Type owner, String name) {
+ return fieldFilter.shouldTransformFieldAccess( classInfo[0], owner.getClassName(), name );
+ }
+ }
+ );
+ }
+
+ private boolean isAlreadyInstrumented(String[] classInfo) {
+ for ( int i = 1; i < classInfo.length; i++ ) {
+ if ( InterceptFieldEnabled.class.getName().equals( classInfo[i] ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,46 +0,0 @@
-package org.hibernate.bytecode.cglib;
-
-import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.repackage.cglib.reflect.FastClass;
-import org.hibernate.InstantiationException;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-/**
- * The {@link ReflectionOptimizer.InstantiationOptimizer} implementation for CGLIB
- * which simply acts as an adpater to the {@link FastClass} class.
- *
- * @author Steve Ebersole
- */
-public class InstantiationOptimizerAdapter implements ReflectionOptimizer.InstantiationOptimizer, Serializable {
- private FastClass fastClass;
-
- public InstantiationOptimizerAdapter(FastClass fastClass) {
- this.fastClass = fastClass;
- }
-
- public Object newInstance() {
- try {
- return fastClass.newInstance();
- }
- catch ( Throwable t ) {
- throw new InstantiationException(
- "Could not instantiate entity with CGLIB optimizer: ",
- fastClass.getJavaClass(),
- t
- );
- }
- }
-
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.writeObject( fastClass.getJavaClass() );
- }
-
- private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
- Class beanClass = ( Class ) in.readObject();
- fastClass = FastClass.create( beanClass );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/InstantiationOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,70 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.cglib;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.repackage.cglib.reflect.FastClass;
+import org.hibernate.InstantiationException;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * The {@link ReflectionOptimizer.InstantiationOptimizer} implementation for CGLIB
+ * which simply acts as an adpater to the {@link FastClass} class.
+ *
+ * @author Steve Ebersole
+ */
+public class InstantiationOptimizerAdapter implements ReflectionOptimizer.InstantiationOptimizer, Serializable {
+ private FastClass fastClass;
+
+ public InstantiationOptimizerAdapter(FastClass fastClass) {
+ this.fastClass = fastClass;
+ }
+
+ public Object newInstance() {
+ try {
+ return fastClass.newInstance();
+ }
+ catch ( Throwable t ) {
+ throw new InstantiationException(
+ "Could not instantiate entity with CGLIB optimizer: ",
+ fastClass.getJavaClass(),
+ t
+ );
+ }
+ }
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ out.writeObject( fastClass.getJavaClass() );
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
+ Class beanClass = ( Class ) in.readObject();
+ fastClass = FastClass.create( beanClass );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,141 +0,0 @@
-package org.hibernate.bytecode.cglib;
-
-import org.hibernate.bytecode.ProxyFactoryFactory;
-import org.hibernate.bytecode.BasicProxyFactory;
-import org.hibernate.proxy.ProxyFactory;
-import org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.repackage.cglib.proxy.Enhancer;
-import org.hibernate.repackage.cglib.proxy.CallbackFilter;
-import org.hibernate.repackage.cglib.proxy.MethodInterceptor;
-import org.hibernate.repackage.cglib.proxy.MethodProxy;
-import org.hibernate.repackage.cglib.proxy.NoOp;
-import org.hibernate.repackage.cglib.proxy.Callback;
-import org.hibernate.repackage.cglib.proxy.Factory;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-/**
- * A factory for CGLIB-based {@link ProxyFactory} instances.
- *
- * @author Steve Ebersole
- */
-public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
-
- /**
- * Builds a CGLIB-based proxy factory.
- *
- * @return a new CGLIB-based proxy factory.
- */
- public ProxyFactory buildProxyFactory() {
- return new CGLIBProxyFactory();
- }
-
- public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces) {
- return new BasicProxyFactoryImpl( superClass, interfaces );
- }
-
- public static class BasicProxyFactoryImpl implements BasicProxyFactory {
- private final Class proxyClass;
- private final Factory factory;
-
- public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
- if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
- throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
- }
-
- Enhancer en = new Enhancer();
- en.setUseCache( false );
- en.setInterceptDuringConstruction( false );
- en.setUseFactory( true );
- en.setCallbackTypes( CALLBACK_TYPES );
- en.setCallbackFilter( FINALIZE_FILTER );
- if ( superClass != null ) {
- en.setSuperclass( superClass );
- }
- if ( interfaces != null && interfaces.length > 0 ) {
- en.setInterfaces( interfaces );
- }
- proxyClass = en.createClass();
- try {
- factory = ( Factory ) proxyClass.newInstance();
- }
- catch ( Throwable t ) {
- throw new HibernateException( "Unable to build CGLIB Factory instance" );
- }
- }
-
- public Object getProxy() {
- try {
- return factory.newInstance(
- new Callback[] { new PassThroughInterceptor( proxyClass.getName() ), NoOp.INSTANCE }
- );
- }
- catch ( Throwable t ) {
- throw new HibernateException( "Unable to instantiate proxy instance" );
- }
- }
- }
-
- private static final CallbackFilter FINALIZE_FILTER = new CallbackFilter() {
- public int accept(Method method) {
- if ( method.getParameterTypes().length == 0 && method.getName().equals("finalize") ){
- return 1;
- }
- else {
- return 0;
- }
- }
- };
-
- private static final Class[] CALLBACK_TYPES = new Class[] { MethodInterceptor.class, NoOp.class };
-
- private static class PassThroughInterceptor implements MethodInterceptor {
- private HashMap data = new HashMap();
- private final String proxiedClassName;
-
- public PassThroughInterceptor(String proxiedClassName) {
- this.proxiedClassName = proxiedClassName;
- }
-
- public Object intercept(
- Object obj,
- Method method,
- Object[] args,
- MethodProxy proxy) throws Throwable {
- String name = method.getName();
- if ( "toString".equals( name ) ) {
- return proxiedClassName + "@" + System.identityHashCode( obj );
- }
- else if ( "equals".equals( name ) ) {
- return args[0] instanceof Factory && ( ( Factory ) args[0] ).getCallback( 0 ) == this
- ? Boolean.TRUE
- : Boolean.FALSE;
- }
- else if ( "hashCode".equals( name ) ) {
- return new Integer( System.identityHashCode( obj ) );
- }
- boolean hasGetterSignature = method.getParameterTypes().length == 0 && method.getReturnType() != null;
- boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class );
- if ( name.startsWith( "get" ) && hasGetterSignature ) {
- String propName = name.substring( 3 );
- return data.get( propName );
- }
- else if ( name.startsWith( "is" ) && hasGetterSignature ) {
- String propName = name.substring( 2 );
- return data.get( propName );
- }
- else if ( name.startsWith( "set" ) && hasSetterSignature) {
- String propName = name.substring( 3 );
- data.put( propName, args[0] );
- return null;
- }
- else {
- // todo : what else to do here?
- return null;
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ProxyFactoryFactoryImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,165 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.cglib;
+
+import org.hibernate.bytecode.ProxyFactoryFactory;
+import org.hibernate.bytecode.BasicProxyFactory;
+import org.hibernate.proxy.ProxyFactory;
+import org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.repackage.cglib.proxy.Enhancer;
+import org.hibernate.repackage.cglib.proxy.CallbackFilter;
+import org.hibernate.repackage.cglib.proxy.MethodInterceptor;
+import org.hibernate.repackage.cglib.proxy.MethodProxy;
+import org.hibernate.repackage.cglib.proxy.NoOp;
+import org.hibernate.repackage.cglib.proxy.Callback;
+import org.hibernate.repackage.cglib.proxy.Factory;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+/**
+ * A factory for CGLIB-based {@link ProxyFactory} instances.
+ *
+ * @author Steve Ebersole
+ */
+public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
+
+ /**
+ * Builds a CGLIB-based proxy factory.
+ *
+ * @return a new CGLIB-based proxy factory.
+ */
+ public ProxyFactory buildProxyFactory() {
+ return new CGLIBProxyFactory();
+ }
+
+ public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces) {
+ return new BasicProxyFactoryImpl( superClass, interfaces );
+ }
+
+ public static class BasicProxyFactoryImpl implements BasicProxyFactory {
+ private final Class proxyClass;
+ private final Factory factory;
+
+ public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
+ if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
+ throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
+ }
+
+ Enhancer en = new Enhancer();
+ en.setUseCache( false );
+ en.setInterceptDuringConstruction( false );
+ en.setUseFactory( true );
+ en.setCallbackTypes( CALLBACK_TYPES );
+ en.setCallbackFilter( FINALIZE_FILTER );
+ if ( superClass != null ) {
+ en.setSuperclass( superClass );
+ }
+ if ( interfaces != null && interfaces.length > 0 ) {
+ en.setInterfaces( interfaces );
+ }
+ proxyClass = en.createClass();
+ try {
+ factory = ( Factory ) proxyClass.newInstance();
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "Unable to build CGLIB Factory instance" );
+ }
+ }
+
+ public Object getProxy() {
+ try {
+ return factory.newInstance(
+ new Callback[] { new PassThroughInterceptor( proxyClass.getName() ), NoOp.INSTANCE }
+ );
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "Unable to instantiate proxy instance" );
+ }
+ }
+ }
+
+ private static final CallbackFilter FINALIZE_FILTER = new CallbackFilter() {
+ public int accept(Method method) {
+ if ( method.getParameterTypes().length == 0 && method.getName().equals("finalize") ){
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+ };
+
+ private static final Class[] CALLBACK_TYPES = new Class[] { MethodInterceptor.class, NoOp.class };
+
+ private static class PassThroughInterceptor implements MethodInterceptor {
+ private HashMap data = new HashMap();
+ private final String proxiedClassName;
+
+ public PassThroughInterceptor(String proxiedClassName) {
+ this.proxiedClassName = proxiedClassName;
+ }
+
+ public Object intercept(
+ Object obj,
+ Method method,
+ Object[] args,
+ MethodProxy proxy) throws Throwable {
+ String name = method.getName();
+ if ( "toString".equals( name ) ) {
+ return proxiedClassName + "@" + System.identityHashCode( obj );
+ }
+ else if ( "equals".equals( name ) ) {
+ return args[0] instanceof Factory && ( ( Factory ) args[0] ).getCallback( 0 ) == this
+ ? Boolean.TRUE
+ : Boolean.FALSE;
+ }
+ else if ( "hashCode".equals( name ) ) {
+ return new Integer( System.identityHashCode( obj ) );
+ }
+ boolean hasGetterSignature = method.getParameterTypes().length == 0 && method.getReturnType() != null;
+ boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class );
+ if ( name.startsWith( "get" ) && hasGetterSignature ) {
+ String propName = name.substring( 3 );
+ return data.get( propName );
+ }
+ else if ( name.startsWith( "is" ) && hasGetterSignature ) {
+ String propName = name.substring( 2 );
+ return data.get( propName );
+ }
+ else if ( name.startsWith( "set" ) && hasSetterSignature) {
+ String propName = name.substring( 3 );
+ data.put( propName, args[0] );
+ return null;
+ }
+ else {
+ // todo : what else to do here?
+ return null;
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,34 +0,0 @@
-package org.hibernate.bytecode.cglib;
-
-import org.hibernate.bytecode.ReflectionOptimizer;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-/**
- * ReflectionOptimizer implementation for CGLIB.
- *
- * @author Steve Ebersole
- */
-public class ReflectionOptimizerImpl implements ReflectionOptimizer, Serializable {
- private transient InstantiationOptimizerAdapter instantiationOptimizer;
- private transient AccessOptimizerAdapter accessOptimizer;
-
- public ReflectionOptimizerImpl(
- InstantiationOptimizerAdapter instantiationOptimizer,
- AccessOptimizerAdapter accessOptimizer) {
- this.instantiationOptimizer = instantiationOptimizer;
- this.accessOptimizer = accessOptimizer;
- }
-
- public InstantiationOptimizer getInstantiationOptimizer() {
- return instantiationOptimizer;
- }
-
- public AccessOptimizer getAccessOptimizer() {
- return accessOptimizer;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/cglib/ReflectionOptimizerImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.cglib;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
+
+import java.io.Serializable;
+
+/**
+ * ReflectionOptimizer implementation for CGLIB.
+ *
+ * @author Steve Ebersole
+ */
+public class ReflectionOptimizerImpl implements ReflectionOptimizer, Serializable {
+ private transient InstantiationOptimizerAdapter instantiationOptimizer;
+ private transient AccessOptimizerAdapter accessOptimizer;
+
+ public ReflectionOptimizerImpl(
+ InstantiationOptimizerAdapter instantiationOptimizer,
+ AccessOptimizerAdapter accessOptimizer) {
+ this.instantiationOptimizer = instantiationOptimizer;
+ this.accessOptimizer = accessOptimizer;
+ }
+
+ public InstantiationOptimizer getInstantiationOptimizer() {
+ return instantiationOptimizer;
+ }
+
+ public AccessOptimizer getAccessOptimizer() {
+ return accessOptimizer;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,81 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.PropertyAccessException;
-
-import java.io.Serializable;
-
-/**
- * The {@link ReflectionOptimizer.AccessOptimizer} implementation for Javassist
- * which simply acts as an adpater to the {@link BulkAccessor} class.
- *
- * @author Steve Ebersole
- */
-public class AccessOptimizerAdapter implements ReflectionOptimizer.AccessOptimizer, Serializable {
-
- public static final String PROPERTY_GET_EXCEPTION =
- "exception getting property value with Javassist (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
-
- public static final String PROPERTY_SET_EXCEPTION =
- "exception setting property value with Javassist (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
-
- private final BulkAccessor bulkAccessor;
- private final Class mappedClass;
-
- public AccessOptimizerAdapter(BulkAccessor bulkAccessor, Class mappedClass) {
- this.bulkAccessor = bulkAccessor;
- this.mappedClass = mappedClass;
- }
-
- public String[] getPropertyNames() {
- return bulkAccessor.getGetters();
- }
-
- public Object[] getPropertyValues(Object object) {
- try {
- return bulkAccessor.getPropertyValues( object );
- }
- catch ( Throwable t ) {
- throw new PropertyAccessException(
- t,
- PROPERTY_GET_EXCEPTION,
- false,
- mappedClass,
- getterName( t, bulkAccessor )
- );
- }
- }
-
- public void setPropertyValues(Object object, Object[] values) {
- try {
- bulkAccessor.setPropertyValues( object, values );
- }
- catch ( Throwable t ) {
- throw new PropertyAccessException(
- t,
- PROPERTY_SET_EXCEPTION,
- true,
- mappedClass,
- setterName( t, bulkAccessor )
- );
- }
- }
-
- private static String setterName(Throwable t, BulkAccessor accessor) {
- if (t instanceof BulkAccessorException ) {
- return accessor.getSetters()[ ( (BulkAccessorException) t ).getIndex() ];
- }
- else {
- return "?";
- }
- }
-
- private static String getterName(Throwable t, BulkAccessor accessor) {
- if (t instanceof BulkAccessorException ) {
- return accessor.getGetters()[ ( (BulkAccessorException) t ).getIndex() ];
- }
- else {
- return "?";
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/AccessOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,105 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.PropertyAccessException;
+
+import java.io.Serializable;
+
+/**
+ * The {@link ReflectionOptimizer.AccessOptimizer} implementation for Javassist
+ * which simply acts as an adpater to the {@link BulkAccessor} class.
+ *
+ * @author Steve Ebersole
+ */
+public class AccessOptimizerAdapter implements ReflectionOptimizer.AccessOptimizer, Serializable {
+
+ public static final String PROPERTY_GET_EXCEPTION =
+ "exception getting property value with Javassist (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
+
+ public static final String PROPERTY_SET_EXCEPTION =
+ "exception setting property value with Javassist (set hibernate.bytecode.use_reflection_optimizer=false for more info)";
+
+ private final BulkAccessor bulkAccessor;
+ private final Class mappedClass;
+
+ public AccessOptimizerAdapter(BulkAccessor bulkAccessor, Class mappedClass) {
+ this.bulkAccessor = bulkAccessor;
+ this.mappedClass = mappedClass;
+ }
+
+ public String[] getPropertyNames() {
+ return bulkAccessor.getGetters();
+ }
+
+ public Object[] getPropertyValues(Object object) {
+ try {
+ return bulkAccessor.getPropertyValues( object );
+ }
+ catch ( Throwable t ) {
+ throw new PropertyAccessException(
+ t,
+ PROPERTY_GET_EXCEPTION,
+ false,
+ mappedClass,
+ getterName( t, bulkAccessor )
+ );
+ }
+ }
+
+ public void setPropertyValues(Object object, Object[] values) {
+ try {
+ bulkAccessor.setPropertyValues( object, values );
+ }
+ catch ( Throwable t ) {
+ throw new PropertyAccessException(
+ t,
+ PROPERTY_SET_EXCEPTION,
+ true,
+ mappedClass,
+ setterName( t, bulkAccessor )
+ );
+ }
+ }
+
+ private static String setterName(Throwable t, BulkAccessor accessor) {
+ if (t instanceof BulkAccessorException ) {
+ return accessor.getSetters()[ ( (BulkAccessorException) t ).getIndex() ];
+ }
+ else {
+ return "?";
+ }
+ }
+
+ private static String getterName(Throwable t, BulkAccessor accessor) {
+ if (t instanceof BulkAccessorException ) {
+ return accessor.getGetters()[ ( (BulkAccessorException) t ).getIndex() ];
+ }
+ else {
+ return "?";
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,92 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import java.io.Serializable;
-
-
-/**
- * A JavaBean accessor.
- * <p/>
- * <p>This object provides methods that set/get multiple properties
- * of a JavaBean at once. This class and its support classes have been
- * developed for the comaptibility with cglib
- * (<tt>http://cglib.sourceforge.net/</tt>).
- *
- * @author Muga Nishizawa
- * @author modified by Shigeru Chiba
- */
-public abstract class BulkAccessor implements Serializable {
- protected Class target;
- protected String[] getters, setters;
- protected Class[] types;
-
- protected BulkAccessor() {
- }
-
- /**
- * Obtains the values of properties of a given bean.
- *
- * @param bean JavaBean.
- * @param values the obtained values are stored in this array.
- */
- public abstract void getPropertyValues(Object bean, Object[] values);
-
- /**
- * Sets properties of a given bean to specified values.
- *
- * @param bean JavaBean.
- * @param values the values assinged to properties.
- */
- public abstract void setPropertyValues(Object bean, Object[] values);
-
- /**
- * Returns the values of properties of a given bean.
- *
- * @param bean JavaBean.
- */
- public Object[] getPropertyValues(Object bean) {
- Object[] values = new Object[getters.length];
- getPropertyValues( bean, values );
- return values;
- }
-
- /**
- * Returns the types of properties.
- */
- public Class[] getPropertyTypes() {
- return ( Class[] ) types.clone();
- }
-
- /**
- * Returns the setter names of properties.
- */
- public String[] getGetters() {
- return ( String[] ) getters.clone();
- }
-
- /**
- * Returns the getter names of the properties.
- */
- public String[] getSetters() {
- return ( String[] ) setters.clone();
- }
-
- /**
- * Creates a new instance of <code>BulkAccessor</code>.
- * The created instance provides methods for setting/getting
- * specified properties at once.
- *
- * @param beanClass the class of the JavaBeans accessed
- * through the created object.
- * @param getters the names of setter methods for specified properties.
- * @param setters the names of getter methods for specified properties.
- * @param types the types of specified properties.
- */
- public static BulkAccessor create(
- Class beanClass,
- String[] getters,
- String[] setters,
- Class[] types) {
- BulkAccessorFactory factory = new BulkAccessorFactory( beanClass, getters, setters, types );
- return factory.create();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,116 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import java.io.Serializable;
+
+
+/**
+ * A JavaBean accessor.
+ * <p/>
+ * <p>This object provides methods that set/get multiple properties
+ * of a JavaBean at once. This class and its support classes have been
+ * developed for the comaptibility with cglib
+ * (<tt>http://cglib.sourceforge.net/</tt>).
+ *
+ * @author Muga Nishizawa
+ * @author modified by Shigeru Chiba
+ */
+public abstract class BulkAccessor implements Serializable {
+ protected Class target;
+ protected String[] getters, setters;
+ protected Class[] types;
+
+ protected BulkAccessor() {
+ }
+
+ /**
+ * Obtains the values of properties of a given bean.
+ *
+ * @param bean JavaBean.
+ * @param values the obtained values are stored in this array.
+ */
+ public abstract void getPropertyValues(Object bean, Object[] values);
+
+ /**
+ * Sets properties of a given bean to specified values.
+ *
+ * @param bean JavaBean.
+ * @param values the values assinged to properties.
+ */
+ public abstract void setPropertyValues(Object bean, Object[] values);
+
+ /**
+ * Returns the values of properties of a given bean.
+ *
+ * @param bean JavaBean.
+ */
+ public Object[] getPropertyValues(Object bean) {
+ Object[] values = new Object[getters.length];
+ getPropertyValues( bean, values );
+ return values;
+ }
+
+ /**
+ * Returns the types of properties.
+ */
+ public Class[] getPropertyTypes() {
+ return ( Class[] ) types.clone();
+ }
+
+ /**
+ * Returns the setter names of properties.
+ */
+ public String[] getGetters() {
+ return ( String[] ) getters.clone();
+ }
+
+ /**
+ * Returns the getter names of the properties.
+ */
+ public String[] getSetters() {
+ return ( String[] ) setters.clone();
+ }
+
+ /**
+ * Creates a new instance of <code>BulkAccessor</code>.
+ * The created instance provides methods for setting/getting
+ * specified properties at once.
+ *
+ * @param beanClass the class of the JavaBeans accessed
+ * through the created object.
+ * @param getters the names of setter methods for specified properties.
+ * @param setters the names of getter methods for specified properties.
+ * @param types the types of specified properties.
+ */
+ public static BulkAccessor create(
+ Class beanClass,
+ String[] getters,
+ String[] setters,
+ Class[] types) {
+ BulkAccessorFactory factory = new BulkAccessorFactory( beanClass, getters, setters, types );
+ return factory.create();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,78 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-/**
- * An exception thrown while generating a bulk accessor.
- *
- * @author Muga Nishizawa
- * @author modified by Shigeru Chiba
- */
-public class BulkAccessorException extends RuntimeException {
- private Throwable myCause;
-
- /**
- * Gets the cause of this throwable.
- * It is for JDK 1.3 compatibility.
- */
- public Throwable getCause() {
- return (myCause == this ? null : myCause);
- }
-
- /**
- * Initializes the cause of this throwable.
- * It is for JDK 1.3 compatibility.
- */
- public synchronized Throwable initCause(Throwable cause) {
- myCause = cause;
- return this;
- }
-
- private int index;
-
- /**
- * Constructs an exception.
- */
- public BulkAccessorException(String message) {
- super(message);
- index = -1;
- initCause(null);
- }
-
- /**
- * Constructs an exception.
- *
- * @param index the index of the property that causes an exception.
- */
- public BulkAccessorException(String message, int index) {
- this(message + ": " + index);
- this.index = index;
- }
-
- /**
- * Constructs an exception.
- */
- public BulkAccessorException(String message, Throwable cause) {
- super(message);
- index = -1;
- initCause(cause);
- }
-
- /**
- * Constructs an exception.
- *
- * @param index the index of the property that causes an exception.
- */
- public BulkAccessorException(Throwable cause, int index) {
- this("Property " + index);
- this.index = index;
- initCause(cause);
- }
-
- /**
- * Returns the index of the property that causes this exception.
- *
- * @return -1 if the index is not specified.
- */
- public int getIndex() {
- return this.index;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,102 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+/**
+ * An exception thrown while generating a bulk accessor.
+ *
+ * @author Muga Nishizawa
+ * @author modified by Shigeru Chiba
+ */
+public class BulkAccessorException extends RuntimeException {
+ private Throwable myCause;
+
+ /**
+ * Gets the cause of this throwable.
+ * It is for JDK 1.3 compatibility.
+ */
+ public Throwable getCause() {
+ return (myCause == this ? null : myCause);
+ }
+
+ /**
+ * Initializes the cause of this throwable.
+ * It is for JDK 1.3 compatibility.
+ */
+ public synchronized Throwable initCause(Throwable cause) {
+ myCause = cause;
+ return this;
+ }
+
+ private int index;
+
+ /**
+ * Constructs an exception.
+ */
+ public BulkAccessorException(String message) {
+ super(message);
+ index = -1;
+ initCause(null);
+ }
+
+ /**
+ * Constructs an exception.
+ *
+ * @param index the index of the property that causes an exception.
+ */
+ public BulkAccessorException(String message, int index) {
+ this(message + ": " + index);
+ this.index = index;
+ }
+
+ /**
+ * Constructs an exception.
+ */
+ public BulkAccessorException(String message, Throwable cause) {
+ super(message);
+ index = -1;
+ initCause(cause);
+ }
+
+ /**
+ * Constructs an exception.
+ *
+ * @param index the index of the property that causes an exception.
+ */
+ public BulkAccessorException(Throwable cause, int index) {
+ this("Property " + index);
+ this.index = index;
+ initCause(cause);
+ }
+
+ /**
+ * Returns the index of the property that causes this exception.
+ *
+ * @return -1 if the index is not specified.
+ */
+ public int getIndex() {
+ return this.index;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,388 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.security.ProtectionDomain;
-
-import javassist.CannotCompileException;
-import javassist.bytecode.AccessFlag;
-import javassist.bytecode.Bytecode;
-import javassist.bytecode.ClassFile;
-import javassist.bytecode.ConstPool;
-import javassist.bytecode.MethodInfo;
-import javassist.bytecode.Opcode;
-import javassist.util.proxy.FactoryHelper;
-import javassist.util.proxy.RuntimeSupport;
-
-/**
- * A factory of bulk accessors.
- *
- * @author Muga Nishizawa
- * @author modified by Shigeru Chiba
- */
-class BulkAccessorFactory {
- private static final String PACKAGE_NAME_PREFIX = "org.javassist.tmp.";
- private static final String BULKACESSOR_CLASS_NAME = BulkAccessor.class.getName();
- private static final String OBJECT_CLASS_NAME = Object.class.getName();
- private static final String GENERATED_GETTER_NAME = "getPropertyValues";
- private static final String GENERATED_SETTER_NAME = "setPropertyValues";
- private static final String GET_SETTER_DESC = "(Ljava/lang/Object;[Ljava/lang/Object;)V";
- private static final String THROWABLE_CLASS_NAME = Throwable.class.getName();
- private static final String BULKEXCEPTION_CLASS_NAME = BulkAccessorException.class.getName();
- private static int counter = 0;
-
- private Class targetBean;
- private String[] getterNames;
- private String[] setterNames;
- private Class[] types;
- public String writeDirectory;
-
- BulkAccessorFactory(
- Class target,
- String[] getterNames,
- String[] setterNames,
- Class[] types) {
- this.targetBean = target;
- this.getterNames = getterNames;
- this.setterNames = setterNames;
- this.types = types;
- this.writeDirectory = null;
- }
-
- BulkAccessor create() {
- Method[] getters = new Method[getterNames.length];
- Method[] setters = new Method[setterNames.length];
- findAccessors( targetBean, getterNames, setterNames, types, getters, setters );
-
- Class beanClass;
- try {
- ClassFile classfile = make( getters, setters );
- ClassLoader loader = this.getClassLoader();
- if ( writeDirectory != null ) {
- FactoryHelper.writeFile( classfile, writeDirectory );
- }
-
- beanClass = FactoryHelper.toClass( classfile, loader, getDomain() );
- return ( BulkAccessor ) this.newInstance( beanClass );
- }
- catch ( Exception e ) {
- throw new BulkAccessorException( e.getMessage(), e );
- }
- }
-
- private ProtectionDomain getDomain() {
- Class cl;
- if ( this.targetBean != null ) {
- cl = this.targetBean;
- }
- else {
- cl = this.getClass();
- }
- return cl.getProtectionDomain();
- }
-
- private ClassFile make(Method[] getters, Method[] setters) throws CannotCompileException {
- String className = targetBean.getName();
- // set the name of bulk accessor.
- className = className + "_$$_bulkaccess_" + counter++;
- if ( className.startsWith( "java." ) ) {
- className = "org.javassist.tmp." + className;
- }
-
- ClassFile classfile = new ClassFile( false, className, BULKACESSOR_CLASS_NAME );
- classfile.setAccessFlags( AccessFlag.PUBLIC );
- addDefaultConstructor( classfile );
- addGetter( classfile, getters );
- addSetter( classfile, setters );
- return classfile;
- }
-
- private ClassLoader getClassLoader() {
- if ( targetBean != null && targetBean.getName().equals( OBJECT_CLASS_NAME ) ) {
- return targetBean.getClassLoader();
- }
- else {
- return getClass().getClassLoader();
- }
- }
-
- private Object newInstance(Class type) throws Exception {
- BulkAccessor instance = ( BulkAccessor ) type.newInstance();
- instance.target = targetBean;
- int len = getterNames.length;
- instance.getters = new String[len];
- instance.setters = new String[len];
- instance.types = new Class[len];
- for ( int i = 0; i < len; i++ ) {
- instance.getters[i] = getterNames[i];
- instance.setters[i] = setterNames[i];
- instance.types[i] = types[i];
- }
-
- return instance;
- }
-
- /**
- * Declares a constructor that takes no parameter.
- *
- * @param classfile
- * @throws CannotCompileException
- */
- private void addDefaultConstructor(ClassFile classfile) throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- String cons_desc = "()V";
- MethodInfo mi = new MethodInfo( cp, MethodInfo.nameInit, cons_desc );
-
- Bytecode code = new Bytecode( cp, 0, 1 );
- // aload_0
- code.addAload( 0 );
- // invokespecial
- code.addInvokespecial( BulkAccessor.class.getName(), MethodInfo.nameInit, cons_desc );
- // return
- code.addOpcode( Opcode.RETURN );
-
- mi.setCodeAttribute( code.toCodeAttribute() );
- mi.setAccessFlags( AccessFlag.PUBLIC );
- classfile.addMethod( mi );
- }
-
- private void addGetter(ClassFile classfile, final Method[] getters) throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- int target_type_index = cp.addClassInfo( this.targetBean.getName() );
- String desc = GET_SETTER_DESC;
- MethodInfo mi = new MethodInfo( cp, GENERATED_GETTER_NAME, desc );
-
- Bytecode code = new Bytecode( cp, 6, 4 );
- /* | this | bean | args | raw bean | */
- if ( getters.length >= 0 ) {
- // aload_1 // load bean
- code.addAload( 1 );
- // checkcast // cast bean
- code.addCheckcast( this.targetBean.getName() );
- // astore_3 // store bean
- code.addAstore( 3 );
- for ( int i = 0; i < getters.length; ++i ) {
- if ( getters[i] != null ) {
- Method getter = getters[i];
- // aload_2 // args
- code.addAload( 2 );
- // iconst_i // continue to aastore
- code.addIconst( i ); // growing stack is 1
- Class returnType = getter.getReturnType();
- int typeIndex = -1;
- if ( returnType.isPrimitive() ) {
- typeIndex = FactoryHelper.typeIndex( returnType );
- // new
- code.addNew( FactoryHelper.wrapperTypes[typeIndex] );
- // dup
- code.addOpcode( Opcode.DUP );
- }
-
- // aload_3 // load the raw bean
- code.addAload( 3 );
- String getter_desc = RuntimeSupport.makeDescriptor( getter );
- String getterName = getter.getName();
- if ( this.targetBean.isInterface() ) {
- // invokeinterface
- code.addInvokeinterface( target_type_index, getterName, getter_desc, 1 );
- }
- else {
- // invokevirtual
- code.addInvokevirtual( target_type_index, getterName, getter_desc );
- }
-
- if ( typeIndex >= 0 ) { // is a primitive type
- // invokespecial
- code.addInvokespecial(
- FactoryHelper.wrapperTypes[typeIndex],
- MethodInfo.nameInit,
- FactoryHelper.wrapperDesc[typeIndex]
- );
- }
-
- // aastore // args
- code.add( Opcode.AASTORE );
- code.growStack( -3 );
- }
- }
- }
- // return
- code.addOpcode( Opcode.RETURN );
-
- mi.setCodeAttribute( code.toCodeAttribute() );
- mi.setAccessFlags( AccessFlag.PUBLIC );
- classfile.addMethod( mi );
- }
-
- private void addSetter(ClassFile classfile, final Method[] setters) throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- int target_type_index = cp.addClassInfo( this.targetBean.getName() );
- String desc = GET_SETTER_DESC;
- MethodInfo mi = new MethodInfo( cp, GENERATED_SETTER_NAME, desc );
-
- Bytecode code = new Bytecode( cp, 4, 6 );
- /* | this | bean | args | i | raw bean | exception | */
- if ( setters.length > 0 ) {
- int start, end; // required to exception table
- // iconst_0 // i
- code.addIconst( 0 );
- // istore_3 // store i
- code.addIstore( 3 );
- // aload_1 // load the bean
- code.addAload( 1 );
- // checkcast // cast the bean into a raw bean
- code.addCheckcast( this.targetBean.getName() );
- // astore 4 // store the raw bean
- code.addAstore( 4 );
- /* current stack len = 0 */
- // start region to handling exception (BulkAccessorException)
- start = code.currentPc();
- int lastIndex = 0;
- for ( int i = 0; i < setters.length; ++i ) {
- if ( setters[i] != null ) {
- int diff = i - lastIndex;
- if ( diff > 0 ) {
- // iinc 3, 1
- code.addOpcode( Opcode.IINC );
- code.add( 3 );
- code.add( diff );
- lastIndex = i;
- }
- }
- /* current stack len = 0 */
- // aload 4 // load the raw bean
- code.addAload( 4 );
- // aload_2 // load the args
- code.addAload( 2 );
- // iconst_i
- code.addIconst( i );
- // aaload
- code.addOpcode( Opcode.AALOAD );
- // checkcast
- Class[] setterParamTypes = setters[i].getParameterTypes();
- Class setterParamType = setterParamTypes[0];
- if ( setterParamType.isPrimitive() ) {
- // checkcast (case of primitive type)
- // invokevirtual (case of primitive type)
- this.addUnwrapper( classfile, code, setterParamType );
- }
- else {
- // checkcast (case of reference type)
- code.addCheckcast( setterParamType.getName() );
- }
- /* current stack len = 2 */
- String rawSetterMethod_desc = RuntimeSupport.makeDescriptor( setters[i] );
- if ( !this.targetBean.isInterface() ) {
- // invokevirtual
- code.addInvokevirtual( target_type_index, setters[i].getName(), rawSetterMethod_desc );
- }
- else {
- // invokeinterface
- Class[] params = setters[i].getParameterTypes();
- int size;
- if ( params[0].equals( Double.TYPE ) || params[0].equals( Long.TYPE ) ) {
- size = 3;
- }
- else {
- size = 2;
- }
-
- code.addInvokeinterface( target_type_index, setters[i].getName(), rawSetterMethod_desc, size );
- }
- }
-
- // end region to handling exception (BulkAccessorException)
- end = code.currentPc();
- // return
- code.addOpcode( Opcode.RETURN );
- /* current stack len = 0 */
- // register in exception table
- int throwableType_index = cp.addClassInfo( THROWABLE_CLASS_NAME );
- code.addExceptionHandler( start, end, code.currentPc(), throwableType_index );
- // astore 5 // store exception
- code.addAstore( 5 );
- // new // BulkAccessorException
- code.addNew( BULKEXCEPTION_CLASS_NAME );
- // dup
- code.addOpcode( Opcode.DUP );
- // aload 5 // load exception
- code.addAload( 5 );
- // iload_3 // i
- code.addIload( 3 );
- // invokespecial // BulkAccessorException.<init>
- String cons_desc = "(Ljava/lang/Throwable;I)V";
- code.addInvokespecial( BULKEXCEPTION_CLASS_NAME, MethodInfo.nameInit, cons_desc );
- // athrow
- code.addOpcode( Opcode.ATHROW );
- }
- else {
- // return
- code.addOpcode( Opcode.RETURN );
- }
-
- mi.setCodeAttribute( code.toCodeAttribute() );
- mi.setAccessFlags( AccessFlag.PUBLIC );
- classfile.addMethod( mi );
- }
-
- private void addUnwrapper(
- ClassFile classfile,
- Bytecode code,
- Class type) {
- int index = FactoryHelper.typeIndex( type );
- String wrapperType = FactoryHelper.wrapperTypes[index];
- // checkcast
- code.addCheckcast( wrapperType );
- // invokevirtual
- code.addInvokevirtual( wrapperType, FactoryHelper.unwarpMethods[index], FactoryHelper.unwrapDesc[index] );
- }
-
- private static void findAccessors(
- Class clazz,
- String[] getterNames,
- String[] setterNames,
- Class[] types,
- Method[] getters,
- Method[] setters) {
- int length = types.length;
- if ( setterNames.length != length || getterNames.length != length ) {
- throw new BulkAccessorException( "bad number of accessors" );
- }
-
- Class[] getParam = new Class[0];
- Class[] setParam = new Class[1];
- for ( int i = 0; i < length; i++ ) {
- if ( getterNames[i] != null ) {
- Method getter = findAccessor( clazz, getterNames[i], getParam, i );
- if ( getter.getReturnType() != types[i] ) {
- throw new BulkAccessorException( "wrong return type: " + getterNames[i], i );
- }
-
- getters[i] = getter;
- }
-
- if ( setterNames[i] != null ) {
- setParam[0] = types[i];
- setters[i] = findAccessor( clazz, setterNames[i], setParam, i );
- }
- }
- }
-
- private static Method findAccessor(
- Class clazz,
- String name,
- Class[] params,
- int index) throws BulkAccessorException {
- try {
- Method method = clazz.getDeclaredMethod( name, params );
- if ( Modifier.isPrivate( method.getModifiers() ) ) {
- throw new BulkAccessorException( "private property", index );
- }
-
- return method;
- }
- catch ( NoSuchMethodException e ) {
- throw new BulkAccessorException( "cannot find an accessor", index );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BulkAccessorFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,412 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.security.ProtectionDomain;
+
+import javassist.CannotCompileException;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+import javassist.util.proxy.FactoryHelper;
+import javassist.util.proxy.RuntimeSupport;
+
+/**
+ * A factory of bulk accessors.
+ *
+ * @author Muga Nishizawa
+ * @author modified by Shigeru Chiba
+ */
+class BulkAccessorFactory {
+ private static final String PACKAGE_NAME_PREFIX = "org.javassist.tmp.";
+ private static final String BULKACESSOR_CLASS_NAME = BulkAccessor.class.getName();
+ private static final String OBJECT_CLASS_NAME = Object.class.getName();
+ private static final String GENERATED_GETTER_NAME = "getPropertyValues";
+ private static final String GENERATED_SETTER_NAME = "setPropertyValues";
+ private static final String GET_SETTER_DESC = "(Ljava/lang/Object;[Ljava/lang/Object;)V";
+ private static final String THROWABLE_CLASS_NAME = Throwable.class.getName();
+ private static final String BULKEXCEPTION_CLASS_NAME = BulkAccessorException.class.getName();
+ private static int counter = 0;
+
+ private Class targetBean;
+ private String[] getterNames;
+ private String[] setterNames;
+ private Class[] types;
+ public String writeDirectory;
+
+ BulkAccessorFactory(
+ Class target,
+ String[] getterNames,
+ String[] setterNames,
+ Class[] types) {
+ this.targetBean = target;
+ this.getterNames = getterNames;
+ this.setterNames = setterNames;
+ this.types = types;
+ this.writeDirectory = null;
+ }
+
+ BulkAccessor create() {
+ Method[] getters = new Method[getterNames.length];
+ Method[] setters = new Method[setterNames.length];
+ findAccessors( targetBean, getterNames, setterNames, types, getters, setters );
+
+ Class beanClass;
+ try {
+ ClassFile classfile = make( getters, setters );
+ ClassLoader loader = this.getClassLoader();
+ if ( writeDirectory != null ) {
+ FactoryHelper.writeFile( classfile, writeDirectory );
+ }
+
+ beanClass = FactoryHelper.toClass( classfile, loader, getDomain() );
+ return ( BulkAccessor ) this.newInstance( beanClass );
+ }
+ catch ( Exception e ) {
+ throw new BulkAccessorException( e.getMessage(), e );
+ }
+ }
+
+ private ProtectionDomain getDomain() {
+ Class cl;
+ if ( this.targetBean != null ) {
+ cl = this.targetBean;
+ }
+ else {
+ cl = this.getClass();
+ }
+ return cl.getProtectionDomain();
+ }
+
+ private ClassFile make(Method[] getters, Method[] setters) throws CannotCompileException {
+ String className = targetBean.getName();
+ // set the name of bulk accessor.
+ className = className + "_$$_bulkaccess_" + counter++;
+ if ( className.startsWith( "java." ) ) {
+ className = "org.javassist.tmp." + className;
+ }
+
+ ClassFile classfile = new ClassFile( false, className, BULKACESSOR_CLASS_NAME );
+ classfile.setAccessFlags( AccessFlag.PUBLIC );
+ addDefaultConstructor( classfile );
+ addGetter( classfile, getters );
+ addSetter( classfile, setters );
+ return classfile;
+ }
+
+ private ClassLoader getClassLoader() {
+ if ( targetBean != null && targetBean.getName().equals( OBJECT_CLASS_NAME ) ) {
+ return targetBean.getClassLoader();
+ }
+ else {
+ return getClass().getClassLoader();
+ }
+ }
+
+ private Object newInstance(Class type) throws Exception {
+ BulkAccessor instance = ( BulkAccessor ) type.newInstance();
+ instance.target = targetBean;
+ int len = getterNames.length;
+ instance.getters = new String[len];
+ instance.setters = new String[len];
+ instance.types = new Class[len];
+ for ( int i = 0; i < len; i++ ) {
+ instance.getters[i] = getterNames[i];
+ instance.setters[i] = setterNames[i];
+ instance.types[i] = types[i];
+ }
+
+ return instance;
+ }
+
+ /**
+ * Declares a constructor that takes no parameter.
+ *
+ * @param classfile
+ * @throws CannotCompileException
+ */
+ private void addDefaultConstructor(ClassFile classfile) throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ String cons_desc = "()V";
+ MethodInfo mi = new MethodInfo( cp, MethodInfo.nameInit, cons_desc );
+
+ Bytecode code = new Bytecode( cp, 0, 1 );
+ // aload_0
+ code.addAload( 0 );
+ // invokespecial
+ code.addInvokespecial( BulkAccessor.class.getName(), MethodInfo.nameInit, cons_desc );
+ // return
+ code.addOpcode( Opcode.RETURN );
+
+ mi.setCodeAttribute( code.toCodeAttribute() );
+ mi.setAccessFlags( AccessFlag.PUBLIC );
+ classfile.addMethod( mi );
+ }
+
+ private void addGetter(ClassFile classfile, final Method[] getters) throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ int target_type_index = cp.addClassInfo( this.targetBean.getName() );
+ String desc = GET_SETTER_DESC;
+ MethodInfo mi = new MethodInfo( cp, GENERATED_GETTER_NAME, desc );
+
+ Bytecode code = new Bytecode( cp, 6, 4 );
+ /* | this | bean | args | raw bean | */
+ if ( getters.length >= 0 ) {
+ // aload_1 // load bean
+ code.addAload( 1 );
+ // checkcast // cast bean
+ code.addCheckcast( this.targetBean.getName() );
+ // astore_3 // store bean
+ code.addAstore( 3 );
+ for ( int i = 0; i < getters.length; ++i ) {
+ if ( getters[i] != null ) {
+ Method getter = getters[i];
+ // aload_2 // args
+ code.addAload( 2 );
+ // iconst_i // continue to aastore
+ code.addIconst( i ); // growing stack is 1
+ Class returnType = getter.getReturnType();
+ int typeIndex = -1;
+ if ( returnType.isPrimitive() ) {
+ typeIndex = FactoryHelper.typeIndex( returnType );
+ // new
+ code.addNew( FactoryHelper.wrapperTypes[typeIndex] );
+ // dup
+ code.addOpcode( Opcode.DUP );
+ }
+
+ // aload_3 // load the raw bean
+ code.addAload( 3 );
+ String getter_desc = RuntimeSupport.makeDescriptor( getter );
+ String getterName = getter.getName();
+ if ( this.targetBean.isInterface() ) {
+ // invokeinterface
+ code.addInvokeinterface( target_type_index, getterName, getter_desc, 1 );
+ }
+ else {
+ // invokevirtual
+ code.addInvokevirtual( target_type_index, getterName, getter_desc );
+ }
+
+ if ( typeIndex >= 0 ) { // is a primitive type
+ // invokespecial
+ code.addInvokespecial(
+ FactoryHelper.wrapperTypes[typeIndex],
+ MethodInfo.nameInit,
+ FactoryHelper.wrapperDesc[typeIndex]
+ );
+ }
+
+ // aastore // args
+ code.add( Opcode.AASTORE );
+ code.growStack( -3 );
+ }
+ }
+ }
+ // return
+ code.addOpcode( Opcode.RETURN );
+
+ mi.setCodeAttribute( code.toCodeAttribute() );
+ mi.setAccessFlags( AccessFlag.PUBLIC );
+ classfile.addMethod( mi );
+ }
+
+ private void addSetter(ClassFile classfile, final Method[] setters) throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ int target_type_index = cp.addClassInfo( this.targetBean.getName() );
+ String desc = GET_SETTER_DESC;
+ MethodInfo mi = new MethodInfo( cp, GENERATED_SETTER_NAME, desc );
+
+ Bytecode code = new Bytecode( cp, 4, 6 );
+ /* | this | bean | args | i | raw bean | exception | */
+ if ( setters.length > 0 ) {
+ int start, end; // required to exception table
+ // iconst_0 // i
+ code.addIconst( 0 );
+ // istore_3 // store i
+ code.addIstore( 3 );
+ // aload_1 // load the bean
+ code.addAload( 1 );
+ // checkcast // cast the bean into a raw bean
+ code.addCheckcast( this.targetBean.getName() );
+ // astore 4 // store the raw bean
+ code.addAstore( 4 );
+ /* current stack len = 0 */
+ // start region to handling exception (BulkAccessorException)
+ start = code.currentPc();
+ int lastIndex = 0;
+ for ( int i = 0; i < setters.length; ++i ) {
+ if ( setters[i] != null ) {
+ int diff = i - lastIndex;
+ if ( diff > 0 ) {
+ // iinc 3, 1
+ code.addOpcode( Opcode.IINC );
+ code.add( 3 );
+ code.add( diff );
+ lastIndex = i;
+ }
+ }
+ /* current stack len = 0 */
+ // aload 4 // load the raw bean
+ code.addAload( 4 );
+ // aload_2 // load the args
+ code.addAload( 2 );
+ // iconst_i
+ code.addIconst( i );
+ // aaload
+ code.addOpcode( Opcode.AALOAD );
+ // checkcast
+ Class[] setterParamTypes = setters[i].getParameterTypes();
+ Class setterParamType = setterParamTypes[0];
+ if ( setterParamType.isPrimitive() ) {
+ // checkcast (case of primitive type)
+ // invokevirtual (case of primitive type)
+ this.addUnwrapper( classfile, code, setterParamType );
+ }
+ else {
+ // checkcast (case of reference type)
+ code.addCheckcast( setterParamType.getName() );
+ }
+ /* current stack len = 2 */
+ String rawSetterMethod_desc = RuntimeSupport.makeDescriptor( setters[i] );
+ if ( !this.targetBean.isInterface() ) {
+ // invokevirtual
+ code.addInvokevirtual( target_type_index, setters[i].getName(), rawSetterMethod_desc );
+ }
+ else {
+ // invokeinterface
+ Class[] params = setters[i].getParameterTypes();
+ int size;
+ if ( params[0].equals( Double.TYPE ) || params[0].equals( Long.TYPE ) ) {
+ size = 3;
+ }
+ else {
+ size = 2;
+ }
+
+ code.addInvokeinterface( target_type_index, setters[i].getName(), rawSetterMethod_desc, size );
+ }
+ }
+
+ // end region to handling exception (BulkAccessorException)
+ end = code.currentPc();
+ // return
+ code.addOpcode( Opcode.RETURN );
+ /* current stack len = 0 */
+ // register in exception table
+ int throwableType_index = cp.addClassInfo( THROWABLE_CLASS_NAME );
+ code.addExceptionHandler( start, end, code.currentPc(), throwableType_index );
+ // astore 5 // store exception
+ code.addAstore( 5 );
+ // new // BulkAccessorException
+ code.addNew( BULKEXCEPTION_CLASS_NAME );
+ // dup
+ code.addOpcode( Opcode.DUP );
+ // aload 5 // load exception
+ code.addAload( 5 );
+ // iload_3 // i
+ code.addIload( 3 );
+ // invokespecial // BulkAccessorException.<init>
+ String cons_desc = "(Ljava/lang/Throwable;I)V";
+ code.addInvokespecial( BULKEXCEPTION_CLASS_NAME, MethodInfo.nameInit, cons_desc );
+ // athrow
+ code.addOpcode( Opcode.ATHROW );
+ }
+ else {
+ // return
+ code.addOpcode( Opcode.RETURN );
+ }
+
+ mi.setCodeAttribute( code.toCodeAttribute() );
+ mi.setAccessFlags( AccessFlag.PUBLIC );
+ classfile.addMethod( mi );
+ }
+
+ private void addUnwrapper(
+ ClassFile classfile,
+ Bytecode code,
+ Class type) {
+ int index = FactoryHelper.typeIndex( type );
+ String wrapperType = FactoryHelper.wrapperTypes[index];
+ // checkcast
+ code.addCheckcast( wrapperType );
+ // invokevirtual
+ code.addInvokevirtual( wrapperType, FactoryHelper.unwarpMethods[index], FactoryHelper.unwrapDesc[index] );
+ }
+
+ private static void findAccessors(
+ Class clazz,
+ String[] getterNames,
+ String[] setterNames,
+ Class[] types,
+ Method[] getters,
+ Method[] setters) {
+ int length = types.length;
+ if ( setterNames.length != length || getterNames.length != length ) {
+ throw new BulkAccessorException( "bad number of accessors" );
+ }
+
+ Class[] getParam = new Class[0];
+ Class[] setParam = new Class[1];
+ for ( int i = 0; i < length; i++ ) {
+ if ( getterNames[i] != null ) {
+ Method getter = findAccessor( clazz, getterNames[i], getParam, i );
+ if ( getter.getReturnType() != types[i] ) {
+ throw new BulkAccessorException( "wrong return type: " + getterNames[i], i );
+ }
+
+ getters[i] = getter;
+ }
+
+ if ( setterNames[i] != null ) {
+ setParam[0] = types[i];
+ setters[i] = findAccessor( clazz, setterNames[i], setParam, i );
+ }
+ }
+ }
+
+ private static Method findAccessor(
+ Class clazz,
+ String name,
+ Class[] params,
+ int index) throws BulkAccessorException {
+ try {
+ Method method = clazz.getDeclaredMethod( name, params );
+ if ( Modifier.isPrivate( method.getModifiers() ) ) {
+ throw new BulkAccessorException( "private property", index );
+ }
+
+ return method;
+ }
+ catch ( NoSuchMethodException e ) {
+ throw new BulkAccessorException( "cannot find an accessor", index );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,84 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import java.lang.reflect.Modifier;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.bytecode.BytecodeProvider;
-import org.hibernate.bytecode.ClassTransformer;
-import org.hibernate.bytecode.ProxyFactoryFactory;
-import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.bytecode.util.ClassFilter;
-import org.hibernate.bytecode.util.FieldFilter;
-import org.hibernate.util.StringHelper;
-
-/**
- * Bytecode provider implementation for Javassist.
- *
- * @author Steve Ebersole
- */
-public class BytecodeProviderImpl implements BytecodeProvider {
-
- private static final Logger log = LoggerFactory.getLogger( BytecodeProviderImpl.class );
-
- public ProxyFactoryFactory getProxyFactoryFactory() {
- return new ProxyFactoryFactoryImpl();
- }
-
- public ReflectionOptimizer getReflectionOptimizer(
- Class clazz,
- String[] getterNames,
- String[] setterNames,
- Class[] types) {
- FastClass fastClass;
- BulkAccessor bulkAccessor;
- try {
- fastClass = FastClass.create( clazz );
- bulkAccessor = BulkAccessor.create( clazz, getterNames, setterNames, types );
- if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
- if ( fastClass == null ) {
- bulkAccessor = null;
- }
- else {
- //test out the optimizer:
- Object instance = fastClass.newInstance();
- bulkAccessor.setPropertyValues( instance, bulkAccessor.getPropertyValues( instance ) );
- }
- }
- }
- catch ( Throwable t ) {
- fastClass = null;
- bulkAccessor = null;
- String message = "reflection optimizer disabled for: " +
- clazz.getName() +
- " [" +
- StringHelper.unqualify( t.getClass().getName() ) +
- ": " +
- t.getMessage();
-
- if ( t instanceof BulkAccessorException ) {
- int index = ( ( BulkAccessorException ) t ).getIndex();
- if ( index >= 0 ) {
- message += " (property " + setterNames[index] + ")";
- }
- }
-
- log.debug( message );
- }
-
- if ( fastClass != null && bulkAccessor != null ) {
- return new ReflectionOptimizerImpl(
- new InstantiationOptimizerAdapter( fastClass ),
- new AccessOptimizerAdapter( bulkAccessor, clazz )
- );
- }
- else {
- return null;
- }
- }
-
- public ClassTransformer getTransformer(ClassFilter classFilter, FieldFilter fieldFilter) {
- return new JavassistClassTransformer( classFilter, fieldFilter );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/BytecodeProviderImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,108 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import java.lang.reflect.Modifier;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.bytecode.BytecodeProvider;
+import org.hibernate.bytecode.ClassTransformer;
+import org.hibernate.bytecode.ProxyFactoryFactory;
+import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.bytecode.util.ClassFilter;
+import org.hibernate.bytecode.util.FieldFilter;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Bytecode provider implementation for Javassist.
+ *
+ * @author Steve Ebersole
+ */
+public class BytecodeProviderImpl implements BytecodeProvider {
+
+ private static final Logger log = LoggerFactory.getLogger( BytecodeProviderImpl.class );
+
+ public ProxyFactoryFactory getProxyFactoryFactory() {
+ return new ProxyFactoryFactoryImpl();
+ }
+
+ public ReflectionOptimizer getReflectionOptimizer(
+ Class clazz,
+ String[] getterNames,
+ String[] setterNames,
+ Class[] types) {
+ FastClass fastClass;
+ BulkAccessor bulkAccessor;
+ try {
+ fastClass = FastClass.create( clazz );
+ bulkAccessor = BulkAccessor.create( clazz, getterNames, setterNames, types );
+ if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {
+ if ( fastClass == null ) {
+ bulkAccessor = null;
+ }
+ else {
+ //test out the optimizer:
+ Object instance = fastClass.newInstance();
+ bulkAccessor.setPropertyValues( instance, bulkAccessor.getPropertyValues( instance ) );
+ }
+ }
+ }
+ catch ( Throwable t ) {
+ fastClass = null;
+ bulkAccessor = null;
+ String message = "reflection optimizer disabled for: " +
+ clazz.getName() +
+ " [" +
+ StringHelper.unqualify( t.getClass().getName() ) +
+ ": " +
+ t.getMessage();
+
+ if ( t instanceof BulkAccessorException ) {
+ int index = ( ( BulkAccessorException ) t ).getIndex();
+ if ( index >= 0 ) {
+ message += " (property " + setterNames[index] + ")";
+ }
+ }
+
+ log.debug( message );
+ }
+
+ if ( fastClass != null && bulkAccessor != null ) {
+ return new ReflectionOptimizerImpl(
+ new InstantiationOptimizerAdapter( fastClass ),
+ new AccessOptimizerAdapter( bulkAccessor, clazz )
+ );
+ }
+ else {
+ return null;
+ }
+ }
+
+ public ClassTransformer getTransformer(ClassFilter classFilter, FieldFilter fieldFilter) {
+ return new JavassistClassTransformer( classFilter, fieldFilter );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,170 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.io.Serializable;
-
-/**
- * @author Muga Nishizawa
- */
-public class FastClass implements Serializable {
-
- private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
-
- private Class type;
-
- private FastClass() {
- }
-
- private FastClass(Class type) {
- this.type = type;
- }
-
- public Object invoke(
- String name,
- Class[] parameterTypes,
- Object obj,
- Object[] args) throws InvocationTargetException {
- return this.invoke( this.getIndex( name, parameterTypes ), obj, args );
- }
-
- public Object invoke(
- int index,
- Object obj,
- Object[] args) throws InvocationTargetException {
- Method[] methods = this.type.getMethods();
- try {
- return methods[index].invoke( obj, args );
- }
- catch ( ArrayIndexOutOfBoundsException e ) {
- throw new IllegalArgumentException(
- "Cannot find matching method/constructor"
- );
- }
- catch ( IllegalAccessException e ) {
- throw new InvocationTargetException( e );
- }
- }
-
- public Object newInstance() throws InvocationTargetException {
- return this.newInstance( this.getIndex( EMPTY_CLASS_ARRAY ), null );
- }
-
- public Object newInstance(
- Class[] parameterTypes,
- Object[] args) throws InvocationTargetException {
- return this.newInstance( this.getIndex( parameterTypes ), args );
- }
-
- public Object newInstance(
- int index,
- Object[] args) throws InvocationTargetException {
- Constructor[] conss = this.type.getConstructors();
- try {
- return conss[index].newInstance( args );
- }
- catch ( ArrayIndexOutOfBoundsException e ) {
- throw new IllegalArgumentException( "Cannot find matching method/constructor" );
- }
- catch ( InstantiationException e ) {
- throw new InvocationTargetException( e );
- }
- catch ( IllegalAccessException e ) {
- throw new InvocationTargetException( e );
- }
- }
-
- public int getIndex(String name, Class[] parameterTypes) {
- Method[] methods = this.type.getMethods();
- boolean eq = true;
- for ( int i = 0; i < methods.length; ++i ) {
- if ( !Modifier.isPublic( methods[i].getModifiers() ) ) {
- continue;
- }
- if ( !methods[i].getName().equals( name ) ) {
- continue;
- }
- Class[] params = methods[i].getParameterTypes();
- if ( params.length != parameterTypes.length ) {
- continue;
- }
- eq = true;
- for ( int j = 0; j < params.length; ++j ) {
- if ( !params[j].equals( parameterTypes[j] ) ) {
- eq = false;
- break;
- }
- }
- if ( eq ) {
- return i;
- }
- }
- return -1;
- }
-
- public int getIndex(Class[] parameterTypes) {
- Constructor[] conss = this.type.getConstructors();
- boolean eq = true;
- for ( int i = 0; i < conss.length; ++i ) {
- if ( !Modifier.isPublic( conss[i].getModifiers() ) ) {
- continue;
- }
- Class[] params = conss[i].getParameterTypes();
- if ( params.length != parameterTypes.length ) {
- continue;
- }
- eq = true;
- for ( int j = 0; j < params.length; ++j ) {
- if ( !params[j].equals( parameterTypes[j] ) ) {
- eq = false;
- break;
- }
- }
- if ( eq ) {
- return i;
- }
- }
- return -1;
- }
-
- public int getMaxIndex() {
- Method[] methods = this.type.getMethods();
- int count = 0;
- for ( int i = 0; i < methods.length; ++i ) {
- if ( Modifier.isPublic( methods[i].getModifiers() ) ) {
- count++;
- }
- }
- return count;
- }
-
- public String getName() {
- return this.type.getName();
- }
-
- public Class getJavaClass() {
- return this.type;
- }
-
- public String toString() {
- return this.type.toString();
- }
-
- public int hashCode() {
- return this.type.hashCode();
- }
-
- public boolean equals(Object o) {
- if (! ( o instanceof FastClass ) ) {
- return false;
- }
- return this.type.equals( ( ( FastClass ) o ).type );
- }
-
- public static FastClass create(Class type) {
- FastClass fc = new FastClass( type );
- return fc;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FastClass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,194 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.io.Serializable;
+
+/**
+ * @author Muga Nishizawa
+ */
+public class FastClass implements Serializable {
+
+ private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
+ private Class type;
+
+ private FastClass() {
+ }
+
+ private FastClass(Class type) {
+ this.type = type;
+ }
+
+ public Object invoke(
+ String name,
+ Class[] parameterTypes,
+ Object obj,
+ Object[] args) throws InvocationTargetException {
+ return this.invoke( this.getIndex( name, parameterTypes ), obj, args );
+ }
+
+ public Object invoke(
+ int index,
+ Object obj,
+ Object[] args) throws InvocationTargetException {
+ Method[] methods = this.type.getMethods();
+ try {
+ return methods[index].invoke( obj, args );
+ }
+ catch ( ArrayIndexOutOfBoundsException e ) {
+ throw new IllegalArgumentException(
+ "Cannot find matching method/constructor"
+ );
+ }
+ catch ( IllegalAccessException e ) {
+ throw new InvocationTargetException( e );
+ }
+ }
+
+ public Object newInstance() throws InvocationTargetException {
+ return this.newInstance( this.getIndex( EMPTY_CLASS_ARRAY ), null );
+ }
+
+ public Object newInstance(
+ Class[] parameterTypes,
+ Object[] args) throws InvocationTargetException {
+ return this.newInstance( this.getIndex( parameterTypes ), args );
+ }
+
+ public Object newInstance(
+ int index,
+ Object[] args) throws InvocationTargetException {
+ Constructor[] conss = this.type.getConstructors();
+ try {
+ return conss[index].newInstance( args );
+ }
+ catch ( ArrayIndexOutOfBoundsException e ) {
+ throw new IllegalArgumentException( "Cannot find matching method/constructor" );
+ }
+ catch ( InstantiationException e ) {
+ throw new InvocationTargetException( e );
+ }
+ catch ( IllegalAccessException e ) {
+ throw new InvocationTargetException( e );
+ }
+ }
+
+ public int getIndex(String name, Class[] parameterTypes) {
+ Method[] methods = this.type.getMethods();
+ boolean eq = true;
+ for ( int i = 0; i < methods.length; ++i ) {
+ if ( !Modifier.isPublic( methods[i].getModifiers() ) ) {
+ continue;
+ }
+ if ( !methods[i].getName().equals( name ) ) {
+ continue;
+ }
+ Class[] params = methods[i].getParameterTypes();
+ if ( params.length != parameterTypes.length ) {
+ continue;
+ }
+ eq = true;
+ for ( int j = 0; j < params.length; ++j ) {
+ if ( !params[j].equals( parameterTypes[j] ) ) {
+ eq = false;
+ break;
+ }
+ }
+ if ( eq ) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int getIndex(Class[] parameterTypes) {
+ Constructor[] conss = this.type.getConstructors();
+ boolean eq = true;
+ for ( int i = 0; i < conss.length; ++i ) {
+ if ( !Modifier.isPublic( conss[i].getModifiers() ) ) {
+ continue;
+ }
+ Class[] params = conss[i].getParameterTypes();
+ if ( params.length != parameterTypes.length ) {
+ continue;
+ }
+ eq = true;
+ for ( int j = 0; j < params.length; ++j ) {
+ if ( !params[j].equals( parameterTypes[j] ) ) {
+ eq = false;
+ break;
+ }
+ }
+ if ( eq ) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int getMaxIndex() {
+ Method[] methods = this.type.getMethods();
+ int count = 0;
+ for ( int i = 0; i < methods.length; ++i ) {
+ if ( Modifier.isPublic( methods[i].getModifiers() ) ) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ public String getName() {
+ return this.type.getName();
+ }
+
+ public Class getJavaClass() {
+ return this.type;
+ }
+
+ public String toString() {
+ return this.type.toString();
+ }
+
+ public int hashCode() {
+ return this.type.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (! ( o instanceof FastClass ) ) {
+ return false;
+ }
+ return this.type.equals( ( ( FastClass ) o ).type );
+ }
+
+ public static FastClass create(Class type) {
+ FastClass fc = new FastClass( type );
+ return fc;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,33 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-/**
- * Contract for deciding whether fields should be read and/or write intercepted.
- *
- * @author Muga Nishizawa
- * @author Steve Ebersole
- */
-public interface FieldFilter {
- /**
- * Should the given field be read intercepted?
- *
- * @param desc
- * @param name
- * @return true if the given field should be read intercepted; otherwise
- * false.
- */
- boolean handleRead(String desc, String name);
-
- /**
- * Should the given field be write intercepted?
- *
- * @param desc
- * @param name
- * @return true if the given field should be write intercepted; otherwise
- * false.
- */
- boolean handleWrite(String desc, String name);
-
- boolean handleReadAccess(String fieldOwnerClassName, String fieldName);
-
- boolean handleWriteAccess(String fieldOwnerClassName, String fieldName);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+/**
+ * Contract for deciding whether fields should be read and/or write intercepted.
+ *
+ * @author Muga Nishizawa
+ * @author Steve Ebersole
+ */
+public interface FieldFilter {
+ /**
+ * Should the given field be read intercepted?
+ *
+ * @param desc
+ * @param name
+ * @return true if the given field should be read intercepted; otherwise
+ * false.
+ */
+ boolean handleRead(String desc, String name);
+
+ /**
+ * Should the given field be write intercepted?
+ *
+ * @param desc
+ * @param name
+ * @return true if the given field should be write intercepted; otherwise
+ * false.
+ */
+ boolean handleWrite(String desc, String name);
+
+ boolean handleReadAccess(String fieldOwnerClassName, String fieldName);
+
+ boolean handleWriteAccess(String fieldOwnerClassName, String fieldName);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,23 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-/**
- * Interface introduced to the enhanced class in order to be able to
- * inject a {@link FieldHandler} to define the interception behavior.
- *
- * @author Muga Nishizawa
- */
-public interface FieldHandled {
- /**
- * Inject the field interception handler to be used.
- *
- * @param handler The field interception handler.
- */
- public void setFieldHandler(FieldHandler handler);
-
- /**
- * Access to the current field interception handler.
- *
- * @return The current field interception handler.
- */
- public FieldHandler getFieldHandler();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandled.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+/**
+ * Interface introduced to the enhanced class in order to be able to
+ * inject a {@link FieldHandler} to define the interception behavior.
+ *
+ * @author Muga Nishizawa
+ */
+public interface FieldHandled {
+ /**
+ * Inject the field interception handler to be used.
+ *
+ * @param handler The field interception handler.
+ */
+ public void setFieldHandler(FieldHandler handler);
+
+ /**
+ * Access to the current field interception handler.
+ *
+ * @return The current field interception handler.
+ */
+ public FieldHandler getFieldHandler();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,56 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-/**
- * The interface defining how interception of a field should be handled.
- *
- * @author Muga Nishizawa
- */
-public interface FieldHandler {
-
- /**
- * Called to handle writing an int value to a given field.
- *
- * @param obj ?
- * @param name The name of the field being written
- * @param oldValue The old field value
- * @param newValue The new field value.
- * @return ?
- */
- int writeInt(Object obj, String name, int oldValue, int newValue);
-
- char writeChar(Object obj, String name, char oldValue, char newValue);
-
- byte writeByte(Object obj, String name, byte oldValue, byte newValue);
-
- boolean writeBoolean(Object obj, String name, boolean oldValue,
- boolean newValue);
-
- short writeShort(Object obj, String name, short oldValue, short newValue);
-
- float writeFloat(Object obj, String name, float oldValue, float newValue);
-
- double writeDouble(Object obj, String name, double oldValue, double newValue);
-
- long writeLong(Object obj, String name, long oldValue, long newValue);
-
- Object writeObject(Object obj, String name, Object oldValue, Object newValue);
-
- int readInt(Object obj, String name, int oldValue);
-
- char readChar(Object obj, String name, char oldValue);
-
- byte readByte(Object obj, String name, byte oldValue);
-
- boolean readBoolean(Object obj, String name, boolean oldValue);
-
- short readShort(Object obj, String name, short oldValue);
-
- float readFloat(Object obj, String name, float oldValue);
-
- double readDouble(Object obj, String name, double oldValue);
-
- long readLong(Object obj, String name, long oldValue);
-
- Object readObject(Object obj, String name, Object oldValue);
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldHandler.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,80 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+/**
+ * The interface defining how interception of a field should be handled.
+ *
+ * @author Muga Nishizawa
+ */
+public interface FieldHandler {
+
+ /**
+ * Called to handle writing an int value to a given field.
+ *
+ * @param obj ?
+ * @param name The name of the field being written
+ * @param oldValue The old field value
+ * @param newValue The new field value.
+ * @return ?
+ */
+ int writeInt(Object obj, String name, int oldValue, int newValue);
+
+ char writeChar(Object obj, String name, char oldValue, char newValue);
+
+ byte writeByte(Object obj, String name, byte oldValue, byte newValue);
+
+ boolean writeBoolean(Object obj, String name, boolean oldValue,
+ boolean newValue);
+
+ short writeShort(Object obj, String name, short oldValue, short newValue);
+
+ float writeFloat(Object obj, String name, float oldValue, float newValue);
+
+ double writeDouble(Object obj, String name, double oldValue, double newValue);
+
+ long writeLong(Object obj, String name, long oldValue, long newValue);
+
+ Object writeObject(Object obj, String name, Object oldValue, Object newValue);
+
+ int readInt(Object obj, String name, int oldValue);
+
+ char readChar(Object obj, String name, char oldValue);
+
+ byte readByte(Object obj, String name, byte oldValue);
+
+ boolean readBoolean(Object obj, String name, boolean oldValue);
+
+ short readShort(Object obj, String name, short oldValue);
+
+ float readFloat(Object obj, String name, float oldValue);
+
+ double readDouble(Object obj, String name, double oldValue);
+
+ long readLong(Object obj, String name, long oldValue);
+
+ Object readObject(Object obj, String name, Object oldValue);
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,581 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.Iterator;
-import java.util.List;
-
-import javassist.CannotCompileException;
-import javassist.bytecode.AccessFlag;
-import javassist.bytecode.BadBytecode;
-import javassist.bytecode.Bytecode;
-import javassist.bytecode.ClassFile;
-import javassist.bytecode.CodeAttribute;
-import javassist.bytecode.CodeIterator;
-import javassist.bytecode.ConstPool;
-import javassist.bytecode.Descriptor;
-import javassist.bytecode.FieldInfo;
-import javassist.bytecode.MethodInfo;
-import javassist.bytecode.Opcode;
-
-/**
- * The thing that handles actual class enhancement in regards to
- * intercepting field accesses.
- *
- * @author Muga Nishizawa
- * @author Steve Ebersole
- */
-public class FieldTransformer {
-
- private static final String EACH_READ_METHOD_PREFIX = "$javassist_read_";
-
- private static final String EACH_WRITE_METHOD_PREFIX = "$javassist_write_";
-
- private static final String FIELD_HANDLED_TYPE_NAME = FieldHandled.class
- .getName();
-
- private static final String HANDLER_FIELD_NAME = "$JAVASSIST_READ_WRITE_HANDLER";
-
- private static final String FIELD_HANDLER_TYPE_NAME = FieldHandler.class
- .getName();
-
- private static final String HANDLER_FIELD_DESCRIPTOR = 'L' + FIELD_HANDLER_TYPE_NAME
- .replace('.', '/') + ';';
-
- private static final String GETFIELDHANDLER_METHOD_NAME = "getFieldHandler";
-
- private static final String SETFIELDHANDLER_METHOD_NAME = "setFieldHandler";
-
- private static final String GETFIELDHANDLER_METHOD_DESCRIPTOR = "()"
- + HANDLER_FIELD_DESCRIPTOR;
-
- private static final String SETFIELDHANDLER_METHOD_DESCRIPTOR = "("
- + HANDLER_FIELD_DESCRIPTOR + ")V";
-
- private FieldFilter filter;
-
- public FieldTransformer() {
- this(null);
- }
-
- public FieldTransformer(FieldFilter f) {
- filter = f;
- }
-
- public void setFieldFilter(FieldFilter f) {
- filter = f;
- }
-
- public void transform(File file) throws Exception {
- DataInputStream in = new DataInputStream(new FileInputStream(file));
- ClassFile classfile = new ClassFile(in);
- transform(classfile);
- DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
- try {
- classfile.write(out);
- } finally {
- out.close();
- }
- }
-
- public void transform(ClassFile classfile) throws Exception {
- if (classfile.isInterface()) {
- return;
- }
- try {
- addFieldHandlerField(classfile);
- addGetFieldHandlerMethod(classfile);
- addSetFieldHandlerMethod(classfile);
- addFieldHandledInterface(classfile);
- addReadWriteMethods(classfile);
- transformInvokevirtualsIntoPutAndGetfields(classfile);
- } catch (CannotCompileException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- private void addFieldHandlerField(ClassFile classfile)
- throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- FieldInfo finfo = new FieldInfo(cp, HANDLER_FIELD_NAME,
- HANDLER_FIELD_DESCRIPTOR);
- finfo.setAccessFlags(AccessFlag.PRIVATE | AccessFlag.TRANSIENT);
- classfile.addField(finfo);
- }
-
- private void addGetFieldHandlerMethod(ClassFile classfile)
- throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- int this_class_index = cp.getThisClassInfo();
- MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME,
- GETFIELDHANDLER_METHOD_DESCRIPTOR);
- /* local variable | this | */
- Bytecode code = new Bytecode(cp, 2, 1);
- // aload_0 // load this
- code.addAload(0);
- // getfield // get field "$JAVASSIST_CALLBACK" defined already
- code.addOpcode(Opcode.GETFIELD);
- int field_index = cp.addFieldrefInfo(this_class_index,
- HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR);
- code.addIndex(field_index);
- // areturn // return the value of the field
- code.addOpcode(Opcode.ARETURN);
- minfo.setCodeAttribute(code.toCodeAttribute());
- minfo.setAccessFlags(AccessFlag.PUBLIC);
- classfile.addMethod(minfo);
- }
-
- private void addSetFieldHandlerMethod(ClassFile classfile)
- throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- int this_class_index = cp.getThisClassInfo();
- MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME,
- SETFIELDHANDLER_METHOD_DESCRIPTOR);
- /* local variables | this | callback | */
- Bytecode code = new Bytecode(cp, 3, 3);
- // aload_0 // load this
- code.addAload(0);
- // aload_1 // load callback
- code.addAload(1);
- // putfield // put field "$JAVASSIST_CALLBACK" defined already
- code.addOpcode(Opcode.PUTFIELD);
- int field_index = cp.addFieldrefInfo(this_class_index,
- HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR);
- code.addIndex(field_index);
- // return
- code.addOpcode(Opcode.RETURN);
- minfo.setCodeAttribute(code.toCodeAttribute());
- minfo.setAccessFlags(AccessFlag.PUBLIC);
- classfile.addMethod(minfo);
- }
-
- private void addFieldHandledInterface(ClassFile classfile) {
- String[] interfaceNames = classfile.getInterfaces();
- String[] newInterfaceNames = new String[interfaceNames.length + 1];
- System.arraycopy(interfaceNames, 0, newInterfaceNames, 0,
- interfaceNames.length);
- newInterfaceNames[newInterfaceNames.length - 1] = FIELD_HANDLED_TYPE_NAME;
- classfile.setInterfaces(newInterfaceNames);
- }
-
- private void addReadWriteMethods(ClassFile classfile)
- throws CannotCompileException {
- List fields = classfile.getFields();
- for (Iterator field_iter = fields.iterator(); field_iter.hasNext();) {
- FieldInfo finfo = (FieldInfo) field_iter.next();
- if ((finfo.getAccessFlags() & AccessFlag.STATIC) == 0
- && (!finfo.getName().equals(HANDLER_FIELD_NAME))) {
- // case of non-static field
- if (filter.handleRead(finfo.getDescriptor(), finfo
- .getName())) {
- addReadMethod(classfile, finfo);
- }
- if (filter.handleWrite(finfo.getDescriptor(), finfo
- .getName())) {
- addWriteMethod(classfile, finfo);
- }
- }
- }
- }
-
- private void addReadMethod(ClassFile classfile, FieldInfo finfo)
- throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- int this_class_index = cp.getThisClassInfo();
- String desc = "()" + finfo.getDescriptor();
- MethodInfo minfo = new MethodInfo(cp, EACH_READ_METHOD_PREFIX
- + finfo.getName(), desc);
- /* local variables | target obj | each oldvalue | */
- Bytecode code = new Bytecode(cp, 5, 3);
- // aload_0
- code.addAload(0);
- // getfield // get each field
- code.addOpcode(Opcode.GETFIELD);
- int base_field_index = cp.addFieldrefInfo(this_class_index, finfo
- .getName(), finfo.getDescriptor());
- code.addIndex(base_field_index);
- // aload_0
- code.addAload(0);
- // invokeinterface // invoke Enabled.getInterceptFieldCallback()
- int enabled_class_index = cp.addClassInfo(FIELD_HANDLED_TYPE_NAME);
- code.addInvokeinterface(enabled_class_index,
- GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
- 1);
- // ifnonnull
- code.addOpcode(Opcode.IFNONNULL);
- code.addIndex(4);
- // *return // each type
- addTypeDependDataReturn(code, finfo.getDescriptor());
- // *store_1 // each type
- addTypeDependDataStore(code, finfo.getDescriptor(), 1);
- // aload_0
- code.addAload(0);
- // invokeinterface // invoke Enabled.getInterceptFieldCallback()
- code.addInvokeinterface(enabled_class_index,
- GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
- 1);
- // aload_0
- code.addAload(0);
- // ldc // name of the field
- code.addLdc(finfo.getName());
- // *load_1 // each type
- addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
- // invokeinterface // invoke Callback.read*() // each type
- addInvokeFieldHandlerMethod(classfile, code, finfo.getDescriptor(),
- true);
- // *return // each type
- addTypeDependDataReturn(code, finfo.getDescriptor());
-
- minfo.setCodeAttribute(code.toCodeAttribute());
- minfo.setAccessFlags(AccessFlag.PUBLIC);
- classfile.addMethod(minfo);
- }
-
- private void addWriteMethod(ClassFile classfile, FieldInfo finfo)
- throws CannotCompileException {
- ConstPool cp = classfile.getConstPool();
- int this_class_index = cp.getThisClassInfo();
- String desc = "(" + finfo.getDescriptor() + ")V";
- MethodInfo minfo = new MethodInfo(cp, EACH_WRITE_METHOD_PREFIX
- + finfo.getName(), desc);
- /* local variables | target obj | each oldvalue | */
- Bytecode code = new Bytecode(cp, 6, 3);
- // aload_0
- code.addAload(0);
- // invokeinterface // enabled.getInterceptFieldCallback()
- int enabled_class_index = cp.addClassInfo(FIELD_HANDLED_TYPE_NAME);
- code.addInvokeinterface(enabled_class_index,
- GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
- 1);
- // ifnonnull (label1)
- code.addOpcode(Opcode.IFNONNULL);
- code.addIndex(9);
- // aload_0
- code.addAload(0);
- // *load_1
- addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
- // putfield
- code.addOpcode(Opcode.PUTFIELD);
- int base_field_index = cp.addFieldrefInfo(this_class_index, finfo
- .getName(), finfo.getDescriptor());
- code.addIndex(base_field_index);
- code.growStack(-Descriptor.dataSize(finfo.getDescriptor()));
- // return ;
- code.addOpcode(Opcode.RETURN);
- // aload_0
- code.addAload(0);
- // dup
- code.addOpcode(Opcode.DUP);
- // invokeinterface // enabled.getInterceptFieldCallback()
- code.addInvokeinterface(enabled_class_index,
- GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
- 1);
- // aload_0
- code.addAload(0);
- // ldc // field name
- code.addLdc(finfo.getName());
- // aload_0
- code.addAload(0);
- // getfield // old value of the field
- code.addOpcode(Opcode.GETFIELD);
- code.addIndex(base_field_index);
- code.growStack(Descriptor.dataSize(finfo.getDescriptor()) - 1);
- // *load_1
- addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
- // invokeinterface // callback.write*(..)
- addInvokeFieldHandlerMethod(classfile, code, finfo.getDescriptor(),
- false);
- // putfield // new value of the field
- code.addOpcode(Opcode.PUTFIELD);
- code.addIndex(base_field_index);
- code.growStack(-Descriptor.dataSize(finfo.getDescriptor()));
- // return
- code.addOpcode(Opcode.RETURN);
-
- minfo.setCodeAttribute(code.toCodeAttribute());
- minfo.setAccessFlags(AccessFlag.PUBLIC);
- classfile.addMethod(minfo);
- }
-
- private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile)
- throws CannotCompileException {
- List methods = classfile.getMethods();
- for (Iterator method_iter = methods.iterator(); method_iter.hasNext();) {
- MethodInfo minfo = (MethodInfo) method_iter.next();
- String methodName = minfo.getName();
- if (methodName.startsWith(EACH_READ_METHOD_PREFIX)
- || methodName.startsWith(EACH_WRITE_METHOD_PREFIX)
- || methodName.equals(GETFIELDHANDLER_METHOD_NAME)
- || methodName.equals(SETFIELDHANDLER_METHOD_NAME)) {
- continue;
- }
- CodeAttribute codeAttr = minfo.getCodeAttribute();
- if (codeAttr == null) {
- return;
- }
- CodeIterator iter = codeAttr.iterator();
- while (iter.hasNext()) {
- try {
- int pos = iter.next();
- pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
- pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
-
- } catch (BadBytecode e) {
- throw new CannotCompileException(e);
- }
- }
- }
- }
-
- private int transformInvokevirtualsIntoGetfields(ClassFile classfile, CodeIterator iter, int pos) {
- ConstPool cp = classfile.getConstPool();
- int c = iter.byteAt(pos);
- if (c != Opcode.GETFIELD) {
- return pos;
- }
- int index = iter.u16bitAt(pos + 1);
- String fieldName = cp.getFieldrefName(index);
- String className = cp.getFieldrefClassName(index);
- if ( !filter.handleReadAccess( className, fieldName ) ) {
- return pos;
- }
- String desc = "()" + cp.getFieldrefType( index );
- int read_method_index = cp.addMethodrefInfo(
- cp.getThisClassInfo(),
- EACH_READ_METHOD_PREFIX + fieldName,
- desc
- );
- iter.writeByte(Opcode.INVOKEVIRTUAL, pos);
- iter.write16bit(read_method_index, pos + 1);
- return pos;
- }
-
- private int transformInvokevirtualsIntoPutfields(
- ClassFile classfile,
- CodeIterator iter, int pos) {
- ConstPool cp = classfile.getConstPool();
- int c = iter.byteAt(pos);
- if (c != Opcode.PUTFIELD) {
- return pos;
- }
- int index = iter.u16bitAt(pos + 1);
- String fieldName = cp.getFieldrefName(index);
- String className = cp.getFieldrefClassName(index);
- if ( !filter.handleWriteAccess( className, fieldName ) ) {
- return pos;
- }
- String desc = "(" + cp.getFieldrefType( index ) + ")V";
- int write_method_index = cp.addMethodrefInfo(
- cp.getThisClassInfo(),
- EACH_WRITE_METHOD_PREFIX + fieldName,
- desc
- );
- iter.writeByte(Opcode.INVOKEVIRTUAL, pos);
- iter.write16bit(write_method_index, pos + 1);
- return pos;
- }
-
- private static void addInvokeFieldHandlerMethod(ClassFile classfile,
- Bytecode code, String typeName, boolean isReadMethod) {
- ConstPool cp = classfile.getConstPool();
- // invokeinterface
- int callback_type_index = cp.addClassInfo(FIELD_HANDLER_TYPE_NAME);
- if ((typeName.charAt(0) == 'L')
- && (typeName.charAt(typeName.length() - 1) == ';')
- || (typeName.charAt(0) == '[')) {
- // reference type
- int indexOfL = typeName.indexOf('L');
- String type;
- if (indexOfL == 0) {
- // not array
- type = typeName.substring(1, typeName.length() - 1);
- type = type.replace('/', '.');
- } else if (indexOfL == -1) {
- // array of primitive type
- // do nothing
- type = typeName;
- } else {
- // array of reference type
- type = typeName.replace('/', '.');
- }
- if (isReadMethod) {
- code
- .addInvokeinterface(
- callback_type_index,
- "readObject",
- "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;",
- 4);
- // checkcast
- code.addCheckcast(type);
- } else {
- code
- .addInvokeinterface(
- callback_type_index,
- "writeObject",
- "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
- 5);
- // checkcast
- code.addCheckcast(type);
- }
- } else if (typeName.equals("Z")) {
- // boolean
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readBoolean",
- "(Ljava/lang/Object;Ljava/lang/String;Z)Z", 4);
- } else {
- code.addInvokeinterface(callback_type_index, "writeBoolean",
- "(Ljava/lang/Object;Ljava/lang/String;ZZ)Z", 5);
- }
- } else if (typeName.equals("B")) {
- // byte
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readByte",
- "(Ljava/lang/Object;Ljava/lang/String;B)B", 4);
- } else {
- code.addInvokeinterface(callback_type_index, "writeByte",
- "(Ljava/lang/Object;Ljava/lang/String;BB)B", 5);
- }
- } else if (typeName.equals("C")) {
- // char
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readChar",
- "(Ljava/lang/Object;Ljava/lang/String;C)C", 4);
- } else {
- code.addInvokeinterface(callback_type_index, "writeChar",
- "(Ljava/lang/Object;Ljava/lang/String;CC)C", 5);
- }
- } else if (typeName.equals("I")) {
- // int
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readInt",
- "(Ljava/lang/Object;Ljava/lang/String;I)I", 4);
- } else {
- code.addInvokeinterface(callback_type_index, "writeInt",
- "(Ljava/lang/Object;Ljava/lang/String;II)I", 5);
- }
- } else if (typeName.equals("S")) {
- // short
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readShort",
- "(Ljava/lang/Object;Ljava/lang/String;S)S", 4);
- } else {
- code.addInvokeinterface(callback_type_index, "writeShort",
- "(Ljava/lang/Object;Ljava/lang/String;SS)S", 5);
- }
- } else if (typeName.equals("D")) {
- // double
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readDouble",
- "(Ljava/lang/Object;Ljava/lang/String;D)D", 5);
- } else {
- code.addInvokeinterface(callback_type_index, "writeDouble",
- "(Ljava/lang/Object;Ljava/lang/String;DD)D", 7);
- }
- } else if (typeName.equals("F")) {
- // float
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readFloat",
- "(Ljava/lang/Object;Ljava/lang/String;F)F", 4);
- } else {
- code.addInvokeinterface(callback_type_index, "writeFloat",
- "(Ljava/lang/Object;Ljava/lang/String;FF)F", 5);
- }
- } else if (typeName.equals("J")) {
- // long
- if (isReadMethod) {
- code.addInvokeinterface(callback_type_index, "readLong",
- "(Ljava/lang/Object;Ljava/lang/String;J)J", 5);
- } else {
- code.addInvokeinterface(callback_type_index, "writeLong",
- "(Ljava/lang/Object;Ljava/lang/String;JJ)J", 7);
- }
- } else {
- // bad type
- throw new RuntimeException("bad type: " + typeName);
- }
- }
-
- private static void addTypeDependDataLoad(Bytecode code, String typeName,
- int i) {
- if ((typeName.charAt(0) == 'L')
- && (typeName.charAt(typeName.length() - 1) == ';')
- || (typeName.charAt(0) == '[')) {
- // reference type
- code.addAload(i);
- } else if (typeName.equals("Z") || typeName.equals("B")
- || typeName.equals("C") || typeName.equals("I")
- || typeName.equals("S")) {
- // boolean, byte, char, int, short
- code.addIload(i);
- } else if (typeName.equals("D")) {
- // double
- code.addDload(i);
- } else if (typeName.equals("F")) {
- // float
- code.addFload(i);
- } else if (typeName.equals("J")) {
- // long
- code.addLload(i);
- } else {
- // bad type
- throw new RuntimeException("bad type: " + typeName);
- }
- }
-
- private static void addTypeDependDataStore(Bytecode code, String typeName,
- int i) {
- if ((typeName.charAt(0) == 'L')
- && (typeName.charAt(typeName.length() - 1) == ';')
- || (typeName.charAt(0) == '[')) {
- // reference type
- code.addAstore(i);
- } else if (typeName.equals("Z") || typeName.equals("B")
- || typeName.equals("C") || typeName.equals("I")
- || typeName.equals("S")) {
- // boolean, byte, char, int, short
- code.addIstore(i);
- } else if (typeName.equals("D")) {
- // double
- code.addDstore(i);
- } else if (typeName.equals("F")) {
- // float
- code.addFstore(i);
- } else if (typeName.equals("J")) {
- // long
- code.addLstore(i);
- } else {
- // bad type
- throw new RuntimeException("bad type: " + typeName);
- }
- }
-
- private static void addTypeDependDataReturn(Bytecode code, String typeName) {
- if ((typeName.charAt(0) == 'L')
- && (typeName.charAt(typeName.length() - 1) == ';')
- || (typeName.charAt(0) == '[')) {
- // reference type
- code.addOpcode(Opcode.ARETURN);
- } else if (typeName.equals("Z") || typeName.equals("B")
- || typeName.equals("C") || typeName.equals("I")
- || typeName.equals("S")) {
- // boolean, byte, char, int, short
- code.addOpcode(Opcode.IRETURN);
- } else if (typeName.equals("D")) {
- // double
- code.addOpcode(Opcode.DRETURN);
- } else if (typeName.equals("F")) {
- // float
- code.addOpcode(Opcode.FRETURN);
- } else if (typeName.equals("J")) {
- // long
- code.addOpcode(Opcode.LRETURN);
- } else {
- // bad type
- throw new RuntimeException("bad type: " + typeName);
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/FieldTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,605 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import javassist.CannotCompileException;
+import javassist.bytecode.AccessFlag;
+import javassist.bytecode.BadBytecode;
+import javassist.bytecode.Bytecode;
+import javassist.bytecode.ClassFile;
+import javassist.bytecode.CodeAttribute;
+import javassist.bytecode.CodeIterator;
+import javassist.bytecode.ConstPool;
+import javassist.bytecode.Descriptor;
+import javassist.bytecode.FieldInfo;
+import javassist.bytecode.MethodInfo;
+import javassist.bytecode.Opcode;
+
+/**
+ * The thing that handles actual class enhancement in regards to
+ * intercepting field accesses.
+ *
+ * @author Muga Nishizawa
+ * @author Steve Ebersole
+ */
+public class FieldTransformer {
+
+ private static final String EACH_READ_METHOD_PREFIX = "$javassist_read_";
+
+ private static final String EACH_WRITE_METHOD_PREFIX = "$javassist_write_";
+
+ private static final String FIELD_HANDLED_TYPE_NAME = FieldHandled.class
+ .getName();
+
+ private static final String HANDLER_FIELD_NAME = "$JAVASSIST_READ_WRITE_HANDLER";
+
+ private static final String FIELD_HANDLER_TYPE_NAME = FieldHandler.class
+ .getName();
+
+ private static final String HANDLER_FIELD_DESCRIPTOR = 'L' + FIELD_HANDLER_TYPE_NAME
+ .replace('.', '/') + ';';
+
+ private static final String GETFIELDHANDLER_METHOD_NAME = "getFieldHandler";
+
+ private static final String SETFIELDHANDLER_METHOD_NAME = "setFieldHandler";
+
+ private static final String GETFIELDHANDLER_METHOD_DESCRIPTOR = "()"
+ + HANDLER_FIELD_DESCRIPTOR;
+
+ private static final String SETFIELDHANDLER_METHOD_DESCRIPTOR = "("
+ + HANDLER_FIELD_DESCRIPTOR + ")V";
+
+ private FieldFilter filter;
+
+ public FieldTransformer() {
+ this(null);
+ }
+
+ public FieldTransformer(FieldFilter f) {
+ filter = f;
+ }
+
+ public void setFieldFilter(FieldFilter f) {
+ filter = f;
+ }
+
+ public void transform(File file) throws Exception {
+ DataInputStream in = new DataInputStream(new FileInputStream(file));
+ ClassFile classfile = new ClassFile(in);
+ transform(classfile);
+ DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
+ try {
+ classfile.write(out);
+ } finally {
+ out.close();
+ }
+ }
+
+ public void transform(ClassFile classfile) throws Exception {
+ if (classfile.isInterface()) {
+ return;
+ }
+ try {
+ addFieldHandlerField(classfile);
+ addGetFieldHandlerMethod(classfile);
+ addSetFieldHandlerMethod(classfile);
+ addFieldHandledInterface(classfile);
+ addReadWriteMethods(classfile);
+ transformInvokevirtualsIntoPutAndGetfields(classfile);
+ } catch (CannotCompileException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ private void addFieldHandlerField(ClassFile classfile)
+ throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ FieldInfo finfo = new FieldInfo(cp, HANDLER_FIELD_NAME,
+ HANDLER_FIELD_DESCRIPTOR);
+ finfo.setAccessFlags(AccessFlag.PRIVATE | AccessFlag.TRANSIENT);
+ classfile.addField(finfo);
+ }
+
+ private void addGetFieldHandlerMethod(ClassFile classfile)
+ throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ int this_class_index = cp.getThisClassInfo();
+ MethodInfo minfo = new MethodInfo(cp, GETFIELDHANDLER_METHOD_NAME,
+ GETFIELDHANDLER_METHOD_DESCRIPTOR);
+ /* local variable | this | */
+ Bytecode code = new Bytecode(cp, 2, 1);
+ // aload_0 // load this
+ code.addAload(0);
+ // getfield // get field "$JAVASSIST_CALLBACK" defined already
+ code.addOpcode(Opcode.GETFIELD);
+ int field_index = cp.addFieldrefInfo(this_class_index,
+ HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR);
+ code.addIndex(field_index);
+ // areturn // return the value of the field
+ code.addOpcode(Opcode.ARETURN);
+ minfo.setCodeAttribute(code.toCodeAttribute());
+ minfo.setAccessFlags(AccessFlag.PUBLIC);
+ classfile.addMethod(minfo);
+ }
+
+ private void addSetFieldHandlerMethod(ClassFile classfile)
+ throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ int this_class_index = cp.getThisClassInfo();
+ MethodInfo minfo = new MethodInfo(cp, SETFIELDHANDLER_METHOD_NAME,
+ SETFIELDHANDLER_METHOD_DESCRIPTOR);
+ /* local variables | this | callback | */
+ Bytecode code = new Bytecode(cp, 3, 3);
+ // aload_0 // load this
+ code.addAload(0);
+ // aload_1 // load callback
+ code.addAload(1);
+ // putfield // put field "$JAVASSIST_CALLBACK" defined already
+ code.addOpcode(Opcode.PUTFIELD);
+ int field_index = cp.addFieldrefInfo(this_class_index,
+ HANDLER_FIELD_NAME, HANDLER_FIELD_DESCRIPTOR);
+ code.addIndex(field_index);
+ // return
+ code.addOpcode(Opcode.RETURN);
+ minfo.setCodeAttribute(code.toCodeAttribute());
+ minfo.setAccessFlags(AccessFlag.PUBLIC);
+ classfile.addMethod(minfo);
+ }
+
+ private void addFieldHandledInterface(ClassFile classfile) {
+ String[] interfaceNames = classfile.getInterfaces();
+ String[] newInterfaceNames = new String[interfaceNames.length + 1];
+ System.arraycopy(interfaceNames, 0, newInterfaceNames, 0,
+ interfaceNames.length);
+ newInterfaceNames[newInterfaceNames.length - 1] = FIELD_HANDLED_TYPE_NAME;
+ classfile.setInterfaces(newInterfaceNames);
+ }
+
+ private void addReadWriteMethods(ClassFile classfile)
+ throws CannotCompileException {
+ List fields = classfile.getFields();
+ for (Iterator field_iter = fields.iterator(); field_iter.hasNext();) {
+ FieldInfo finfo = (FieldInfo) field_iter.next();
+ if ((finfo.getAccessFlags() & AccessFlag.STATIC) == 0
+ && (!finfo.getName().equals(HANDLER_FIELD_NAME))) {
+ // case of non-static field
+ if (filter.handleRead(finfo.getDescriptor(), finfo
+ .getName())) {
+ addReadMethod(classfile, finfo);
+ }
+ if (filter.handleWrite(finfo.getDescriptor(), finfo
+ .getName())) {
+ addWriteMethod(classfile, finfo);
+ }
+ }
+ }
+ }
+
+ private void addReadMethod(ClassFile classfile, FieldInfo finfo)
+ throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ int this_class_index = cp.getThisClassInfo();
+ String desc = "()" + finfo.getDescriptor();
+ MethodInfo minfo = new MethodInfo(cp, EACH_READ_METHOD_PREFIX
+ + finfo.getName(), desc);
+ /* local variables | target obj | each oldvalue | */
+ Bytecode code = new Bytecode(cp, 5, 3);
+ // aload_0
+ code.addAload(0);
+ // getfield // get each field
+ code.addOpcode(Opcode.GETFIELD);
+ int base_field_index = cp.addFieldrefInfo(this_class_index, finfo
+ .getName(), finfo.getDescriptor());
+ code.addIndex(base_field_index);
+ // aload_0
+ code.addAload(0);
+ // invokeinterface // invoke Enabled.getInterceptFieldCallback()
+ int enabled_class_index = cp.addClassInfo(FIELD_HANDLED_TYPE_NAME);
+ code.addInvokeinterface(enabled_class_index,
+ GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
+ 1);
+ // ifnonnull
+ code.addOpcode(Opcode.IFNONNULL);
+ code.addIndex(4);
+ // *return // each type
+ addTypeDependDataReturn(code, finfo.getDescriptor());
+ // *store_1 // each type
+ addTypeDependDataStore(code, finfo.getDescriptor(), 1);
+ // aload_0
+ code.addAload(0);
+ // invokeinterface // invoke Enabled.getInterceptFieldCallback()
+ code.addInvokeinterface(enabled_class_index,
+ GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
+ 1);
+ // aload_0
+ code.addAload(0);
+ // ldc // name of the field
+ code.addLdc(finfo.getName());
+ // *load_1 // each type
+ addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
+ // invokeinterface // invoke Callback.read*() // each type
+ addInvokeFieldHandlerMethod(classfile, code, finfo.getDescriptor(),
+ true);
+ // *return // each type
+ addTypeDependDataReturn(code, finfo.getDescriptor());
+
+ minfo.setCodeAttribute(code.toCodeAttribute());
+ minfo.setAccessFlags(AccessFlag.PUBLIC);
+ classfile.addMethod(minfo);
+ }
+
+ private void addWriteMethod(ClassFile classfile, FieldInfo finfo)
+ throws CannotCompileException {
+ ConstPool cp = classfile.getConstPool();
+ int this_class_index = cp.getThisClassInfo();
+ String desc = "(" + finfo.getDescriptor() + ")V";
+ MethodInfo minfo = new MethodInfo(cp, EACH_WRITE_METHOD_PREFIX
+ + finfo.getName(), desc);
+ /* local variables | target obj | each oldvalue | */
+ Bytecode code = new Bytecode(cp, 6, 3);
+ // aload_0
+ code.addAload(0);
+ // invokeinterface // enabled.getInterceptFieldCallback()
+ int enabled_class_index = cp.addClassInfo(FIELD_HANDLED_TYPE_NAME);
+ code.addInvokeinterface(enabled_class_index,
+ GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
+ 1);
+ // ifnonnull (label1)
+ code.addOpcode(Opcode.IFNONNULL);
+ code.addIndex(9);
+ // aload_0
+ code.addAload(0);
+ // *load_1
+ addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
+ // putfield
+ code.addOpcode(Opcode.PUTFIELD);
+ int base_field_index = cp.addFieldrefInfo(this_class_index, finfo
+ .getName(), finfo.getDescriptor());
+ code.addIndex(base_field_index);
+ code.growStack(-Descriptor.dataSize(finfo.getDescriptor()));
+ // return ;
+ code.addOpcode(Opcode.RETURN);
+ // aload_0
+ code.addAload(0);
+ // dup
+ code.addOpcode(Opcode.DUP);
+ // invokeinterface // enabled.getInterceptFieldCallback()
+ code.addInvokeinterface(enabled_class_index,
+ GETFIELDHANDLER_METHOD_NAME, GETFIELDHANDLER_METHOD_DESCRIPTOR,
+ 1);
+ // aload_0
+ code.addAload(0);
+ // ldc // field name
+ code.addLdc(finfo.getName());
+ // aload_0
+ code.addAload(0);
+ // getfield // old value of the field
+ code.addOpcode(Opcode.GETFIELD);
+ code.addIndex(base_field_index);
+ code.growStack(Descriptor.dataSize(finfo.getDescriptor()) - 1);
+ // *load_1
+ addTypeDependDataLoad(code, finfo.getDescriptor(), 1);
+ // invokeinterface // callback.write*(..)
+ addInvokeFieldHandlerMethod(classfile, code, finfo.getDescriptor(),
+ false);
+ // putfield // new value of the field
+ code.addOpcode(Opcode.PUTFIELD);
+ code.addIndex(base_field_index);
+ code.growStack(-Descriptor.dataSize(finfo.getDescriptor()));
+ // return
+ code.addOpcode(Opcode.RETURN);
+
+ minfo.setCodeAttribute(code.toCodeAttribute());
+ minfo.setAccessFlags(AccessFlag.PUBLIC);
+ classfile.addMethod(minfo);
+ }
+
+ private void transformInvokevirtualsIntoPutAndGetfields(ClassFile classfile)
+ throws CannotCompileException {
+ List methods = classfile.getMethods();
+ for (Iterator method_iter = methods.iterator(); method_iter.hasNext();) {
+ MethodInfo minfo = (MethodInfo) method_iter.next();
+ String methodName = minfo.getName();
+ if (methodName.startsWith(EACH_READ_METHOD_PREFIX)
+ || methodName.startsWith(EACH_WRITE_METHOD_PREFIX)
+ || methodName.equals(GETFIELDHANDLER_METHOD_NAME)
+ || methodName.equals(SETFIELDHANDLER_METHOD_NAME)) {
+ continue;
+ }
+ CodeAttribute codeAttr = minfo.getCodeAttribute();
+ if (codeAttr == null) {
+ return;
+ }
+ CodeIterator iter = codeAttr.iterator();
+ while (iter.hasNext()) {
+ try {
+ int pos = iter.next();
+ pos = transformInvokevirtualsIntoGetfields(classfile, iter, pos);
+ pos = transformInvokevirtualsIntoPutfields(classfile, iter, pos);
+
+ } catch (BadBytecode e) {
+ throw new CannotCompileException(e);
+ }
+ }
+ }
+ }
+
+ private int transformInvokevirtualsIntoGetfields(ClassFile classfile, CodeIterator iter, int pos) {
+ ConstPool cp = classfile.getConstPool();
+ int c = iter.byteAt(pos);
+ if (c != Opcode.GETFIELD) {
+ return pos;
+ }
+ int index = iter.u16bitAt(pos + 1);
+ String fieldName = cp.getFieldrefName(index);
+ String className = cp.getFieldrefClassName(index);
+ if ( !filter.handleReadAccess( className, fieldName ) ) {
+ return pos;
+ }
+ String desc = "()" + cp.getFieldrefType( index );
+ int read_method_index = cp.addMethodrefInfo(
+ cp.getThisClassInfo(),
+ EACH_READ_METHOD_PREFIX + fieldName,
+ desc
+ );
+ iter.writeByte(Opcode.INVOKEVIRTUAL, pos);
+ iter.write16bit(read_method_index, pos + 1);
+ return pos;
+ }
+
+ private int transformInvokevirtualsIntoPutfields(
+ ClassFile classfile,
+ CodeIterator iter, int pos) {
+ ConstPool cp = classfile.getConstPool();
+ int c = iter.byteAt(pos);
+ if (c != Opcode.PUTFIELD) {
+ return pos;
+ }
+ int index = iter.u16bitAt(pos + 1);
+ String fieldName = cp.getFieldrefName(index);
+ String className = cp.getFieldrefClassName(index);
+ if ( !filter.handleWriteAccess( className, fieldName ) ) {
+ return pos;
+ }
+ String desc = "(" + cp.getFieldrefType( index ) + ")V";
+ int write_method_index = cp.addMethodrefInfo(
+ cp.getThisClassInfo(),
+ EACH_WRITE_METHOD_PREFIX + fieldName,
+ desc
+ );
+ iter.writeByte(Opcode.INVOKEVIRTUAL, pos);
+ iter.write16bit(write_method_index, pos + 1);
+ return pos;
+ }
+
+ private static void addInvokeFieldHandlerMethod(ClassFile classfile,
+ Bytecode code, String typeName, boolean isReadMethod) {
+ ConstPool cp = classfile.getConstPool();
+ // invokeinterface
+ int callback_type_index = cp.addClassInfo(FIELD_HANDLER_TYPE_NAME);
+ if ((typeName.charAt(0) == 'L')
+ && (typeName.charAt(typeName.length() - 1) == ';')
+ || (typeName.charAt(0) == '[')) {
+ // reference type
+ int indexOfL = typeName.indexOf('L');
+ String type;
+ if (indexOfL == 0) {
+ // not array
+ type = typeName.substring(1, typeName.length() - 1);
+ type = type.replace('/', '.');
+ } else if (indexOfL == -1) {
+ // array of primitive type
+ // do nothing
+ type = typeName;
+ } else {
+ // array of reference type
+ type = typeName.replace('/', '.');
+ }
+ if (isReadMethod) {
+ code
+ .addInvokeinterface(
+ callback_type_index,
+ "readObject",
+ "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;",
+ 4);
+ // checkcast
+ code.addCheckcast(type);
+ } else {
+ code
+ .addInvokeinterface(
+ callback_type_index,
+ "writeObject",
+ "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+ 5);
+ // checkcast
+ code.addCheckcast(type);
+ }
+ } else if (typeName.equals("Z")) {
+ // boolean
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readBoolean",
+ "(Ljava/lang/Object;Ljava/lang/String;Z)Z", 4);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeBoolean",
+ "(Ljava/lang/Object;Ljava/lang/String;ZZ)Z", 5);
+ }
+ } else if (typeName.equals("B")) {
+ // byte
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readByte",
+ "(Ljava/lang/Object;Ljava/lang/String;B)B", 4);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeByte",
+ "(Ljava/lang/Object;Ljava/lang/String;BB)B", 5);
+ }
+ } else if (typeName.equals("C")) {
+ // char
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readChar",
+ "(Ljava/lang/Object;Ljava/lang/String;C)C", 4);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeChar",
+ "(Ljava/lang/Object;Ljava/lang/String;CC)C", 5);
+ }
+ } else if (typeName.equals("I")) {
+ // int
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readInt",
+ "(Ljava/lang/Object;Ljava/lang/String;I)I", 4);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeInt",
+ "(Ljava/lang/Object;Ljava/lang/String;II)I", 5);
+ }
+ } else if (typeName.equals("S")) {
+ // short
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readShort",
+ "(Ljava/lang/Object;Ljava/lang/String;S)S", 4);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeShort",
+ "(Ljava/lang/Object;Ljava/lang/String;SS)S", 5);
+ }
+ } else if (typeName.equals("D")) {
+ // double
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readDouble",
+ "(Ljava/lang/Object;Ljava/lang/String;D)D", 5);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeDouble",
+ "(Ljava/lang/Object;Ljava/lang/String;DD)D", 7);
+ }
+ } else if (typeName.equals("F")) {
+ // float
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readFloat",
+ "(Ljava/lang/Object;Ljava/lang/String;F)F", 4);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeFloat",
+ "(Ljava/lang/Object;Ljava/lang/String;FF)F", 5);
+ }
+ } else if (typeName.equals("J")) {
+ // long
+ if (isReadMethod) {
+ code.addInvokeinterface(callback_type_index, "readLong",
+ "(Ljava/lang/Object;Ljava/lang/String;J)J", 5);
+ } else {
+ code.addInvokeinterface(callback_type_index, "writeLong",
+ "(Ljava/lang/Object;Ljava/lang/String;JJ)J", 7);
+ }
+ } else {
+ // bad type
+ throw new RuntimeException("bad type: " + typeName);
+ }
+ }
+
+ private static void addTypeDependDataLoad(Bytecode code, String typeName,
+ int i) {
+ if ((typeName.charAt(0) == 'L')
+ && (typeName.charAt(typeName.length() - 1) == ';')
+ || (typeName.charAt(0) == '[')) {
+ // reference type
+ code.addAload(i);
+ } else if (typeName.equals("Z") || typeName.equals("B")
+ || typeName.equals("C") || typeName.equals("I")
+ || typeName.equals("S")) {
+ // boolean, byte, char, int, short
+ code.addIload(i);
+ } else if (typeName.equals("D")) {
+ // double
+ code.addDload(i);
+ } else if (typeName.equals("F")) {
+ // float
+ code.addFload(i);
+ } else if (typeName.equals("J")) {
+ // long
+ code.addLload(i);
+ } else {
+ // bad type
+ throw new RuntimeException("bad type: " + typeName);
+ }
+ }
+
+ private static void addTypeDependDataStore(Bytecode code, String typeName,
+ int i) {
+ if ((typeName.charAt(0) == 'L')
+ && (typeName.charAt(typeName.length() - 1) == ';')
+ || (typeName.charAt(0) == '[')) {
+ // reference type
+ code.addAstore(i);
+ } else if (typeName.equals("Z") || typeName.equals("B")
+ || typeName.equals("C") || typeName.equals("I")
+ || typeName.equals("S")) {
+ // boolean, byte, char, int, short
+ code.addIstore(i);
+ } else if (typeName.equals("D")) {
+ // double
+ code.addDstore(i);
+ } else if (typeName.equals("F")) {
+ // float
+ code.addFstore(i);
+ } else if (typeName.equals("J")) {
+ // long
+ code.addLstore(i);
+ } else {
+ // bad type
+ throw new RuntimeException("bad type: " + typeName);
+ }
+ }
+
+ private static void addTypeDependDataReturn(Bytecode code, String typeName) {
+ if ((typeName.charAt(0) == 'L')
+ && (typeName.charAt(typeName.length() - 1) == ';')
+ || (typeName.charAt(0) == '[')) {
+ // reference type
+ code.addOpcode(Opcode.ARETURN);
+ } else if (typeName.equals("Z") || typeName.equals("B")
+ || typeName.equals("C") || typeName.equals("I")
+ || typeName.equals("S")) {
+ // boolean, byte, char, int, short
+ code.addOpcode(Opcode.IRETURN);
+ } else if (typeName.equals("D")) {
+ // double
+ code.addOpcode(Opcode.DRETURN);
+ } else if (typeName.equals("F")) {
+ // float
+ code.addOpcode(Opcode.FRETURN);
+ } else if (typeName.equals("J")) {
+ // long
+ code.addOpcode(Opcode.LRETURN);
+ } else {
+ // bad type
+ throw new RuntimeException("bad type: " + typeName);
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,32 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import org.hibernate.bytecode.ReflectionOptimizer;
-import org.hibernate.InstantiationException;
-
-import java.io.Serializable;
-
-/**
- * The {@link ReflectionOptimizer.InstantiationOptimizer} implementation for Javassist
- * which simply acts as an adpater to the {@link FastClass} class.
- *
- * @author Steve Ebersole
- */
-public class InstantiationOptimizerAdapter implements ReflectionOptimizer.InstantiationOptimizer, Serializable {
- private final FastClass fastClass;
-
- public InstantiationOptimizerAdapter(FastClass fastClass) {
- this.fastClass = fastClass;
- }
-
- public Object newInstance() {
- try {
- return fastClass.newInstance();
- }
- catch ( Throwable t ) {
- throw new InstantiationException(
- "Could not instantiate entity with Javassist optimizer: ",
- fastClass.getJavaClass(), t
- );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/InstantiationOptimizerAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
+import org.hibernate.InstantiationException;
+
+import java.io.Serializable;
+
+/**
+ * The {@link ReflectionOptimizer.InstantiationOptimizer} implementation for Javassist
+ * which simply acts as an adpater to the {@link FastClass} class.
+ *
+ * @author Steve Ebersole
+ */
+public class InstantiationOptimizerAdapter implements ReflectionOptimizer.InstantiationOptimizer, Serializable {
+ private final FastClass fastClass;
+
+ public InstantiationOptimizerAdapter(FastClass fastClass) {
+ this.fastClass = fastClass;
+ }
+
+ public Object newInstance() {
+ try {
+ return fastClass.newInstance();
+ }
+ catch ( Throwable t ) {
+ throw new InstantiationException(
+ "Could not instantiate entity with Javassist optimizer: ",
+ fastClass.getJavaClass(), t
+ );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,111 +0,0 @@
-//$Id: $
-package org.hibernate.bytecode.javassist;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.security.ProtectionDomain;
-
-import javassist.bytecode.ClassFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.bytecode.AbstractClassTransformerImpl;
-import org.hibernate.bytecode.util.ClassFilter;
-
-/**
- * Enhance the classes allowing them to implements InterceptFieldEnabled
- * This interface is then used by Hibernate for some optimizations.
- *
- * @author Emmanuel Bernard
- * @author Steve Ebersole
- */
-public class JavassistClassTransformer extends AbstractClassTransformerImpl {
-
- private static Logger log = LoggerFactory.getLogger( JavassistClassTransformer.class.getName() );
-
- public JavassistClassTransformer(ClassFilter classFilter, org.hibernate.bytecode.util.FieldFilter fieldFilter) {
- super( classFilter, fieldFilter );
- }
-
- protected byte[] doTransform(
- ClassLoader loader,
- String className,
- Class classBeingRedefined,
- ProtectionDomain protectionDomain,
- byte[] classfileBuffer) {
- ClassFile classfile;
- try {
- // WARNING: classfile only
- classfile = new ClassFile( new DataInputStream( new ByteArrayInputStream( classfileBuffer ) ) );
- }
- catch (IOException e) {
- log.error( "Unable to build enhancement metamodel for " + className );
- return classfileBuffer;
- }
- FieldTransformer transformer = getFieldTransformer( classfile );
- if ( transformer != null ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "Enhancing " + className );
- }
- DataOutputStream out = null;
- try {
- transformer.transform( classfile );
- ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- out = new DataOutputStream( byteStream );
- classfile.write( out );
- return byteStream.toByteArray();
- }
- catch (Exception e) {
- log.error( "Unable to transform class", e );
- throw new HibernateException( "Unable to transform class: " + e.getMessage() );
- }
- finally {
- try {
- if ( out != null ) out.close();
- }
- catch (IOException e) {
- //swallow
- }
- }
- }
- return classfileBuffer;
- }
-
- protected FieldTransformer getFieldTransformer(final ClassFile classfile) {
- if ( alreadyInstrumented( classfile ) ) {
- return null;
- }
- return new FieldTransformer(
- new FieldFilter() {
- public boolean handleRead(String desc, String name) {
- return fieldFilter.shouldInstrumentField( classfile.getName(), name );
- }
-
- public boolean handleWrite(String desc, String name) {
- return fieldFilter.shouldInstrumentField( classfile.getName(), name );
- }
-
- public boolean handleReadAccess(String fieldOwnerClassName, String fieldName) {
- return fieldFilter.shouldTransformFieldAccess( classfile.getName(), fieldOwnerClassName, fieldName );
- }
-
- public boolean handleWriteAccess(String fieldOwnerClassName, String fieldName) {
- return fieldFilter.shouldTransformFieldAccess( classfile.getName(), fieldOwnerClassName, fieldName );
- }
- }
- );
- }
-
- private boolean alreadyInstrumented(ClassFile classfile) {
- String[] intfs = classfile.getInterfaces();
- for ( int i = 0; i < intfs.length; i++ ) {
- if ( FieldHandled.class.getName().equals( intfs[i] ) ) {
- return true;
- }
- }
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/JavassistClassTransformer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,134 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.security.ProtectionDomain;
+
+import javassist.bytecode.ClassFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.bytecode.AbstractClassTransformerImpl;
+import org.hibernate.bytecode.util.ClassFilter;
+
+/**
+ * Enhance the classes allowing them to implements InterceptFieldEnabled
+ * This interface is then used by Hibernate for some optimizations.
+ *
+ * @author Emmanuel Bernard
+ * @author Steve Ebersole
+ */
+public class JavassistClassTransformer extends AbstractClassTransformerImpl {
+
+ private static Logger log = LoggerFactory.getLogger( JavassistClassTransformer.class.getName() );
+
+ public JavassistClassTransformer(ClassFilter classFilter, org.hibernate.bytecode.util.FieldFilter fieldFilter) {
+ super( classFilter, fieldFilter );
+ }
+
+ protected byte[] doTransform(
+ ClassLoader loader,
+ String className,
+ Class classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer) {
+ ClassFile classfile;
+ try {
+ // WARNING: classfile only
+ classfile = new ClassFile( new DataInputStream( new ByteArrayInputStream( classfileBuffer ) ) );
+ }
+ catch (IOException e) {
+ log.error( "Unable to build enhancement metamodel for " + className );
+ return classfileBuffer;
+ }
+ FieldTransformer transformer = getFieldTransformer( classfile );
+ if ( transformer != null ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Enhancing " + className );
+ }
+ DataOutputStream out = null;
+ try {
+ transformer.transform( classfile );
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ out = new DataOutputStream( byteStream );
+ classfile.write( out );
+ return byteStream.toByteArray();
+ }
+ catch (Exception e) {
+ log.error( "Unable to transform class", e );
+ throw new HibernateException( "Unable to transform class: " + e.getMessage() );
+ }
+ finally {
+ try {
+ if ( out != null ) out.close();
+ }
+ catch (IOException e) {
+ //swallow
+ }
+ }
+ }
+ return classfileBuffer;
+ }
+
+ protected FieldTransformer getFieldTransformer(final ClassFile classfile) {
+ if ( alreadyInstrumented( classfile ) ) {
+ return null;
+ }
+ return new FieldTransformer(
+ new FieldFilter() {
+ public boolean handleRead(String desc, String name) {
+ return fieldFilter.shouldInstrumentField( classfile.getName(), name );
+ }
+
+ public boolean handleWrite(String desc, String name) {
+ return fieldFilter.shouldInstrumentField( classfile.getName(), name );
+ }
+
+ public boolean handleReadAccess(String fieldOwnerClassName, String fieldName) {
+ return fieldFilter.shouldTransformFieldAccess( classfile.getName(), fieldOwnerClassName, fieldName );
+ }
+
+ public boolean handleWriteAccess(String fieldOwnerClassName, String fieldName) {
+ return fieldFilter.shouldTransformFieldAccess( classfile.getName(), fieldOwnerClassName, fieldName );
+ }
+ }
+ );
+ }
+
+ private boolean alreadyInstrumented(ClassFile classfile) {
+ String[] intfs = classfile.getInterfaces();
+ for ( int i = 0; i < intfs.length; i++ ) {
+ if ( FieldHandled.class.getName().equals( intfs[i] ) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,123 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import org.hibernate.bytecode.ProxyFactoryFactory;
-import org.hibernate.bytecode.BasicProxyFactory;
-import org.hibernate.proxy.ProxyFactory;
-import org.hibernate.proxy.pojo.javassist.JavassistProxyFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import javassist.util.proxy.MethodFilter;
-import javassist.util.proxy.ProxyObject;
-import javassist.util.proxy.MethodHandler;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-/**
- * A factory for Javassist-based {@link ProxyFactory} instances.
- *
- * @author Steve Ebersole
- */
-public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
-
- /**
- * Builds a Javassist-based proxy factory.
- *
- * @return a new Javassist-based proxy factory.
- */
- public ProxyFactory buildProxyFactory() {
- return new JavassistProxyFactory();
- }
-
- public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces) {
- return new BasicProxyFactoryImpl( superClass, interfaces );
- }
-
- private static class BasicProxyFactoryImpl implements BasicProxyFactory {
- private final Class proxyClass;
-
- public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
- if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
- throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
- }
- javassist.util.proxy.ProxyFactory factory = new javassist.util.proxy.ProxyFactory();
- factory.setFilter( FINALIZE_FILTER );
- if ( superClass != null ) {
- factory.setSuperclass( superClass );
- }
- if ( interfaces != null && interfaces.length > 0 ) {
- factory.setInterfaces( interfaces );
- }
- proxyClass = factory.createClass();
- }
-
- public Object getProxy() {
- try {
- ProxyObject proxy = ( ProxyObject ) proxyClass.newInstance();
- proxy.setHandler( new PassThroughHandler( proxy, proxyClass.getName() ) );
- return proxy;
- }
- catch ( Throwable t ) {
- throw new HibernateException( "Unable to instantiated proxy instance" );
- }
- }
-
- public boolean isInstance(Object object) {
- return proxyClass.isInstance( object );
- }
- }
-
- private static final MethodFilter FINALIZE_FILTER = new MethodFilter() {
- public boolean isHandled(Method m) {
- // skip finalize methods
- return !( m.getParameterTypes().length == 0 && m.getName().equals( "finalize" ) );
- }
- };
-
- private static class PassThroughHandler implements MethodHandler {
- private HashMap data = new HashMap();
- private final Object proxiedObject;
- private final String proxiedClassName;
-
- public PassThroughHandler(Object proxiedObject, String proxiedClassName) {
- this.proxiedObject = proxiedObject;
- this.proxiedClassName = proxiedClassName;
- }
-
- public Object invoke(
- Object object,
- Method method,
- Method method1,
- Object[] args) throws Exception {
- String name = method.getName();
- if ( "toString".equals( name ) ) {
- return proxiedClassName + "@" + System.identityHashCode( object );
- }
- else if ( "equals".equals( name ) ) {
- return proxiedObject == object ? Boolean.TRUE : Boolean.FALSE;
- }
- else if ( "hashCode".equals( name ) ) {
- return new Integer( System.identityHashCode( object ) );
- }
- boolean hasGetterSignature = method.getParameterTypes().length == 0 && method.getReturnType() != null;
- boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class );
- if ( name.startsWith( "get" ) && hasGetterSignature ) {
- String propName = name.substring( 3 );
- return data.get( propName );
- }
- else if ( name.startsWith( "is" ) && hasGetterSignature ) {
- String propName = name.substring( 2 );
- return data.get( propName );
- }
- else if ( name.startsWith( "set" ) && hasSetterSignature) {
- String propName = name.substring( 3 );
- data.put( propName, args[0] );
- return null;
- }
- else {
- // todo : what else to do here?
- return null;
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ProxyFactoryFactoryImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,147 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import org.hibernate.bytecode.ProxyFactoryFactory;
+import org.hibernate.bytecode.BasicProxyFactory;
+import org.hibernate.proxy.ProxyFactory;
+import org.hibernate.proxy.pojo.javassist.JavassistProxyFactory;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import javassist.util.proxy.MethodFilter;
+import javassist.util.proxy.ProxyObject;
+import javassist.util.proxy.MethodHandler;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+/**
+ * A factory for Javassist-based {@link ProxyFactory} instances.
+ *
+ * @author Steve Ebersole
+ */
+public class ProxyFactoryFactoryImpl implements ProxyFactoryFactory {
+
+ /**
+ * Builds a Javassist-based proxy factory.
+ *
+ * @return a new Javassist-based proxy factory.
+ */
+ public ProxyFactory buildProxyFactory() {
+ return new JavassistProxyFactory();
+ }
+
+ public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces) {
+ return new BasicProxyFactoryImpl( superClass, interfaces );
+ }
+
+ private static class BasicProxyFactoryImpl implements BasicProxyFactory {
+ private final Class proxyClass;
+
+ public BasicProxyFactoryImpl(Class superClass, Class[] interfaces) {
+ if ( superClass == null && ( interfaces == null || interfaces.length < 1 ) ) {
+ throw new AssertionFailure( "attempting to build proxy without any superclass or interfaces" );
+ }
+ javassist.util.proxy.ProxyFactory factory = new javassist.util.proxy.ProxyFactory();
+ factory.setFilter( FINALIZE_FILTER );
+ if ( superClass != null ) {
+ factory.setSuperclass( superClass );
+ }
+ if ( interfaces != null && interfaces.length > 0 ) {
+ factory.setInterfaces( interfaces );
+ }
+ proxyClass = factory.createClass();
+ }
+
+ public Object getProxy() {
+ try {
+ ProxyObject proxy = ( ProxyObject ) proxyClass.newInstance();
+ proxy.setHandler( new PassThroughHandler( proxy, proxyClass.getName() ) );
+ return proxy;
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "Unable to instantiated proxy instance" );
+ }
+ }
+
+ public boolean isInstance(Object object) {
+ return proxyClass.isInstance( object );
+ }
+ }
+
+ private static final MethodFilter FINALIZE_FILTER = new MethodFilter() {
+ public boolean isHandled(Method m) {
+ // skip finalize methods
+ return !( m.getParameterTypes().length == 0 && m.getName().equals( "finalize" ) );
+ }
+ };
+
+ private static class PassThroughHandler implements MethodHandler {
+ private HashMap data = new HashMap();
+ private final Object proxiedObject;
+ private final String proxiedClassName;
+
+ public PassThroughHandler(Object proxiedObject, String proxiedClassName) {
+ this.proxiedObject = proxiedObject;
+ this.proxiedClassName = proxiedClassName;
+ }
+
+ public Object invoke(
+ Object object,
+ Method method,
+ Method method1,
+ Object[] args) throws Exception {
+ String name = method.getName();
+ if ( "toString".equals( name ) ) {
+ return proxiedClassName + "@" + System.identityHashCode( object );
+ }
+ else if ( "equals".equals( name ) ) {
+ return proxiedObject == object ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if ( "hashCode".equals( name ) ) {
+ return new Integer( System.identityHashCode( object ) );
+ }
+ boolean hasGetterSignature = method.getParameterTypes().length == 0 && method.getReturnType() != null;
+ boolean hasSetterSignature = method.getParameterTypes().length == 1 && ( method.getReturnType() == null || method.getReturnType() == void.class );
+ if ( name.startsWith( "get" ) && hasGetterSignature ) {
+ String propName = name.substring( 3 );
+ return data.get( propName );
+ }
+ else if ( name.startsWith( "is" ) && hasGetterSignature ) {
+ String propName = name.substring( 2 );
+ return data.get( propName );
+ }
+ else if ( name.startsWith( "set" ) && hasSetterSignature) {
+ String propName = name.substring( 3 );
+ data.put( propName, args[0] );
+ return null;
+ }
+ else {
+ // todo : what else to do here?
+ return null;
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,32 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import org.hibernate.bytecode.ReflectionOptimizer;
-
-import java.io.Serializable;
-
-/**
- * ReflectionOptimizer implementation for Javassist.
- *
- * @author Steve Ebersole
- */
-public class ReflectionOptimizerImpl implements ReflectionOptimizer, Serializable {
-
- private final InstantiationOptimizer instantiationOptimizer;
- private final AccessOptimizer accessOptimizer;
-
- public ReflectionOptimizerImpl(
- InstantiationOptimizer instantiationOptimizer,
- AccessOptimizer accessOptimizer) {
- this.instantiationOptimizer = instantiationOptimizer;
- this.accessOptimizer = accessOptimizer;
- }
-
- public InstantiationOptimizer getInstantiationOptimizer() {
- return instantiationOptimizer;
- }
-
- public AccessOptimizer getAccessOptimizer() {
- return accessOptimizer;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/ReflectionOptimizerImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import org.hibernate.bytecode.ReflectionOptimizer;
+
+import java.io.Serializable;
+
+/**
+ * ReflectionOptimizer implementation for Javassist.
+ *
+ * @author Steve Ebersole
+ */
+public class ReflectionOptimizerImpl implements ReflectionOptimizer, Serializable {
+
+ private final InstantiationOptimizer instantiationOptimizer;
+ private final AccessOptimizer accessOptimizer;
+
+ public ReflectionOptimizerImpl(
+ InstantiationOptimizer instantiationOptimizer,
+ AccessOptimizer accessOptimizer) {
+ this.instantiationOptimizer = instantiationOptimizer;
+ this.accessOptimizer = accessOptimizer;
+ }
+
+ public InstantiationOptimizer getInstantiationOptimizer() {
+ return instantiationOptimizer;
+ }
+
+ public AccessOptimizer getAccessOptimizer() {
+ return accessOptimizer;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,57 +0,0 @@
-package org.hibernate.bytecode.javassist;
-
-import javassist.ClassPool;
-import javassist.NotFoundException;
-import javassist.CtClass;
-import javassist.CannotCompileException;
-import org.hibernate.HibernateException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * @author Steve Ebersole
- */
-public class TransformingClassLoader extends ClassLoader {
- private ClassLoader parent;
- private ClassPool classPool;
-
- /*package*/ TransformingClassLoader(ClassLoader parent, String[] classpath) {
- this.parent = parent;
- classPool = new ClassPool( true );
- for ( int i = 0; i < classpath.length; i++ ) {
- try {
- classPool.appendClassPath( classpath[i] );
- }
- catch ( NotFoundException e ) {
- throw new HibernateException(
- "Unable to resolve requested classpath for transformation [" +
- classpath[i] + "] : " + e.getMessage()
- );
- }
- }
- }
-
- protected Class findClass(String name) throws ClassNotFoundException {
- try {
- CtClass cc = classPool.get( name );
- // todo : modify the class definition if not already transformed...
- byte[] b = cc.toBytecode();
- return defineClass( name, b, 0, b.length );
- }
- catch ( NotFoundException e ) {
- throw new ClassNotFoundException();
- }
- catch ( IOException e ) {
- throw new ClassNotFoundException();
- }
- catch ( CannotCompileException e ) {
- throw new ClassNotFoundException();
- }
- }
-
- public void release() {
- classPool = null;
- parent = null;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/javassist/TransformingClassLoader.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,80 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.javassist;
+
+import javassist.ClassPool;
+import javassist.NotFoundException;
+import javassist.CtClass;
+import javassist.CannotCompileException;
+import org.hibernate.HibernateException;
+
+import java.io.IOException;
+
+/**
+ * @author Steve Ebersole
+ */
+public class TransformingClassLoader extends ClassLoader {
+ private ClassLoader parent;
+ private ClassPool classPool;
+
+ /*package*/ TransformingClassLoader(ClassLoader parent, String[] classpath) {
+ this.parent = parent;
+ classPool = new ClassPool( true );
+ for ( int i = 0; i < classpath.length; i++ ) {
+ try {
+ classPool.appendClassPath( classpath[i] );
+ }
+ catch ( NotFoundException e ) {
+ throw new HibernateException(
+ "Unable to resolve requested classpath for transformation [" +
+ classpath[i] + "] : " + e.getMessage()
+ );
+ }
+ }
+ }
+
+ protected Class findClass(String name) throws ClassNotFoundException {
+ try {
+ CtClass cc = classPool.get( name );
+ // todo : modify the class definition if not already transformed...
+ byte[] b = cc.toBytecode();
+ return defineClass( name, b, 0, b.length );
+ }
+ catch ( NotFoundException e ) {
+ throw new ClassNotFoundException();
+ }
+ catch ( IOException e ) {
+ throw new ClassNotFoundException();
+ }
+ catch ( CannotCompileException e ) {
+ throw new ClassNotFoundException();
+ }
+ }
+
+ public void release() {
+ classPool = null;
+ parent = null;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,38 +0,0 @@
-<html>
- <head></head>
- <body>
- <p>
- This package defines the API for plugging in bytecode libraries
- for usage by Hibernate. Hibernate uses these bytecode libraries
- in three scenarios:<ol>
- <li>
- <b>Reflection optimization</b> - to speed up the performance of
- POJO entity and component conctruction and field/property access
- </li>
- <li>
- <b>Proxy generation</b> - runtime building of proxies used for
- deferred loading of lazy entities
- </li>
- <li>
- <b>Field-level interception</b> - build-time instrumentation of entity
- classes for the purpose of intercepting field-level access (read/write)
- for both lazy loading and dirty tracking.
- </li>
- </ol>
- </p>
- <p>
- Currently, both CGLIB and Javassist are supported out-of-the-box.
- </p>
- <p>
- Note that for field-level interception, simply plugging in a new {@link BytecodeProvider}
- is not enough for Hibernate to be able to recognize new providers. You would additionally
- need to make appropriate code changes to the {@link org.hibernate.intercept.Helper}
- class. This is because the detection of these enhanced classes is needed in a static
- environment (i.e. outside the scope of any {@link org.hibernate.SessionFactory}.
- </p>
- <p>
- Note that in the current form the ability to specify a different bytecode provider
- is actually considered a global settings (global to the JVM).
- </p>
- </body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,63 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+ <head></head>
+ <body>
+ <p>
+ This package defines the API for plugging in bytecode libraries
+ for usage by Hibernate. Hibernate uses these bytecode libraries
+ in three scenarios:<ol>
+ <li>
+ <b>Reflection optimization</b> - to speed up the performance of
+ POJO entity and component conctruction and field/property access
+ </li>
+ <li>
+ <b>Proxy generation</b> - runtime building of proxies used for
+ deferred loading of lazy entities
+ </li>
+ <li>
+ <b>Field-level interception</b> - build-time instrumentation of entity
+ classes for the purpose of intercepting field-level access (read/write)
+ for both lazy loading and dirty tracking.
+ </li>
+ </ol>
+ </p>
+ <p>
+ Currently, both CGLIB and Javassist are supported out-of-the-box.
+ </p>
+ <p>
+ Note that for field-level interception, simply plugging in a new {@link BytecodeProvider}
+ is not enough for Hibernate to be able to recognize new providers. You would additionally
+ need to make appropriate code changes to the {@link org.hibernate.intercept.Helper}
+ class. This is because the detection of these enhanced classes is needed in a static
+ environment (i.e. outside the scope of any {@link org.hibernate.SessionFactory}.
+ </p>
+ <p>
+ Note that in the current form the ability to specify a different bytecode provider
+ is actually considered a global settings (global to the JVM).
+ </p>
+ </body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,59 +0,0 @@
-package org.hibernate.bytecode.util;
-
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * BasicClassFilter provides class filtering based on a series of packages to
- * be included and/or a series of explicit class names to be included. If
- * neither is specified, then no restrictions are applied.
- *
- * @author Steve Ebersole
- */
-public class BasicClassFilter implements ClassFilter {
- private final String[] includedPackages;
- private final Set includedClassNames = new HashSet();
- private final boolean isAllEmpty;
-
- public BasicClassFilter() {
- this( null, null );
- }
-
- public BasicClassFilter(String[] includedPackages, String[] includedClassNames) {
- this.includedPackages = includedPackages;
- if ( includedClassNames != null ) {
- for ( int i = 0; i < includedClassNames.length; i++ ) {
- this.includedClassNames.add( includedClassNames[i] );
- }
- }
-
- isAllEmpty = ( this.includedPackages == null || this.includedPackages.length == 0 )
- && ( this.includedClassNames.isEmpty() );
- }
-
- public boolean shouldInstrumentClass(String className) {
- if ( isAllEmpty ) {
- return true;
- }
- else if ( includedClassNames.contains( className ) ) {
- return true;
- }
- else if ( isInIncludedPackage( className ) ) {
- return true;
- }
- else {
- return false;
- }
- }
-
- private boolean isInIncludedPackage(String className) {
- if ( includedPackages != null ) {
- for ( int i = 0; i < includedPackages.length; i++ ) {
- if ( className.startsWith( includedPackages[i] ) ) {
- return true;
- }
- }
- }
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/BasicClassFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.util;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * BasicClassFilter provides class filtering based on a series of packages to
+ * be included and/or a series of explicit class names to be included. If
+ * neither is specified, then no restrictions are applied.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicClassFilter implements ClassFilter {
+ private final String[] includedPackages;
+ private final Set includedClassNames = new HashSet();
+ private final boolean isAllEmpty;
+
+ public BasicClassFilter() {
+ this( null, null );
+ }
+
+ public BasicClassFilter(String[] includedPackages, String[] includedClassNames) {
+ this.includedPackages = includedPackages;
+ if ( includedClassNames != null ) {
+ for ( int i = 0; i < includedClassNames.length; i++ ) {
+ this.includedClassNames.add( includedClassNames[i] );
+ }
+ }
+
+ isAllEmpty = ( this.includedPackages == null || this.includedPackages.length == 0 )
+ && ( this.includedClassNames.isEmpty() );
+ }
+
+ public boolean shouldInstrumentClass(String className) {
+ if ( isAllEmpty ) {
+ return true;
+ }
+ else if ( includedClassNames.contains( className ) ) {
+ return true;
+ }
+ else if ( isInIncludedPackage( className ) ) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ private boolean isInIncludedPackage(String className) {
+ if ( includedPackages != null ) {
+ for ( int i = 0; i < includedPackages.length; i++ ) {
+ if ( className.startsWith( includedPackages[i] ) ) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,78 +0,0 @@
-package org.hibernate.bytecode.util;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.BufferedInputStream;
-import java.util.zip.ZipInputStream;
-
-/**
- * A helper for reading byte code from various input sources.
- *
- * @author Steve Ebersole
- */
-public class ByteCodeHelper {
- private ByteCodeHelper() {
- }
-
- /**
- * Reads class byte array info from the given input stream.
- * <p/>
- * The stream is closed within this method!
- *
- * @param inputStream
- * @return
- * @throws IOException
- */
- public static byte[] readByteCode(InputStream inputStream) throws IOException {
- if ( inputStream == null ) {
- throw new IOException( "null input stream" );
- }
-
- byte[] buffer = new byte[409600];
- byte[] classBytes = new byte[0];
- int r = 0;
-
- try {
- r = inputStream.read( buffer );
- while ( r >= buffer.length ) {
- byte[] temp = new byte[ classBytes.length + buffer.length ];
- System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
- System.arraycopy( buffer, 0, temp, classBytes.length, buffer.length );
- classBytes = temp;
- }
- if ( r != -1 ) {
- byte[] temp = new byte[ classBytes.length + r ];
- System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
- System.arraycopy( buffer, 0, temp, classBytes.length, r );
- classBytes = temp;
- }
- }
- finally {
- try {
- inputStream.close();
- }
- catch (IOException ignore) {
- // intentionally empty
- }
- }
-
- return classBytes;
- }
-
- public static byte[] readByteCode(File file) throws IOException {
- return ByteCodeHelper.readByteCode( new FileInputStream( file ) );
- }
-
- public static byte[] readByteCode(ZipInputStream zip) throws IOException {
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- InputStream in = new BufferedInputStream( zip );
- int b;
- while ( ( b = in.read() ) != -1 ) {
- bout.write( b );
- }
- return bout.toByteArray();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ByteCodeHelper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,102 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.util;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedInputStream;
+import java.util.zip.ZipInputStream;
+
+/**
+ * A helper for reading byte code from various input sources.
+ *
+ * @author Steve Ebersole
+ */
+public class ByteCodeHelper {
+ private ByteCodeHelper() {
+ }
+
+ /**
+ * Reads class byte array info from the given input stream.
+ * <p/>
+ * The stream is closed within this method!
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ public static byte[] readByteCode(InputStream inputStream) throws IOException {
+ if ( inputStream == null ) {
+ throw new IOException( "null input stream" );
+ }
+
+ byte[] buffer = new byte[409600];
+ byte[] classBytes = new byte[0];
+ int r = 0;
+
+ try {
+ r = inputStream.read( buffer );
+ while ( r >= buffer.length ) {
+ byte[] temp = new byte[ classBytes.length + buffer.length ];
+ System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
+ System.arraycopy( buffer, 0, temp, classBytes.length, buffer.length );
+ classBytes = temp;
+ }
+ if ( r != -1 ) {
+ byte[] temp = new byte[ classBytes.length + r ];
+ System.arraycopy( classBytes, 0, temp, 0, classBytes.length );
+ System.arraycopy( buffer, 0, temp, classBytes.length, r );
+ classBytes = temp;
+ }
+ }
+ finally {
+ try {
+ inputStream.close();
+ }
+ catch (IOException ignore) {
+ // intentionally empty
+ }
+ }
+
+ return classBytes;
+ }
+
+ public static byte[] readByteCode(File file) throws IOException {
+ return ByteCodeHelper.readByteCode( new FileInputStream( file ) );
+ }
+
+ public static byte[] readByteCode(ZipInputStream zip) throws IOException {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ InputStream in = new BufferedInputStream( zip );
+ int b;
+ while ( ( b = in.read() ) != -1 ) {
+ bout.write( b );
+ }
+ return bout.toByteArray();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,30 +0,0 @@
-package org.hibernate.bytecode.util;
-
-/**
- * Contract describing the information Hibernate needs in terms of instrumenting
- * a class, either via ant task or dynamic classloader.
- *
- * @author Steve Ebersole
- */
-public interface ClassDescriptor {
- /**
- * The name of the class.
- *
- * @return The class name.
- */
- public String getName();
-
- /**
- * Determine if the class is already instrumented.
- *
- * @return True if already instrumented; false otherwise.
- */
- public boolean isInstrumented();
-
- /**
- * The bytes making up the class' bytecode.
- *
- * @return The bytecode bytes.
- */
- public byte[] getBytes();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassDescriptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,54 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.util;
+
+/**
+ * Contract describing the information Hibernate needs in terms of instrumenting
+ * a class, either via ant task or dynamic classloader.
+ *
+ * @author Steve Ebersole
+ */
+public interface ClassDescriptor {
+ /**
+ * The name of the class.
+ *
+ * @return The class name.
+ */
+ public String getName();
+
+ /**
+ * Determine if the class is already instrumented.
+ *
+ * @return True if already instrumented; false otherwise.
+ */
+ public boolean isInstrumented();
+
+ /**
+ * The bytes making up the class' bytecode.
+ *
+ * @return The bytecode bytes.
+ */
+ public byte[] getBytes();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-package org.hibernate.bytecode.util;
-
-/**
- * Used to determine whether a class should be instrumented.
- *
- * @author Steve Ebersole
- */
-public interface ClassFilter {
- public boolean shouldInstrumentClass(String className);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/ClassFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.util;
+
+/**
+ * Used to determine whether a class should be instrumented.
+ *
+ * @author Steve Ebersole
+ */
+public interface ClassFilter {
+ public boolean shouldInstrumentClass(String className);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,29 +0,0 @@
-package org.hibernate.bytecode.util;
-
-/**
- * Used to determine whether a field reference should be instrumented.
- *
- * @author Steve Ebersole
- */
-public interface FieldFilter {
- /**
- * Should this field definition be instrumented?
- *
- * @param className The name of the class currently being processed
- * @param fieldName The name of the field being checked.
- * @return True if we should instrument this field.
- */
- public boolean shouldInstrumentField(String className, String fieldName);
-
- /**
- * Should we instrument *access to* the given field. This differs from
- * {@link #shouldInstrumentField} in that here we are talking about a particular usage of
- * a field.
- *
- * @param transformingClassName The class currently being transformed.
- * @param fieldOwnerClassName The name of the class owning this field being checked.
- * @param fieldName The name of the field being checked.
- * @return True if this access should be transformed.
- */
- public boolean shouldTransformFieldAccess(String transformingClassName, String fieldOwnerClassName, String fieldName);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/bytecode/util/FieldFilter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,53 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.bytecode.util;
+
+/**
+ * Used to determine whether a field reference should be instrumented.
+ *
+ * @author Steve Ebersole
+ */
+public interface FieldFilter {
+ /**
+ * Should this field definition be instrumented?
+ *
+ * @param className The name of the class currently being processed
+ * @param fieldName The name of the field being checked.
+ * @return True if we should instrument this field.
+ */
+ public boolean shouldInstrumentField(String className, String fieldName);
+
+ /**
+ * Should we instrument *access to* the given field. This differs from
+ * {@link #shouldInstrumentField} in that here we are talking about a particular usage of
+ * a field.
+ *
+ * @param transformingClassName The class currently being transformed.
+ * @param fieldOwnerClassName The name of the class owning this field being checked.
+ * @param fieldName The name of the field being checked.
+ * @return True if this access should be transformed.
+ */
+ public boolean shouldTransformFieldAccess(String transformingClassName, String fieldOwnerClassName, String fieldName);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,86 +0,0 @@
-// $Id: AbstractJndiBoundCacheProvider.java 6079 2005-03-16 06:01:18Z oneovthafew $
-package org.hibernate.cache;
-
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.cfg.Environment;
-import org.hibernate.util.NamingHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * Support for CacheProvider implementations which are backed by caches bound
- * into JNDI namespace.
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractJndiBoundCacheProvider implements CacheProvider {
-
- private static final Logger log = LoggerFactory.getLogger( AbstractJndiBoundCacheProvider.class );
- private Object cache;
-
- protected void prepare(Properties properties) {
- // Do nothing; subclasses may override.
- }
-
- protected void release() {
- // Do nothing; subclasses may override.
- }
-
- /**
- * Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory
- * construction.
- *
- * @param properties current configuration settings.
- */
- public final void start(Properties properties) throws CacheException {
- String jndiNamespace = properties.getProperty( Environment.CACHE_NAMESPACE );
- if ( StringHelper.isEmpty( jndiNamespace ) ) {
- throw new CacheException( "No JNDI namespace specified for cache" );
- }
- cache = locateCache( jndiNamespace, NamingHelper.getJndiProperties( properties ) );
- prepare( properties );
- }
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache
- * implementation during SessionFactory.close().
- */
- public final void stop() {
- release();
- cache = null;
- }
-
- private Object locateCache(String jndiNamespace, Properties jndiProperties) {
-
- Context ctx = null;
- try {
- ctx = new InitialContext( jndiProperties );
- return ctx.lookup( jndiNamespace );
- }
- catch (NamingException ne) {
- String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
- log.info( msg, ne );
- throw new CacheException( msg );
- }
- finally {
- if ( ctx != null ) {
- try {
- ctx.close();
- }
- catch( NamingException ne ) {
- log.info( "Unable to release initial context", ne );
- }
- }
- }
- }
-
- public Object getCache() {
- return cache;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/AbstractJndiBoundCacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,109 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.cfg.Environment;
+import org.hibernate.util.NamingHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Support for CacheProvider implementations which are backed by caches bound
+ * into JNDI namespace.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractJndiBoundCacheProvider implements CacheProvider {
+
+ private static final Logger log = LoggerFactory.getLogger( AbstractJndiBoundCacheProvider.class );
+ private Object cache;
+
+ protected void prepare(Properties properties) {
+ // Do nothing; subclasses may override.
+ }
+
+ protected void release() {
+ // Do nothing; subclasses may override.
+ }
+
+ /**
+ * Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory
+ * construction.
+ *
+ * @param properties current configuration settings.
+ */
+ public final void start(Properties properties) throws CacheException {
+ String jndiNamespace = properties.getProperty( Environment.CACHE_NAMESPACE );
+ if ( StringHelper.isEmpty( jndiNamespace ) ) {
+ throw new CacheException( "No JNDI namespace specified for cache" );
+ }
+ cache = locateCache( jndiNamespace, NamingHelper.getJndiProperties( properties ) );
+ prepare( properties );
+ }
+
+ /**
+ * Callback to perform any necessary cleanup of the underlying cache
+ * implementation during SessionFactory.close().
+ */
+ public final void stop() {
+ release();
+ cache = null;
+ }
+
+ private Object locateCache(String jndiNamespace, Properties jndiProperties) {
+
+ Context ctx = null;
+ try {
+ ctx = new InitialContext( jndiProperties );
+ return ctx.lookup( jndiNamespace );
+ }
+ catch (NamingException ne) {
+ String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
+ log.info( msg, ne );
+ throw new CacheException( msg );
+ }
+ finally {
+ if ( ctx != null ) {
+ try {
+ ctx.close();
+ }
+ catch( NamingException ne ) {
+ log.info( "Unable to release initial context", ne );
+ }
+ }
+ }
+ }
+
+ public Object getCache() {
+ return cache;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/Cache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,108 +0,0 @@
-//$Id: Cache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.Map;
-
-/**
- * Implementors define a caching algorithm. All implementors
- * <b>must</b> be threadsafe.
- *
- * @deprecated As of 3.3; see <a href="package.html"/> for details.
- */
-public interface Cache {
- /**
- * Get an item from the cache
- * @param key
- * @return the cached object or <tt>null</tt>
- * @throws CacheException
- */
- public Object read(Object key) throws CacheException;
- /**
- * Get an item from the cache, nontransactionally
- * @param key
- * @return the cached object or <tt>null</tt>
- * @throws CacheException
- */
- public Object get(Object key) throws CacheException;
- /**
- * Add an item to the cache, nontransactionally, with
- * failfast semantics
- * @param key
- * @param value
- * @throws CacheException
- */
- public void put(Object key, Object value) throws CacheException;
- /**
- * Add an item to the cache
- * @param key
- * @param value
- * @throws CacheException
- */
- public void update(Object key, Object value) throws CacheException;
- /**
- * Remove an item from the cache
- */
- public void remove(Object key) throws CacheException;
- /**
- * Clear the cache
- */
- public void clear() throws CacheException;
- /**
- * Clean up
- */
- public void destroy() throws CacheException;
- /**
- * If this is a clustered cache, lock the item
- */
- public void lock(Object key) throws CacheException;
- /**
- * If this is a clustered cache, unlock the item
- */
- public void unlock(Object key) throws CacheException;
- /**
- * Generate a timestamp
- */
- public long nextTimestamp();
- /**
- * Get a reasonable "lock timeout"
- */
- public int getTimeout();
-
- /**
- * Get the name of the cache region
- */
- public String getRegionName();
-
- /**
- * The number of bytes is this cache region currently consuming in memory.
- *
- * @return The number of bytes consumed by this region; -1 if unknown or
- * unsupported.
- */
- public long getSizeInMemory();
-
- /**
- * The count of entries currently contained in the regions in-memory store.
- *
- * @return The count of entries in memory; -1 if unknown or unsupported.
- */
- public long getElementCountInMemory();
-
- /**
- * The count of entries currently contained in the regions disk store.
- *
- * @return The count of entries on disk; -1 if unknown or unsupported.
- */
- public long getElementCountOnDisk();
-
- /**
- * optional operation
- */
- public Map toMap();
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/Cache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Cache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,131 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Map;
+
+/**
+ * Implementors define a caching algorithm. All implementors
+ * <b>must</b> be threadsafe.
+ *
+ * @deprecated As of 3.3; see <a href="package.html"/> for details.
+ */
+public interface Cache {
+ /**
+ * Get an item from the cache
+ * @param key
+ * @return the cached object or <tt>null</tt>
+ * @throws CacheException
+ */
+ public Object read(Object key) throws CacheException;
+ /**
+ * Get an item from the cache, nontransactionally
+ * @param key
+ * @return the cached object or <tt>null</tt>
+ * @throws CacheException
+ */
+ public Object get(Object key) throws CacheException;
+ /**
+ * Add an item to the cache, nontransactionally, with
+ * failfast semantics
+ * @param key
+ * @param value
+ * @throws CacheException
+ */
+ public void put(Object key, Object value) throws CacheException;
+ /**
+ * Add an item to the cache
+ * @param key
+ * @param value
+ * @throws CacheException
+ */
+ public void update(Object key, Object value) throws CacheException;
+ /**
+ * Remove an item from the cache
+ */
+ public void remove(Object key) throws CacheException;
+ /**
+ * Clear the cache
+ */
+ public void clear() throws CacheException;
+ /**
+ * Clean up
+ */
+ public void destroy() throws CacheException;
+ /**
+ * If this is a clustered cache, lock the item
+ */
+ public void lock(Object key) throws CacheException;
+ /**
+ * If this is a clustered cache, unlock the item
+ */
+ public void unlock(Object key) throws CacheException;
+ /**
+ * Generate a timestamp
+ */
+ public long nextTimestamp();
+ /**
+ * Get a reasonable "lock timeout"
+ */
+ public int getTimeout();
+
+ /**
+ * Get the name of the cache region
+ */
+ public String getRegionName();
+
+ /**
+ * The number of bytes is this cache region currently consuming in memory.
+ *
+ * @return The number of bytes consumed by this region; -1 if unknown or
+ * unsupported.
+ */
+ public long getSizeInMemory();
+
+ /**
+ * The count of entries currently contained in the regions in-memory store.
+ *
+ * @return The count of entries in memory; -1 if unknown or unsupported.
+ */
+ public long getElementCountInMemory();
+
+ /**
+ * The count of entries currently contained in the regions disk store.
+ *
+ * @return The count of entries on disk; -1 if unknown or unsupported.
+ */
+ public long getElementCountOnDisk();
+
+ /**
+ * optional operation
+ */
+ public Map toMap();
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,174 +0,0 @@
-//$Id: CacheConcurrencyStrategy.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.Comparator;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- * Implementors manage transactional access to cached data. Transactions
- * pass in a timestamp indicating transaction start time. Two different
- * implementation patterns are provided for.<ul>
- * <li>A transaction-aware cache implementation might be wrapped by a
- * "synchronous" concurrency strategy, where updates to the cache are written
- * to the cache inside the transaction.</li>
- * <li>A non transaction-aware cache would be wrapped by an "asynchronous"
- * concurrency strategy, where items are merely "soft locked" during the
- * transaction and then updated during the "after transaction completion"
- * phase; the soft lock is not an actual lock on the database row -
- * only upon the cached representation of the item.</li>
- * </ul>
- * <p/>
- * In terms of entity caches, the expected call sequences are: <ul>
- * <li><b>DELETES</b> : {@link #lock} -> {@link #evict} -> {@link #release}</li>
- * <li><b>UPDATES</b> : {@link #lock} -> {@link #update} -> {@link #afterUpdate}</li>
- * <li><b>INSERTS</b> : {@link #insert} -> {@link #afterInsert}</li>
- * </ul>
- * <p/>
- * In terms of collection caches, all modification actions actually just
- * invalidate the entry(s). The call sequence here is:
- * {@link #lock} -> {@link #evict} -> {@link #release}
- * <p/>
- * Note that, for an asynchronous cache, cache invalidation must be a two
- * step process (lock->release, or lock-afterUpdate), since this is the only
- * way to guarantee consistency with the database for a nontransactional cache
- * implementation. For a synchronous cache, cache invalidation is a single
- * step process (evict, or update). Hence, this interface defines a three
- * step process, to cater for both models.
- * <p/>
- * Note that query result caching does not go through a concurrency strategy; they
- * are managed directly against the underlying {@link Cache cache regions}.
- *
- * @deprecated As of 3.3; see <a href="package.html"/> for details.
- */
-public interface CacheConcurrencyStrategy {
-
- /**
- * Attempt to retrieve an object from the cache. Mainly used in attempting
- * to resolve entities/collections from the second level cache.
- *
- * @param key
- * @param txTimestamp a timestamp prior to the transaction start time
- * @return the cached object or <tt>null</tt>
- * @throws CacheException
- */
- public Object get(Object key, long txTimestamp) throws CacheException;
-
- /**
- * Attempt to cache an object, after loading from the database.
- *
- * @param key
- * @param value
- * @param txTimestamp a timestamp prior to the transaction start time
- * @param version the item version number
- * @param versionComparator a comparator used to compare version numbers
- * @param minimalPut indicates that the cache should avoid a put is the item is already cached
- * @return <tt>true</tt> if the object was successfully cached
- * @throws CacheException
- */
- public boolean put(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- Comparator versionComparator,
- boolean minimalPut)
- throws CacheException;
-
- /**
- * We are going to attempt to update/delete the keyed object. This
- * method is used by "asynchronous" concurrency strategies.
- * <p/>
- * The returned object must be passed back to release(), to release the
- * lock. Concurrency strategies which do not support client-visible
- * locks may silently return null.
- *
- * @param key
- * @param version
- * @throws CacheException
- */
- public SoftLock lock(Object key, Object version) throws CacheException;
-
- /**
- * Called after an item has become stale (before the transaction completes).
- * This method is used by "synchronous" concurrency strategies.
- */
- public void evict(Object key) throws CacheException;
-
- /**
- * Called after an item has been updated (before the transaction completes),
- * instead of calling evict().
- * This method is used by "synchronous" concurrency strategies.
- */
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
-
- /**
- * Called after an item has been inserted (before the transaction completes),
- * instead of calling evict().
- * This method is used by "synchronous" concurrency strategies.
- */
- public boolean insert(Object key, Object value, Object currentVersion) throws CacheException;
-
-
- /**
- * Called when we have finished the attempted update/delete (which may or
- * may not have been successful), after transaction completion.
- * This method is used by "asynchronous" concurrency strategies.
- * @param key
- * @throws CacheException
- */
- public void release(Object key, SoftLock lock) throws CacheException;
- /**
- * Called after an item has been updated (after the transaction completes),
- * instead of calling release().
- * This method is used by "asynchronous" concurrency strategies.
- */
- public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock)
- throws CacheException;
- /**
- * Called after an item has been inserted (after the transaction completes),
- * instead of calling release().
- * This method is used by "asynchronous" concurrency strategies.
- */
- public boolean afterInsert(Object key, Object value, Object version)
- throws CacheException;
-
-
- /**
- * Evict an item from the cache immediately (without regard for transaction
- * isolation).
- * @param key
- * @throws CacheException
- */
- public void remove(Object key) throws CacheException;
- /**
- * Evict all items from the cache immediately.
- * @throws CacheException
- */
- public void clear() throws CacheException;
- /**
- * Clean up all resources.
- */
- public void destroy();
- /**
- * Set the underlying cache implementation.
- * @param cache
- */
- public void setCache(Cache cache);
-
- /**
- * Get the cache region name
- */
- public String getRegionName();
-
- /**
- * Get the wrapped cache implementation
- */
- public Cache getCache();
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheConcurrencyStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,197 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Comparator;
+
+import org.hibernate.cache.access.SoftLock;
+
+/**
+ * Implementors manage transactional access to cached data. Transactions
+ * pass in a timestamp indicating transaction start time. Two different
+ * implementation patterns are provided for.<ul>
+ * <li>A transaction-aware cache implementation might be wrapped by a
+ * "synchronous" concurrency strategy, where updates to the cache are written
+ * to the cache inside the transaction.</li>
+ * <li>A non transaction-aware cache would be wrapped by an "asynchronous"
+ * concurrency strategy, where items are merely "soft locked" during the
+ * transaction and then updated during the "after transaction completion"
+ * phase; the soft lock is not an actual lock on the database row -
+ * only upon the cached representation of the item.</li>
+ * </ul>
+ * <p/>
+ * In terms of entity caches, the expected call sequences are: <ul>
+ * <li><b>DELETES</b> : {@link #lock} -> {@link #evict} -> {@link #release}</li>
+ * <li><b>UPDATES</b> : {@link #lock} -> {@link #update} -> {@link #afterUpdate}</li>
+ * <li><b>INSERTS</b> : {@link #insert} -> {@link #afterInsert}</li>
+ * </ul>
+ * <p/>
+ * In terms of collection caches, all modification actions actually just
+ * invalidate the entry(s). The call sequence here is:
+ * {@link #lock} -> {@link #evict} -> {@link #release}
+ * <p/>
+ * Note that, for an asynchronous cache, cache invalidation must be a two
+ * step process (lock->release, or lock-afterUpdate), since this is the only
+ * way to guarantee consistency with the database for a nontransactional cache
+ * implementation. For a synchronous cache, cache invalidation is a single
+ * step process (evict, or update). Hence, this interface defines a three
+ * step process, to cater for both models.
+ * <p/>
+ * Note that query result caching does not go through a concurrency strategy; they
+ * are managed directly against the underlying {@link Cache cache regions}.
+ *
+ * @deprecated As of 3.3; see <a href="package.html"/> for details.
+ */
+public interface CacheConcurrencyStrategy {
+
+ /**
+ * Attempt to retrieve an object from the cache. Mainly used in attempting
+ * to resolve entities/collections from the second level cache.
+ *
+ * @param key
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @return the cached object or <tt>null</tt>
+ * @throws CacheException
+ */
+ public Object get(Object key, long txTimestamp) throws CacheException;
+
+ /**
+ * Attempt to cache an object, after loading from the database.
+ *
+ * @param key
+ * @param value
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @param version the item version number
+ * @param versionComparator a comparator used to compare version numbers
+ * @param minimalPut indicates that the cache should avoid a put is the item is already cached
+ * @return <tt>true</tt> if the object was successfully cached
+ * @throws CacheException
+ */
+ public boolean put(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ Comparator versionComparator,
+ boolean minimalPut)
+ throws CacheException;
+
+ /**
+ * We are going to attempt to update/delete the keyed object. This
+ * method is used by "asynchronous" concurrency strategies.
+ * <p/>
+ * The returned object must be passed back to release(), to release the
+ * lock. Concurrency strategies which do not support client-visible
+ * locks may silently return null.
+ *
+ * @param key
+ * @param version
+ * @throws CacheException
+ */
+ public SoftLock lock(Object key, Object version) throws CacheException;
+
+ /**
+ * Called after an item has become stale (before the transaction completes).
+ * This method is used by "synchronous" concurrency strategies.
+ */
+ public void evict(Object key) throws CacheException;
+
+ /**
+ * Called after an item has been updated (before the transaction completes),
+ * instead of calling evict().
+ * This method is used by "synchronous" concurrency strategies.
+ */
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
+
+ /**
+ * Called after an item has been inserted (before the transaction completes),
+ * instead of calling evict().
+ * This method is used by "synchronous" concurrency strategies.
+ */
+ public boolean insert(Object key, Object value, Object currentVersion) throws CacheException;
+
+
+ /**
+ * Called when we have finished the attempted update/delete (which may or
+ * may not have been successful), after transaction completion.
+ * This method is used by "asynchronous" concurrency strategies.
+ * @param key
+ * @throws CacheException
+ */
+ public void release(Object key, SoftLock lock) throws CacheException;
+ /**
+ * Called after an item has been updated (after the transaction completes),
+ * instead of calling release().
+ * This method is used by "asynchronous" concurrency strategies.
+ */
+ public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock)
+ throws CacheException;
+ /**
+ * Called after an item has been inserted (after the transaction completes),
+ * instead of calling release().
+ * This method is used by "asynchronous" concurrency strategies.
+ */
+ public boolean afterInsert(Object key, Object value, Object version)
+ throws CacheException;
+
+
+ /**
+ * Evict an item from the cache immediately (without regard for transaction
+ * isolation).
+ * @param key
+ * @throws CacheException
+ */
+ public void remove(Object key) throws CacheException;
+ /**
+ * Evict all items from the cache immediately.
+ * @throws CacheException
+ */
+ public void clear() throws CacheException;
+ /**
+ * Clean up all resources.
+ */
+ public void destroy();
+ /**
+ * Set the underlying cache implementation.
+ * @param cache
+ */
+ public void setCache(Cache cache);
+
+ /**
+ * Get the cache region name
+ */
+ public String getRegionName();
+
+ /**
+ * Get the wrapped cache implementation
+ */
+ public Cache getCache();
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/CacheDataDescription.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,35 +0,0 @@
-package org.hibernate.cache;
-
-import java.util.Comparator;
-
-/**
- * Describes attributes regarding the type of data to be cached.
- *
- * @author Steve Ebersole
- */
-public interface CacheDataDescription {
- /**
- * Is the data marked as being mutable?
- *
- * @return True if the data is mutable; false otherwise.
- */
- public boolean isMutable();
-
- /**
- * Is the data to be cached considered versioned?
- * <p/>
- * If true, it is illegal for {@link #getVersionComparator} to return
- * null.
- *
- * @return True if the data is versioned; false otherwise.
- */
- public boolean isVersioned();
-
- /**
- * Get the comparator used to compare two different version values.
- * <p/>
- * May return null <b>if</b> {@link #isVersioned()} returns false.
- * @return
- */
- public Comparator getVersionComparator();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/CacheDataDescription.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheDataDescription.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Comparator;
+
+/**
+ * Describes attributes regarding the type of data to be cached.
+ *
+ * @author Steve Ebersole
+ */
+public interface CacheDataDescription {
+ /**
+ * Is the data marked as being mutable?
+ *
+ * @return True if the data is mutable; false otherwise.
+ */
+ public boolean isMutable();
+
+ /**
+ * Is the data to be cached considered versioned?
+ * <p/>
+ * If true, it is illegal for {@link #getVersionComparator} to return
+ * null.
+ *
+ * @return True if the data is versioned; false otherwise.
+ */
+ public boolean isVersioned();
+
+ /**
+ * Get the comparator used to compare two different version values.
+ * <p/>
+ * May return null <b>if</b> {@link #isVersioned()} returns false.
+ * @return
+ */
+ public Comparator getVersionComparator();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/CacheException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,23 +0,0 @@
-//$Id: CacheException.java 11492 2007-05-09 01:57:11Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import org.hibernate.HibernateException;
-
-/**
- * Something went wrong in the cache
- */
-public class CacheException extends HibernateException {
-
- public CacheException(String s) {
- super(s);
- }
-
- public CacheException(String s, Throwable e) {
- super(s, e);
- }
-
- public CacheException(Throwable e) {
- super(e);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/CacheException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Something went wrong in the cache
+ */
+public class CacheException extends HibernateException {
+
+ public CacheException(String s) {
+ super(s);
+ }
+
+ public CacheException(String s, Throwable e) {
+ super(s, e);
+ }
+
+ public CacheException(Throwable e) {
+ super(e);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/CacheKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,72 +0,0 @@
-//$Id: CacheKey.java 11499 2007-05-09 17:35:55Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.io.Serializable;
-
-import org.hibernate.EntityMode;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Allows multiple entity classes / collection roles to be
- * stored in the same cache region. Also allows for composite
- * keys which do not properly implement equals()/hashCode().
- *
- * @author Gavin King
- */
-public class CacheKey implements Serializable {
- private final Serializable key;
- private final Type type;
- private final String entityOrRoleName;
- private final EntityMode entityMode;
- private final int hashCode;
-
- /**
- * Construct a new key for a collection or entity instance.
- * Note that an entity name should always be the root entity
- * name, not a subclass entity name.
- *
- * @param id The identifier associated with the cached data
- * @param type The Hibernate type mapping
- * @param entityOrRoleName The entity or collection-role name.
- * @param entityMode The entiyt mode of the originating session
- * @param factory The session factory for which we are caching
- */
- public CacheKey(
- final Serializable id,
- final Type type,
- final String entityOrRoleName,
- final EntityMode entityMode,
- final SessionFactoryImplementor factory) {
- this.key = id;
- this.type = type;
- this.entityOrRoleName = entityOrRoleName;
- this.entityMode = entityMode;
- hashCode = type.getHashCode( key, entityMode, factory );
- }
-
- //Mainly for OSCache
- public String toString() {
- return entityOrRoleName + '#' + key.toString();//"CacheKey#" + type.toString(key, sf);
- }
-
- public boolean equals(Object other) {
- if ( !(other instanceof CacheKey) ) return false;
- CacheKey that = (CacheKey) other;
- return entityOrRoleName.equals( that.entityOrRoleName )
- && type.isEqual( key, that.key, entityMode );
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public Serializable getKey() {
- return key;
- }
-
- public String getEntityOrRoleName() {
- return entityOrRoleName;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/CacheKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,95 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.io.Serializable;
+
+import org.hibernate.EntityMode;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Allows multiple entity classes / collection roles to be
+ * stored in the same cache region. Also allows for composite
+ * keys which do not properly implement equals()/hashCode().
+ *
+ * @author Gavin King
+ */
+public class CacheKey implements Serializable {
+ private final Serializable key;
+ private final Type type;
+ private final String entityOrRoleName;
+ private final EntityMode entityMode;
+ private final int hashCode;
+
+ /**
+ * Construct a new key for a collection or entity instance.
+ * Note that an entity name should always be the root entity
+ * name, not a subclass entity name.
+ *
+ * @param id The identifier associated with the cached data
+ * @param type The Hibernate type mapping
+ * @param entityOrRoleName The entity or collection-role name.
+ * @param entityMode The entiyt mode of the originating session
+ * @param factory The session factory for which we are caching
+ */
+ public CacheKey(
+ final Serializable id,
+ final Type type,
+ final String entityOrRoleName,
+ final EntityMode entityMode,
+ final SessionFactoryImplementor factory) {
+ this.key = id;
+ this.type = type;
+ this.entityOrRoleName = entityOrRoleName;
+ this.entityMode = entityMode;
+ hashCode = type.getHashCode( key, entityMode, factory );
+ }
+
+ //Mainly for OSCache
+ public String toString() {
+ return entityOrRoleName + '#' + key.toString();//"CacheKey#" + type.toString(key, sf);
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof CacheKey) ) return false;
+ CacheKey that = (CacheKey) other;
+ return entityOrRoleName.equals( that.entityOrRoleName )
+ && type.isEqual( key, that.key, entityMode );
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public Serializable getKey() {
+ return key;
+ }
+
+ public String getEntityOrRoleName() {
+ return entityOrRoleName;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/CacheProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,44 +0,0 @@
-//$Id: CacheProvider.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.Properties;
-
-/**
- * Support for pluggable caches.
- *
- * @author Gavin King
- * @deprecated As of 3.3; see <a href="package.html"/> for details.
- */
-public interface CacheProvider {
-
- /**
- * Configure the cache
- *
- * @param regionName the name of the cache region
- * @param properties configuration settings
- * @throws CacheException
- */
- public Cache buildCache(String regionName, Properties properties) throws CacheException;
-
- /**
- * Generate a timestamp
- */
- public long nextTimestamp();
-
- /**
- * Callback to perform any necessary initialization of the underlying cache implementation
- * during SessionFactory construction.
- *
- * @param properties current configuration settings.
- */
- public void start(Properties properties) throws CacheException;
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache implementation
- * during SessionFactory.close().
- */
- public void stop();
-
- public boolean isMinimalPutsEnabledByDefault();
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/CacheProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Properties;
+
+/**
+ * Support for pluggable caches.
+ *
+ * @author Gavin King
+ * @deprecated As of 3.3; see <a href="package.html"/> for details.
+ */
+public interface CacheProvider {
+
+ /**
+ * Configure the cache
+ *
+ * @param regionName the name of the cache region
+ * @param properties configuration settings
+ * @throws CacheException
+ */
+ public Cache buildCache(String regionName, Properties properties) throws CacheException;
+
+ /**
+ * Generate a timestamp
+ */
+ public long nextTimestamp();
+
+ /**
+ * Callback to perform any necessary initialization of the underlying cache implementation
+ * during SessionFactory construction.
+ *
+ * @param properties current configuration settings.
+ */
+ public void start(Properties properties) throws CacheException;
+
+ /**
+ * Callback to perform any necessary cleanup of the underlying cache implementation
+ * during SessionFactory.close().
+ */
+ public void stop();
+
+ public boolean isMinimalPutsEnabledByDefault();
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/CollectionRegion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,28 +0,0 @@
-package org.hibernate.cache;
-
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.access.AccessType;
-
-/**
- * Defines the contract for a cache region which will specifically be used to
- * store collection data.
- * <p/>
- * Impl note: Hibernate always deals with changes to collections which
- * (potentially) has its data in the L2 cache by removing that collection
- * data; in other words it never tries to update the cached state, thereby
- * allowing it to avoid a bunch of concurrency problems.
- *
- * @author Steve Ebersole
- */
-public interface CollectionRegion extends TransactionalDataRegion {
-
- /**
- * Build an access strategy for the requested access type.
- *
- * @param accessType The type of access strategy to build; never null.
- * @return The appropriate strategy contract for accessing this region
- * for the requested type of access.
- * @throws CacheException Usually indicates mis-configuration.
- */
- public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/CollectionRegion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/CollectionRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,52 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.AccessType;
+
+/**
+ * Defines the contract for a cache region which will specifically be used to
+ * store collection data.
+ * <p/>
+ * Impl note: Hibernate always deals with changes to collections which
+ * (potentially) has its data in the L2 cache by removing that collection
+ * data; in other words it never tries to update the cached state, thereby
+ * allowing it to avoid a bunch of concurrency problems.
+ *
+ * @author Steve Ebersole
+ */
+public interface CollectionRegion extends TransactionalDataRegion {
+
+ /**
+ * Build an access strategy for the requested access type.
+ *
+ * @param accessType The type of access strategy to build; never null.
+ * @return The appropriate strategy contract for accessing this region
+ * for the requested type of access.
+ * @throws CacheException Usually indicates mis-configuration.
+ */
+ public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/EntityRegion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,23 +0,0 @@
-package org.hibernate.cache;
-
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.access.AccessType;
-
-/**
- * Defines the contract for a cache region which will specifically be used to
- * store entity data.
- *
- * @author Steve Ebersole
- */
-public interface EntityRegion extends TransactionalDataRegion {
-
- /**
- * Build an access strategy for the requested access type.
- *
- * @param accessType The type of access strategy to build; never null.
- * @return The appropriate strategy contract for accessing this region
- * for the requested type of access.
- * @throws CacheException Usually indicates mis-configuration.
- */
- public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/EntityRegion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/EntityRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.AccessType;
+
+/**
+ * Defines the contract for a cache region which will specifically be used to
+ * store entity data.
+ *
+ * @author Steve Ebersole
+ */
+public interface EntityRegion extends TransactionalDataRegion {
+
+ /**
+ * Build an access strategy for the requested access type.
+ *
+ * @param accessType The type of access strategy to build; never null.
+ * @return The appropriate strategy contract for accessing this region
+ * for the requested type of access.
+ * @throws CacheException Usually indicates mis-configuration.
+ */
+ public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/FilterKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,70 +0,0 @@
-//$Id: FilterKey.java 8754 2005-12-05 23:36:59Z steveebersole $
-package org.hibernate.cache;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.EntityMode;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.impl.FilterImpl;
-import org.hibernate.type.Type;
-
-/**
- * Allows cached queries to be keyed by enabled filters.
- *
- * @author Gavin King
- */
-public final class FilterKey implements Serializable {
- private String filterName;
- private Map filterParameters = new HashMap();
-
- public FilterKey(String name, Map params, Map types, EntityMode entityMode) {
- filterName = name;
- Iterator iter = params.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry me = (Map.Entry) iter.next();
- Type type = (Type) types.get( me.getKey() );
- filterParameters.put( me.getKey(), new TypedValue( type, me.getValue(), entityMode ) );
- }
- }
-
- public int hashCode() {
- int result = 13;
- result = 37 * result + filterName.hashCode();
- result = 37 * result + filterParameters.hashCode();
- return result;
- }
-
- public boolean equals(Object other) {
- if ( !(other instanceof FilterKey) ) return false;
- FilterKey that = (FilterKey) other;
- if ( !that.filterName.equals(filterName) ) return false;
- if ( !that.filterParameters.equals(filterParameters) ) return false;
- return true;
- }
-
- public String toString() {
- return "FilterKey[" + filterName + filterParameters + ']';
- }
-
- public static Set createFilterKeys(Map enabledFilters, EntityMode entityMode) {
- if ( enabledFilters.size()==0 ) return null;
- Set result = new HashSet();
- Iterator iter = enabledFilters.values().iterator();
- while ( iter.hasNext() ) {
- FilterImpl filter = (FilterImpl) iter.next();
- FilterKey key = new FilterKey(
- filter.getName(),
- filter.getParameters(),
- filter.getFilterDefinition().getParameterTypes(),
- entityMode
- );
- result.add(key);
- }
- return result;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/FilterKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/FilterKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,93 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.EntityMode;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.impl.FilterImpl;
+import org.hibernate.type.Type;
+
+/**
+ * Allows cached queries to be keyed by enabled filters.
+ *
+ * @author Gavin King
+ */
+public final class FilterKey implements Serializable {
+ private String filterName;
+ private Map filterParameters = new HashMap();
+
+ public FilterKey(String name, Map params, Map types, EntityMode entityMode) {
+ filterName = name;
+ Iterator iter = params.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry me = (Map.Entry) iter.next();
+ Type type = (Type) types.get( me.getKey() );
+ filterParameters.put( me.getKey(), new TypedValue( type, me.getValue(), entityMode ) );
+ }
+ }
+
+ public int hashCode() {
+ int result = 13;
+ result = 37 * result + filterName.hashCode();
+ result = 37 * result + filterParameters.hashCode();
+ return result;
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof FilterKey) ) return false;
+ FilterKey that = (FilterKey) other;
+ if ( !that.filterName.equals(filterName) ) return false;
+ if ( !that.filterParameters.equals(filterParameters) ) return false;
+ return true;
+ }
+
+ public String toString() {
+ return "FilterKey[" + filterName + filterParameters + ']';
+ }
+
+ public static Set createFilterKeys(Map enabledFilters, EntityMode entityMode) {
+ if ( enabledFilters.size()==0 ) return null;
+ Set result = new HashSet();
+ Iterator iter = enabledFilters.values().iterator();
+ while ( iter.hasNext() ) {
+ FilterImpl filter = (FilterImpl) iter.next();
+ FilterKey key = new FilterKey(
+ filter.getName(),
+ filter.getParameters(),
+ filter.getFilterDefinition().getParameterTypes(),
+ entityMode
+ );
+ result.add(key);
+ }
+ return result;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,44 +0,0 @@
-package org.hibernate.cache;
-
-/**
- * Contract for general-purpose cache regions.
- *
- * @author Steve Ebersole
- */
-public interface GeneralDataRegion extends Region {
-
- /**
- * Get an item from the cache.
- *
- * @param key The key of the item to be retrieved.
- * @return the cached object or <tt>null</tt>
- * @throws CacheException Indicates a problem accessing the item or region.
- */
- public Object get(Object key) throws CacheException;
-
- /**
- * Put an item into the cache.
- *
- * @param key The key under which to cache the item.
- * @param value The item to cache.
- * @throws CacheException Indicates a problem accessing the region.
- */
- public void put(Object key, Object value) throws CacheException;
-
- /**
- * Evict an item from the cache immediately (without regard for transaction
- * isolation).
- *
- * @param key The key of the item to remove
- * @throws CacheException Indicates a problem accessing the item or region.
- */
- public void evict(Object key) throws CacheException;
-
- /**
- * Evict all contents of this particular cache region (without regard for transaction
- * isolation).
- *
- * @throws CacheException Indicates problem accessing the region.
- */
- public void evictAll() throws CacheException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/GeneralDataRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * Contract for general-purpose cache regions.
+ *
+ * @author Steve Ebersole
+ */
+public interface GeneralDataRegion extends Region {
+
+ /**
+ * Get an item from the cache.
+ *
+ * @param key The key of the item to be retrieved.
+ * @return the cached object or <tt>null</tt>
+ * @throws CacheException Indicates a problem accessing the item or region.
+ */
+ public Object get(Object key) throws CacheException;
+
+ /**
+ * Put an item into the cache.
+ *
+ * @param key The key under which to cache the item.
+ * @param value The item to cache.
+ * @throws CacheException Indicates a problem accessing the region.
+ */
+ public void put(Object key, Object value) throws CacheException;
+
+ /**
+ * Evict an item from the cache immediately (without regard for transaction
+ * isolation).
+ *
+ * @param key The key of the item to remove
+ * @throws CacheException Indicates a problem accessing the item or region.
+ */
+ public void evict(Object key) throws CacheException;
+
+ /**
+ * Evict all contents of this particular cache region (without regard for transaction
+ * isolation).
+ *
+ * @throws CacheException Indicates problem accessing the region.
+ */
+ public void evictAll() throws CacheException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/HashtableCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,90 +0,0 @@
-//$Id: HashtableCache.java 6478 2005-04-21 07:57:19Z oneovthafew $
-package org.hibernate.cache;
-
-import java.util.Collections;
-import java.util.Hashtable;
-
-import java.util.Map;
-
-/**
- * A lightweight implementation of the <tt>Cache</tt> interface
- * @author Gavin King
- */
-public class HashtableCache implements Cache {
-
- private final Map hashtable = new Hashtable();
- private final String regionName;
-
- public HashtableCache(String regionName) {
- this.regionName = regionName;
- }
-
- public String getRegionName() {
- return regionName;
- }
-
- public Object read(Object key) throws CacheException {
- return hashtable.get(key);
- }
-
- public Object get(Object key) throws CacheException {
- return hashtable.get(key);
- }
-
- public void update(Object key, Object value) throws CacheException {
- put(key, value);
- }
-
- public void put(Object key, Object value) throws CacheException {
- hashtable.put(key, value);
- }
-
- public void remove(Object key) throws CacheException {
- hashtable.remove(key);
- }
-
- public void clear() throws CacheException {
- hashtable.clear();
- }
-
- public void destroy() throws CacheException {
-
- }
-
- public void lock(Object key) throws CacheException {
- // local cache, so we use synchronization
- }
-
- public void unlock(Object key) throws CacheException {
- // local cache, so we use synchronization
- }
-
- public long nextTimestamp() {
- return Timestamper.next();
- }
-
- public int getTimeout() {
- return Timestamper.ONE_MS * 60000; //ie. 60 seconds
- }
-
- public long getSizeInMemory() {
- return -1;
- }
-
- public long getElementCountInMemory() {
- return hashtable.size();
- }
-
- public long getElementCountOnDisk() {
- return 0;
- }
-
- public Map toMap() {
- return Collections.unmodifiableMap(hashtable);
- }
-
- public String toString() {
- return "HashtableCache(" + regionName + ')';
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/HashtableCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,113 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Collections;
+import java.util.Hashtable;
+
+import java.util.Map;
+
+/**
+ * A lightweight implementation of the <tt>Cache</tt> interface
+ * @author Gavin King
+ */
+public class HashtableCache implements Cache {
+
+ private final Map hashtable = new Hashtable();
+ private final String regionName;
+
+ public HashtableCache(String regionName) {
+ this.regionName = regionName;
+ }
+
+ public String getRegionName() {
+ return regionName;
+ }
+
+ public Object read(Object key) throws CacheException {
+ return hashtable.get(key);
+ }
+
+ public Object get(Object key) throws CacheException {
+ return hashtable.get(key);
+ }
+
+ public void update(Object key, Object value) throws CacheException {
+ put(key, value);
+ }
+
+ public void put(Object key, Object value) throws CacheException {
+ hashtable.put(key, value);
+ }
+
+ public void remove(Object key) throws CacheException {
+ hashtable.remove(key);
+ }
+
+ public void clear() throws CacheException {
+ hashtable.clear();
+ }
+
+ public void destroy() throws CacheException {
+
+ }
+
+ public void lock(Object key) throws CacheException {
+ // local cache, so we use synchronization
+ }
+
+ public void unlock(Object key) throws CacheException {
+ // local cache, so we use synchronization
+ }
+
+ public long nextTimestamp() {
+ return Timestamper.next();
+ }
+
+ public int getTimeout() {
+ return Timestamper.ONE_MS * 60000; //ie. 60 seconds
+ }
+
+ public long getSizeInMemory() {
+ return -1;
+ }
+
+ public long getElementCountInMemory() {
+ return hashtable.size();
+ }
+
+ public long getElementCountOnDisk() {
+ return 0;
+ }
+
+ public Map toMap() {
+ return Collections.unmodifiableMap(hashtable);
+ }
+
+ public String toString() {
+ return "HashtableCache(" + regionName + ')';
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,42 +0,0 @@
-//$Id: HashtableCacheProvider.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.cache;
-
-import java.util.Properties;
-
-/**
- * A simple in-memory Hashtable-based cache impl.
- *
- * @author Gavin King
- */
-public class HashtableCacheProvider implements CacheProvider {
-
- public Cache buildCache(String regionName, Properties properties) throws CacheException {
- return new HashtableCache( regionName );
- }
-
- public long nextTimestamp() {
- return Timestamper.next();
- }
-
- /**
- * Callback to perform any necessary initialization of the underlying cache implementation
- * during SessionFactory construction.
- *
- * @param properties current configuration settings.
- */
- public void start(Properties properties) throws CacheException {
- }
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache implementation
- * during SessionFactory.close().
- */
- public void stop() {
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- return false;
- }
-
-}
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/HashtableCacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,65 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Properties;
+
+/**
+ * A simple in-memory Hashtable-based cache impl.
+ *
+ * @author Gavin King
+ */
+public class HashtableCacheProvider implements CacheProvider {
+
+ public Cache buildCache(String regionName, Properties properties) throws CacheException {
+ return new HashtableCache( regionName );
+ }
+
+ public long nextTimestamp() {
+ return Timestamper.next();
+ }
+
+ /**
+ * Callback to perform any necessary initialization of the underlying cache implementation
+ * during SessionFactory construction.
+ *
+ * @param properties current configuration settings.
+ */
+ public void start(Properties properties) throws CacheException {
+ }
+
+ /**
+ * Callback to perform any necessary cleanup of the underlying cache implementation
+ * during SessionFactory.close().
+ */
+ public void stop() {
+ }
+
+ public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+}
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/NoCacheProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,58 +0,0 @@
-// $Id: NoCacheProvider.java 6433 2005-04-15 18:20:03Z steveebersole $
-package org.hibernate.cache;
-
-import java.util.Properties;
-
-/**
- * Implementation of NoCacheProvider.
- *
- * @author Steve Ebersole
- */
-public class NoCacheProvider implements CacheProvider {
- /**
- * Configure the cache
- *
- * @param regionName the name of the cache region
- * @param properties configuration settings
- *
- * @throws CacheException
- */
- public Cache buildCache(String regionName, Properties properties) throws CacheException {
- throw new NoCachingEnabledException();
- }
-
- /**
- * Generate a timestamp
- */
- public long nextTimestamp() {
- // This, is used by SessionFactoryImpl to hand to the generated SessionImpl;
- // was the only reason I could see that we cannot just use null as
- // Settings.cacheProvider
- return System.currentTimeMillis() / 100;
- }
-
- /**
- * Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory
- * construction.
- *
- * @param properties current configuration settings.
- */
- public void start(Properties properties) throws CacheException {
- // this is called by SessionFactory irregardless; we just disregard here;
- // could also add a check to SessionFactory to only conditionally call start
- }
-
- /**
- * Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().
- */
- public void stop() {
- // this is called by SessionFactory irregardless; we just disregard here;
- // could also add a check to SessionFactory to only conditionally call stop
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- // this is called from SettingsFactory irregardless; trivial to simply disregard
- return false;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/NoCacheProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCacheProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Properties;
+
+/**
+ * Implementation of NoCacheProvider.
+ *
+ * @author Steve Ebersole
+ */
+public class NoCacheProvider implements CacheProvider {
+ /**
+ * Configure the cache
+ *
+ * @param regionName the name of the cache region
+ * @param properties configuration settings
+ *
+ * @throws CacheException
+ */
+ public Cache buildCache(String regionName, Properties properties) throws CacheException {
+ throw new NoCachingEnabledException();
+ }
+
+ /**
+ * Generate a timestamp
+ */
+ public long nextTimestamp() {
+ // This, is used by SessionFactoryImpl to hand to the generated SessionImpl;
+ // was the only reason I could see that we cannot just use null as
+ // Settings.cacheProvider
+ return System.currentTimeMillis() / 100;
+ }
+
+ /**
+ * Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory
+ * construction.
+ *
+ * @param properties current configuration settings.
+ */
+ public void start(Properties properties) throws CacheException {
+ // this is called by SessionFactory irregardless; we just disregard here;
+ // could also add a check to SessionFactory to only conditionally call start
+ }
+
+ /**
+ * Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().
+ */
+ public void stop() {
+ // this is called by SessionFactory irregardless; we just disregard here;
+ // could also add a check to SessionFactory to only conditionally call stop
+ }
+
+ public boolean isMinimalPutsEnabledByDefault() {
+ // this is called from SettingsFactory irregardless; trivial to simply disregard
+ return false;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,20 +0,0 @@
-// $Id: NoCachingEnabledException.java 6433 2005-04-15 18:20:03Z steveebersole $
-package org.hibernate.cache;
-
-import org.hibernate.cfg.Environment;
-
-/**
- * Implementation of NoCachingEnabledException.
- *
- * @author Steve Ebersole
- */
-public class NoCachingEnabledException extends CacheException {
- private static final String MSG =
- "Second-level cache is not enabled for usage [" +
- Environment.USE_SECOND_LEVEL_CACHE +
- " | " + Environment.USE_QUERY_CACHE + "]";
-
- public NoCachingEnabledException() {
- super( MSG );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NoCachingEnabledException.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import org.hibernate.cfg.Environment;
+
+/**
+ * Implementation of NoCachingEnabledException.
+ *
+ * @author Steve Ebersole
+ */
+public class NoCachingEnabledException extends CacheException {
+ private static final String MSG =
+ "Second-level cache is not enabled for usage [" +
+ Environment.USE_SECOND_LEVEL_CACHE +
+ " | " + Environment.USE_QUERY_CACHE + "]";
+
+ public NoCachingEnabledException() {
+ super( MSG );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,172 +0,0 @@
-//$Id: NonstrictReadWriteCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.Comparator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- * Caches data that is sometimes updated without ever locking the cache.
- * If concurrent access to an item is possible, this concurrency strategy
- * makes no guarantee that the item returned from the cache is the latest
- * version available in the database. Configure your cache timeout accordingly!
- * This is an "asynchronous" concurrency strategy.
- *
- * @author Gavin King
- * @see ReadWriteCache for a much stricter algorithm
- */
-public class NonstrictReadWriteCache implements CacheConcurrencyStrategy {
-
- private Cache cache;
-
- private static final Logger log = LoggerFactory.getLogger( NonstrictReadWriteCache.class );
-
- public NonstrictReadWriteCache() {
- }
-
- public void setCache(Cache cache) {
- this.cache = cache;
- }
-
- public Cache getCache() {
- return cache;
- }
-
- /**
- * Get the most recent version, if available.
- */
- public Object get(Object key, long txTimestamp) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Cache lookup: " + key );
- }
-
- Object result = cache.get( key );
- if ( result != null ) {
- log.debug( "Cache hit" );
- }
- else {
- log.debug( "Cache miss" );
- }
- return result;
- }
-
- /**
- * Add an item to the cache.
- */
- public boolean put(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- Comparator versionComparator,
- boolean minimalPut) throws CacheException {
- if ( minimalPut && cache.get( key ) != null ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "item already cached: " + key );
- }
- return false;
- }
- if ( log.isDebugEnabled() ) {
- log.debug( "Caching: " + key );
- }
-
- cache.put( key, value );
- return true;
-
- }
-
- /**
- * Do nothing.
- *
- * @return null, no lock
- */
- public SoftLock lock(Object key, Object version) throws CacheException {
- return null;
- }
-
- public void remove(Object key) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Removing: " + key );
- }
- cache.remove( key );
- }
-
- public void clear() throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Clearing" );
- }
- cache.clear();
- }
-
- public void destroy() {
- try {
- cache.destroy();
- }
- catch ( Exception e ) {
- log.warn( "could not destroy cache", e );
- }
- }
-
- /**
- * Invalidate the item
- */
- public void evict(Object key) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Invalidating: " + key );
- }
-
- cache.remove( key );
- }
-
- /**
- * Invalidate the item
- */
- public boolean insert(Object key, Object value, Object currentVersion) {
- return false;
- }
-
- /**
- * Do nothing.
- */
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) {
- evict( key );
- return false;
- }
-
- /**
- * Invalidate the item (again, for safety).
- */
- public void release(Object key, SoftLock lock) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Invalidating (again): " + key );
- }
-
- cache.remove( key );
- }
-
- /**
- * Invalidate the item (again, for safety).
- */
- public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws CacheException {
- release( key, lock );
- return false;
- }
-
- /**
- * Do nothing.
- */
- public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
- return false;
- }
-
- public String getRegionName() {
- return cache.getRegionName();
- }
-
- public String toString() {
- return cache + "(nonstrict-read-write)";
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/NonstrictReadWriteCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,195 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Comparator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.access.SoftLock;
+
+/**
+ * Caches data that is sometimes updated without ever locking the cache.
+ * If concurrent access to an item is possible, this concurrency strategy
+ * makes no guarantee that the item returned from the cache is the latest
+ * version available in the database. Configure your cache timeout accordingly!
+ * This is an "asynchronous" concurrency strategy.
+ *
+ * @author Gavin King
+ * @see ReadWriteCache for a much stricter algorithm
+ */
+public class NonstrictReadWriteCache implements CacheConcurrencyStrategy {
+
+ private Cache cache;
+
+ private static final Logger log = LoggerFactory.getLogger( NonstrictReadWriteCache.class );
+
+ public NonstrictReadWriteCache() {
+ }
+
+ public void setCache(Cache cache) {
+ this.cache = cache;
+ }
+
+ public Cache getCache() {
+ return cache;
+ }
+
+ /**
+ * Get the most recent version, if available.
+ */
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Cache lookup: " + key );
+ }
+
+ Object result = cache.get( key );
+ if ( result != null ) {
+ log.debug( "Cache hit" );
+ }
+ else {
+ log.debug( "Cache miss" );
+ }
+ return result;
+ }
+
+ /**
+ * Add an item to the cache.
+ */
+ public boolean put(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ Comparator versionComparator,
+ boolean minimalPut) throws CacheException {
+ if ( minimalPut && cache.get( key ) != null ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "item already cached: " + key );
+ }
+ return false;
+ }
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Caching: " + key );
+ }
+
+ cache.put( key, value );
+ return true;
+
+ }
+
+ /**
+ * Do nothing.
+ *
+ * @return null, no lock
+ */
+ public SoftLock lock(Object key, Object version) throws CacheException {
+ return null;
+ }
+
+ public void remove(Object key) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Removing: " + key );
+ }
+ cache.remove( key );
+ }
+
+ public void clear() throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Clearing" );
+ }
+ cache.clear();
+ }
+
+ public void destroy() {
+ try {
+ cache.destroy();
+ }
+ catch ( Exception e ) {
+ log.warn( "could not destroy cache", e );
+ }
+ }
+
+ /**
+ * Invalidate the item
+ */
+ public void evict(Object key) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Invalidating: " + key );
+ }
+
+ cache.remove( key );
+ }
+
+ /**
+ * Invalidate the item
+ */
+ public boolean insert(Object key, Object value, Object currentVersion) {
+ return false;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) {
+ evict( key );
+ return false;
+ }
+
+ /**
+ * Invalidate the item (again, for safety).
+ */
+ public void release(Object key, SoftLock lock) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Invalidating (again): " + key );
+ }
+
+ cache.remove( key );
+ }
+
+ /**
+ * Invalidate the item (again, for safety).
+ */
+ public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws CacheException {
+ release( key, lock );
+ return false;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
+ return false;
+ }
+
+ public String getRegionName() {
+ return cache.getRegionName();
+ }
+
+ public String toString() {
+ return cache + "(nonstrict-read-write)";
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/OptimisticCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,64 +0,0 @@
-package org.hibernate.cache;
-
-/**
- * A contract for transactional cache implementations which support
- * optimistic locking of items within the cache.
- * <p/>
- * The optimisitic locking capabilities are only utilized for
- * the entity cache regions.
- * <p/>
- * Unlike the methods on the {@link Cache} interface, all the methods
- * here will only ever be called from access scenarios where versioned
- * data is actually a possiblity (i.e., entity data). Be sure to consult
- * with {@link OptimisticCacheSource#isVersioned()} to determine whether
- * versioning is actually in effect.
- *
- * @author Steve Ebersole
- */
-public interface OptimisticCache extends Cache {
- /**
- * Indicates the "source" of the cached data. Currently this will
- * only ever represent an {@link org.hibernate.persister.entity.EntityPersister}.
- * <p/>
- * Made available to the cache so that it can access certain information
- * about versioning strategy.
- *
- * @param source The source.
- */
- public void setSource(OptimisticCacheSource source);
-
- /**
- * Called during {@link CacheConcurrencyStrategy#insert} processing for
- * transactional strategies. Indicates we have just performed an insert
- * into the DB and now need to cache that entity's data.
- *
- * @param key The cache key.
- * @param value The data to be cached.
- * @param currentVersion The entity's version; or null if not versioned.
- */
- public void writeInsert(Object key, Object value, Object currentVersion);
-
- /**
- * Called during {@link CacheConcurrencyStrategy#update} processing for
- * transactional strategies. Indicates we have just performed an update
- * against the DB and now need to cache the updated state.
- *
- * @param key The cache key.
- * @param value The data to be cached.
- * @param currentVersion The entity's current version
- * @param previousVersion The entity's previous version (before the update);
- * or null if not versioned.
- */
- public void writeUpdate(Object key, Object value, Object currentVersion, Object previousVersion);
-
- /**
- * Called during {@link CacheConcurrencyStrategy#put} processing for
- * transactional strategies. Indicates we have just loaded an entity's
- * state from the database and need it cached.
- *
- * @param key The cache key.
- * @param value The data to be cached.
- * @param currentVersion The entity's version; or null if not versioned.
- */
- public void writeLoad(Object key, Object value, Object currentVersion);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/OptimisticCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,88 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * A contract for transactional cache implementations which support
+ * optimistic locking of items within the cache.
+ * <p/>
+ * The optimisitic locking capabilities are only utilized for
+ * the entity cache regions.
+ * <p/>
+ * Unlike the methods on the {@link Cache} interface, all the methods
+ * here will only ever be called from access scenarios where versioned
+ * data is actually a possiblity (i.e., entity data). Be sure to consult
+ * with {@link OptimisticCacheSource#isVersioned()} to determine whether
+ * versioning is actually in effect.
+ *
+ * @author Steve Ebersole
+ */
+public interface OptimisticCache extends Cache {
+ /**
+ * Indicates the "source" of the cached data. Currently this will
+ * only ever represent an {@link org.hibernate.persister.entity.EntityPersister}.
+ * <p/>
+ * Made available to the cache so that it can access certain information
+ * about versioning strategy.
+ *
+ * @param source The source.
+ */
+ public void setSource(OptimisticCacheSource source);
+
+ /**
+ * Called during {@link CacheConcurrencyStrategy#insert} processing for
+ * transactional strategies. Indicates we have just performed an insert
+ * into the DB and now need to cache that entity's data.
+ *
+ * @param key The cache key.
+ * @param value The data to be cached.
+ * @param currentVersion The entity's version; or null if not versioned.
+ */
+ public void writeInsert(Object key, Object value, Object currentVersion);
+
+ /**
+ * Called during {@link CacheConcurrencyStrategy#update} processing for
+ * transactional strategies. Indicates we have just performed an update
+ * against the DB and now need to cache the updated state.
+ *
+ * @param key The cache key.
+ * @param value The data to be cached.
+ * @param currentVersion The entity's current version
+ * @param previousVersion The entity's previous version (before the update);
+ * or null if not versioned.
+ */
+ public void writeUpdate(Object key, Object value, Object currentVersion, Object previousVersion);
+
+ /**
+ * Called during {@link CacheConcurrencyStrategy#put} processing for
+ * transactional strategies. Indicates we have just loaded an entity's
+ * state from the database and need it cached.
+ *
+ * @param key The cache key.
+ * @param value The data to be cached.
+ * @param currentVersion The entity's version; or null if not versioned.
+ */
+ public void writeLoad(Object key, Object value, Object currentVersion);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,32 +0,0 @@
-package org.hibernate.cache;
-
-import java.util.Comparator;
-
-/**
- * Contract for sources of optimistically lockable data sent to the second level
- * cache.
- * <p/>
- * Note currently {@link org.hibernate.persister.entity.EntityPersister}s are
- * the only viable source.
- *
- * @author Steve Ebersole
- */
-public interface OptimisticCacheSource {
- /**
- * Is the data to be cached considered versioned?
- * <p/>
- * If true, it is illegal for {@link #getVersionComparator} to return
- * null.
- *
- * @return True if the data is versioned; false otherwise.
- */
- public boolean isVersioned();
-
- /**
- * Get the comparator used to compare two different version values.
- * <p/>
- * May return null <b>if</b> {@link #isVersioned()} returns false.
- * @return
- */
- public Comparator getVersionComparator();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/OptimisticCacheSource.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Comparator;
+
+/**
+ * Contract for sources of optimistically lockable data sent to the second level
+ * cache.
+ * <p/>
+ * Note currently {@link org.hibernate.persister.entity.EntityPersister}s are
+ * the only viable source.
+ *
+ * @author Steve Ebersole
+ */
+public interface OptimisticCacheSource {
+ /**
+ * Is the data to be cached considered versioned?
+ * <p/>
+ * If true, it is illegal for {@link #getVersionComparator} to return
+ * null.
+ *
+ * @return True if the data is versioned; false otherwise.
+ */
+ public boolean isVersioned();
+
+ /**
+ * Get the comparator used to compare two different version values.
+ * <p/>
+ * May return null <b>if</b> {@link #isVersioned()} returns false.
+ * @return
+ */
+ public Comparator getVersionComparator();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/QueryCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-//$Id: QueryCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Defines the contract for caches capable of storing query results. These
- * caches should only concern themselves with storing the matching result ids.
- * The transactional semantics are necessarily less strict than the semantics
- * of an item cache.
- *
- * @author Gavin King
- */
-public interface QueryCache {
-
- public void clear() throws CacheException;
-
- public boolean put(QueryKey key, Type[] returnTypes, List result, boolean isNaturalKeyLookup, SessionImplementor session) throws HibernateException;
-
- public List get(QueryKey key, Type[] returnTypes, boolean isNaturalKeyLookup, Set spaces, SessionImplementor session) throws HibernateException;
-
- public void destroy();
-
- public QueryResultsRegion getRegion();
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/QueryCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,54 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Defines the contract for caches capable of storing query results. These
+ * caches should only concern themselves with storing the matching result ids.
+ * The transactional semantics are necessarily less strict than the semantics
+ * of an item cache.
+ *
+ * @author Gavin King
+ */
+public interface QueryCache {
+
+ public void clear() throws CacheException;
+
+ public boolean put(QueryKey key, Type[] returnTypes, List result, boolean isNaturalKeyLookup, SessionImplementor session) throws HibernateException;
+
+ public List get(QueryKey key, Type[] returnTypes, boolean isNaturalKeyLookup, Set spaces, SessionImplementor session) throws HibernateException;
+
+ public void destroy();
+
+ public QueryResultsRegion getRegion();
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,24 +0,0 @@
-// $Id: QueryCacheFactory.java 4690 2004-10-26 09:35:46Z oneovthafew $
-package org.hibernate.cache;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Settings;
-
-import java.util.Properties;
-
-/**
- * Defines a factory for query cache instances. These factories are responsible for
- * creating individual QueryCache instances.
- *
- * @author Steve Ebersole
- */
-public interface QueryCacheFactory {
-
- public QueryCache getQueryCache(
- String regionName,
- UpdateTimestampsCache updateTimestampsCache,
- Settings settings,
- Properties props)
- throws HibernateException;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryCacheFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Settings;
+
+import java.util.Properties;
+
+/**
+ * Defines a factory for query cache instances. These factories are responsible for
+ * creating individual QueryCache instances.
+ *
+ * @author Steve Ebersole
+ */
+public interface QueryCacheFactory {
+
+ public QueryCache getQueryCache(
+ String regionName,
+ UpdateTimestampsCache updateTimestampsCache,
+ Settings settings,
+ Properties props)
+ throws HibernateException;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/QueryKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,118 +0,0 @@
-//$Id: QueryKey.java 9636 2006-03-16 14:14:48Z max.andersen(a)jboss.com $
-package org.hibernate.cache;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.EntityMode;
-import org.hibernate.engine.QueryParameters;
-import org.hibernate.engine.RowSelection;
-import org.hibernate.transform.ResultTransformer;
-import org.hibernate.type.Type;
-import org.hibernate.util.EqualsHelper;
-
-/**
- * A key that identifies a particular query with bound parameter values
- * @author Gavin King
- */
-public class QueryKey implements Serializable {
- private final String sqlQueryString;
- private final Type[] types;
- private final Object[] values;
- private final Integer firstRow;
- private final Integer maxRows;
- private final Map namedParameters;
- private final EntityMode entityMode;
- private final Set filters;
- private final int hashCode;
-
- // the user provided resulttransformer, not the one used with "select new". Here to avoid mangling transformed/non-transformed results.
- private final ResultTransformer customTransformer;
-
- public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
- this.sqlQueryString = queryString;
- this.types = queryParameters.getPositionalParameterTypes();
- this.values = queryParameters.getPositionalParameterValues();
- RowSelection selection = queryParameters.getRowSelection();
- if (selection!=null) {
- firstRow = selection.getFirstRow();
- maxRows = selection.getMaxRows();
- }
- else {
- firstRow = null;
- maxRows = null;
- }
- this.namedParameters = queryParameters.getNamedParameters();
- this.entityMode = entityMode;
- this.filters = filters;
- this.customTransformer = queryParameters.getResultTransformer();
- this.hashCode = getHashCode();
- }
-
- public boolean equals(Object other) {
- if (!(other instanceof QueryKey)) return false;
- QueryKey that = (QueryKey) other;
- if ( !sqlQueryString.equals(that.sqlQueryString) ) return false;
- if ( !EqualsHelper.equals(firstRow, that.firstRow) || !EqualsHelper.equals(maxRows, that.maxRows) ) return false;
- if ( !EqualsHelper.equals(customTransformer, that.customTransformer) ) return false;
- if (types==null) {
- if (that.types!=null) return false;
- }
- else {
- if (that.types==null) return false;
- if ( types.length!=that.types.length ) return false;
- for ( int i=0; i<types.length; i++ ) {
- if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) return false;
- if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) return false;
- }
- }
- if ( !EqualsHelper.equals(filters, that.filters) ) return false;
- if ( !EqualsHelper.equals(namedParameters, that.namedParameters) ) return false;
- return true;
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- private int getHashCode() {
- int result = 13;
- result = 37 * result + ( firstRow==null ? 0 : firstRow.hashCode() );
- result = 37 * result + ( maxRows==null ? 0 : maxRows.hashCode() );
- for ( int i=0; i<values.length; i++ ) {
- result = 37 * result + ( values[i]==null ? 0 : types[i].getHashCode( values[i], entityMode ) );
- }
- result = 37 * result + ( namedParameters==null ? 0 : namedParameters.hashCode() );
- result = 37 * result + ( filters==null ? 0 : filters.hashCode() );
- result = 37 * result + ( customTransformer==null ? 0 : customTransformer.hashCode() );
- result = 37 * result + sqlQueryString.hashCode();
- return result;
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer()
- .append("sql: ")
- .append(sqlQueryString);
- if (values!=null) {
- buf.append("; parameters: ");
- for (int i=0; i<values.length; i++) {
- buf.append( values[i] )
- .append(", ");
- }
- }
- if (namedParameters!=null) {
- buf.append("; named parameters: ")
- .append(namedParameters);
- }
- if (filters!=null) {
- buf.append("; filters: ")
- .append(filters);
- }
- if (firstRow!=null) buf.append("; first row: ").append(firstRow);
- if (maxRows!=null) buf.append("; max rows: ").append(maxRows);
- if (customTransformer!=null) buf.append("; transformer: ").append(customTransformer);
- return buf.toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/QueryKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,141 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.EntityMode;
+import org.hibernate.engine.QueryParameters;
+import org.hibernate.engine.RowSelection;
+import org.hibernate.transform.ResultTransformer;
+import org.hibernate.type.Type;
+import org.hibernate.util.EqualsHelper;
+
+/**
+ * A key that identifies a particular query with bound parameter values
+ * @author Gavin King
+ */
+public class QueryKey implements Serializable {
+ private final String sqlQueryString;
+ private final Type[] types;
+ private final Object[] values;
+ private final Integer firstRow;
+ private final Integer maxRows;
+ private final Map namedParameters;
+ private final EntityMode entityMode;
+ private final Set filters;
+ private final int hashCode;
+
+ // the user provided resulttransformer, not the one used with "select new". Here to avoid mangling transformed/non-transformed results.
+ private final ResultTransformer customTransformer;
+
+ public QueryKey(String queryString, QueryParameters queryParameters, Set filters, EntityMode entityMode) {
+ this.sqlQueryString = queryString;
+ this.types = queryParameters.getPositionalParameterTypes();
+ this.values = queryParameters.getPositionalParameterValues();
+ RowSelection selection = queryParameters.getRowSelection();
+ if (selection!=null) {
+ firstRow = selection.getFirstRow();
+ maxRows = selection.getMaxRows();
+ }
+ else {
+ firstRow = null;
+ maxRows = null;
+ }
+ this.namedParameters = queryParameters.getNamedParameters();
+ this.entityMode = entityMode;
+ this.filters = filters;
+ this.customTransformer = queryParameters.getResultTransformer();
+ this.hashCode = getHashCode();
+ }
+
+ public boolean equals(Object other) {
+ if (!(other instanceof QueryKey)) return false;
+ QueryKey that = (QueryKey) other;
+ if ( !sqlQueryString.equals(that.sqlQueryString) ) return false;
+ if ( !EqualsHelper.equals(firstRow, that.firstRow) || !EqualsHelper.equals(maxRows, that.maxRows) ) return false;
+ if ( !EqualsHelper.equals(customTransformer, that.customTransformer) ) return false;
+ if (types==null) {
+ if (that.types!=null) return false;
+ }
+ else {
+ if (that.types==null) return false;
+ if ( types.length!=that.types.length ) return false;
+ for ( int i=0; i<types.length; i++ ) {
+ if ( types[i].getReturnedClass() != that.types[i].getReturnedClass() ) return false;
+ if ( !types[i].isEqual( values[i], that.values[i], entityMode ) ) return false;
+ }
+ }
+ if ( !EqualsHelper.equals(filters, that.filters) ) return false;
+ if ( !EqualsHelper.equals(namedParameters, that.namedParameters) ) return false;
+ return true;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ private int getHashCode() {
+ int result = 13;
+ result = 37 * result + ( firstRow==null ? 0 : firstRow.hashCode() );
+ result = 37 * result + ( maxRows==null ? 0 : maxRows.hashCode() );
+ for ( int i=0; i<values.length; i++ ) {
+ result = 37 * result + ( values[i]==null ? 0 : types[i].getHashCode( values[i], entityMode ) );
+ }
+ result = 37 * result + ( namedParameters==null ? 0 : namedParameters.hashCode() );
+ result = 37 * result + ( filters==null ? 0 : filters.hashCode() );
+ result = 37 * result + ( customTransformer==null ? 0 : customTransformer.hashCode() );
+ result = 37 * result + sqlQueryString.hashCode();
+ return result;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer()
+ .append("sql: ")
+ .append(sqlQueryString);
+ if (values!=null) {
+ buf.append("; parameters: ");
+ for (int i=0; i<values.length; i++) {
+ buf.append( values[i] )
+ .append(", ");
+ }
+ }
+ if (namedParameters!=null) {
+ buf.append("; named parameters: ")
+ .append(namedParameters);
+ }
+ if (filters!=null) {
+ buf.append("; filters: ")
+ .append(filters);
+ }
+ if (firstRow!=null) buf.append("; first row: ").append(firstRow);
+ if (maxRows!=null) buf.append("; max rows: ").append(maxRows);
+ if (customTransformer!=null) buf.append("; transformer: ").append(customTransformer);
+ return buf.toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-package org.hibernate.cache;
-
-/**
- * Defines the contract for a cache region which will specifically be used to
- * store query results.
- *
- * @author Steve Ebersole
- */
-public interface QueryResultsRegion extends GeneralDataRegion {
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/QueryResultsRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * Defines the contract for a cache region which will specifically be used to
+ * store query results.
+ *
+ * @author Steve Ebersole
+ */
+public interface QueryResultsRegion extends GeneralDataRegion {
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,139 +0,0 @@
-//$Id: ReadOnlyCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.Comparator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- * Caches data that is never updated.
- * @see CacheConcurrencyStrategy
- */
-public class ReadOnlyCache implements CacheConcurrencyStrategy {
-
- private Cache cache;
- private static final Logger log = LoggerFactory.getLogger(ReadOnlyCache.class);
-
- public ReadOnlyCache() {}
-
- public void setCache(Cache cache) {
- this.cache=cache;
- }
-
- public Cache getCache() {
- return cache;
- }
-
- public String getRegionName() {
- return cache.getRegionName();
- }
-
- public synchronized Object get(Object key, long timestamp) throws CacheException {
- Object result = cache.get(key);
- if ( result!=null && log.isDebugEnabled() ) log.debug("Cache hit: " + key);
- return result;
- }
-
- /**
- * Unsupported!
- */
- public SoftLock lock(Object key, Object version) {
- log.error("Application attempted to edit read only item: " + key);
- throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- public synchronized boolean put(
- Object key,
- Object value,
- long timestamp,
- Object version,
- Comparator versionComparator,
- boolean minimalPut)
- throws CacheException {
- if ( minimalPut && cache.get(key)!=null ) {
- if ( log.isDebugEnabled() ) log.debug("item already cached: " + key);
- return false;
- }
- if ( log.isDebugEnabled() ) log.debug("Caching: " + key);
- cache.put(key, value);
- return true;
- }
-
- /**
- * Unsupported!
- */
- public void release(Object key, SoftLock lock) {
- log.error("Application attempted to edit read only item: " + key);
- //throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- public void clear() throws CacheException {
- cache.clear();
- }
-
- public void remove(Object key) throws CacheException {
- cache.remove(key);
- }
-
- public void destroy() {
- try {
- cache.destroy();
- }
- catch (Exception e) {
- log.warn("could not destroy cache", e);
- }
- }
-
- /**
- * Unsupported!
- */
- public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws CacheException {
- log.error("Application attempted to edit read only item: " + key);
- throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- /**
- * Do nothing.
- */
- public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
- if ( log.isDebugEnabled() ) log.debug("Caching after insert: " + key);
- cache.update(key, value);
- return true;
- }
-
- /**
- * Do nothing.
- */
- public void evict(Object key) throws CacheException {
- // noop
- }
-
- /**
- * Do nothing.
- */
- public boolean insert(Object key, Object value, Object currentVersion) {
- return false;
- }
-
- /**
- * Unsupported!
- */
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) {
- log.error("Application attempted to edit read only item: " + key);
- throw new UnsupportedOperationException("Can't write to a readonly object");
- }
-
- public String toString() {
- return cache + "(read-only)";
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadOnlyCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,162 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Comparator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.access.SoftLock;
+
+/**
+ * Caches data that is never updated.
+ * @see CacheConcurrencyStrategy
+ */
+public class ReadOnlyCache implements CacheConcurrencyStrategy {
+
+ private Cache cache;
+ private static final Logger log = LoggerFactory.getLogger(ReadOnlyCache.class);
+
+ public ReadOnlyCache() {}
+
+ public void setCache(Cache cache) {
+ this.cache=cache;
+ }
+
+ public Cache getCache() {
+ return cache;
+ }
+
+ public String getRegionName() {
+ return cache.getRegionName();
+ }
+
+ public synchronized Object get(Object key, long timestamp) throws CacheException {
+ Object result = cache.get(key);
+ if ( result!=null && log.isDebugEnabled() ) log.debug("Cache hit: " + key);
+ return result;
+ }
+
+ /**
+ * Unsupported!
+ */
+ public SoftLock lock(Object key, Object version) {
+ log.error("Application attempted to edit read only item: " + key);
+ throw new UnsupportedOperationException("Can't write to a readonly object");
+ }
+
+ public synchronized boolean put(
+ Object key,
+ Object value,
+ long timestamp,
+ Object version,
+ Comparator versionComparator,
+ boolean minimalPut)
+ throws CacheException {
+ if ( minimalPut && cache.get(key)!=null ) {
+ if ( log.isDebugEnabled() ) log.debug("item already cached: " + key);
+ return false;
+ }
+ if ( log.isDebugEnabled() ) log.debug("Caching: " + key);
+ cache.put(key, value);
+ return true;
+ }
+
+ /**
+ * Unsupported!
+ */
+ public void release(Object key, SoftLock lock) {
+ log.error("Application attempted to edit read only item: " + key);
+ //throw new UnsupportedOperationException("Can't write to a readonly object");
+ }
+
+ public void clear() throws CacheException {
+ cache.clear();
+ }
+
+ public void remove(Object key) throws CacheException {
+ cache.remove(key);
+ }
+
+ public void destroy() {
+ try {
+ cache.destroy();
+ }
+ catch (Exception e) {
+ log.warn("could not destroy cache", e);
+ }
+ }
+
+ /**
+ * Unsupported!
+ */
+ public boolean afterUpdate(Object key, Object value, Object version, SoftLock lock) throws CacheException {
+ log.error("Application attempted to edit read only item: " + key);
+ throw new UnsupportedOperationException("Can't write to a readonly object");
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
+ if ( log.isDebugEnabled() ) log.debug("Caching after insert: " + key);
+ cache.update(key, value);
+ return true;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public void evict(Object key) throws CacheException {
+ // noop
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean insert(Object key, Object value, Object currentVersion) {
+ return false;
+ }
+
+ /**
+ * Unsupported!
+ */
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) {
+ log.error("Application attempted to edit read only item: " + key);
+ throw new UnsupportedOperationException("Can't write to a readonly object");
+ }
+
+ public String toString() {
+ return cache + "(read-only)";
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/ReadWriteCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,508 +0,0 @@
-//$Id: ReadWriteCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- * Caches data that is sometimes updated while maintaining the semantics of
- * "read committed" isolation level. If the database is set to "repeatable
- * read", this concurrency strategy <em>almost</em> maintains the semantics.
- * Repeatable read isolation is compromised in the case of concurrent writes.
- * This is an "asynchronous" concurrency strategy.<br>
- * <br>
- * If this strategy is used in a cluster, the underlying cache implementation
- * must support distributed hard locks (which are held only momentarily). This
- * strategy also assumes that the underlying cache implementation does not do
- * asynchronous replication and that state has been fully replicated as soon
- * as the lock is released.
- *
- * @see NonstrictReadWriteCache for a faster algorithm
- * @see CacheConcurrencyStrategy
- */
-public class ReadWriteCache implements CacheConcurrencyStrategy {
-
- private static final Logger log = LoggerFactory.getLogger(ReadWriteCache.class);
-
- private Cache cache;
- private int nextLockId;
-
- public ReadWriteCache() {}
-
- public void setCache(Cache cache) {
- this.cache=cache;
- }
-
- public Cache getCache() {
- return cache;
- }
-
- public String getRegionName() {
- return cache.getRegionName();
- }
-
- /**
- * Generate an id for a new lock. Uniqueness per cache instance is very
- * desirable but not absolutely critical. Must be called from one of the
- * synchronized methods of this class.
- */
- private int nextLockId() {
- if (nextLockId==Integer.MAX_VALUE) nextLockId = Integer.MIN_VALUE;
- return nextLockId++;
- }
-
- /**
- * Do not return an item whose timestamp is later than the current
- * transaction timestamp. (Otherwise we might compromise repeatable
- * read unnecessarily.) Do not return an item which is soft-locked.
- * Always go straight to the database instead.<br>
- * <br>
- * Note that since reading an item from that cache does not actually
- * go to the database, it is possible to see a kind of phantom read
- * due to the underlying row being updated after we have read it
- * from the cache. This would not be possible in a lock-based
- * implementation of repeatable read isolation. It is also possible
- * to overwrite changes made and committed by another transaction
- * after the current transaction read the item from the cache. This
- * problem would be caught by the update-time version-checking, if
- * the data is versioned or timestamped.
- */
- public synchronized Object get(Object key, long txTimestamp) throws CacheException {
-
- if ( log.isTraceEnabled() ) log.trace("Cache lookup: " + key);
-
- /*try {
- cache.lock(key);*/
-
- Lockable lockable = (Lockable) cache.get(key);
-
- boolean gettable = lockable!=null && lockable.isGettable(txTimestamp);
-
- if (gettable) {
- if ( log.isTraceEnabled() ) log.trace("Cache hit: " + key);
- return ( (Item) lockable ).getValue();
- }
- else {
- if ( log.isTraceEnabled() ) {
- if (lockable==null) {
- log.trace("Cache miss: " + key);
- }
- else {
- log.trace("Cached item was locked: " + key);
- }
- }
- return null;
- }
- /*}
- finally {
- cache.unlock(key);
- }*/
- }
-
- /**
- * Stop any other transactions reading or writing this item to/from
- * the cache. Send them straight to the database instead. (The lock
- * does time out eventually.) This implementation tracks concurrent
- * locks of transactions which simultaneously attempt to write to an
- * item.
- */
- public synchronized SoftLock lock(Object key, Object version) throws CacheException {
- if ( log.isTraceEnabled() ) log.trace("Invalidating: " + key);
-
- try {
- cache.lock(key);
-
- Lockable lockable = (Lockable) cache.get(key);
- long timeout = cache.nextTimestamp() + cache.getTimeout();
- final Lock lock = (lockable==null) ?
- new Lock( timeout, nextLockId(), version ) :
- lockable.lock( timeout, nextLockId() );
- cache.update(key, lock);
- return lock;
- }
- finally {
- cache.unlock(key);
- }
-
- }
-
- /**
- * Do not add an item to the cache unless the current transaction
- * timestamp is later than the timestamp at which the item was
- * invalidated. (Otherwise, a stale item might be re-added if the
- * database is operating in repeatable read isolation mode.)
- * For versioned data, don't add the item unless it is the later
- * version.
- */
- public synchronized boolean put(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- Comparator versionComparator,
- boolean minimalPut)
- throws CacheException {
- if ( log.isTraceEnabled() ) log.trace("Caching: " + key);
-
- try {
- cache.lock(key);
-
- Lockable lockable = (Lockable) cache.get(key);
-
- boolean puttable = lockable==null ||
- lockable.isPuttable(txTimestamp, version, versionComparator);
-
- if (puttable) {
- cache.put( key, new Item( value, version, cache.nextTimestamp() ) );
- if ( log.isTraceEnabled() ) log.trace("Cached: " + key);
- return true;
- }
- else {
- if ( log.isTraceEnabled() ) {
- if ( lockable.isLock() ) {
- log.trace("Item was locked: " + key);
- }
- else {
- log.trace("Item was already cached: " + key);
- }
- }
- return false;
- }
- }
- finally {
- cache.unlock(key);
- }
- }
-
- /**
- * decrement a lock and put it back in the cache
- */
- private void decrementLock(Object key, Lock lock) throws CacheException {
- //decrement the lock
- lock.unlock( cache.nextTimestamp() );
- cache.update(key, lock);
- }
-
- /**
- * Release the soft lock on the item. Other transactions may now
- * re-cache the item (assuming that no other transaction holds a
- * simultaneous lock).
- */
- public synchronized void release(Object key, SoftLock clientLock) throws CacheException {
- if ( log.isTraceEnabled() ) log.trace("Releasing: " + key);
-
- try {
- cache.lock(key);
-
- Lockable lockable = (Lockable) cache.get(key);
- if ( isUnlockable(clientLock, lockable) ) {
- decrementLock(key, (Lock) lockable);
- }
- else {
- handleLockExpiry(key);
- }
- }
- finally {
- cache.unlock(key);
- }
- }
-
- void handleLockExpiry(Object key) throws CacheException {
- log.warn("An item was expired by the cache while it was locked (increase your cache timeout): " + key);
- long ts = cache.nextTimestamp() + cache.getTimeout();
- // create new lock that times out immediately
- Lock lock = new Lock( ts, nextLockId(), null );
- lock.unlock(ts);
- cache.update(key, lock);
- }
-
- public void clear() throws CacheException {
- cache.clear();
- }
-
- public void remove(Object key) throws CacheException {
- cache.remove(key);
- }
-
- public void destroy() {
- try {
- cache.destroy();
- }
- catch (Exception e) {
- log.warn("could not destroy cache", e);
- }
- }
-
- /**
- * Re-cache the updated state, if and only if there there are
- * no other concurrent soft locks. Release our lock.
- */
- public synchronized boolean afterUpdate(Object key, Object value, Object version, SoftLock clientLock)
- throws CacheException {
-
- if ( log.isTraceEnabled() ) log.trace("Updating: " + key);
-
- try {
- cache.lock(key);
-
- Lockable lockable = (Lockable) cache.get(key);
- if ( isUnlockable(clientLock, lockable) ) {
- Lock lock = (Lock) lockable;
- if ( lock.wasLockedConcurrently() ) {
- // just decrement the lock, don't recache
- // (we don't know which transaction won)
- decrementLock(key, lock);
- return false;
- }
- else {
- //recache the updated state
- cache.update( key, new Item( value, version, cache.nextTimestamp() ) );
- if ( log.isTraceEnabled() ) log.trace("Updated: " + key);
- return true;
- }
- }
- else {
- handleLockExpiry(key);
- return false;
- }
-
- }
- finally {
- cache.unlock(key);
- }
- }
-
- /**
- * Add the new item to the cache, checking that no other transaction has
- * accessed the item.
- */
- public synchronized boolean afterInsert(Object key, Object value, Object version)
- throws CacheException {
-
- if ( log.isTraceEnabled() ) log.trace("Inserting: " + key);
- try {
- cache.lock(key);
-
- Lockable lockable = (Lockable) cache.get(key);
- if (lockable==null) {
- cache.update( key, new Item( value, version, cache.nextTimestamp() ) );
- if ( log.isTraceEnabled() ) log.trace("Inserted: " + key);
- return true;
- }
- else {
- return false;
- }
- }
- finally {
- cache.unlock(key);
- }
- }
-
- /**
- * Do nothing.
- */
- public void evict(Object key) throws CacheException {
- // noop
- }
-
- /**
- * Do nothing.
- */
- public boolean insert(Object key, Object value, Object currentVersion) {
- return false;
- }
-
- /**
- * Do nothing.
- */
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) {
- return false;
- }
-
- /**
- * Is the client's lock commensurate with the item in the cache?
- * If it is not, we know that the cache expired the original
- * lock.
- */
- private boolean isUnlockable(SoftLock clientLock, Lockable myLock)
- throws CacheException {
- //null clientLock is remotely possible but will never happen in practice
- return myLock!=null &&
- myLock.isLock() &&
- clientLock!=null &&
- ( (Lock) clientLock ).getId()==( (Lock) myLock ).getId();
- }
-
- public static interface Lockable {
- public Lock lock(long timeout, int id);
- public boolean isLock();
- public boolean isGettable(long txTimestamp);
- public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator);
- }
-
- /**
- * An item of cached data, timestamped with the time it was cached,.
- * @see ReadWriteCache
- */
- public static final class Item implements Serializable, Lockable {
-
- private final long freshTimestamp;
- private final Object value;
- private final Object version;
-
- public Item(Object value, Object version, long currentTimestamp) {
- this.value = value;
- this.version = version;
- freshTimestamp = currentTimestamp;
- }
- /**
- * The timestamp on the cached data
- */
- public long getFreshTimestamp() {
- return freshTimestamp;
- }
- /**
- * The actual cached data
- */
- public Object getValue() {
- return value;
- }
-
- /**
- * Lock the item
- */
- public Lock lock(long timeout, int id) {
- return new Lock(timeout, id, version);
- }
- /**
- * Not a lock!
- */
- public boolean isLock() {
- return false;
- }
- /**
- * Is this item visible to the timestamped
- * transaction?
- */
- public boolean isGettable(long txTimestamp) {
- return freshTimestamp < txTimestamp;
- }
-
- /**
- * Don't overwite already cached items
- */
- public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator) {
- // we really could refresh the item if it
- // is not a lock, but it might be slower
- //return freshTimestamp < txTimestamp
- return version!=null && comparator.compare(version, newVersion) < 0;
- }
-
- public String toString() {
- return "Item{version=" + version +
- ",freshTimestamp=" + freshTimestamp;
- }
- }
-
- /**
- * A soft lock which supports concurrent locking,
- * timestamped with the time it was released
- * @author Gavin King
- */
- public static final class Lock implements Serializable, Lockable, SoftLock {
- private long unlockTimestamp = -1;
- private int multiplicity = 1;
- private boolean concurrentLock = false;
- private long timeout;
- private final int id;
- private final Object version;
-
- public Lock(long timeout, int id, Object version) {
- this.timeout = timeout;
- this.id = id;
- this.version = version;
- }
-
- public long getUnlockTimestamp() {
- return unlockTimestamp;
- }
- /**
- * Increment the lock, setting the
- * new lock timeout
- */
- public Lock lock(long timeout, int id) {
- concurrentLock = true;
- multiplicity++;
- this.timeout = timeout;
- return this;
- }
- /**
- * Decrement the lock, setting the unlock
- * timestamp if now unlocked
- * @param currentTimestamp
- */
- public void unlock(long currentTimestamp) {
- if ( --multiplicity == 0 ) {
- unlockTimestamp = currentTimestamp;
- }
- }
-
- /**
- * Can the timestamped transaction re-cache this
- * locked item now?
- */
- public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator) {
- if (timeout < txTimestamp) return true;
- if (multiplicity>0) return false;
- return version==null ?
- unlockTimestamp < txTimestamp :
- comparator.compare(version, newVersion) < 0; //by requiring <, we rely on lock timeout in the case of an unsuccessful update!
- }
-
- /**
- * Was this lock held concurrently by multiple
- * transactions?
- */
- public boolean wasLockedConcurrently() {
- return concurrentLock;
- }
- /**
- * Yes, this is a lock
- */
- public boolean isLock() {
- return true;
- }
- /**
- * locks are not returned to the client!
- */
- public boolean isGettable(long txTimestamp) {
- return false;
- }
-
- public int getId() { return id; }
-
- public String toString() {
- return "Lock{id=" + id +
- ",version=" + version +
- ",multiplicity=" + multiplicity +
- ",unlockTimestamp=" + unlockTimestamp;
- }
-
- }
-
- public String toString() {
- return cache + "(read-write)";
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/ReadWriteCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/ReadWriteCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,531 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.access.SoftLock;
+
+/**
+ * Caches data that is sometimes updated while maintaining the semantics of
+ * "read committed" isolation level. If the database is set to "repeatable
+ * read", this concurrency strategy <em>almost</em> maintains the semantics.
+ * Repeatable read isolation is compromised in the case of concurrent writes.
+ * This is an "asynchronous" concurrency strategy.<br>
+ * <br>
+ * If this strategy is used in a cluster, the underlying cache implementation
+ * must support distributed hard locks (which are held only momentarily). This
+ * strategy also assumes that the underlying cache implementation does not do
+ * asynchronous replication and that state has been fully replicated as soon
+ * as the lock is released.
+ *
+ * @see NonstrictReadWriteCache for a faster algorithm
+ * @see CacheConcurrencyStrategy
+ */
+public class ReadWriteCache implements CacheConcurrencyStrategy {
+
+ private static final Logger log = LoggerFactory.getLogger(ReadWriteCache.class);
+
+ private Cache cache;
+ private int nextLockId;
+
+ public ReadWriteCache() {}
+
+ public void setCache(Cache cache) {
+ this.cache=cache;
+ }
+
+ public Cache getCache() {
+ return cache;
+ }
+
+ public String getRegionName() {
+ return cache.getRegionName();
+ }
+
+ /**
+ * Generate an id for a new lock. Uniqueness per cache instance is very
+ * desirable but not absolutely critical. Must be called from one of the
+ * synchronized methods of this class.
+ */
+ private int nextLockId() {
+ if (nextLockId==Integer.MAX_VALUE) nextLockId = Integer.MIN_VALUE;
+ return nextLockId++;
+ }
+
+ /**
+ * Do not return an item whose timestamp is later than the current
+ * transaction timestamp. (Otherwise we might compromise repeatable
+ * read unnecessarily.) Do not return an item which is soft-locked.
+ * Always go straight to the database instead.<br>
+ * <br>
+ * Note that since reading an item from that cache does not actually
+ * go to the database, it is possible to see a kind of phantom read
+ * due to the underlying row being updated after we have read it
+ * from the cache. This would not be possible in a lock-based
+ * implementation of repeatable read isolation. It is also possible
+ * to overwrite changes made and committed by another transaction
+ * after the current transaction read the item from the cache. This
+ * problem would be caught by the update-time version-checking, if
+ * the data is versioned or timestamped.
+ */
+ public synchronized Object get(Object key, long txTimestamp) throws CacheException {
+
+ if ( log.isTraceEnabled() ) log.trace("Cache lookup: " + key);
+
+ /*try {
+ cache.lock(key);*/
+
+ Lockable lockable = (Lockable) cache.get(key);
+
+ boolean gettable = lockable!=null && lockable.isGettable(txTimestamp);
+
+ if (gettable) {
+ if ( log.isTraceEnabled() ) log.trace("Cache hit: " + key);
+ return ( (Item) lockable ).getValue();
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ if (lockable==null) {
+ log.trace("Cache miss: " + key);
+ }
+ else {
+ log.trace("Cached item was locked: " + key);
+ }
+ }
+ return null;
+ }
+ /*}
+ finally {
+ cache.unlock(key);
+ }*/
+ }
+
+ /**
+ * Stop any other transactions reading or writing this item to/from
+ * the cache. Send them straight to the database instead. (The lock
+ * does time out eventually.) This implementation tracks concurrent
+ * locks of transactions which simultaneously attempt to write to an
+ * item.
+ */
+ public synchronized SoftLock lock(Object key, Object version) throws CacheException {
+ if ( log.isTraceEnabled() ) log.trace("Invalidating: " + key);
+
+ try {
+ cache.lock(key);
+
+ Lockable lockable = (Lockable) cache.get(key);
+ long timeout = cache.nextTimestamp() + cache.getTimeout();
+ final Lock lock = (lockable==null) ?
+ new Lock( timeout, nextLockId(), version ) :
+ lockable.lock( timeout, nextLockId() );
+ cache.update(key, lock);
+ return lock;
+ }
+ finally {
+ cache.unlock(key);
+ }
+
+ }
+
+ /**
+ * Do not add an item to the cache unless the current transaction
+ * timestamp is later than the timestamp at which the item was
+ * invalidated. (Otherwise, a stale item might be re-added if the
+ * database is operating in repeatable read isolation mode.)
+ * For versioned data, don't add the item unless it is the later
+ * version.
+ */
+ public synchronized boolean put(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ Comparator versionComparator,
+ boolean minimalPut)
+ throws CacheException {
+ if ( log.isTraceEnabled() ) log.trace("Caching: " + key);
+
+ try {
+ cache.lock(key);
+
+ Lockable lockable = (Lockable) cache.get(key);
+
+ boolean puttable = lockable==null ||
+ lockable.isPuttable(txTimestamp, version, versionComparator);
+
+ if (puttable) {
+ cache.put( key, new Item( value, version, cache.nextTimestamp() ) );
+ if ( log.isTraceEnabled() ) log.trace("Cached: " + key);
+ return true;
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ if ( lockable.isLock() ) {
+ log.trace("Item was locked: " + key);
+ }
+ else {
+ log.trace("Item was already cached: " + key);
+ }
+ }
+ return false;
+ }
+ }
+ finally {
+ cache.unlock(key);
+ }
+ }
+
+ /**
+ * decrement a lock and put it back in the cache
+ */
+ private void decrementLock(Object key, Lock lock) throws CacheException {
+ //decrement the lock
+ lock.unlock( cache.nextTimestamp() );
+ cache.update(key, lock);
+ }
+
+ /**
+ * Release the soft lock on the item. Other transactions may now
+ * re-cache the item (assuming that no other transaction holds a
+ * simultaneous lock).
+ */
+ public synchronized void release(Object key, SoftLock clientLock) throws CacheException {
+ if ( log.isTraceEnabled() ) log.trace("Releasing: " + key);
+
+ try {
+ cache.lock(key);
+
+ Lockable lockable = (Lockable) cache.get(key);
+ if ( isUnlockable(clientLock, lockable) ) {
+ decrementLock(key, (Lock) lockable);
+ }
+ else {
+ handleLockExpiry(key);
+ }
+ }
+ finally {
+ cache.unlock(key);
+ }
+ }
+
+ void handleLockExpiry(Object key) throws CacheException {
+ log.warn("An item was expired by the cache while it was locked (increase your cache timeout): " + key);
+ long ts = cache.nextTimestamp() + cache.getTimeout();
+ // create new lock that times out immediately
+ Lock lock = new Lock( ts, nextLockId(), null );
+ lock.unlock(ts);
+ cache.update(key, lock);
+ }
+
+ public void clear() throws CacheException {
+ cache.clear();
+ }
+
+ public void remove(Object key) throws CacheException {
+ cache.remove(key);
+ }
+
+ public void destroy() {
+ try {
+ cache.destroy();
+ }
+ catch (Exception e) {
+ log.warn("could not destroy cache", e);
+ }
+ }
+
+ /**
+ * Re-cache the updated state, if and only if there there are
+ * no other concurrent soft locks. Release our lock.
+ */
+ public synchronized boolean afterUpdate(Object key, Object value, Object version, SoftLock clientLock)
+ throws CacheException {
+
+ if ( log.isTraceEnabled() ) log.trace("Updating: " + key);
+
+ try {
+ cache.lock(key);
+
+ Lockable lockable = (Lockable) cache.get(key);
+ if ( isUnlockable(clientLock, lockable) ) {
+ Lock lock = (Lock) lockable;
+ if ( lock.wasLockedConcurrently() ) {
+ // just decrement the lock, don't recache
+ // (we don't know which transaction won)
+ decrementLock(key, lock);
+ return false;
+ }
+ else {
+ //recache the updated state
+ cache.update( key, new Item( value, version, cache.nextTimestamp() ) );
+ if ( log.isTraceEnabled() ) log.trace("Updated: " + key);
+ return true;
+ }
+ }
+ else {
+ handleLockExpiry(key);
+ return false;
+ }
+
+ }
+ finally {
+ cache.unlock(key);
+ }
+ }
+
+ /**
+ * Add the new item to the cache, checking that no other transaction has
+ * accessed the item.
+ */
+ public synchronized boolean afterInsert(Object key, Object value, Object version)
+ throws CacheException {
+
+ if ( log.isTraceEnabled() ) log.trace("Inserting: " + key);
+ try {
+ cache.lock(key);
+
+ Lockable lockable = (Lockable) cache.get(key);
+ if (lockable==null) {
+ cache.update( key, new Item( value, version, cache.nextTimestamp() ) );
+ if ( log.isTraceEnabled() ) log.trace("Inserted: " + key);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ finally {
+ cache.unlock(key);
+ }
+ }
+
+ /**
+ * Do nothing.
+ */
+ public void evict(Object key) throws CacheException {
+ // noop
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean insert(Object key, Object value, Object currentVersion) {
+ return false;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) {
+ return false;
+ }
+
+ /**
+ * Is the client's lock commensurate with the item in the cache?
+ * If it is not, we know that the cache expired the original
+ * lock.
+ */
+ private boolean isUnlockable(SoftLock clientLock, Lockable myLock)
+ throws CacheException {
+ //null clientLock is remotely possible but will never happen in practice
+ return myLock!=null &&
+ myLock.isLock() &&
+ clientLock!=null &&
+ ( (Lock) clientLock ).getId()==( (Lock) myLock ).getId();
+ }
+
+ public static interface Lockable {
+ public Lock lock(long timeout, int id);
+ public boolean isLock();
+ public boolean isGettable(long txTimestamp);
+ public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator);
+ }
+
+ /**
+ * An item of cached data, timestamped with the time it was cached,.
+ * @see ReadWriteCache
+ */
+ public static final class Item implements Serializable, Lockable {
+
+ private final long freshTimestamp;
+ private final Object value;
+ private final Object version;
+
+ public Item(Object value, Object version, long currentTimestamp) {
+ this.value = value;
+ this.version = version;
+ freshTimestamp = currentTimestamp;
+ }
+ /**
+ * The timestamp on the cached data
+ */
+ public long getFreshTimestamp() {
+ return freshTimestamp;
+ }
+ /**
+ * The actual cached data
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * Lock the item
+ */
+ public Lock lock(long timeout, int id) {
+ return new Lock(timeout, id, version);
+ }
+ /**
+ * Not a lock!
+ */
+ public boolean isLock() {
+ return false;
+ }
+ /**
+ * Is this item visible to the timestamped
+ * transaction?
+ */
+ public boolean isGettable(long txTimestamp) {
+ return freshTimestamp < txTimestamp;
+ }
+
+ /**
+ * Don't overwite already cached items
+ */
+ public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator) {
+ // we really could refresh the item if it
+ // is not a lock, but it might be slower
+ //return freshTimestamp < txTimestamp
+ return version!=null && comparator.compare(version, newVersion) < 0;
+ }
+
+ public String toString() {
+ return "Item{version=" + version +
+ ",freshTimestamp=" + freshTimestamp;
+ }
+ }
+
+ /**
+ * A soft lock which supports concurrent locking,
+ * timestamped with the time it was released
+ * @author Gavin King
+ */
+ public static final class Lock implements Serializable, Lockable, SoftLock {
+ private long unlockTimestamp = -1;
+ private int multiplicity = 1;
+ private boolean concurrentLock = false;
+ private long timeout;
+ private final int id;
+ private final Object version;
+
+ public Lock(long timeout, int id, Object version) {
+ this.timeout = timeout;
+ this.id = id;
+ this.version = version;
+ }
+
+ public long getUnlockTimestamp() {
+ return unlockTimestamp;
+ }
+ /**
+ * Increment the lock, setting the
+ * new lock timeout
+ */
+ public Lock lock(long timeout, int id) {
+ concurrentLock = true;
+ multiplicity++;
+ this.timeout = timeout;
+ return this;
+ }
+ /**
+ * Decrement the lock, setting the unlock
+ * timestamp if now unlocked
+ * @param currentTimestamp
+ */
+ public void unlock(long currentTimestamp) {
+ if ( --multiplicity == 0 ) {
+ unlockTimestamp = currentTimestamp;
+ }
+ }
+
+ /**
+ * Can the timestamped transaction re-cache this
+ * locked item now?
+ */
+ public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator) {
+ if (timeout < txTimestamp) return true;
+ if (multiplicity>0) return false;
+ return version==null ?
+ unlockTimestamp < txTimestamp :
+ comparator.compare(version, newVersion) < 0; //by requiring <, we rely on lock timeout in the case of an unsuccessful update!
+ }
+
+ /**
+ * Was this lock held concurrently by multiple
+ * transactions?
+ */
+ public boolean wasLockedConcurrently() {
+ return concurrentLock;
+ }
+ /**
+ * Yes, this is a lock
+ */
+ public boolean isLock() {
+ return true;
+ }
+ /**
+ * locks are not returned to the client!
+ */
+ public boolean isGettable(long txTimestamp) {
+ return false;
+ }
+
+ public int getId() { return id; }
+
+ public String toString() {
+ return "Lock{id=" + id +
+ ",version=" + version +
+ ",multiplicity=" + multiplicity +
+ ",unlockTimestamp=" + unlockTimestamp;
+ }
+
+ }
+
+ public String toString() {
+ return cache + "(read-write)";
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/Region.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,62 +0,0 @@
-package org.hibernate.cache;
-
-import java.util.Map;
-
-/**
- * Defines a contract for accessing a particular named region within the
- * underlying cache implementation.
- *
- * @author Steve Ebersole
- */
-public interface Region {
- /**
- * Retrieve the name of this region.
- *
- * @return The region name
- */
- public String getName();
-
- /**
- * The "end state" contract of the region's lifecycle. Called
- * during {@link org.hibernate.SessionFactory#close()} to give
- * the region a chance to cleanup.
- *
- * @throws CacheException Indicates problem shutting down
- */
- public void destroy() throws CacheException;
-
- /**
- * The number of bytes is this cache region currently consuming in memory.
- *
- * @return The number of bytes consumed by this region; -1 if unknown or
- * unsupported.
- */
- public long getSizeInMemory();
-
- /**
- * The count of entries currently contained in the regions in-memory store.
- *
- * @return The count of entries in memory; -1 if unknown or unsupported.
- */
- public long getElementCountInMemory();
-
- /**
- * The count of entries currently contained in the regions disk store.
- *
- * @return The count of entries on disk; -1 if unknown or unsupported.
- */
- public long getElementCountOnDisk();
-
- /**
- * Get the contents of this region as a map.
- * <p/>
- * Implementors which do not support this notion
- * should simply return an empty map.
- *
- * @return The content map.
- */
- public Map toMap();
-
- public long nextTimestamp();
- public int getTimeout();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/Region.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Region.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Map;
+
+/**
+ * Defines a contract for accessing a particular named region within the
+ * underlying cache implementation.
+ *
+ * @author Steve Ebersole
+ */
+public interface Region {
+ /**
+ * Retrieve the name of this region.
+ *
+ * @return The region name
+ */
+ public String getName();
+
+ /**
+ * The "end state" contract of the region's lifecycle. Called
+ * during {@link org.hibernate.SessionFactory#close()} to give
+ * the region a chance to cleanup.
+ *
+ * @throws CacheException Indicates problem shutting down
+ */
+ public void destroy() throws CacheException;
+
+ /**
+ * The number of bytes is this cache region currently consuming in memory.
+ *
+ * @return The number of bytes consumed by this region; -1 if unknown or
+ * unsupported.
+ */
+ public long getSizeInMemory();
+
+ /**
+ * The count of entries currently contained in the regions in-memory store.
+ *
+ * @return The count of entries in memory; -1 if unknown or unsupported.
+ */
+ public long getElementCountInMemory();
+
+ /**
+ * The count of entries currently contained in the regions disk store.
+ *
+ * @return The count of entries on disk; -1 if unknown or unsupported.
+ */
+ public long getElementCountOnDisk();
+
+ /**
+ * Get the contents of this region as a map.
+ * <p/>
+ * Implementors which do not support this notion
+ * should simply return an empty map.
+ *
+ * @return The content map.
+ */
+ public Map toMap();
+
+ public long nextTimestamp();
+ public int getTimeout();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/RegionFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,106 +0,0 @@
-package org.hibernate.cache;
-
-import java.util.Properties;
-
-import org.hibernate.cfg.Settings;
-
-/**
- * Contract for building second level cache regions.
- * <p/>
- * Implementors should define a constructor in one of two forms:<ul>
- * <li>MyRegionFactoryImpl({@link java.util.Properties})</li>
- * <li>MyRegionFactoryImpl()</li>
- * </ul>
- * Use the first when we need to read config properties prior to
- * {@link #start} being called. For an example, have a look at
- * {@link org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge}
- * where we need the properties in order to determine which legacy
- * {@link CacheProvider} to use so that we can answer the
- * {@link #isMinimalPutsEnabledByDefault()} question for the
- * {@link org.hibernate.cfg.SettingsFactory}.
- *
- * @author Steve Ebersole
- */
-public interface RegionFactory {
-
- /**
- * Lifecycle callback to perform any necessary initialization of the
- * underlying cache implementation(s). Called exactly once during the
- * construction of a {@link org.hibernate.impl.SessionFactoryImpl}.
- *
- * @param settings The settings in effect.
- * @param properties The defined cfg properties
- * @throws CacheException Indicates problems starting the L2 cache impl;
- * considered as a sign to stop {@link org.hibernate.SessionFactory}
- * building.
- */
- public void start(Settings settings, Properties properties) throws CacheException;
-
- /**
- * Lifecycle callback to perform any necessary cleanup of the underlying
- * cache implementation(s). Called exactly once during
- * {@link org.hibernate.SessionFactory#close}.
- */
- public void stop();
-
- /**
- * By default should we perform "minimal puts" when using this second
- * level cache implementation?
- *
- * @return True if "minimal puts" should be performed by default; false
- * otherwise.
- */
- public boolean isMinimalPutsEnabledByDefault();
-
- /**
- * Generate a timestamp.
- * <p/>
- * This is generally used for cache content locking/unlocking purposes
- * depending upon the access-strategy being used.
- *
- * @return The generated timestamp.
- */
- public long nextTimestamp();
-
- /**
- * Build a cache region specialized for storing entity data.
- *
- * @param regionName The name of the region.
- * @param properties Configuration properties.
- * @param metadata Information regarding the type of data to be cached
- * @return The built region
- * @throws CacheException Indicates problems building the region.
- */
- public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;
-
- /**
- * Build a cache region specialized for storing collection data.
- *
- * @param regionName The name of the region.
- * @param properties Configuration properties.
- * @param metadata Information regarding the type of data to be cached
- * @return The built region
- * @throws CacheException Indicates problems building the region.
- */
- public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;
-
- /**
- * Build a cache region specialized for storing query results
- *
- * @param regionName The name of the region.
- * @param properties Configuration properties.
- * @return The built region
- * @throws CacheException Indicates problems building the region.
- */
- public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException;
-
- /**
- * Build a cache region specialized for storing update-timestamps data.
- *
- * @param regionName The name of the region.
- * @param properties Configuration properties.
- * @return The built region
- * @throws CacheException Indicates problems building the region.
- */
- public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/RegionFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/RegionFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,130 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Properties;
+
+import org.hibernate.cfg.Settings;
+
+/**
+ * Contract for building second level cache regions.
+ * <p/>
+ * Implementors should define a constructor in one of two forms:<ul>
+ * <li>MyRegionFactoryImpl({@link java.util.Properties})</li>
+ * <li>MyRegionFactoryImpl()</li>
+ * </ul>
+ * Use the first when we need to read config properties prior to
+ * {@link #start} being called. For an example, have a look at
+ * {@link org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge}
+ * where we need the properties in order to determine which legacy
+ * {@link CacheProvider} to use so that we can answer the
+ * {@link #isMinimalPutsEnabledByDefault()} question for the
+ * {@link org.hibernate.cfg.SettingsFactory}.
+ *
+ * @author Steve Ebersole
+ */
+public interface RegionFactory {
+
+ /**
+ * Lifecycle callback to perform any necessary initialization of the
+ * underlying cache implementation(s). Called exactly once during the
+ * construction of a {@link org.hibernate.impl.SessionFactoryImpl}.
+ *
+ * @param settings The settings in effect.
+ * @param properties The defined cfg properties
+ * @throws CacheException Indicates problems starting the L2 cache impl;
+ * considered as a sign to stop {@link org.hibernate.SessionFactory}
+ * building.
+ */
+ public void start(Settings settings, Properties properties) throws CacheException;
+
+ /**
+ * Lifecycle callback to perform any necessary cleanup of the underlying
+ * cache implementation(s). Called exactly once during
+ * {@link org.hibernate.SessionFactory#close}.
+ */
+ public void stop();
+
+ /**
+ * By default should we perform "minimal puts" when using this second
+ * level cache implementation?
+ *
+ * @return True if "minimal puts" should be performed by default; false
+ * otherwise.
+ */
+ public boolean isMinimalPutsEnabledByDefault();
+
+ /**
+ * Generate a timestamp.
+ * <p/>
+ * This is generally used for cache content locking/unlocking purposes
+ * depending upon the access-strategy being used.
+ *
+ * @return The generated timestamp.
+ */
+ public long nextTimestamp();
+
+ /**
+ * Build a cache region specialized for storing entity data.
+ *
+ * @param regionName The name of the region.
+ * @param properties Configuration properties.
+ * @param metadata Information regarding the type of data to be cached
+ * @return The built region
+ * @throws CacheException Indicates problems building the region.
+ */
+ public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;
+
+ /**
+ * Build a cache region specialized for storing collection data.
+ *
+ * @param regionName The name of the region.
+ * @param properties Configuration properties.
+ * @param metadata Information regarding the type of data to be cached
+ * @return The built region
+ * @throws CacheException Indicates problems building the region.
+ */
+ public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;
+
+ /**
+ * Build a cache region specialized for storing query results
+ *
+ * @param regionName The name of the region.
+ * @param properties Configuration properties.
+ * @return The built region
+ * @throws CacheException Indicates problems building the region.
+ */
+ public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException;
+
+ /**
+ * Build a cache region specialized for storing update-timestamps data.
+ *
+ * @param regionName The name of the region.
+ * @param properties Configuration properties.
+ * @return The built region
+ * @throws CacheException Indicates problems building the region.
+ */
+ public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/StandardQueryCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,184 +0,0 @@
-//$Id: StandardQueryCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.HibernateException;
-import org.hibernate.UnresolvableObjectException;
-import org.hibernate.cfg.Settings;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.type.Type;
-import org.hibernate.type.TypeFactory;
-
-/**
- * The standard implementation of the Hibernate QueryCache interface. This
- * implementation is very good at recognizing stale query results and
- * and re-running queries when it detects this condition, recaching the new
- * results.
- *
- * @author Gavin King
- * @author Steve Ebersole
- */
-public class StandardQueryCache implements QueryCache {
-
- private static final Logger log = LoggerFactory.getLogger( StandardQueryCache.class );
-
- private QueryResultsRegion cacheRegion;
- private UpdateTimestampsCache updateTimestampsCache;
-
- public void clear() throws CacheException {
- cacheRegion.evictAll();
- }
-
- public StandardQueryCache(
- final Settings settings,
- final Properties props,
- final UpdateTimestampsCache updateTimestampsCache,
- String regionName) throws HibernateException {
- if ( regionName == null ) {
- regionName = StandardQueryCache.class.getName();
- }
- String prefix = settings.getCacheRegionPrefix();
- if ( prefix != null ) {
- regionName = prefix + '.' + regionName;
- }
- log.info( "starting query cache at region: " + regionName );
-
- this.cacheRegion = settings.getRegionFactory().buildQueryResultsRegion( regionName, props );
- this.updateTimestampsCache = updateTimestampsCache;
- }
-
- public boolean put(
- QueryKey key,
- Type[] returnTypes,
- List result,
- boolean isNaturalKeyLookup,
- SessionImplementor session) throws HibernateException {
- if ( isNaturalKeyLookup && result.size() == 0 ) {
- return false;
- }
- else {
- Long ts = new Long( session.getTimestamp() );
-
- if ( log.isDebugEnabled() ) {
- log.debug( "caching query results in region: " + cacheRegion.getName() + "; timestamp=" + ts );
- }
-
- List cacheable = new ArrayList( result.size() + 1 );
- cacheable.add( ts );
- for ( int i = 0; i < result.size(); i++ ) {
- if ( returnTypes.length == 1 ) {
- cacheable.add( returnTypes[0].disassemble( result.get( i ), session, null ) );
- }
- else {
- cacheable.add(
- TypeFactory.disassemble(
- ( Object[] ) result.get( i ), returnTypes, null, session, null
- )
- );
- }
- }
-
- cacheRegion.put( key, cacheable );
-
- return true;
-
- }
-
- }
-
- public List get(
- QueryKey key,
- Type[] returnTypes,
- boolean isNaturalKeyLookup,
- Set spaces,
- SessionImplementor session) throws HibernateException {
- if ( log.isDebugEnabled() ) {
- log.debug( "checking cached query results in region: " + cacheRegion.getName() );
- }
-
- List cacheable = ( List ) cacheRegion.get( key );
- if ( cacheable == null ) {
- log.debug( "query results were not found in cache" );
- return null;
- }
-
- Long timestamp = ( Long ) cacheable.get( 0 );
- if ( !isNaturalKeyLookup && !isUpToDate( spaces, timestamp ) ) {
- log.debug( "cached query results were not up to date" );
- return null;
- }
-
- log.debug( "returning cached query results" );
- for ( int i = 1; i < cacheable.size(); i++ ) {
- if ( returnTypes.length == 1 ) {
- returnTypes[0].beforeAssemble( ( Serializable ) cacheable.get( i ), session );
- }
- else {
- TypeFactory.beforeAssemble( ( Serializable[] ) cacheable.get( i ), returnTypes, session );
- }
- }
- List result = new ArrayList( cacheable.size() - 1 );
- for ( int i = 1; i < cacheable.size(); i++ ) {
- try {
- if ( returnTypes.length == 1 ) {
- result.add( returnTypes[0].assemble( ( Serializable ) cacheable.get( i ), session, null ) );
- }
- else {
- result.add(
- TypeFactory.assemble(
- ( Serializable[] ) cacheable.get( i ), returnTypes, session, null
- )
- );
- }
- }
- 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;
- }
- else {
- throw uoe;
- }
- }
- }
- return result;
- }
-
- protected boolean isUpToDate(Set spaces, Long timestamp) {
- if ( log.isDebugEnabled() ) {
- log.debug( "Checking query spaces for up-to-dateness: " + spaces );
- }
- return updateTimestampsCache.isUpToDate( spaces, timestamp );
- }
-
- public void destroy() {
- try {
- cacheRegion.destroy();
- }
- catch ( Exception e ) {
- log.warn( "could not destroy query cache: " + cacheRegion.getName(), e );
- }
- }
-
- public QueryResultsRegion getRegion() {
- return cacheRegion;
- }
-
- public String toString() {
- return "StandardQueryCache(" + cacheRegion.getName() + ')';
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/StandardQueryCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,207 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.HibernateException;
+import org.hibernate.UnresolvableObjectException;
+import org.hibernate.cfg.Settings;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.type.Type;
+import org.hibernate.type.TypeFactory;
+
+/**
+ * The standard implementation of the Hibernate QueryCache interface. This
+ * implementation is very good at recognizing stale query results and
+ * and re-running queries when it detects this condition, recaching the new
+ * results.
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ */
+public class StandardQueryCache implements QueryCache {
+
+ private static final Logger log = LoggerFactory.getLogger( StandardQueryCache.class );
+
+ private QueryResultsRegion cacheRegion;
+ private UpdateTimestampsCache updateTimestampsCache;
+
+ public void clear() throws CacheException {
+ cacheRegion.evictAll();
+ }
+
+ public StandardQueryCache(
+ final Settings settings,
+ final Properties props,
+ final UpdateTimestampsCache updateTimestampsCache,
+ String regionName) throws HibernateException {
+ if ( regionName == null ) {
+ regionName = StandardQueryCache.class.getName();
+ }
+ String prefix = settings.getCacheRegionPrefix();
+ if ( prefix != null ) {
+ regionName = prefix + '.' + regionName;
+ }
+ log.info( "starting query cache at region: " + regionName );
+
+ this.cacheRegion = settings.getRegionFactory().buildQueryResultsRegion( regionName, props );
+ this.updateTimestampsCache = updateTimestampsCache;
+ }
+
+ public boolean put(
+ QueryKey key,
+ Type[] returnTypes,
+ List result,
+ boolean isNaturalKeyLookup,
+ SessionImplementor session) throws HibernateException {
+ if ( isNaturalKeyLookup && result.size() == 0 ) {
+ return false;
+ }
+ else {
+ Long ts = new Long( session.getTimestamp() );
+
+ if ( log.isDebugEnabled() ) {
+ log.debug( "caching query results in region: " + cacheRegion.getName() + "; timestamp=" + ts );
+ }
+
+ List cacheable = new ArrayList( result.size() + 1 );
+ cacheable.add( ts );
+ for ( int i = 0; i < result.size(); i++ ) {
+ if ( returnTypes.length == 1 ) {
+ cacheable.add( returnTypes[0].disassemble( result.get( i ), session, null ) );
+ }
+ else {
+ cacheable.add(
+ TypeFactory.disassemble(
+ ( Object[] ) result.get( i ), returnTypes, null, session, null
+ )
+ );
+ }
+ }
+
+ cacheRegion.put( key, cacheable );
+
+ return true;
+
+ }
+
+ }
+
+ public List get(
+ QueryKey key,
+ Type[] returnTypes,
+ boolean isNaturalKeyLookup,
+ Set spaces,
+ SessionImplementor session) throws HibernateException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "checking cached query results in region: " + cacheRegion.getName() );
+ }
+
+ List cacheable = ( List ) cacheRegion.get( key );
+ if ( cacheable == null ) {
+ log.debug( "query results were not found in cache" );
+ return null;
+ }
+
+ Long timestamp = ( Long ) cacheable.get( 0 );
+ if ( !isNaturalKeyLookup && !isUpToDate( spaces, timestamp ) ) {
+ log.debug( "cached query results were not up to date" );
+ return null;
+ }
+
+ log.debug( "returning cached query results" );
+ for ( int i = 1; i < cacheable.size(); i++ ) {
+ if ( returnTypes.length == 1 ) {
+ returnTypes[0].beforeAssemble( ( Serializable ) cacheable.get( i ), session );
+ }
+ else {
+ TypeFactory.beforeAssemble( ( Serializable[] ) cacheable.get( i ), returnTypes, session );
+ }
+ }
+ List result = new ArrayList( cacheable.size() - 1 );
+ for ( int i = 1; i < cacheable.size(); i++ ) {
+ try {
+ if ( returnTypes.length == 1 ) {
+ result.add( returnTypes[0].assemble( ( Serializable ) cacheable.get( i ), session, null ) );
+ }
+ else {
+ result.add(
+ TypeFactory.assemble(
+ ( Serializable[] ) cacheable.get( i ), returnTypes, session, null
+ )
+ );
+ }
+ }
+ 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;
+ }
+ else {
+ throw uoe;
+ }
+ }
+ }
+ return result;
+ }
+
+ protected boolean isUpToDate(Set spaces, Long timestamp) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Checking query spaces for up-to-dateness: " + spaces );
+ }
+ return updateTimestampsCache.isUpToDate( spaces, timestamp );
+ }
+
+ public void destroy() {
+ try {
+ cacheRegion.destroy();
+ }
+ catch ( Exception e ) {
+ log.warn( "could not destroy query cache: " + cacheRegion.getName(), e );
+ }
+ }
+
+ public QueryResultsRegion getRegion() {
+ return cacheRegion;
+ }
+
+ public String toString() {
+ return "StandardQueryCache(" + cacheRegion.getName() + ')';
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,24 +0,0 @@
-// $Id: StandardQueryCacheFactory.java 4690 2004-10-26 09:35:46Z oneovthafew $
-package org.hibernate.cache;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Settings;
-
-import java.util.Properties;
-
-/**
- * Standard Hibernate implementation of the QueryCacheFactory interface. Returns
- * instances of {@link StandardQueryCache}.
- */
-public class StandardQueryCacheFactory implements QueryCacheFactory {
-
- public QueryCache getQueryCache(
- final String regionName,
- final UpdateTimestampsCache updateTimestampsCache,
- final Settings settings,
- final Properties props)
- throws HibernateException {
- return new StandardQueryCache(settings, props, updateTimestampsCache, regionName);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/StandardQueryCacheFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Settings;
+
+import java.util.Properties;
+
+/**
+ * Standard Hibernate implementation of the QueryCacheFactory interface. Returns
+ * instances of {@link StandardQueryCache}.
+ */
+public class StandardQueryCacheFactory implements QueryCacheFactory {
+
+ public QueryCache getQueryCache(
+ final String regionName,
+ final UpdateTimestampsCache updateTimestampsCache,
+ final Settings settings,
+ final Properties props)
+ throws HibernateException {
+ return new StandardQueryCache(settings, props, updateTimestampsCache, regionName);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/Timestamper.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,37 +0,0 @@
-//$Id: Timestamper.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate.cache;
-
-/**
- * Generates increasing identifiers (in a single VM only).
- * Not valid across multiple VMs. Identifiers are not necessarily
- * strictly increasing, but usually are.
- */
-public final class Timestamper {
- private static short counter = 0;
- private static long time;
- private static final int BIN_DIGITS = 12;
- public static final short ONE_MS = 1<<BIN_DIGITS;
-
- public static long next() {
- synchronized(Timestamper.class) {
- long newTime = System.currentTimeMillis() << BIN_DIGITS;
- if (time<newTime) {
- time = newTime;
- counter = 0;
- }
- else if (counter < ONE_MS - 1 ) {
- counter++;
- }
-
- return time + counter;
- }
- }
-
- private Timestamper() {}
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/Timestamper.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/Timestamper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,60 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * Generates increasing identifiers (in a single VM only).
+ * Not valid across multiple VMs. Identifiers are not necessarily
+ * strictly increasing, but usually are.
+ */
+public final class Timestamper {
+ private static short counter = 0;
+ private static long time;
+ private static final int BIN_DIGITS = 12;
+ public static final short ONE_MS = 1<<BIN_DIGITS;
+
+ public static long next() {
+ synchronized(Timestamper.class) {
+ long newTime = System.currentTimeMillis() << BIN_DIGITS;
+ if (time<newTime) {
+ time = newTime;
+ counter = 0;
+ }
+ else if (counter < ONE_MS - 1 ) {
+ counter++;
+ }
+
+ return time + counter;
+ }
+ }
+
+ private Timestamper() {}
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/TimestampsRegion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-package org.hibernate.cache;
-
-/**
- * Defines the contract for a cache region which will specifically be used to
- * store entity "update timestamps".
- *
- * @author Steve Ebersole
- */
-public interface TimestampsRegion extends GeneralDataRegion {
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/TimestampsRegion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TimestampsRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * Defines the contract for a cache region which will specifically be used to
+ * store entity "update timestamps".
+ *
+ * @author Steve Ebersole
+ */
+public interface TimestampsRegion extends GeneralDataRegion {
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,11 +0,0 @@
-package org.hibernate.cache;
-
-/**
- * Marker interface for identifying cache impls which are aware of
- * JTA transactions
- *
- * @author Steve Ebersole
- */
-public interface TransactionAwareCache {
-}
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionAwareCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * Marker interface for identifying cache impls which are aware of
+ * JTA transactions
+ *
+ * @author Steve Ebersole
+ */
+public interface TransactionAwareCache {
+}
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/TransactionalCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,171 +0,0 @@
-//$Id: TransactionalCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.util.Comparator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.access.SoftLock;
-
-/**
- * Support for fully transactional cache implementations like
- * JBoss TreeCache. Note that this might be a less scalable
- * concurrency strategy than <tt>ReadWriteCache</tt>. This is
- * a "synchronous" concurrency strategy.
- *
- * @author Gavin King
- */
-public class TransactionalCache implements CacheConcurrencyStrategy {
-
- private static final Logger log = LoggerFactory.getLogger( TransactionalCache.class );
-
- private Cache cache;
-
- public String getRegionName() {
- return cache.getRegionName();
- }
-
- public Object get(Object key, long txTimestamp) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "cache lookup: " + key );
- }
- Object result = cache.read( key );
- if ( log.isDebugEnabled() ) {
- log.debug( result == null ? "cache miss" : "cache hit" );
- }
- return result;
- }
-
- public boolean put(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- Comparator versionComparator,
- boolean minimalPut) throws CacheException {
- if ( minimalPut && cache.read( key ) != null ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "item already cached: " + key );
- }
- return false;
- }
- if ( log.isDebugEnabled() ) {
- log.debug( "caching: " + key );
- }
- if ( cache instanceof OptimisticCache ) {
- ( ( OptimisticCache ) cache ).writeLoad( key, value, version );
- }
- else {
- cache.put( key, value );
- }
- return true;
- }
-
- /**
- * Do nothing, returning null.
- */
- public SoftLock lock(Object key, Object version) throws CacheException {
- //noop
- return null;
- }
-
- /**
- * Do nothing.
- */
- public void release(Object key, SoftLock clientLock) throws CacheException {
- //noop
- }
-
- public boolean update(
- Object key,
- Object value,
- Object currentVersion,
- Object previousVersion) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "updating: " + key );
- }
- if ( cache instanceof OptimisticCache ) {
- ( ( OptimisticCache ) cache ).writeUpdate( key, value, currentVersion, previousVersion );
- }
- else {
- cache.update( key, value );
- }
- return true;
- }
-
- public boolean insert(
- Object key,
- Object value,
- Object currentVersion) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "inserting: " + key );
- }
- if ( cache instanceof OptimisticCache ) {
- ( ( OptimisticCache ) cache ).writeInsert( key, value, currentVersion );
- }
- else {
- cache.update( key, value );
- }
- return true;
- }
-
- public void evict(Object key) throws CacheException {
- cache.remove( key );
- }
-
- public void remove(Object key) throws CacheException {
- if ( log.isDebugEnabled() ) {
- log.debug( "removing: " + key );
- }
- cache.remove( key );
- }
-
- public void clear() throws CacheException {
- log.debug( "clearing" );
- cache.clear();
- }
-
- public void destroy() {
- try {
- cache.destroy();
- }
- catch ( Exception e ) {
- log.warn( "could not destroy cache", e );
- }
- }
-
- public void setCache(Cache cache) {
- this.cache = cache;
- }
-
- public Cache getCache() {
- return cache;
- }
-
- /**
- * Do nothing.
- */
- public boolean afterInsert(
- Object key,
- Object value,
- Object version) throws CacheException {
- return false;
- }
-
- /**
- * Do nothing.
- */
- public boolean afterUpdate(
- Object key,
- Object value,
- Object version,
- SoftLock clientLock) throws CacheException {
- return false;
- }
-
- public String toString() {
- return cache + "(transactional)";
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/TransactionalCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,194 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.util.Comparator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.access.SoftLock;
+
+/**
+ * Support for fully transactional cache implementations like
+ * JBoss TreeCache. Note that this might be a less scalable
+ * concurrency strategy than <tt>ReadWriteCache</tt>. This is
+ * a "synchronous" concurrency strategy.
+ *
+ * @author Gavin King
+ */
+public class TransactionalCache implements CacheConcurrencyStrategy {
+
+ private static final Logger log = LoggerFactory.getLogger( TransactionalCache.class );
+
+ private Cache cache;
+
+ public String getRegionName() {
+ return cache.getRegionName();
+ }
+
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "cache lookup: " + key );
+ }
+ Object result = cache.read( key );
+ if ( log.isDebugEnabled() ) {
+ log.debug( result == null ? "cache miss" : "cache hit" );
+ }
+ return result;
+ }
+
+ public boolean put(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ Comparator versionComparator,
+ boolean minimalPut) throws CacheException {
+ if ( minimalPut && cache.read( key ) != null ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "item already cached: " + key );
+ }
+ return false;
+ }
+ if ( log.isDebugEnabled() ) {
+ log.debug( "caching: " + key );
+ }
+ if ( cache instanceof OptimisticCache ) {
+ ( ( OptimisticCache ) cache ).writeLoad( key, value, version );
+ }
+ else {
+ cache.put( key, value );
+ }
+ return true;
+ }
+
+ /**
+ * Do nothing, returning null.
+ */
+ public SoftLock lock(Object key, Object version) throws CacheException {
+ //noop
+ return null;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public void release(Object key, SoftLock clientLock) throws CacheException {
+ //noop
+ }
+
+ public boolean update(
+ Object key,
+ Object value,
+ Object currentVersion,
+ Object previousVersion) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "updating: " + key );
+ }
+ if ( cache instanceof OptimisticCache ) {
+ ( ( OptimisticCache ) cache ).writeUpdate( key, value, currentVersion, previousVersion );
+ }
+ else {
+ cache.update( key, value );
+ }
+ return true;
+ }
+
+ public boolean insert(
+ Object key,
+ Object value,
+ Object currentVersion) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "inserting: " + key );
+ }
+ if ( cache instanceof OptimisticCache ) {
+ ( ( OptimisticCache ) cache ).writeInsert( key, value, currentVersion );
+ }
+ else {
+ cache.update( key, value );
+ }
+ return true;
+ }
+
+ public void evict(Object key) throws CacheException {
+ cache.remove( key );
+ }
+
+ public void remove(Object key) throws CacheException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "removing: " + key );
+ }
+ cache.remove( key );
+ }
+
+ public void clear() throws CacheException {
+ log.debug( "clearing" );
+ cache.clear();
+ }
+
+ public void destroy() {
+ try {
+ cache.destroy();
+ }
+ catch ( Exception e ) {
+ log.warn( "could not destroy cache", e );
+ }
+ }
+
+ public void setCache(Cache cache) {
+ this.cache = cache;
+ }
+
+ public Cache getCache() {
+ return cache;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean afterInsert(
+ Object key,
+ Object value,
+ Object version) throws CacheException {
+ return false;
+ }
+
+ /**
+ * Do nothing.
+ */
+ public boolean afterUpdate(
+ Object key,
+ Object value,
+ Object version,
+ SoftLock clientLock) throws CacheException {
+ return false;
+ }
+
+ public String toString() {
+ return cache + "(transactional)";
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-package org.hibernate.cache;
-
-/**
- * Defines contract for regions which hold transactionally-managed data.
- * <p/>
- * The data is not transactionally managed within the region; merely it is
- * transactionally-managed in relation to its association with a particular
- * {@link org.hibernate.Session}.
- *
- * @author Steve Ebersole
- */
-public interface TransactionalDataRegion extends Region {
- /**
- * Is the underlying cache implementation aware of (and "participating in")
- * ongoing JTA transactions?
- * <p/>
- * Regions which report that they are transaction-aware are considered
- * "synchronous", in that we assume we can immediately (i.e. synchronously)
- * write the changes to the cache and that the cache will properly manage
- * application of the written changes within the bounds of ongoing JTA
- * transactions. Conversely, regions reporting false are considered
- * "asynchronous", where it is assumed that changes must be manually
- * delayed by Hibernate until we are certain that the current transaction
- * is successful (i.e. maintaining READ_COMMITTED isolation).
- *
- * @return True if transaction aware; false otherwise.
- */
- public boolean isTransactionAware();
-
- public CacheDataDescription getCacheDataDescription();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/TransactionalDataRegion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+/**
+ * Defines contract for regions which hold transactionally-managed data.
+ * <p/>
+ * The data is not transactionally managed within the region; merely it is
+ * transactionally-managed in relation to its association with a particular
+ * {@link org.hibernate.Session}.
+ *
+ * @author Steve Ebersole
+ */
+public interface TransactionalDataRegion extends Region {
+ /**
+ * Is the underlying cache implementation aware of (and "participating in")
+ * ongoing JTA transactions?
+ * <p/>
+ * Regions which report that they are transaction-aware are considered
+ * "synchronous", in that we assume we can immediately (i.e. synchronously)
+ * write the changes to the cache and that the cache will properly manage
+ * application of the written changes within the bounds of ongoing JTA
+ * transactions. Conversely, regions reporting false are considered
+ * "asynchronous", where it is assumed that changes must be manually
+ * delayed by Hibernate until we are certain that the current transaction
+ * is successful (i.e. maintaining READ_COMMITTED isolation).
+ *
+ * @return True if transaction aware; false otherwise.
+ */
+ public boolean isTransactionAware();
+
+ public CacheDataDescription getCacheDataDescription();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,110 +0,0 @@
-//$Id: UpdateTimestampsCache.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.cache;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Settings;
-
-/**
- * Tracks the timestamps of the most recent updates to particular tables. It is
- * important that the cache timeout of the underlying cache implementation be set
- * to a higher value than the timeouts of any of the query caches. In fact, we
- * recommend that the the underlying cache not be configured for expiry at all.
- * Note, in particular, that an LRU cache expiry policy is never appropriate.
- *
- * @author Gavin King
- * @author Mikheil Kapanadze
- */
-public class UpdateTimestampsCache {
- public static final String REGION_NAME = UpdateTimestampsCache.class.getName();
- private static final Logger log = LoggerFactory.getLogger( UpdateTimestampsCache.class );
-
- private final TimestampsRegion region;
-
- public UpdateTimestampsCache(Settings settings, Properties props) throws HibernateException {
- String prefix = settings.getCacheRegionPrefix();
- String regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;
- log.info( "starting update timestamps cache at region: " + regionName );
- this.region = settings.getRegionFactory().buildTimestampsRegion( regionName, props );
- }
-
- public synchronized void preinvalidate(Serializable[] spaces) throws CacheException {
- //TODO: to handle concurrent writes correctly, this should return a Lock to the client
- Long ts = new Long( region.nextTimestamp() + region.getTimeout() );
- for ( int i=0; i<spaces.length; i++ ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "Pre-invalidating space [" + spaces[i] + "]" );
- }
- //put() has nowait semantics, is this really appropriate?
- //note that it needs to be async replication, never local or sync
- region.put( spaces[i], ts );
- }
- //TODO: return new Lock(ts);
- }
-
- public synchronized void invalidate(Serializable[] spaces) throws CacheException {
- //TODO: to handle concurrent writes correctly, the client should pass in a Lock
- Long ts = new Long( region.nextTimestamp() );
- //TODO: if lock.getTimestamp().equals(ts)
- for ( int i=0; i<spaces.length; i++ ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "Invalidating space [" + spaces[i] + "], timestamp: " + ts);
- }
- //put() has nowait semantics, is this really appropriate?
- //note that it needs to be async replication, never local or sync
- region.put( spaces[i], ts );
- }
- }
-
- public synchronized boolean isUpToDate(Set spaces, Long timestamp) throws HibernateException {
- Iterator iter = spaces.iterator();
- while ( iter.hasNext() ) {
- Serializable space = (Serializable) iter.next();
- Long lastUpdate = (Long) region.get(space);
- if ( lastUpdate==null ) {
- //the last update timestamp was lost from the cache
- //(or there were no updates since startup!)
- //updateTimestamps.put( space, new Long( updateTimestamps.nextTimestamp() ) );
- //result = false; // safer
- }
- else {
- if ( log.isDebugEnabled() ) {
- log.debug("[" + space + "] last update timestamp: " + lastUpdate + ", result set timestamp: " + timestamp );
- }
- if ( lastUpdate.longValue() >= timestamp.longValue() ) {
- return false;
- }
- }
- }
- return true;
- }
-
- public void clear() throws CacheException {
- region.evictAll();
- }
-
- public void destroy() {
- try {
- region.destroy();
- }
- catch (Exception e) {
- log.warn("could not destroy UpdateTimestamps cache", e);
- }
- }
-
- public TimestampsRegion getRegion() {
- return region;
- }
-
- public String toString() {
- return "UpdateTimestampeCache";
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/UpdateTimestampsCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,133 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Tracks the timestamps of the most recent updates to particular tables. It is
+ * important that the cache timeout of the underlying cache implementation be set
+ * to a higher value than the timeouts of any of the query caches. In fact, we
+ * recommend that the the underlying cache not be configured for expiry at all.
+ * Note, in particular, that an LRU cache expiry policy is never appropriate.
+ *
+ * @author Gavin King
+ * @author Mikheil Kapanadze
+ */
+public class UpdateTimestampsCache {
+ public static final String REGION_NAME = UpdateTimestampsCache.class.getName();
+ private static final Logger log = LoggerFactory.getLogger( UpdateTimestampsCache.class );
+
+ private final TimestampsRegion region;
+
+ public UpdateTimestampsCache(Settings settings, Properties props) throws HibernateException {
+ String prefix = settings.getCacheRegionPrefix();
+ String regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;
+ log.info( "starting update timestamps cache at region: " + regionName );
+ this.region = settings.getRegionFactory().buildTimestampsRegion( regionName, props );
+ }
+
+ public synchronized void preinvalidate(Serializable[] spaces) throws CacheException {
+ //TODO: to handle concurrent writes correctly, this should return a Lock to the client
+ Long ts = new Long( region.nextTimestamp() + region.getTimeout() );
+ for ( int i=0; i<spaces.length; i++ ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Pre-invalidating space [" + spaces[i] + "]" );
+ }
+ //put() has nowait semantics, is this really appropriate?
+ //note that it needs to be async replication, never local or sync
+ region.put( spaces[i], ts );
+ }
+ //TODO: return new Lock(ts);
+ }
+
+ public synchronized void invalidate(Serializable[] spaces) throws CacheException {
+ //TODO: to handle concurrent writes correctly, the client should pass in a Lock
+ Long ts = new Long( region.nextTimestamp() );
+ //TODO: if lock.getTimestamp().equals(ts)
+ for ( int i=0; i<spaces.length; i++ ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Invalidating space [" + spaces[i] + "], timestamp: " + ts);
+ }
+ //put() has nowait semantics, is this really appropriate?
+ //note that it needs to be async replication, never local or sync
+ region.put( spaces[i], ts );
+ }
+ }
+
+ public synchronized boolean isUpToDate(Set spaces, Long timestamp) throws HibernateException {
+ Iterator iter = spaces.iterator();
+ while ( iter.hasNext() ) {
+ Serializable space = (Serializable) iter.next();
+ Long lastUpdate = (Long) region.get(space);
+ if ( lastUpdate==null ) {
+ //the last update timestamp was lost from the cache
+ //(or there were no updates since startup!)
+ //updateTimestamps.put( space, new Long( updateTimestamps.nextTimestamp() ) );
+ //result = false; // safer
+ }
+ else {
+ if ( log.isDebugEnabled() ) {
+ log.debug("[" + space + "] last update timestamp: " + lastUpdate + ", result set timestamp: " + timestamp );
+ }
+ if ( lastUpdate.longValue() >= timestamp.longValue() ) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public void clear() throws CacheException {
+ region.evictAll();
+ }
+
+ public void destroy() {
+ try {
+ region.destroy();
+ }
+ catch (Exception e) {
+ log.warn("could not destroy UpdateTimestamps cache", e);
+ }
+ }
+
+ public TimestampsRegion getRegion() {
+ return region;
+ }
+
+ public String toString() {
+ return "UpdateTimestampeCache";
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/AccessType.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,62 +0,0 @@
-package org.hibernate.cache.access;
-
-import java.io.Serializable;
-
-/**
- * The types of access strategies available.
- *
- * @author Steve Ebersole
- */
-public class AccessType implements Serializable {
- public static final AccessType READ_ONLY = new AccessType( "read-only" );
- public static final AccessType READ_WRITE = new AccessType( "read-write" );
- public static final AccessType NONSTRICT_READ_WRITE = new AccessType( "nonstrict-read-write" );
- public static final AccessType TRANSACTIONAL = new AccessType( "transactional" );
-
- private final String name;
-
- private AccessType(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String toString() {
- return "AccessType[" + name + "]";
- }
-
- private static AccessType resolve(String name) {
- if ( READ_ONLY.name.equals( name ) ) {
- return READ_ONLY;
- }
- else if ( READ_WRITE.name.equals( name ) ) {
- return READ_WRITE;
- }
- else if ( NONSTRICT_READ_WRITE.name.equals( name ) ) {
- return NONSTRICT_READ_WRITE;
- }
- else if ( TRANSACTIONAL.name.equals( name ) ) {
- return TRANSACTIONAL;
- }
- else {
- return null;
- }
- }
-
- public static AccessType parse(String name) {
- return resolve( name );
- }
-
- private Object readResolve() {
- return resolve( name );
- }
-
- public static String getValidUsageString() {
- return "cache usage attribute should be " + READ_ONLY.name +
- ", " + READ_WRITE.name +
- ", " + NONSTRICT_READ_WRITE.name +
- ", or " + TRANSACTIONAL.name;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/access/AccessType.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/AccessType.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.access;
+
+import java.io.Serializable;
+
+/**
+ * The types of access strategies available.
+ *
+ * @author Steve Ebersole
+ */
+public class AccessType implements Serializable {
+ public static final AccessType READ_ONLY = new AccessType( "read-only" );
+ public static final AccessType READ_WRITE = new AccessType( "read-write" );
+ public static final AccessType NONSTRICT_READ_WRITE = new AccessType( "nonstrict-read-write" );
+ public static final AccessType TRANSACTIONAL = new AccessType( "transactional" );
+
+ private final String name;
+
+ private AccessType(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ return "AccessType[" + name + "]";
+ }
+
+ private static AccessType resolve(String name) {
+ if ( READ_ONLY.name.equals( name ) ) {
+ return READ_ONLY;
+ }
+ else if ( READ_WRITE.name.equals( name ) ) {
+ return READ_WRITE;
+ }
+ else if ( NONSTRICT_READ_WRITE.name.equals( name ) ) {
+ return NONSTRICT_READ_WRITE;
+ }
+ else if ( TRANSACTIONAL.name.equals( name ) ) {
+ return TRANSACTIONAL;
+ }
+ else {
+ return null;
+ }
+ }
+
+ public static AccessType parse(String name) {
+ return resolve( name );
+ }
+
+ private Object readResolve() {
+ return resolve( name );
+ }
+
+ public static String getValidUsageString() {
+ return "cache usage attribute should be " + READ_ONLY.name +
+ ", " + READ_WRITE.name +
+ ", " + NONSTRICT_READ_WRITE.name +
+ ", or " + TRANSACTIONAL.name;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,149 +0,0 @@
-package org.hibernate.cache.access;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CollectionRegion;
-
-/**
- * Contract for managing transactional and concurrent access to cached collection
- * data. For cached collection data, all modification actions actually just
- * invalidate the entry(s). The call sequence here is:
- * {@link #lockItem} -> {@link #remove} -> {@link #unlockItem}
- * <p/>
- * There is another usage pattern that is used to invalidate entries
- * after performing "bulk" HQL/SQL operations:
- * {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
- *
- * @author Gavin King
- * @author Steve Ebersole
- */
-public interface CollectionRegionAccessStrategy {
-
- /**
- * Get the wrapped collection cache region
- *
- * @return The underlying region
- */
- public CollectionRegion getRegion();
-
- /**
- * Attempt to retrieve an object from the cache. Mainly used in attempting
- * to resolve entities/collections from the second level cache.
- *
- * @param key The key of the item to be retrieved.
- * @param txTimestamp a timestamp prior to the transaction start time
- * @return the cached object or <tt>null</tt>
- * @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public Object get(Object key, long txTimestamp) throws CacheException;
-
- /**
- * Attempt to cache an object, after loading from the database.
- *
- * @param key The item key
- * @param value The item
- * @param txTimestamp a timestamp prior to the transaction start time
- * @param version the item version number
- * @return <tt>true</tt> if the object was successfully cached
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version) throws CacheException;
-
- /**
- * Attempt to cache an object, after loading from the database, explicitly
- * specifying the minimalPut behavior.
- *
- * @param key The item key
- * @param value The item
- * @param txTimestamp a timestamp prior to the transaction start time
- * @param version the item version number
- * @param minimalPutOverride Explicit minimalPut flag
- * @return <tt>true</tt> if the object was successfully cached
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- boolean minimalPutOverride) throws CacheException;
-
- /**
- * We are going to attempt to update/delete the keyed object. This
- * method is used by "asynchronous" concurrency strategies.
- * <p/>
- * The returned object must be passed back to release(), to release the
- * lock. Concurrency strategies which do not support client-visible
- * locks may silently return null.
- *
- * @param key The key of the item to lock
- * @param version The item's current version value
- * @return A representation of our lock on the item; or null.
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public SoftLock lockItem(Object key, Object version) throws CacheException;
-
- /**
- * Lock the entire region
- *
- * @return A representation of our lock on the item; or null.
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public SoftLock lockRegion() throws CacheException;
-
- /**
- * Called when we have finished the attempted update/delete (which may or
- * may not have been successful), after transaction completion. This method
- * is used by "asynchronous" concurrency strategies.
- *
- * @param key The item key
- * @param lock The lock previously obtained from {@link #lockItem}
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void unlockItem(Object key, SoftLock lock) throws CacheException;
-
- /**
- * Called after we have finished the attempted invalidation of the entire
- * region
- *
- * @param lock The lock previously obtained from {@link #lockRegion}
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void unlockRegion(SoftLock lock) throws CacheException;
-
- /**
- * Called after an item has become stale (before the transaction completes).
- * This method is used by "synchronous" concurrency strategies.
- *
- * @param key The key of the item to remove
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void remove(Object key) throws CacheException;
-
- /**
- * Called to evict data from the entire region
- *
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void removeAll() throws CacheException;
-
- /**
- * Forcibly evict an item from the cache immediately without regard for transaction
- * isolation.
- *
- * @param key The key of the item to remove
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void evict(Object key) throws CacheException;
-
- /**
- * Forcibly evict all items from the cache immediately without regard for transaction
- * isolation.
- *
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void evictAll() throws CacheException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/CollectionRegionAccessStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,173 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.access;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+
+/**
+ * Contract for managing transactional and concurrent access to cached collection
+ * data. For cached collection data, all modification actions actually just
+ * invalidate the entry(s). The call sequence here is:
+ * {@link #lockItem} -> {@link #remove} -> {@link #unlockItem}
+ * <p/>
+ * There is another usage pattern that is used to invalidate entries
+ * after performing "bulk" HQL/SQL operations:
+ * {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ */
+public interface CollectionRegionAccessStrategy {
+
+ /**
+ * Get the wrapped collection cache region
+ *
+ * @return The underlying region
+ */
+ public CollectionRegion getRegion();
+
+ /**
+ * Attempt to retrieve an object from the cache. Mainly used in attempting
+ * to resolve entities/collections from the second level cache.
+ *
+ * @param key The key of the item to be retrieved.
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @return the cached object or <tt>null</tt>
+ * @throws org.hibernate.cache.CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public Object get(Object key, long txTimestamp) throws CacheException;
+
+ /**
+ * Attempt to cache an object, after loading from the database.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @param version the item version number
+ * @return <tt>true</tt> if the object was successfully cached
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version) throws CacheException;
+
+ /**
+ * Attempt to cache an object, after loading from the database, explicitly
+ * specifying the minimalPut behavior.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @param version the item version number
+ * @param minimalPutOverride Explicit minimalPut flag
+ * @return <tt>true</tt> if the object was successfully cached
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ boolean minimalPutOverride) throws CacheException;
+
+ /**
+ * We are going to attempt to update/delete the keyed object. This
+ * method is used by "asynchronous" concurrency strategies.
+ * <p/>
+ * The returned object must be passed back to release(), to release the
+ * lock. Concurrency strategies which do not support client-visible
+ * locks may silently return null.
+ *
+ * @param key The key of the item to lock
+ * @param version The item's current version value
+ * @return A representation of our lock on the item; or null.
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public SoftLock lockItem(Object key, Object version) throws CacheException;
+
+ /**
+ * Lock the entire region
+ *
+ * @return A representation of our lock on the item; or null.
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public SoftLock lockRegion() throws CacheException;
+
+ /**
+ * Called when we have finished the attempted update/delete (which may or
+ * may not have been successful), after transaction completion. This method
+ * is used by "asynchronous" concurrency strategies.
+ *
+ * @param key The item key
+ * @param lock The lock previously obtained from {@link #lockItem}
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void unlockItem(Object key, SoftLock lock) throws CacheException;
+
+ /**
+ * Called after we have finished the attempted invalidation of the entire
+ * region
+ *
+ * @param lock The lock previously obtained from {@link #lockRegion}
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void unlockRegion(SoftLock lock) throws CacheException;
+
+ /**
+ * Called after an item has become stale (before the transaction completes).
+ * This method is used by "synchronous" concurrency strategies.
+ *
+ * @param key The key of the item to remove
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void remove(Object key) throws CacheException;
+
+ /**
+ * Called to evict data from the entire region
+ *
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void removeAll() throws CacheException;
+
+ /**
+ * Forcibly evict an item from the cache immediately without regard for transaction
+ * isolation.
+ *
+ * @param key The key of the item to remove
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void evict(Object key) throws CacheException;
+
+ /**
+ * Forcibly evict all items from the cache immediately without regard for transaction
+ * isolation.
+ *
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void evictAll() throws CacheException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,206 +0,0 @@
-package org.hibernate.cache.access;
-
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.CacheException;
-
-/**
- * Contract for managing transactional and concurrent access to cached entity
- * data. The expected call sequences related to various operations are:<ul>
- * <li><b>INSERTS</b> : {@link #insert} -> {@link #afterInsert}</li>
- * <li><b>UPDATES</b> : {@link #lockItem} -> {@link #update} -> {@link #afterUpdate}</li>
- * <li><b>DELETES</b> : {@link #lockItem} -> {@link #remove} -> {@link #unlockItem}</li>
- * </ul>
- * <p/>
- * There is another usage pattern that is used to invalidate entries
- * after performing "bulk" HQL/SQL operations:
- * {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
- *
- * @author Gavin King
- * @author Steve Ebersole
- */
-public interface EntityRegionAccessStrategy {
-
- /**
- * Get the wrapped entity cache region
- *
- * @return The underlying region
- */
- public EntityRegion getRegion();
-
- /**
- * Attempt to retrieve an object from the cache. Mainly used in attempting
- * to resolve entities/collections from the second level cache.
- *
- * @param key The key of the item to be retrieved.
- * @param txTimestamp a timestamp prior to the transaction start time
- * @return the cached object or <tt>null</tt>
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public Object get(Object key, long txTimestamp) throws CacheException;
-
- /**
- * Attempt to cache an object, after loading from the database.
- *
- * @param key The item key
- * @param value The item
- * @param txTimestamp a timestamp prior to the transaction start time
- * @param version the item version number
- * @return <tt>true</tt> if the object was successfully cached
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version) throws CacheException;
-
- /**
- * Attempt to cache an object, after loading from the database, explicitly
- * specifying the minimalPut behavior.
- *
- * @param key The item key
- * @param value The item
- * @param txTimestamp a timestamp prior to the transaction start time
- * @param version the item version number
- * @param minimalPutOverride Explicit minimalPut flag
- * @return <tt>true</tt> if the object was successfully cached
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- boolean minimalPutOverride) throws CacheException;
-
- /**
- * We are going to attempt to update/delete the keyed object. This
- * method is used by "asynchronous" concurrency strategies.
- * <p/>
- * The returned object must be passed back to release(), to release the
- * lock. Concurrency strategies which do not support client-visible
- * locks may silently return null.
- *
- * @param key The key of the item to lock
- * @param version The item's current version value
- * @return A representation of our lock on the item; or null.
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public SoftLock lockItem(Object key, Object version) throws CacheException;
-
- /**
- * Lock the entire region
- *
- * @return A representation of our lock on the item; or null.
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public SoftLock lockRegion() throws CacheException;
-
- /**
- * Called when we have finished the attempted update/delete (which may or
- * may not have been successful), after transaction completion. This method
- * is used by "asynchronous" concurrency strategies.
- *
- * @param key The item key
- * @param lock The lock previously obtained from {@link #lockItem}
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void unlockItem(Object key, SoftLock lock) throws CacheException;
-
- /**
- * Called after we have finished the attempted invalidation of the entire
- * region
- *
- * @param lock The lock previously obtained from {@link #lockRegion}
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void unlockRegion(SoftLock lock) throws CacheException;
-
- /**
- * Called after an item has been inserted (before the transaction completes),
- * instead of calling evict().
- * This method is used by "synchronous" concurrency strategies.
- *
- * @param key The item key
- * @param value The item
- * @param version The item's version value
- * @return Were the contents of the cache actual changed by this operation?
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean insert(Object key, Object value, Object version) throws CacheException;
-
- /**
- * Called after an item has been inserted (after the transaction completes),
- * instead of calling release().
- * This method is used by "asynchronous" concurrency strategies.
- *
- * @param key The item key
- * @param value The item
- * @param version The item's version value
- * @return Were the contents of the cache actual changed by this operation?
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean afterInsert(Object key, Object value, Object version) throws CacheException;
-
- /**
- * Called after an item has been updated (before the transaction completes),
- * instead of calling evict(). This method is used by "synchronous" concurrency
- * strategies.
- *
- * @param key The item key
- * @param value The item
- * @param currentVersion The item's current version value
- * @param previousVersion The item's previous version value
- * @return Were the contents of the cache actual changed by this operation?
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
-
- /**
- * Called after an item has been updated (after the transaction completes),
- * instead of calling release(). This method is used by "asynchronous"
- * concurrency strategies.
- *
- * @param key The item key
- * @param value The item
- * @param currentVersion The item's current version value
- * @param previousVersion The item's previous version value
- * @param lock The lock previously obtained from {@link #lockItem}
- * @return Were the contents of the cache actual changed by this operation?
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException;
-
- /**
- * Called after an item has become stale (before the transaction completes).
- * This method is used by "synchronous" concurrency strategies.
- *
- * @param key The key of the item to remove
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void remove(Object key) throws CacheException;
-
- /**
- * Called to evict data from the entire region
- *
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void removeAll() throws CacheException;
-
- /**
- * Forcibly evict an item from the cache immediately without regard for transaction
- * isolation.
- *
- * @param key The key of the item to remove
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void evict(Object key) throws CacheException;
-
- /**
- * Forcibly evict all items from the cache immediately without regard for transaction
- * isolation.
- *
- * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
- */
- public void evictAll() throws CacheException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/EntityRegionAccessStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,230 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.access;
+
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.CacheException;
+
+/**
+ * Contract for managing transactional and concurrent access to cached entity
+ * data. The expected call sequences related to various operations are:<ul>
+ * <li><b>INSERTS</b> : {@link #insert} -> {@link #afterInsert}</li>
+ * <li><b>UPDATES</b> : {@link #lockItem} -> {@link #update} -> {@link #afterUpdate}</li>
+ * <li><b>DELETES</b> : {@link #lockItem} -> {@link #remove} -> {@link #unlockItem}</li>
+ * </ul>
+ * <p/>
+ * There is another usage pattern that is used to invalidate entries
+ * after performing "bulk" HQL/SQL operations:
+ * {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion}
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ */
+public interface EntityRegionAccessStrategy {
+
+ /**
+ * Get the wrapped entity cache region
+ *
+ * @return The underlying region
+ */
+ public EntityRegion getRegion();
+
+ /**
+ * Attempt to retrieve an object from the cache. Mainly used in attempting
+ * to resolve entities/collections from the second level cache.
+ *
+ * @param key The key of the item to be retrieved.
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @return the cached object or <tt>null</tt>
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public Object get(Object key, long txTimestamp) throws CacheException;
+
+ /**
+ * Attempt to cache an object, after loading from the database.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @param version the item version number
+ * @return <tt>true</tt> if the object was successfully cached
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version) throws CacheException;
+
+ /**
+ * Attempt to cache an object, after loading from the database, explicitly
+ * specifying the minimalPut behavior.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param txTimestamp a timestamp prior to the transaction start time
+ * @param version the item version number
+ * @param minimalPutOverride Explicit minimalPut flag
+ * @return <tt>true</tt> if the object was successfully cached
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ boolean minimalPutOverride) throws CacheException;
+
+ /**
+ * We are going to attempt to update/delete the keyed object. This
+ * method is used by "asynchronous" concurrency strategies.
+ * <p/>
+ * The returned object must be passed back to release(), to release the
+ * lock. Concurrency strategies which do not support client-visible
+ * locks may silently return null.
+ *
+ * @param key The key of the item to lock
+ * @param version The item's current version value
+ * @return A representation of our lock on the item; or null.
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public SoftLock lockItem(Object key, Object version) throws CacheException;
+
+ /**
+ * Lock the entire region
+ *
+ * @return A representation of our lock on the item; or null.
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public SoftLock lockRegion() throws CacheException;
+
+ /**
+ * Called when we have finished the attempted update/delete (which may or
+ * may not have been successful), after transaction completion. This method
+ * is used by "asynchronous" concurrency strategies.
+ *
+ * @param key The item key
+ * @param lock The lock previously obtained from {@link #lockItem}
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void unlockItem(Object key, SoftLock lock) throws CacheException;
+
+ /**
+ * Called after we have finished the attempted invalidation of the entire
+ * region
+ *
+ * @param lock The lock previously obtained from {@link #lockRegion}
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void unlockRegion(SoftLock lock) throws CacheException;
+
+ /**
+ * Called after an item has been inserted (before the transaction completes),
+ * instead of calling evict().
+ * This method is used by "synchronous" concurrency strategies.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param version The item's version value
+ * @return Were the contents of the cache actual changed by this operation?
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean insert(Object key, Object value, Object version) throws CacheException;
+
+ /**
+ * Called after an item has been inserted (after the transaction completes),
+ * instead of calling release().
+ * This method is used by "asynchronous" concurrency strategies.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param version The item's version value
+ * @return Were the contents of the cache actual changed by this operation?
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean afterInsert(Object key, Object value, Object version) throws CacheException;
+
+ /**
+ * Called after an item has been updated (before the transaction completes),
+ * instead of calling evict(). This method is used by "synchronous" concurrency
+ * strategies.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param currentVersion The item's current version value
+ * @param previousVersion The item's previous version value
+ * @return Were the contents of the cache actual changed by this operation?
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
+
+ /**
+ * Called after an item has been updated (after the transaction completes),
+ * instead of calling release(). This method is used by "asynchronous"
+ * concurrency strategies.
+ *
+ * @param key The item key
+ * @param value The item
+ * @param currentVersion The item's current version value
+ * @param previousVersion The item's previous version value
+ * @param lock The lock previously obtained from {@link #lockItem}
+ * @return Were the contents of the cache actual changed by this operation?
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException;
+
+ /**
+ * Called after an item has become stale (before the transaction completes).
+ * This method is used by "synchronous" concurrency strategies.
+ *
+ * @param key The key of the item to remove
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void remove(Object key) throws CacheException;
+
+ /**
+ * Called to evict data from the entire region
+ *
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void removeAll() throws CacheException;
+
+ /**
+ * Forcibly evict an item from the cache immediately without regard for transaction
+ * isolation.
+ *
+ * @param key The key of the item to remove
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void evict(Object key) throws CacheException;
+
+ /**
+ * Forcibly evict all items from the cache immediately without regard for transaction
+ * isolation.
+ *
+ * @throws CacheException Propogated from underlying {@link org.hibernate.cache.Region}
+ */
+ public void evictAll() throws CacheException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/SoftLock.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-package org.hibernate.cache.access;
-
-/**
- * Moved up from inner definition on the now deprecated
- * {@link org.hibernate.cache.CacheConcurrencyStrategy}.
- *
- * @author Steve Ebersole
- */
-public interface SoftLock {
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/access/SoftLock.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/SoftLock.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.access;
+
+/**
+ * Moved up from inner definition on the now deprecated
+ * {@link org.hibernate.cache.CacheConcurrencyStrategy}.
+ *
+ * @author Steve Ebersole
+ */
+public interface SoftLock {
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/access/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,41 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- Defines contracts for transactional and concurrent access to cached
- {@link org.hibernate.cache.access.EntityRegionAccessStrategy entity} and
- {@link org.hibernate.cache.access.CollectionRegionAccessStrategy collection} data. Transactions pass in a
- timestamp indicating transaction start time which is then used to protect against concurrent access (exactly how
- that occurs is based on the actual access-strategy impl used). Two different implementation patterns are provided
- for.
- <ul>
- <li>
- A transaction-aware cache implementation might be wrapped by a <i>synchronous</i> access strategy,
- where updates to the cache are written to the cache inside the transaction.
- </li>
- <li>
- A non-transaction-aware cache would be wrapped by an <i>asynchronous</i> access strategy, where items
- are merely "soft locked" during the transaction and then updated during the "after transaction completion"
- phase; the soft lock is not an actual lock on the database row - only upon the cached representation of the
- item.
- </li>
- </ul>
- The <i>asynchronous</i> access strategies are: {@link org.hibernate.cache.access.AccessType.READ_ONLY read-only},
- {@link org.hibernate.cache.access.AccessType.READ_WRITE read-write} and
- {@link org.hibernate.cache.access.AccessType.NONSTRICT_READ_WRITE nonstrict-read-write}. The only
- <i>synchronous</i> access strategy is {@link org.hibernate.cache.access.AccessType.TRANSACTIONAL transactional}.
-</p>
-<p>
- Note that, for an <i>asynchronous</i> cache, cache invalidation must be a two step process (lock->unlock or
- lock->afterUpdate), since this is the only way to guarantee consistency with the database for a nontransactional
- cache implementation. For a <i>synchronous</i> cache, cache invalidation is a single step process (evict or update).
- Hence, these contracts ({@link org.hibernate.cache.access.EntityRegionAcessStrategy} and
- {@link org.hibernate.cache.access.CollectionRegionAccessStrategy}) define a three step process to cater for both
- models (see the individual contracts for details).
-</p>
-<p>
- Note that query result caching does not go through an access strategy; those caches are managed directly against
- the underlying {@link org.hibernate.cache.QueryResultsRegion}.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/access/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/access/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,66 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ Defines contracts for transactional and concurrent access to cached
+ {@link org.hibernate.cache.access.EntityRegionAccessStrategy entity} and
+ {@link org.hibernate.cache.access.CollectionRegionAccessStrategy collection} data. Transactions pass in a
+ timestamp indicating transaction start time which is then used to protect against concurrent access (exactly how
+ that occurs is based on the actual access-strategy impl used). Two different implementation patterns are provided
+ for.
+ <ul>
+ <li>
+ A transaction-aware cache implementation might be wrapped by a <i>synchronous</i> access strategy,
+ where updates to the cache are written to the cache inside the transaction.
+ </li>
+ <li>
+ A non-transaction-aware cache would be wrapped by an <i>asynchronous</i> access strategy, where items
+ are merely "soft locked" during the transaction and then updated during the "after transaction completion"
+ phase; the soft lock is not an actual lock on the database row - only upon the cached representation of the
+ item.
+ </li>
+ </ul>
+ The <i>asynchronous</i> access strategies are: {@link org.hibernate.cache.access.AccessType.READ_ONLY read-only},
+ {@link org.hibernate.cache.access.AccessType.READ_WRITE read-write} and
+ {@link org.hibernate.cache.access.AccessType.NONSTRICT_READ_WRITE nonstrict-read-write}. The only
+ <i>synchronous</i> access strategy is {@link org.hibernate.cache.access.AccessType.TRANSACTIONAL transactional}.
+</p>
+<p>
+ Note that, for an <i>asynchronous</i> cache, cache invalidation must be a two step process (lock->unlock or
+ lock->afterUpdate), since this is the only way to guarantee consistency with the database for a nontransactional
+ cache implementation. For a <i>synchronous</i> cache, cache invalidation is a single step process (evict or update).
+ Hence, these contracts ({@link org.hibernate.cache.access.EntityRegionAcessStrategy} and
+ {@link org.hibernate.cache.access.CollectionRegionAccessStrategy}) define a three step process to cater for both
+ models (see the individual contracts for details).
+</p>
+<p>
+ Note that query result caching does not go through an access strategy; those caches are managed directly against
+ the underlying {@link org.hibernate.cache.QueryResultsRegion}.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,143 +0,0 @@
-//$Id: CacheEntry.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import java.io.Serializable;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.event.EventSource;
-import org.hibernate.event.PreLoadEvent;
-import org.hibernate.event.PreLoadEventListener;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.TypeFactory;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * A cached instance of a persistent class
- *
- * @author Gavin King
- */
-public final class CacheEntry implements Serializable {
-
- private final Serializable[] disassembledState;
- private final String subclass;
- private final boolean lazyPropertiesAreUnfetched;
- private final Object version;
-
- public String getSubclass() {
- return subclass;
- }
-
- public boolean areLazyPropertiesUnfetched() {
- return lazyPropertiesAreUnfetched;
- }
-
- public CacheEntry(
- final Object[] state,
- final EntityPersister persister,
- final boolean unfetched,
- final Object version,
- final SessionImplementor session,
- final Object owner)
- throws HibernateException {
- //disassembled state gets put in a new array (we write to cache by value!)
- this.disassembledState = TypeFactory.disassemble(
- state,
- persister.getPropertyTypes(),
- persister.isLazyPropertiesCacheable() ?
- null : persister.getPropertyLaziness(),
- session,
- owner
- );
- subclass = persister.getEntityName();
- lazyPropertiesAreUnfetched = unfetched || !persister.isLazyPropertiesCacheable();
- this.version = version;
- }
-
- public Object getVersion() {
- return version;
- }
-
- CacheEntry(Serializable[] state, String subclass, boolean unfetched, Object version) {
- this.disassembledState = state;
- this.subclass = subclass;
- this.lazyPropertiesAreUnfetched = unfetched;
- this.version = version;
- }
-
- public Object[] assemble(
- final Object instance,
- final Serializable id,
- final EntityPersister persister,
- final Interceptor interceptor,
- final EventSource session)
- throws HibernateException {
-
- if ( !persister.getEntityName().equals(subclass) ) {
- throw new AssertionFailure("Tried to assemble a different subclass instance");
- }
-
- return assemble(disassembledState, instance, id, persister, interceptor, session);
-
- }
-
- private static Object[] assemble(
- final Serializable[] values,
- final Object result,
- final Serializable id,
- final EntityPersister persister,
- final Interceptor interceptor,
- final EventSource session)
- throws HibernateException {
-
- //assembled state gets put in a new array (we read from cache by value!)
- Object[] assembledProps = TypeFactory.assemble(
- values,
- persister.getPropertyTypes(),
- session, result
- );
-
- //persister.setIdentifier(result, id); //before calling interceptor, for consistency with normal load
-
- //TODO: reuse the PreLoadEvent
- PreLoadEvent preLoadEvent = new PreLoadEvent( session )
- .setEntity(result)
- .setState(assembledProps)
- .setId(id)
- .setPersister(persister);
-
- PreLoadEventListener[] listeners = session.getListeners().getPreLoadEventListeners();
- for ( int i = 0; i < listeners.length; i++ ) {
- listeners[i].onPreLoad(preLoadEvent);
- }
-
- persister.setPropertyValues(
- result,
- assembledProps,
- session.getEntityMode()
- );
-
- return assembledProps;
- }
-
- public Serializable[] getDisassembledState() {
- // todo: this was added to support initializing an entity's EntityEntry snapshot during reattach;
- // this should be refactored to instead expose a method to assemble a EntityEntry based on this
- // state for return.
- return disassembledState;
- }
-
- public String toString() {
- return "CacheEntry(" + subclass + ')' +
- ArrayHelper.toString(disassembledState);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,166 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import java.io.Serializable;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.event.EventSource;
+import org.hibernate.event.PreLoadEvent;
+import org.hibernate.event.PreLoadEventListener;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.TypeFactory;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * A cached instance of a persistent class
+ *
+ * @author Gavin King
+ */
+public final class CacheEntry implements Serializable {
+
+ private final Serializable[] disassembledState;
+ private final String subclass;
+ private final boolean lazyPropertiesAreUnfetched;
+ private final Object version;
+
+ public String getSubclass() {
+ return subclass;
+ }
+
+ public boolean areLazyPropertiesUnfetched() {
+ return lazyPropertiesAreUnfetched;
+ }
+
+ public CacheEntry(
+ final Object[] state,
+ final EntityPersister persister,
+ final boolean unfetched,
+ final Object version,
+ final SessionImplementor session,
+ final Object owner)
+ throws HibernateException {
+ //disassembled state gets put in a new array (we write to cache by value!)
+ this.disassembledState = TypeFactory.disassemble(
+ state,
+ persister.getPropertyTypes(),
+ persister.isLazyPropertiesCacheable() ?
+ null : persister.getPropertyLaziness(),
+ session,
+ owner
+ );
+ subclass = persister.getEntityName();
+ lazyPropertiesAreUnfetched = unfetched || !persister.isLazyPropertiesCacheable();
+ this.version = version;
+ }
+
+ public Object getVersion() {
+ return version;
+ }
+
+ CacheEntry(Serializable[] state, String subclass, boolean unfetched, Object version) {
+ this.disassembledState = state;
+ this.subclass = subclass;
+ this.lazyPropertiesAreUnfetched = unfetched;
+ this.version = version;
+ }
+
+ public Object[] assemble(
+ final Object instance,
+ final Serializable id,
+ final EntityPersister persister,
+ final Interceptor interceptor,
+ final EventSource session)
+ throws HibernateException {
+
+ if ( !persister.getEntityName().equals(subclass) ) {
+ throw new AssertionFailure("Tried to assemble a different subclass instance");
+ }
+
+ return assemble(disassembledState, instance, id, persister, interceptor, session);
+
+ }
+
+ private static Object[] assemble(
+ final Serializable[] values,
+ final Object result,
+ final Serializable id,
+ final EntityPersister persister,
+ final Interceptor interceptor,
+ final EventSource session)
+ throws HibernateException {
+
+ //assembled state gets put in a new array (we read from cache by value!)
+ Object[] assembledProps = TypeFactory.assemble(
+ values,
+ persister.getPropertyTypes(),
+ session, result
+ );
+
+ //persister.setIdentifier(result, id); //before calling interceptor, for consistency with normal load
+
+ //TODO: reuse the PreLoadEvent
+ PreLoadEvent preLoadEvent = new PreLoadEvent( session )
+ .setEntity(result)
+ .setState(assembledProps)
+ .setId(id)
+ .setPersister(persister);
+
+ PreLoadEventListener[] listeners = session.getListeners().getPreLoadEventListeners();
+ for ( int i = 0; i < listeners.length; i++ ) {
+ listeners[i].onPreLoad(preLoadEvent);
+ }
+
+ persister.setPropertyValues(
+ result,
+ assembledProps,
+ session.getEntityMode()
+ );
+
+ return assembledProps;
+ }
+
+ public Serializable[] getDisassembledState() {
+ // todo: this was added to support initializing an entity's EntityEntry snapshot during reattach;
+ // this should be refactored to instead expose a method to assemble a EntityEntry based on this
+ // state for return.
+ return disassembledState;
+ }
+
+ public String toString() {
+ return "CacheEntry(" + subclass + ')' +
+ ArrayHelper.toString(disassembledState);
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,14 +0,0 @@
-//$Id: CacheEntryStructure.java 5707 2005-02-13 12:47:01Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-
-
-
-/**
- * @author Gavin King
- */
-public interface CacheEntryStructure {
- public Object structure(Object item);
- public Object destructure(Object map, SessionFactoryImplementor factory);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CacheEntryStructure.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+
+
+/**
+ * @author Gavin King
+ */
+public interface CacheEntryStructure {
+ public Object structure(Object item);
+ public Object destructure(Object map, SessionFactoryImplementor factory);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,43 +0,0 @@
-//$Id: CollectionCacheEntry.java 6838 2005-05-20 19:50:07Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import java.io.Serializable;
-
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * @author Gavin King
- */
-public class CollectionCacheEntry implements Serializable {
-
- private final Serializable state;
-
- public Serializable[] getState() {
- //TODO: assumes all collections disassemble to an array!
- return (Serializable[]) state;
- }
-
- public CollectionCacheEntry(PersistentCollection collection, CollectionPersister persister) {
- this.state = collection.disassemble(persister);
- }
-
- CollectionCacheEntry(Serializable state) {
- this.state = state;
- }
-
- public void assemble(
- final PersistentCollection collection,
- final CollectionPersister persister,
- final Object owner
- ) {
- collection.initializeFromCache(persister, state, owner);
- collection.afterInitialize();
- }
-
- public String toString() {
- return "CollectionCacheEntry" + ArrayHelper.toString( getState() );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/CollectionCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,66 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import java.io.Serializable;
+
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * @author Gavin King
+ */
+public class CollectionCacheEntry implements Serializable {
+
+ private final Serializable state;
+
+ public Serializable[] getState() {
+ //TODO: assumes all collections disassemble to an array!
+ return (Serializable[]) state;
+ }
+
+ public CollectionCacheEntry(PersistentCollection collection, CollectionPersister persister) {
+ this.state = collection.disassemble(persister);
+ }
+
+ CollectionCacheEntry(Serializable state) {
+ this.state = state;
+ }
+
+ public void assemble(
+ final PersistentCollection collection,
+ final CollectionPersister persister,
+ final Object owner
+ ) {
+ collection.initializeFromCache(persister, state, owner);
+ collection.afterInitialize();
+ }
+
+ public String toString() {
+ return "CollectionCacheEntry" + ArrayHelper.toString( getState() );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,48 +0,0 @@
-//$Id: StructuredCacheEntry.java 7764 2005-08-05 16:16:46Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.persister.entity.EntityPersister;
-
-/**
- * @author Gavin King
- */
-public class StructuredCacheEntry implements CacheEntryStructure {
-
- private EntityPersister persister;
-
- public StructuredCacheEntry(EntityPersister persister) {
- this.persister = persister;
- }
-
- public Object destructure(Object item, SessionFactoryImplementor factory) {
- Map map = (Map) item;
- boolean lazyPropertiesUnfetched = ( (Boolean) map.get("_lazyPropertiesUnfetched") ).booleanValue();
- String subclass = (String) map.get("_subclass");
- Object version = map.get("_version");
- EntityPersister subclassPersister = factory.getEntityPersister(subclass);
- String[] names = subclassPersister.getPropertyNames();
- Serializable[] state = new Serializable[names.length];
- for ( int i=0; i<names.length; i++ ) {
- state[i] = (Serializable) map.get( names[i] );
- }
- return new CacheEntry(state, subclass, lazyPropertiesUnfetched, version);
- }
-
- public Object structure(Object item) {
- CacheEntry entry = (CacheEntry) item;
- String[] names = persister.getPropertyNames();
- Map map = new HashMap(names.length+2);
- map.put( "_subclass", entry.getSubclass() );
- map.put( "_version", entry.getVersion() );
- map.put( "_lazyPropertiesUnfetched", entry.areLazyPropertiesUnfetched() ? Boolean.TRUE : Boolean.FALSE );
- for ( int i=0; i<names.length; i++ ) {
- map.put( names[i], entry.getDisassembledState()[i] );
- }
- return map;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,71 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * @author Gavin King
+ */
+public class StructuredCacheEntry implements CacheEntryStructure {
+
+ private EntityPersister persister;
+
+ public StructuredCacheEntry(EntityPersister persister) {
+ this.persister = persister;
+ }
+
+ public Object destructure(Object item, SessionFactoryImplementor factory) {
+ Map map = (Map) item;
+ boolean lazyPropertiesUnfetched = ( (Boolean) map.get("_lazyPropertiesUnfetched") ).booleanValue();
+ String subclass = (String) map.get("_subclass");
+ Object version = map.get("_version");
+ EntityPersister subclassPersister = factory.getEntityPersister(subclass);
+ String[] names = subclassPersister.getPropertyNames();
+ Serializable[] state = new Serializable[names.length];
+ for ( int i=0; i<names.length; i++ ) {
+ state[i] = (Serializable) map.get( names[i] );
+ }
+ return new CacheEntry(state, subclass, lazyPropertiesUnfetched, version);
+ }
+
+ public Object structure(Object item) {
+ CacheEntry entry = (CacheEntry) item;
+ String[] names = persister.getPropertyNames();
+ Map map = new HashMap(names.length+2);
+ map.put( "_subclass", entry.getSubclass() );
+ map.put( "_version", entry.getVersion() );
+ map.put( "_lazyPropertiesUnfetched", entry.areLazyPropertiesUnfetched() ? Boolean.TRUE : Boolean.FALSE );
+ for ( int i=0; i<names.length; i++ ) {
+ map.put( names[i], entry.getDisassembledState()[i] );
+ }
+ return map;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,25 +0,0 @@
-//$Id: StructuredCollectionCacheEntry.java 5707 2005-02-13 12:47:01Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * @author Gavin King
- */
-public class StructuredCollectionCacheEntry implements CacheEntryStructure {
-
- public Object structure(Object item) {
- CollectionCacheEntry entry = (CollectionCacheEntry) item;
- return Arrays.asList( entry.getState() );
- }
-
- public Object destructure(Object item, SessionFactoryImplementor factory) {
- List list = (List) item;
- return new CollectionCacheEntry( list.toArray( new Serializable[list.size()] ) );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredCollectionCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,48 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * @author Gavin King
+ */
+public class StructuredCollectionCacheEntry implements CacheEntryStructure {
+
+ public Object structure(Object item) {
+ CollectionCacheEntry entry = (CollectionCacheEntry) item;
+ return Arrays.asList( entry.getState() );
+ }
+
+ public Object destructure(Object item, SessionFactoryImplementor factory) {
+ List list = (List) item;
+ return new CollectionCacheEntry( list.toArray( new Serializable[list.size()] ) );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,39 +0,0 @@
-//$Id: StructuredMapCacheEntry.java 5707 2005-02-13 12:47:01Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * @author Gavin King
- */
-public class StructuredMapCacheEntry implements CacheEntryStructure {
-
- public Object structure(Object item) {
- CollectionCacheEntry entry = (CollectionCacheEntry) item;
- Serializable[] state = entry.getState();
- Map map = new HashMap(state.length);
- for ( int i=0; i<state.length; ) {
- map.put( state[i++], state[i++] );
- }
- return map;
- }
-
- public Object destructure(Object item, SessionFactoryImplementor factory) {
- Map map = (Map) item;
- Serializable[] state = new Serializable[ map.size()*2 ];
- int i=0;
- Iterator iter = map.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry me = (Map.Entry) iter.next();
- state[i++] = (Serializable) me.getKey();
- state[i++] = (Serializable) me.getValue();
- }
- return new CollectionCacheEntry(state);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/StructuredMapCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,62 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * @author Gavin King
+ */
+public class StructuredMapCacheEntry implements CacheEntryStructure {
+
+ public Object structure(Object item) {
+ CollectionCacheEntry entry = (CollectionCacheEntry) item;
+ Serializable[] state = entry.getState();
+ Map map = new HashMap(state.length);
+ for ( int i=0; i<state.length; ) {
+ map.put( state[i++], state[i++] );
+ }
+ return map;
+ }
+
+ public Object destructure(Object item, SessionFactoryImplementor factory) {
+ Map map = (Map) item;
+ Serializable[] state = new Serializable[ map.size()*2 ];
+ int i=0;
+ Iterator iter = map.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry me = (Map.Entry) iter.next();
+ state[i++] = (Serializable) me.getKey();
+ state[i++] = (Serializable) me.getValue();
+ }
+ return new CollectionCacheEntry(state);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,20 +0,0 @@
-//$Id: UnstructuredCacheEntry.java 5707 2005-02-13 12:47:01Z oneovthafew $
-package org.hibernate.cache.entry;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-
-
-/**
- * @author Gavin King
- */
-public class UnstructuredCacheEntry implements CacheEntryStructure {
-
- public Object structure(Object item) {
- return item;
- }
-
- public Object destructure(Object map, SessionFactoryImplementor factory) {
- return map;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/UnstructuredCacheEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.entry;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+
+
+/**
+ * @author Gavin King
+ */
+public class UnstructuredCacheEntry implements CacheEntryStructure {
+
+ public Object structure(Object item) {
+ return item;
+ }
+
+ public Object destructure(Object map, SessionFactoryImplementor factory) {
+ return map;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/entry/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-<p>
- This package defines formats for disassembled state
- kept in the second level cache.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/entry/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/entry/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,35 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head>
+</head>
+<body>
+<p>
+ This package defines formats for disassembled state
+ kept in the second level cache.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,53 +0,0 @@
-package org.hibernate.cache.impl;
-
-import java.util.Comparator;
-
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Collection;
-import org.hibernate.type.VersionType;
-
-/**
- * {@inheritDoc}
- *
- * @author Steve Ebersole
- */
-public class CacheDataDescriptionImpl implements CacheDataDescription {
- private final boolean mutable;
- private final boolean versioned;
- private final Comparator versionComparator;
-
- public CacheDataDescriptionImpl(boolean mutable, boolean versioned, Comparator versionComparator) {
- this.mutable = mutable;
- this.versioned = versioned;
- this.versionComparator = versionComparator;
- }
-
- public boolean isMutable() {
- return mutable;
- }
-
- public boolean isVersioned() {
- return versioned;
- }
-
- public Comparator getVersionComparator() {
- return versionComparator;
- }
-
- public static CacheDataDescriptionImpl decode(PersistentClass model) {
- return new CacheDataDescriptionImpl(
- model.isMutable(),
- model.isVersioned(),
- model.isVersioned() ? ( ( VersionType ) model.getVersion().getType() ).getComparator() : null
- );
- }
-
- public static CacheDataDescriptionImpl decode(Collection model) {
- return new CacheDataDescriptionImpl(
- model.isMutable(),
- model.getOwner().isVersioned(),
- model.getOwner().isVersioned() ? ( ( VersionType ) model.getOwner().getVersion().getType() ).getComparator() : null
- );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/CacheDataDescriptionImpl.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,77 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl;
+
+import java.util.Comparator;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Collection;
+import org.hibernate.type.VersionType;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class CacheDataDescriptionImpl implements CacheDataDescription {
+ private final boolean mutable;
+ private final boolean versioned;
+ private final Comparator versionComparator;
+
+ public CacheDataDescriptionImpl(boolean mutable, boolean versioned, Comparator versionComparator) {
+ this.mutable = mutable;
+ this.versioned = versioned;
+ this.versionComparator = versionComparator;
+ }
+
+ public boolean isMutable() {
+ return mutable;
+ }
+
+ public boolean isVersioned() {
+ return versioned;
+ }
+
+ public Comparator getVersionComparator() {
+ return versionComparator;
+ }
+
+ public static CacheDataDescriptionImpl decode(PersistentClass model) {
+ return new CacheDataDescriptionImpl(
+ model.isMutable(),
+ model.isVersioned(),
+ model.isVersioned() ? ( ( VersionType ) model.getVersion().getType() ).getComparator() : null
+ );
+ }
+
+ public static CacheDataDescriptionImpl decode(Collection model) {
+ return new CacheDataDescriptionImpl(
+ model.isMutable(),
+ model.getOwner().isVersioned(),
+ model.getOwner().isVersioned() ? ( ( VersionType ) model.getOwner().getVersion().getType() ).getComparator() : null
+ );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,57 +0,0 @@
-package org.hibernate.cache.impl;
-
-import java.util.Properties;
-
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.QueryResultsRegion;
-import org.hibernate.cache.TimestampsRegion;
-import org.hibernate.cache.NoCachingEnabledException;
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cfg.Settings;
-
-/**
- * Factory used if no caching enabled in config...
- *
- * @author Steve Ebersole
- */
-public class NoCachingRegionFactory implements RegionFactory {
-
-
- public NoCachingRegionFactory(Properties properties) {
- }
-
- public void start(Settings settings, Properties properties) throws CacheException {
- }
-
- public void stop() {
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- return false;
- }
-
- public long nextTimestamp() {
- return System.currentTimeMillis() / 100;
- }
-
- public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
- throws CacheException {
- throw new NoCachingEnabledException();
- }
-
- public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
- throws CacheException {
- throw new NoCachingEnabledException();
- }
-
- public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
- throw new NoCachingEnabledException();
- }
-
- public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
- throw new NoCachingEnabledException();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/NoCachingRegionFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl;
+
+import java.util.Properties;
+
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.NoCachingEnabledException;
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Factory used if no caching enabled in config...
+ *
+ * @author Steve Ebersole
+ */
+public class NoCachingRegionFactory implements RegionFactory {
+
+
+ public NoCachingRegionFactory(Properties properties) {
+ }
+
+ public void start(Settings settings, Properties properties) throws CacheException {
+ }
+
+ public void stop() {
+ }
+
+ public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+ public long nextTimestamp() {
+ return System.currentTimeMillis() / 100;
+ }
+
+ public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
+ throws CacheException {
+ throw new NoCachingEnabledException();
+ }
+
+ public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
+ throws CacheException {
+ throw new NoCachingEnabledException();
+ }
+
+ public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
+ throw new NoCachingEnabledException();
+ }
+
+ public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
+ throw new NoCachingEnabledException();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,34 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.hibernate.cache.GeneralDataRegion;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cfg.Settings;
-
-/**
- * {@inheritDoc}
-*
-* @author Steve Ebersole
-*/
-public abstract class BaseGeneralDataRegionAdapter extends BaseRegionAdapter implements GeneralDataRegion {
-
- protected BaseGeneralDataRegionAdapter(Cache underlyingCache, Settings settings) {
- super( underlyingCache, settings );
- }
-
- public Object get(Object key) throws CacheException {
- return underlyingCache.get( key );
- }
-
- public void put(Object key, Object value) throws CacheException {
- underlyingCache.put( key, value );
- }
-
- public void evict(Object key) throws CacheException {
- underlyingCache.remove( key );
- }
-
- public void evictAll() throws CacheException {
- underlyingCache.clear();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseGeneralDataRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.hibernate.cache.GeneralDataRegion;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cfg.Settings;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public abstract class BaseGeneralDataRegionAdapter extends BaseRegionAdapter implements GeneralDataRegion {
+
+ protected BaseGeneralDataRegionAdapter(Cache underlyingCache, Settings settings) {
+ super( underlyingCache, settings );
+ }
+
+ public Object get(Object key) throws CacheException {
+ return underlyingCache.get( key );
+ }
+
+ public void put(Object key, Object value) throws CacheException {
+ underlyingCache.put( key, value );
+ }
+
+ public void evict(Object key) throws CacheException {
+ underlyingCache.remove( key );
+ }
+
+ public void evictAll() throws CacheException {
+ underlyingCache.clear();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,59 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import java.util.Map;
-
-import org.hibernate.cache.Region;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cfg.Settings;
-
-/**
- * Basic adapter bridging between {@link Region} and {@link Cache}.
- *
- * @author Steve Ebersole
- */
-public abstract class BaseRegionAdapter implements Region {
- protected final Cache underlyingCache;
- protected final Settings settings;
-
- protected BaseRegionAdapter(Cache underlyingCache, Settings settings) {
- this.underlyingCache = underlyingCache;
- this.settings = settings;
- }
-
- public String getName() {
- return underlyingCache.getRegionName();
- }
-
- public void clear() throws CacheException {
- underlyingCache.clear();
- }
-
- public void destroy() throws CacheException {
- underlyingCache.destroy();
- }
-
- public long getSizeInMemory() {
- return underlyingCache.getSizeInMemory();
- }
-
- public long getElementCountInMemory() {
- return underlyingCache.getElementCountInMemory();
- }
-
- public long getElementCountOnDisk() {
- return underlyingCache.getElementCountOnDisk();
- }
-
- public Map toMap() {
- return underlyingCache.toMap();
- }
-
- public long nextTimestamp() {
- return underlyingCache.nextTimestamp();
- }
-
- public int getTimeout() {
- return underlyingCache.getTimeout();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import java.util.Map;
+
+import org.hibernate.cache.Region;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Basic adapter bridging between {@link Region} and {@link Cache}.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class BaseRegionAdapter implements Region {
+ protected final Cache underlyingCache;
+ protected final Settings settings;
+
+ protected BaseRegionAdapter(Cache underlyingCache, Settings settings) {
+ this.underlyingCache = underlyingCache;
+ this.settings = settings;
+ }
+
+ public String getName() {
+ return underlyingCache.getRegionName();
+ }
+
+ public void clear() throws CacheException {
+ underlyingCache.clear();
+ }
+
+ public void destroy() throws CacheException {
+ underlyingCache.destroy();
+ }
+
+ public long getSizeInMemory() {
+ return underlyingCache.getSizeInMemory();
+ }
+
+ public long getElementCountInMemory() {
+ return underlyingCache.getElementCountInMemory();
+ }
+
+ public long getElementCountOnDisk() {
+ return underlyingCache.getElementCountOnDisk();
+ }
+
+ public Map toMap() {
+ return underlyingCache.toMap();
+ }
+
+ public long nextTimestamp() {
+ return underlyingCache.nextTimestamp();
+ }
+
+ public int getTimeout() {
+ return underlyingCache.getTimeout();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.hibernate.cache.TransactionalDataRegion;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cfg.Settings;
-
-/**
- * {@inheritDoc}
-*
-* @author Steve Ebersole
-*/
-public abstract class BaseTransactionalDataRegionAdapter
- extends BaseRegionAdapter
- implements TransactionalDataRegion {
-
- protected final CacheDataDescription metadata;
-
- protected BaseTransactionalDataRegionAdapter(Cache underlyingCache, Settings settings, CacheDataDescription metadata) {
- super( underlyingCache, settings );
- this.metadata = metadata;
- }
-
- public boolean isTransactionAware() {
- return underlyingCache instanceof org.hibernate.cache.TransactionAwareCache;
- }
-
- public CacheDataDescription getCacheDataDescription() {
- return metadata;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/BaseTransactionalDataRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.hibernate.cache.TransactionalDataRegion;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cfg.Settings;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public abstract class BaseTransactionalDataRegionAdapter
+ extends BaseRegionAdapter
+ implements TransactionalDataRegion {
+
+ protected final CacheDataDescription metadata;
+
+ protected BaseTransactionalDataRegionAdapter(Cache underlyingCache, Settings settings, CacheDataDescription metadata) {
+ super( underlyingCache, settings );
+ this.metadata = metadata;
+ }
+
+ public boolean isTransactionAware() {
+ return underlyingCache instanceof org.hibernate.cache.TransactionAwareCache;
+ }
+
+ public CacheDataDescription getCacheDataDescription() {
+ return metadata;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,91 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cache.CacheConcurrencyStrategy;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically bridging {@link CollectionRegionAccessStrategy} to {@link CacheConcurrencyStrategy}.
- *
- * @author Steve Ebersole
- */
-public class CollectionAccessStrategyAdapter implements CollectionRegionAccessStrategy {
- private final CollectionRegion region;
- private final CacheConcurrencyStrategy ccs;
- private final Settings settings;
-
- public CollectionAccessStrategyAdapter(CollectionRegion region, CacheConcurrencyStrategy ccs, Settings settings) {
- this.region = region;
- this.ccs = ccs;
- this.settings = settings;
- }
-
- public CollectionRegion getRegion() {
- return region;
- }
-
- public Object get(Object key, long txTimestamp) throws CacheException {
- return ccs.get( key, txTimestamp );
- }
-
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
- return putFromLoad( key, value, txTimestamp, version, settings.isMinimalPutsEnabled() );
- }
-
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- boolean minimalPutOverride) throws CacheException {
- return ccs.put( key, value, txTimestamp, version, region.getCacheDataDescription().getVersionComparator(), minimalPutOverride );
- }
-
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- return ccs.lock( key, version );
- }
-
- public SoftLock lockRegion() throws CacheException {
- // no-op; CCS did not have such a concept
- return null;
- }
-
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- ccs.release( key, lock );
- }
-
- public void unlockRegion(SoftLock lock) throws CacheException {
- // again, CCS did not have such a concept; but a reasonable
- // proximity is to clear the cache after transaction *as long as*
- // the underlying cache is not JTA aware.
- if ( !region.isTransactionAware() ) {
- ccs.clear();
- }
- }
-
- public void remove(Object key) throws CacheException {
- ccs.evict( key );
- }
-
- public void removeAll() throws CacheException {
- // again, CCS did not have such a concept; however a reasonable
- // proximity is to clear the cache. For non-transaction aware
- // caches, we will also do a clear at the end of the transaction
- ccs.clear();
- }
-
- public void evict(Object key) throws CacheException {
- ccs.remove( key );
- }
-
- public void evictAll() throws CacheException {
- ccs.clear();
- }
-
- public void destroy() {
- ccs.destroy();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionAccessStrategyAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,115 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cache.CacheConcurrencyStrategy;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Adapter specifically bridging {@link CollectionRegionAccessStrategy} to {@link CacheConcurrencyStrategy}.
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionAccessStrategyAdapter implements CollectionRegionAccessStrategy {
+ private final CollectionRegion region;
+ private final CacheConcurrencyStrategy ccs;
+ private final Settings settings;
+
+ public CollectionAccessStrategyAdapter(CollectionRegion region, CacheConcurrencyStrategy ccs, Settings settings) {
+ this.region = region;
+ this.ccs = ccs;
+ this.settings = settings;
+ }
+
+ public CollectionRegion getRegion() {
+ return region;
+ }
+
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ return ccs.get( key, txTimestamp );
+ }
+
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
+ return putFromLoad( key, value, txTimestamp, version, settings.isMinimalPutsEnabled() );
+ }
+
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ boolean minimalPutOverride) throws CacheException {
+ return ccs.put( key, value, txTimestamp, version, region.getCacheDataDescription().getVersionComparator(), minimalPutOverride );
+ }
+
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ return ccs.lock( key, version );
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ // no-op; CCS did not have such a concept
+ return null;
+ }
+
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ ccs.release( key, lock );
+ }
+
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ // again, CCS did not have such a concept; but a reasonable
+ // proximity is to clear the cache after transaction *as long as*
+ // the underlying cache is not JTA aware.
+ if ( !region.isTransactionAware() ) {
+ ccs.clear();
+ }
+ }
+
+ public void remove(Object key) throws CacheException {
+ ccs.evict( key );
+ }
+
+ public void removeAll() throws CacheException {
+ // again, CCS did not have such a concept; however a reasonable
+ // proximity is to clear the cache. For non-transaction aware
+ // caches, we will also do a clear at the end of the transaction
+ ccs.clear();
+ }
+
+ public void evict(Object key) throws CacheException {
+ ccs.remove( key );
+ }
+
+ public void evictAll() throws CacheException {
+ ccs.clear();
+ }
+
+ public void destroy() {
+ ccs.destroy();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,58 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.OptimisticCache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheConcurrencyStrategy;
-import org.hibernate.cache.TransactionalCache;
-import org.hibernate.cache.ReadWriteCache;
-import org.hibernate.cache.NonstrictReadWriteCache;
-import org.hibernate.cache.ReadOnlyCache;
-import org.hibernate.cache.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.access.AccessType;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically bridging {@link CollectionRegion} to {@link Cache}.
- *
- * @author Steve Ebersole
- */
-public class CollectionRegionAdapter extends BaseTransactionalDataRegionAdapter implements CollectionRegion {
- private static final Logger log = LoggerFactory.getLogger( CollectionRegionAdapter.class );
-
- public CollectionRegionAdapter(Cache underlyingCache, Settings settings, CacheDataDescription metadata) {
- super( underlyingCache, settings, metadata );
- if ( underlyingCache instanceof OptimisticCache ) {
- ( ( OptimisticCache ) underlyingCache ).setSource( new OptimisticCacheSourceAdapter( metadata ) );
- }
- }
-
- public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- CacheConcurrencyStrategy ccs;
- if ( AccessType.READ_ONLY.equals( accessType ) ) {
- if ( metadata.isMutable() ) {
- log.warn( "read-only cache configured for mutable collection [" + getName() + "]" );
- }
- ccs = new ReadOnlyCache();
- }
- else if ( AccessType.READ_WRITE.equals( accessType ) ) {
- ccs = new ReadWriteCache();
- }
- else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) {
- ccs = new NonstrictReadWriteCache();
- }
- else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
- ccs = new TransactionalCache();
- }
- else {
- throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
- }
- ccs.setCache( underlyingCache );
- return new CollectionAccessStrategyAdapter( this, ccs, settings );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,82 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.OptimisticCache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheConcurrencyStrategy;
+import org.hibernate.cache.TransactionalCache;
+import org.hibernate.cache.ReadWriteCache;
+import org.hibernate.cache.NonstrictReadWriteCache;
+import org.hibernate.cache.ReadOnlyCache;
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.AccessType;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Adapter specifically bridging {@link CollectionRegion} to {@link Cache}.
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionRegionAdapter extends BaseTransactionalDataRegionAdapter implements CollectionRegion {
+ private static final Logger log = LoggerFactory.getLogger( CollectionRegionAdapter.class );
+
+ public CollectionRegionAdapter(Cache underlyingCache, Settings settings, CacheDataDescription metadata) {
+ super( underlyingCache, settings, metadata );
+ if ( underlyingCache instanceof OptimisticCache ) {
+ ( ( OptimisticCache ) underlyingCache ).setSource( new OptimisticCacheSourceAdapter( metadata ) );
+ }
+ }
+
+ public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ CacheConcurrencyStrategy ccs;
+ if ( AccessType.READ_ONLY.equals( accessType ) ) {
+ if ( metadata.isMutable() ) {
+ log.warn( "read-only cache configured for mutable collection [" + getName() + "]" );
+ }
+ ccs = new ReadOnlyCache();
+ }
+ else if ( AccessType.READ_WRITE.equals( accessType ) ) {
+ ccs = new ReadWriteCache();
+ }
+ else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) {
+ ccs = new NonstrictReadWriteCache();
+ }
+ else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
+ ccs = new TransactionalCache();
+ }
+ else {
+ throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
+ }
+ ccs.setCache( underlyingCache );
+ return new CollectionAccessStrategyAdapter( this, ccs, settings );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,109 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.hibernate.cache.CacheConcurrencyStrategy;
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.access.SoftLock;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically bridging {@link EntityRegionAccessStrategy} to {@link CacheConcurrencyStrategy}.
- *
- * @author Steve Ebersole
- */
-public class EntityAccessStrategyAdapter implements EntityRegionAccessStrategy {
- private final EntityRegion region;
- private final CacheConcurrencyStrategy ccs;
- private final Settings settings;
-
- public EntityAccessStrategyAdapter(EntityRegion region, CacheConcurrencyStrategy ccs, Settings settings) {
- this.region = region;
- this.ccs = ccs;
- this.settings = settings;
- }
-
- public EntityRegion getRegion() {
- return region;
- }
-
- public Object get(Object key, long txTimestamp) throws CacheException {
- return ccs.get( key, txTimestamp );
- }
-
- public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
- return putFromLoad( key, value, txTimestamp, version, settings.isMinimalPutsEnabled() );
- }
-
- public boolean putFromLoad(
- Object key,
- Object value,
- long txTimestamp,
- Object version,
- boolean minimalPutOverride) throws CacheException {
- return ccs.put( key, value, txTimestamp, version, region.getCacheDataDescription().getVersionComparator(), minimalPutOverride );
- }
-
- public SoftLock lockItem(Object key, Object version) throws CacheException {
- return ccs.lock( key, version );
- }
-
- public SoftLock lockRegion() throws CacheException {
- // no-op; CCS did not have such a concept
- return null;
- }
-
- public void unlockItem(Object key, SoftLock lock) throws CacheException {
- ccs.release( key, lock );
- }
-
- public void unlockRegion(SoftLock lock) throws CacheException {
- // again, CCS did not have such a concept; but a reasonable
- // proximity is to clear the cache after transaction *as long as*
- // the underlying cache is not JTA aware.
- if ( !region.isTransactionAware() ) {
- ccs.clear();
- }
- }
-
- public boolean insert(Object key, Object value, Object version) throws CacheException {
- return ccs.insert( key, value, version );
- }
-
- public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
- return ccs.afterInsert( key, value, version );
- }
-
- public boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
- throws CacheException {
- return ccs.update( key, value, currentVersion, previousVersion );
- }
-
- public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
- throws CacheException {
- return ccs.afterUpdate( key, value, currentVersion, lock );
- }
-
- public void remove(Object key) throws CacheException {
- ccs.evict( key );
- }
-
- public void removeAll() throws CacheException {
- // again, CCS did not have such a concept; however a reasonable
- // proximity is to clear the cache. For non-transaction aware
- // caches, we will also do a clear at the end of the transaction
- ccs.clear();
- }
-
- public void evict(Object key) throws CacheException {
- ccs.remove( key );
- }
-
- public void evictAll() throws CacheException {
- ccs.clear();
- }
-
- public void destroy() {
- ccs.destroy();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityAccessStrategyAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,133 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.hibernate.cache.CacheConcurrencyStrategy;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Adapter specifically bridging {@link EntityRegionAccessStrategy} to {@link CacheConcurrencyStrategy}.
+ *
+ * @author Steve Ebersole
+ */
+public class EntityAccessStrategyAdapter implements EntityRegionAccessStrategy {
+ private final EntityRegion region;
+ private final CacheConcurrencyStrategy ccs;
+ private final Settings settings;
+
+ public EntityAccessStrategyAdapter(EntityRegion region, CacheConcurrencyStrategy ccs, Settings settings) {
+ this.region = region;
+ this.ccs = ccs;
+ this.settings = settings;
+ }
+
+ public EntityRegion getRegion() {
+ return region;
+ }
+
+ public Object get(Object key, long txTimestamp) throws CacheException {
+ return ccs.get( key, txTimestamp );
+ }
+
+ public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
+ return putFromLoad( key, value, txTimestamp, version, settings.isMinimalPutsEnabled() );
+ }
+
+ public boolean putFromLoad(
+ Object key,
+ Object value,
+ long txTimestamp,
+ Object version,
+ boolean minimalPutOverride) throws CacheException {
+ return ccs.put( key, value, txTimestamp, version, region.getCacheDataDescription().getVersionComparator(), minimalPutOverride );
+ }
+
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ return ccs.lock( key, version );
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ // no-op; CCS did not have such a concept
+ return null;
+ }
+
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ ccs.release( key, lock );
+ }
+
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ // again, CCS did not have such a concept; but a reasonable
+ // proximity is to clear the cache after transaction *as long as*
+ // the underlying cache is not JTA aware.
+ if ( !region.isTransactionAware() ) {
+ ccs.clear();
+ }
+ }
+
+ public boolean insert(Object key, Object value, Object version) throws CacheException {
+ return ccs.insert( key, value, version );
+ }
+
+ public boolean afterInsert(Object key, Object value, Object version) throws CacheException {
+ return ccs.afterInsert( key, value, version );
+ }
+
+ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion)
+ throws CacheException {
+ return ccs.update( key, value, currentVersion, previousVersion );
+ }
+
+ public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
+ throws CacheException {
+ return ccs.afterUpdate( key, value, currentVersion, lock );
+ }
+
+ public void remove(Object key) throws CacheException {
+ ccs.evict( key );
+ }
+
+ public void removeAll() throws CacheException {
+ // again, CCS did not have such a concept; however a reasonable
+ // proximity is to clear the cache. For non-transaction aware
+ // caches, we will also do a clear at the end of the transaction
+ ccs.clear();
+ }
+
+ public void evict(Object key) throws CacheException {
+ ccs.remove( key );
+ }
+
+ public void evictAll() throws CacheException {
+ ccs.clear();
+ }
+
+ public void destroy() {
+ ccs.destroy();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,59 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.cache.OptimisticCache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheConcurrencyStrategy;
-import org.hibernate.cache.ReadOnlyCache;
-import org.hibernate.cache.ReadWriteCache;
-import org.hibernate.cache.NonstrictReadWriteCache;
-import org.hibernate.cache.TransactionalCache;
-import org.hibernate.cache.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.access.AccessType;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically bridging {@link EntityRegion} to {@link Cache}.
- *
- * @author Steve Ebersole
- */
-public class EntityRegionAdapter extends BaseTransactionalDataRegionAdapter implements EntityRegion {
- private static final Logger log = LoggerFactory.getLogger( EntityRegionAdapter.class );
-
- public EntityRegionAdapter(Cache underlyingCache, Settings settings, CacheDataDescription metadata) {
- super( underlyingCache, settings, metadata );
- if ( underlyingCache instanceof OptimisticCache ) {
- ( ( OptimisticCache ) underlyingCache ).setSource( new OptimisticCacheSourceAdapter( metadata ) );
- }
- }
-
- public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- CacheConcurrencyStrategy ccs;
- if ( AccessType.READ_ONLY.equals( accessType ) ) {
- if ( metadata.isMutable() ) {
- log.warn( "read-only cache configured for mutable entity [" + getName() + "]" );
- }
- ccs = new ReadOnlyCache();
- }
- else if ( AccessType.READ_WRITE.equals( accessType ) ) {
- ccs = new ReadWriteCache();
- }
- else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) {
- ccs = new NonstrictReadWriteCache();
- }
- else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
- ccs = new TransactionalCache();
- }
- else {
- throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
- }
- ccs.setCache( underlyingCache );
- return new EntityAccessStrategyAdapter( this, ccs, settings );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.OptimisticCache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CacheConcurrencyStrategy;
+import org.hibernate.cache.ReadOnlyCache;
+import org.hibernate.cache.ReadWriteCache;
+import org.hibernate.cache.NonstrictReadWriteCache;
+import org.hibernate.cache.TransactionalCache;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.AccessType;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Adapter specifically bridging {@link EntityRegion} to {@link Cache}.
+ *
+ * @author Steve Ebersole
+ */
+public class EntityRegionAdapter extends BaseTransactionalDataRegionAdapter implements EntityRegion {
+ private static final Logger log = LoggerFactory.getLogger( EntityRegionAdapter.class );
+
+ public EntityRegionAdapter(Cache underlyingCache, Settings settings, CacheDataDescription metadata) {
+ super( underlyingCache, settings, metadata );
+ if ( underlyingCache instanceof OptimisticCache ) {
+ ( ( OptimisticCache ) underlyingCache ).setSource( new OptimisticCacheSourceAdapter( metadata ) );
+ }
+ }
+
+ public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ CacheConcurrencyStrategy ccs;
+ if ( AccessType.READ_ONLY.equals( accessType ) ) {
+ if ( metadata.isMutable() ) {
+ log.warn( "read-only cache configured for mutable entity [" + getName() + "]" );
+ }
+ ccs = new ReadOnlyCache();
+ }
+ else if ( AccessType.READ_WRITE.equals( accessType ) ) {
+ ccs = new ReadWriteCache();
+ }
+ else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) {
+ ccs = new NonstrictReadWriteCache();
+ }
+ else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
+ ccs = new TransactionalCache();
+ }
+ else {
+ throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
+ }
+ ccs.setCache( underlyingCache );
+ return new EntityAccessStrategyAdapter( this, ccs, settings );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,27 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import java.util.Comparator;
-
-import org.hibernate.cache.OptimisticCacheSource;
-import org.hibernate.cache.CacheDataDescription;
-
-/**
- * {@inheritDoc}
-*
-* @author Steve Ebersole
-*/
-public class OptimisticCacheSourceAdapter implements OptimisticCacheSource {
- private final CacheDataDescription dataDescription;
-
- public OptimisticCacheSourceAdapter(CacheDataDescription dataDescription) {
- this.dataDescription = dataDescription;
- }
-
- public boolean isVersioned() {
- return dataDescription.isVersioned();
- }
-
- public Comparator getVersionComparator() {
- return dataDescription.getVersionComparator();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/OptimisticCacheSourceAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import java.util.Comparator;
+
+import org.hibernate.cache.OptimisticCacheSource;
+import org.hibernate.cache.CacheDataDescription;
+
+/**
+ * {@inheritDoc}
+*
+* @author Steve Ebersole
+*/
+public class OptimisticCacheSourceAdapter implements OptimisticCacheSource {
+ private final CacheDataDescription dataDescription;
+
+ public OptimisticCacheSourceAdapter(CacheDataDescription dataDescription) {
+ this.dataDescription = dataDescription;
+ }
+
+ public boolean isVersioned() {
+ return dataDescription.isVersioned();
+ }
+
+ public Comparator getVersionComparator() {
+ return dataDescription.getVersionComparator();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,16 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.hibernate.cache.QueryResultsRegion;
-import org.hibernate.cache.Cache;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically briding {@link QueryResultsRegion} to {@link Cache}.
-*
-* @author Steve Ebersole
- */
-public class QueryResultsRegionAdapter extends BaseGeneralDataRegionAdapter implements QueryResultsRegion {
- protected QueryResultsRegionAdapter(Cache underlyingCache, Settings settings) {
- super( underlyingCache, settings );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/QueryResultsRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.Cache;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Adapter specifically briding {@link QueryResultsRegion} to {@link Cache}.
+*
+* @author Steve Ebersole
+ */
+public class QueryResultsRegionAdapter extends BaseGeneralDataRegionAdapter implements QueryResultsRegion {
+ protected QueryResultsRegionAdapter(Cache underlyingCache, Settings settings) {
+ super( underlyingCache, settings );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,91 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.cache.CacheProvider;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.EntityRegion;
-import org.hibernate.cache.CollectionRegion;
-import org.hibernate.cache.QueryResultsRegion;
-import org.hibernate.cache.NoCacheProvider;
-import org.hibernate.cache.TimestampsRegion;
-import org.hibernate.cache.CacheDataDescription;
-import org.hibernate.util.PropertiesHelper;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.Settings;
-
-/**
- * Acts as a bridge between the {@link RegionFactory} contract and the older
- * {@link CacheProvider} contract.
- *
- * @author Steve Ebersole
- */
-public class RegionFactoryCacheProviderBridge implements RegionFactory {
- public static final String DEF_PROVIDER = NoCacheProvider.class.getName();
- private static final Logger log = LoggerFactory.getLogger( RegionFactoryCacheProviderBridge.class );
-
- private CacheProvider cacheProvider;
- private Settings settings;
-
- public RegionFactoryCacheProviderBridge(Properties properties) {
- String providerClassName = PropertiesHelper.getString( Environment.CACHE_PROVIDER, properties, DEF_PROVIDER );
- log.info( "Cache provider: " + providerClassName );
- try {
- cacheProvider = ( CacheProvider ) ReflectHelper.classForName( providerClassName ).newInstance();
- }
- catch ( Exception cnfe ) {
- throw new CacheException( "could not instantiate CacheProvider [" + providerClassName + "]", cnfe );
- }
- }
-
- public void start(Settings settings, Properties properties) throws CacheException {
- this.settings = settings;
- cacheProvider.start( properties );
- }
-
- public void stop() {
- cacheProvider.stop();
- cacheProvider = null;
- }
-
- public boolean isMinimalPutsEnabledByDefault() {
- return cacheProvider.isMinimalPutsEnabledByDefault();
- }
-
- public long nextTimestamp() {
- return cacheProvider.nextTimestamp();
- }
-
- public CacheProvider getCacheProvider() {
- return cacheProvider;
- }
-
- public EntityRegion buildEntityRegion(
- String regionName,
- Properties properties,
- CacheDataDescription metadata) throws CacheException {
- return new EntityRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings, metadata );
- }
-
- public CollectionRegion buildCollectionRegion(
- String regionName,
- Properties properties,
- CacheDataDescription metadata) throws CacheException {
- return new CollectionRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings, metadata );
- }
-
- public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
- return new QueryResultsRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings );
- }
-
- public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
- return new TimestampsRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings );
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/RegionFactoryCacheProviderBridge.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,115 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.CacheProvider;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.NoCacheProvider;
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.util.PropertiesHelper;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Acts as a bridge between the {@link RegionFactory} contract and the older
+ * {@link CacheProvider} contract.
+ *
+ * @author Steve Ebersole
+ */
+public class RegionFactoryCacheProviderBridge implements RegionFactory {
+ public static final String DEF_PROVIDER = NoCacheProvider.class.getName();
+ private static final Logger log = LoggerFactory.getLogger( RegionFactoryCacheProviderBridge.class );
+
+ private CacheProvider cacheProvider;
+ private Settings settings;
+
+ public RegionFactoryCacheProviderBridge(Properties properties) {
+ String providerClassName = PropertiesHelper.getString( Environment.CACHE_PROVIDER, properties, DEF_PROVIDER );
+ log.info( "Cache provider: " + providerClassName );
+ try {
+ cacheProvider = ( CacheProvider ) ReflectHelper.classForName( providerClassName ).newInstance();
+ }
+ catch ( Exception cnfe ) {
+ throw new CacheException( "could not instantiate CacheProvider [" + providerClassName + "]", cnfe );
+ }
+ }
+
+ public void start(Settings settings, Properties properties) throws CacheException {
+ this.settings = settings;
+ cacheProvider.start( properties );
+ }
+
+ public void stop() {
+ cacheProvider.stop();
+ cacheProvider = null;
+ }
+
+ public boolean isMinimalPutsEnabledByDefault() {
+ return cacheProvider.isMinimalPutsEnabledByDefault();
+ }
+
+ public long nextTimestamp() {
+ return cacheProvider.nextTimestamp();
+ }
+
+ public CacheProvider getCacheProvider() {
+ return cacheProvider;
+ }
+
+ public EntityRegion buildEntityRegion(
+ String regionName,
+ Properties properties,
+ CacheDataDescription metadata) throws CacheException {
+ return new EntityRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings, metadata );
+ }
+
+ public CollectionRegion buildCollectionRegion(
+ String regionName,
+ Properties properties,
+ CacheDataDescription metadata) throws CacheException {
+ return new CollectionRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings, metadata );
+ }
+
+ public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
+ return new QueryResultsRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings );
+ }
+
+ public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException {
+ return new TimestampsRegionAdapter( cacheProvider.buildCache( regionName, properties ), settings );
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,16 +0,0 @@
-package org.hibernate.cache.impl.bridge;
-
-import org.hibernate.cache.TimestampsRegion;
-import org.hibernate.cache.Cache;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically briding {@link TimestampsRegion} to {@link Cache}.
-*
-* @author Steve Ebersole
- */
-public class TimestampsRegionAdapter extends BaseGeneralDataRegionAdapter implements TimestampsRegion {
- protected TimestampsRegionAdapter(Cache underlyingCache, Settings settings) {
- super( underlyingCache, settings );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/impl/bridge/TimestampsRegionAdapter.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cache.impl.bridge;
+
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.Cache;
+import org.hibernate.cfg.Settings;
+
+/**
+ * Adapter specifically briding {@link TimestampsRegion} to {@link Cache}.
+*
+* @author Steve Ebersole
+ */
+public class TimestampsRegionAdapter extends BaseGeneralDataRegionAdapter implements TimestampsRegion {
+ protected TimestampsRegionAdapter(Cache underlyingCache, Settings settings) {
+ super( underlyingCache, settings );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cache/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,36 +0,0 @@
-<html>
- <head>
- </head>
-
- <body>
- <p>
- This package defines APIs/SPIs and implementations for the Hibernate second-level cache.
- </p>
- <p>
- The legacy (and now deprecated) approach to caching is defined by the {@link org.hibernate.cache.CacheProvider} and
- {@link org.hibernate.cache.Cache} interfaces as well as the {@link org.hibernate.cache.CacheConcurrencyStrategy}
- interface along with the various implementations of all these interfaces. In that scheme, a
- {@link org.hibernate.cache.CacheProvider} defined how to configure and perform lifecycle operations
- in regards to a particular underlying caching library; it also defined how to build {@link org.hibernate.cache.Cache}
- instances which in turn defined how to access the "regions" of the underlying cache instance.
- For entity and collection data cache regions, {@link org.hibernate.cache.CacheConcurrencyStrategy} wrapped
- access to those cache regions to apply transactional/concurrent access semantics.
- </p>
- <p>
- The improved approach is based on {@link org.hibernate.cache.RegionFactory}, the various
- {@link org.hibernate.cache.Region} specializations and the two access strategies contracts
- ({@link org.hibernate.cache.access.EntityRegionAccessStrategy} and
- {@link org.hibernate.cache.access.CollectionRegionAccessStrategy}). The general approach here is that
- {@link org.hibernate.cache.RegionFactory} defined how to configure and perform lifecycle operations
- in regards to a particular underlying caching library (<b>or libraries</b>).
- {@link org.hibernate.cache.RegionFactory} also defines how to build specialized
- {@link org.hibernate.cache.Region} instances based on the type of data we will be storing in that given
- region. The fact that {@link org.hibernate.cache.RegionFactory} is asked to build <b>specialized</b>
- regions (as opposed to just general access) is the first <i>improvement</i> over the legacy scheme. The
- second <i>improvement</i> is the fact that the regions (well the ones like entity and collection regions
- that are responsible for storing {@link org.hibernate.cache.TransactionalDataRegion transactional} data) are
- asked to build their own access strategies (see {@link org.hibernate.cache.EntityRegion#buildAccessStrategy}
- and {@link org.hibernate.cache.CollectionRegion#buildAccessStrategy}).
- </p>
- </body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cache/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cache/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,61 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+ <head>
+ </head>
+
+ <body>
+ <p>
+ This package defines APIs/SPIs and implementations for the Hibernate second-level cache.
+ </p>
+ <p>
+ The legacy (and now deprecated) approach to caching is defined by the {@link org.hibernate.cache.CacheProvider} and
+ {@link org.hibernate.cache.Cache} interfaces as well as the {@link org.hibernate.cache.CacheConcurrencyStrategy}
+ interface along with the various implementations of all these interfaces. In that scheme, a
+ {@link org.hibernate.cache.CacheProvider} defined how to configure and perform lifecycle operations
+ in regards to a particular underlying caching library; it also defined how to build {@link org.hibernate.cache.Cache}
+ instances which in turn defined how to access the "regions" of the underlying cache instance.
+ For entity and collection data cache regions, {@link org.hibernate.cache.CacheConcurrencyStrategy} wrapped
+ access to those cache regions to apply transactional/concurrent access semantics.
+ </p>
+ <p>
+ The improved approach is based on {@link org.hibernate.cache.RegionFactory}, the various
+ {@link org.hibernate.cache.Region} specializations and the two access strategies contracts
+ ({@link org.hibernate.cache.access.EntityRegionAccessStrategy} and
+ {@link org.hibernate.cache.access.CollectionRegionAccessStrategy}). The general approach here is that
+ {@link org.hibernate.cache.RegionFactory} defined how to configure and perform lifecycle operations
+ in regards to a particular underlying caching library (<b>or libraries</b>).
+ {@link org.hibernate.cache.RegionFactory} also defines how to build specialized
+ {@link org.hibernate.cache.Region} instances based on the type of data we will be storing in that given
+ region. The fact that {@link org.hibernate.cache.RegionFactory} is asked to build <b>specialized</b>
+ regions (as opposed to just general access) is the first <i>improvement</i> over the legacy scheme. The
+ second <i>improvement</i> is the fact that the regions (well the ones like entity and collection regions
+ that are responsible for storing {@link org.hibernate.cache.TransactionalDataRegion transactional} data) are
+ asked to build their own access strategies (see {@link org.hibernate.cache.EntityRegion#buildAccessStrategy}
+ and {@link org.hibernate.cache.CollectionRegion#buildAccessStrategy}).
+ </p>
+ </body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,73 +0,0 @@
-//$Id: CollectionSecondPass.java 10196 2006-08-03 07:53:27Z max.andersen(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.MappingException;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.IndexedCollection;
-import org.hibernate.mapping.OneToMany;
-import org.hibernate.mapping.Selectable;
-import org.hibernate.mapping.Value;
-
-/**
- * Collection second pass
- *
- * @author Emmanuel Bernard
- */
-public abstract class CollectionSecondPass implements SecondPass {
- private static Logger log = LoggerFactory.getLogger( CollectionSecondPass.class );
- Mappings mappings;
- Collection collection;
- private Map localInheritedMetas;
-
- public CollectionSecondPass(Mappings mappings, Collection collection, java.util.Map inheritedMetas) {
- this.collection = collection;
- this.mappings = mappings;
- this.localInheritedMetas = inheritedMetas;
- }
-
- public CollectionSecondPass(Mappings mappings, Collection collection) {
- this(mappings, collection, Collections.EMPTY_MAP);
- }
-
- public void doSecondPass(java.util.Map persistentClasses)
- throws MappingException {
- if ( log.isDebugEnabled() )
- log.debug( "Second pass for collection: " + collection.getRole() );
-
- secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
- collection.createAllKeys();
-
- if ( log.isDebugEnabled() ) {
- String msg = "Mapped collection key: " + columns( collection.getKey() );
- if ( collection.isIndexed() )
- msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() );
- if ( collection.isOneToMany() ) {
- msg += ", one-to-many: "
- + ( (OneToMany) collection.getElement() ).getReferencedEntityName();
- }
- else {
- msg += ", element: " + columns( collection.getElement() );
- }
- log.debug( msg );
- }
- }
-
- abstract public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
- throws MappingException;
-
- private static String columns(Value val) {
- StringBuffer columns = new StringBuffer();
- Iterator iter = val.getColumnIterator();
- while ( iter.hasNext() ) {
- columns.append( ( (Selectable) iter.next() ).getText() );
- if ( iter.hasNext() ) columns.append( ", " );
- }
- return columns.toString();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,96 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.MappingException;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.IndexedCollection;
+import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.Selectable;
+import org.hibernate.mapping.Value;
+
+/**
+ * Collection second pass
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class CollectionSecondPass implements SecondPass {
+ private static Logger log = LoggerFactory.getLogger( CollectionSecondPass.class );
+ Mappings mappings;
+ Collection collection;
+ private Map localInheritedMetas;
+
+ public CollectionSecondPass(Mappings mappings, Collection collection, java.util.Map inheritedMetas) {
+ this.collection = collection;
+ this.mappings = mappings;
+ this.localInheritedMetas = inheritedMetas;
+ }
+
+ public CollectionSecondPass(Mappings mappings, Collection collection) {
+ this(mappings, collection, Collections.EMPTY_MAP);
+ }
+
+ public void doSecondPass(java.util.Map persistentClasses)
+ throws MappingException {
+ if ( log.isDebugEnabled() )
+ log.debug( "Second pass for collection: " + collection.getRole() );
+
+ secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
+ collection.createAllKeys();
+
+ if ( log.isDebugEnabled() ) {
+ String msg = "Mapped collection key: " + columns( collection.getKey() );
+ if ( collection.isIndexed() )
+ msg += ", index: " + columns( ( (IndexedCollection) collection ).getIndex() );
+ if ( collection.isOneToMany() ) {
+ msg += ", one-to-many: "
+ + ( (OneToMany) collection.getElement() ).getReferencedEntityName();
+ }
+ else {
+ msg += ", element: " + columns( collection.getElement() );
+ }
+ log.debug( msg );
+ }
+ }
+
+ abstract public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
+ throws MappingException;
+
+ private static String columns(Value val) {
+ StringBuffer columns = new StringBuffer();
+ Iterator iter = val.getColumnIterator();
+ while ( iter.hasNext() ) {
+ columns.append( ( (Selectable) iter.next() ).getText() );
+ if ( iter.hasNext() ) columns.append( ", " );
+ }
+ return columns.toString();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,2180 +0,0 @@
-//$Id: Configuration.java 10841 2006-11-17 18:29:10Z max.andersen(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.lang.reflect.Array;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-
-import org.dom4j.Attribute;
-import org.dom4j.DocumentException;
-import org.dom4j.Element;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-
-import org.hibernate.EmptyInterceptor;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.InvalidMappingException;
-import org.hibernate.MappingException;
-import org.hibernate.MappingNotFoundException;
-import org.hibernate.SessionFactory;
-import org.hibernate.SessionFactoryObserver;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.engine.FilterDefinition;
-import org.hibernate.engine.Mapping;
-import org.hibernate.event.AutoFlushEventListener;
-import org.hibernate.event.DeleteEventListener;
-import org.hibernate.event.DirtyCheckEventListener;
-import org.hibernate.event.EventListeners;
-import org.hibernate.event.EvictEventListener;
-import org.hibernate.event.FlushEntityEventListener;
-import org.hibernate.event.FlushEventListener;
-import org.hibernate.event.InitializeCollectionEventListener;
-import org.hibernate.event.LoadEventListener;
-import org.hibernate.event.LockEventListener;
-import org.hibernate.event.MergeEventListener;
-import org.hibernate.event.PersistEventListener;
-import org.hibernate.event.PostCollectionRecreateEventListener;
-import org.hibernate.event.PostCollectionRemoveEventListener;
-import org.hibernate.event.PostCollectionUpdateEventListener;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostLoadEventListener;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PreCollectionRecreateEventListener;
-import org.hibernate.event.PreCollectionRemoveEventListener;
-import org.hibernate.event.PreCollectionUpdateEventListener;
-import org.hibernate.event.PreDeleteEventListener;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.PreLoadEventListener;
-import org.hibernate.event.PreUpdateEventListener;
-import org.hibernate.event.RefreshEventListener;
-import org.hibernate.event.ReplicateEventListener;
-import org.hibernate.event.SaveOrUpdateEventListener;
-import org.hibernate.id.IdentifierGenerator;
-import org.hibernate.id.PersistentIdentifierGenerator;
-import org.hibernate.impl.SessionFactoryImpl;
-import org.hibernate.mapping.AuxiliaryDatabaseObject;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.ForeignKey;
-import org.hibernate.mapping.IdentifierCollection;
-import org.hibernate.mapping.Index;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.Table;
-import org.hibernate.mapping.UniqueKey;
-import org.hibernate.proxy.EntityNotFoundDelegate;
-import org.hibernate.secure.JACCConfiguration;
-import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
-import org.hibernate.tool.hbm2ddl.TableMetadata;
-import org.hibernate.type.SerializationException;
-import org.hibernate.type.Type;
-import org.hibernate.util.ArrayHelper;
-import org.hibernate.util.CollectionHelper;
-import org.hibernate.util.ConfigHelper;
-import org.hibernate.util.PropertiesHelper;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.SerializationHelper;
-import org.hibernate.util.StringHelper;
-import org.hibernate.util.XMLHelper;
-
-/**
- * An instance of <tt>Configuration</tt> allows the application
- * to specify properties and mapping documents to be used when
- * creating a <tt>SessionFactory</tt>. Usually an application will create
- * a single <tt>Configuration</tt>, build a single instance of
- * <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in
- * threads servicing client requests. The <tt>Configuration</tt> is meant
- * only as an initialization-time object. <tt>SessionFactory</tt>s are
- * immutable and do not retain any association back to the
- * <tt>Configuration</tt>.<br>
- * <br>
- * A new <tt>Configuration</tt> will use the properties specified in
- * <tt>hibernate.properties</tt> by default.
- *
- * @author Gavin King
- * @see org.hibernate.SessionFactory
- */
-public class Configuration implements Serializable {
-
- private static Logger log = LoggerFactory.getLogger( Configuration.class );
-
- protected Map classes;
- protected Map imports;
- protected Map collections;
- protected Map tables;
- protected List auxiliaryDatabaseObjects;
- protected Map sqlFunctions;
- protected Map namedQueries;
- protected Map namedSqlQueries;
- /**
- * Map<String, SqlResultSetMapping> result set name, result set description
- */
- protected Map sqlResultSetMappings;
- protected Map filterDefinitions;
- protected List secondPasses;
- protected List propertyReferences;
-// protected List extendsQueue;
- protected Map extendsQueue;
- protected Map tableNameBinding;
- protected Map columnNameBindingPerTable;
- private Interceptor interceptor;
- private Properties properties;
- private EntityResolver entityResolver;
- private EntityNotFoundDelegate entityNotFoundDelegate;
-
- protected transient XMLHelper xmlHelper;
- protected transient Map typeDefs;
-
- protected NamingStrategy namingStrategy;
-
- private EventListeners eventListeners;
-
- protected final SettingsFactory settingsFactory;
-
- private SessionFactoryObserver sessionFactoryObserver;
-
- protected void reset() {
- classes = new HashMap();
- imports = new HashMap();
- collections = new HashMap();
- tables = new TreeMap();
- namedQueries = new HashMap();
- namedSqlQueries = new HashMap();
- sqlResultSetMappings = new HashMap();
- xmlHelper = new XMLHelper();
- typeDefs = new HashMap();
- propertyReferences = new ArrayList();
- secondPasses = new ArrayList();
- interceptor = EmptyInterceptor.INSTANCE;
- properties = Environment.getProperties();
- entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
- eventListeners = new EventListeners();
- filterDefinitions = new HashMap();
-// extendsQueue = new ArrayList();
- extendsQueue = new HashMap();
- auxiliaryDatabaseObjects = new ArrayList();
- tableNameBinding = new HashMap();
- columnNameBindingPerTable = new HashMap();
- namingStrategy = DefaultNamingStrategy.INSTANCE;
- sqlFunctions = new HashMap();
- }
-
- private transient Mapping mapping = buildMapping();
-
-
-
- protected Configuration(SettingsFactory settingsFactory) {
- this.settingsFactory = settingsFactory;
- reset();
- }
-
- public Configuration() {
- this( new SettingsFactory() );
- }
-
- /**
- * Iterate the entity mappings
- *
- * @return Iterator of the entity mappings currently contained in the configuration.
- */
- public Iterator getClassMappings() {
- return classes.values().iterator();
- }
-
- /**
- * Iterate the collection mappings
- *
- * @return Iterator of the collection mappings currently contained in the configuration.
- */
- public Iterator getCollectionMappings() {
- return collections.values().iterator();
- }
-
- /**
- * Iterate the table mappings
- *
- * @return Iterator of the table mappings currently contained in the configuration.
- */
- public Iterator getTableMappings() {
- return tables.values().iterator();
- }
-
- /**
- * Get the mapping for a particular entity
- *
- * @param entityName An entity name.
- * @return the entity mapping information
- */
- public PersistentClass getClassMapping(String entityName) {
- return (PersistentClass) classes.get( entityName );
- }
-
- /**
- * Get the mapping for a particular collection role
- *
- * @param role a collection role
- * @return The collection mapping information
- */
- public Collection getCollectionMapping(String role) {
- return (Collection) collections.get( role );
- }
-
- /**
- * Set a custom entity resolver. This entity resolver must be
- * set before addXXX(misc) call.
- * Default value is {@link org.hibernate.util.DTDEntityResolver}
- *
- * @param entityResolver entity resolver to use
- */
- public void setEntityResolver(EntityResolver entityResolver) {
- this.entityResolver = entityResolver;
- }
-
- public EntityResolver getEntityResolver() {
- return entityResolver;
- }
-
- /**
- * Retrieve the user-supplied delegate to handle non-existent entity
- * scenarios. May be null.
- *
- * @return The user-supplied delegate
- */
- public EntityNotFoundDelegate getEntityNotFoundDelegate() {
- return entityNotFoundDelegate;
- }
-
- /**
- * Specify a user-supplied delegate to be used to handle scenarios where an entity could not be
- * located by specified id. This is mainly intended for EJB3 implementations to be able to
- * control how proxy initialization errors should be handled...
- *
- * @param entityNotFoundDelegate The delegate to use
- */
- public void setEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) {
- this.entityNotFoundDelegate = entityNotFoundDelegate;
- }
-
- /**
- * Read mappings from a particular XML file
- *
- * @param xmlFile a path to a file
- * @return this (for method chaining purposes)
- * @throws org.hibernate.MappingException Indicates inability to locate or parse
- * the specified mapping file.
- * @see #addFile(java.io.File)
- */
- public Configuration addFile(String xmlFile) throws MappingException {
- return addFile( new File( xmlFile ) );
- }
-
- /**
- * Read mappings from a particular XML file
- *
- * @param xmlFile a path to a file
- * @return this (for method chaining purposes)
- * @throws org.hibernate.MappingException Indicates inability to locate or parse
- * the specified mapping file.
- */
- public Configuration addFile(File xmlFile) throws MappingException {
- log.info( "Reading mappings from file: " + xmlFile.getPath() );
- if ( !xmlFile.exists() ) {
- throw new MappingNotFoundException( "file", xmlFile.toString() );
- }
- try {
- List errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile.toString(), errors, entityResolver ).read( xmlFile );
- if ( errors.size() != 0 ) {
- throw new InvalidMappingException( "file", xmlFile.toString(), ( Throwable ) errors.get( 0 ) );
- }
- add( doc );
- return this;
- }
- catch ( InvalidMappingException e ) {
- throw e;
- }
- catch ( MappingNotFoundException e ) {
- throw e;
- }
- catch ( Exception e ) {
- throw new InvalidMappingException( "file", xmlFile.toString(), e );
- }
- }
-
- /**
- * Add a cached mapping file. A cached file is a serialized representation
- * of the DOM structure of a particular mapping. It is saved from a previous
- * call as a file with the name <tt>xmlFile + ".bin"</tt> where xmlFile is
- * the name of the original mapping file.
- * </p>
- * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than
- * <tt>xmlFile</tt> the <tt>".bin"</tt> file will be read directly. Otherwise
- * xmlFile is read and then serialized to <tt>xmlFile + ".bin"</tt> for use
- * the next time.
- *
- * @param xmlFile The cacheable mapping file to be added.
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the cached file or processing
- * the non-cached file.
- */
- public Configuration addCacheableFile(File xmlFile) throws MappingException {
- try {
- File cachedFile = new File( xmlFile.getAbsolutePath() + ".bin" );
- org.dom4j.Document doc = null;
-
- final boolean useCachedFile = xmlFile.exists() &&
- cachedFile.exists() &&
- xmlFile.lastModified() < cachedFile.lastModified();
-
- if ( useCachedFile ) {
- try {
- log.info( "Reading mappings from cache file: " + cachedFile );
- doc = ( org.dom4j.Document ) SerializationHelper.deserialize( new FileInputStream( cachedFile ) );
- }
- catch ( SerializationException e ) {
- log.warn( "Could not deserialize cache file: " + cachedFile.getPath(), e );
- }
- catch ( FileNotFoundException e ) {
- log.warn( "I/O reported cached file could not be found : " + cachedFile.getPath(), e );
- }
- }
-
- // if doc is null, then for whatever reason, the cached file cannot be used...
- if ( doc == null ) {
- if ( !xmlFile.exists() ) {
- throw new MappingNotFoundException( "file", xmlFile.toString() );
- }
-
- log.info( "Reading mappings from file: " + xmlFile );
- List errors = new ArrayList();
- try {
- doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );
- }
- }
- catch( DocumentException e){
- throw new MappingException( "invalid mapping", e );
- }
-
- try {
- log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
- SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStream( cachedFile ) );
- }
- catch ( SerializationException e ) {
- log.warn( "Could not write cached file: " + cachedFile, e );
- }
- catch ( FileNotFoundException e ) {
- log.warn( "I/O reported error writing cached file : " + cachedFile.getPath(), e );
- }
- }
-
- add( doc );
- return this;
-
- }
- catch ( InvalidMappingException e ) {
- throw e;
- }
- catch ( MappingNotFoundException e ) {
- throw e;
- }
- catch ( Exception e ) {
- throw new InvalidMappingException( "file", xmlFile.toString(), e );
- }
- }
-
- /**
- * Add a cacheable mapping file.
- *
- * @param xmlFile The name of the file to be added. This must be in a form
- * useable to simply construct a {@link java.io.File} instance.
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the cached file or processing
- * the non-cached file.
- * @see #addCacheableFile(java.io.File)
- */
- public Configuration addCacheableFile(String xmlFile) throws MappingException {
- return addCacheableFile( new File( xmlFile ) );
- }
-
-
- /**
- * Read mappings from a <tt>String</tt>
- *
- * @param xml an XML string
- * @return this (for method chaining purposes)
- * @throws org.hibernate.MappingException Indicates problems parsing the
- * given XML string
- */
- public Configuration addXML(String xml) throws MappingException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Mapping XML:\n" + xml );
- }
- try {
- List errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( "XML String", errors, entityResolver )
- .read( new StringReader( xml ) );
- if ( errors.size() != 0 ) {
- throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
- }
- add( doc );
- }
- catch (DocumentException e) {
- throw new MappingException( "Could not parse mapping document in XML string", e );
- }
- return this;
- }
-
- /**
- * Read mappings from a <tt>URL</tt>
- *
- * @param url The url for the mapping document to be read.
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the URL or processing
- * the mapping document.
- */
- public Configuration addURL(URL url) throws MappingException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Reading mapping document from URL:" + url.toExternalForm() );
- }
- try {
- addInputStream( url.openStream() );
- }
- catch ( InvalidMappingException e ) {
- throw new InvalidMappingException( "URL", url.toExternalForm(), e.getCause() );
- }
- catch (Exception e) {
- throw new InvalidMappingException( "URL", url.toExternalForm(), e );
- }
- return this;
- }
-
- /**
- * Read mappings from a DOM <tt>Document</tt>
- *
- * @param doc The DOM document
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the DOM or processing
- * the mapping document.
- */
- public Configuration addDocument(Document doc) throws MappingException {
- if ( log.isDebugEnabled() ) {
- log.debug( "Mapping document:\n" + doc );
- }
- add( xmlHelper.createDOMReader().read( doc ) );
- return this;
- }
-
- /**
- * Read mappings from an {@link java.io.InputStream}.
- *
- * @param xmlInputStream The input stream containing a DOM.
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the stream, or
- * processing the contained mapping document.
- */
- public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
- try {
- List errors = new ArrayList();
- org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, entityResolver )
- .read( new InputSource( xmlInputStream ) );
- if ( errors.size() != 0 ) {
- throw new InvalidMappingException( "invalid mapping", null, (Throwable) errors.get( 0 ) );
- }
- add( doc );
- return this;
- }
- catch (DocumentException e) {
- throw new InvalidMappingException( "input stream", null, e );
- }
- finally {
- try {
- xmlInputStream.close();
- }
- catch (IOException ioe) {
- log.warn( "Could not close input stream", ioe );
- }
- }
- }
-
- /**
- * Read mappings as a application resource (i.e. classpath lookup).
- *
- * @param resourceName The resource name
- * @param classLoader The class loader to use.
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems locating the resource or
- * processing the contained mapping document.
- */
- public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
- log.info( "Reading mappings from resource: " + resourceName );
- InputStream rsrc = classLoader.getResourceAsStream( resourceName );
- if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", resourceName );
- }
- try {
- return addInputStream( rsrc );
- }
- catch (MappingException me) {
- throw new InvalidMappingException( "resource", resourceName, me );
- }
- }
-
- /**
- * Read mappings as a application resourceName (i.e. classpath lookup)
- * trying different classloaders.
- *
- * @param resourceName The resource name
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems locating the resource or
- * processing the contained mapping document.
- */
- public Configuration addResource(String resourceName) throws MappingException {
- log.info( "Reading mappings from resource : " + resourceName );
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- InputStream rsrc = null;
- if (contextClassLoader!=null) {
- rsrc = contextClassLoader.getResourceAsStream( resourceName );
- }
- if ( rsrc == null ) {
- rsrc = Environment.class.getClassLoader().getResourceAsStream( resourceName );
- }
- if ( rsrc == null ) {
- throw new MappingNotFoundException( "resource", resourceName );
- }
- try {
- return addInputStream( rsrc );
- }
- catch (MappingException me) {
- throw new InvalidMappingException( "resource", resourceName, me );
- }
- }
-
- /**
- * Read a mapping as an application resouurce using the convention that a class
- * named <tt>foo.bar.Foo</tt> is mapped by a file <tt>foo/bar/Foo.hbm.xml</tt>
- * which can be resolved as a classpath resource.
- *
- * @param persistentClass The mapped class
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems locating the resource or
- * processing the contained mapping document.
- */
- public Configuration addClass(Class persistentClass) throws MappingException {
- String mappingResourceName = persistentClass.getName().replace( '.', '/' ) + ".hbm.xml";
- log.info( "Reading mappings from resource: " + mappingResourceName );
- return addResource( mappingResourceName, persistentClass.getClassLoader() );
- }
-
- /**
- * Read all mappings from a jar file
- * <p/>
- * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
- *
- * @param jar a jar file
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the jar file or
- * processing the contained mapping documents.
- */
- public Configuration addJar(File jar) throws MappingException {
- log.info( "Searching for mapping documents in jar: " + jar.getName() );
- JarFile jarFile = null;
- try {
- try {
- jarFile = new JarFile( jar );
- }
- catch (IOException ioe) {
- throw new InvalidMappingException(
- "Could not read mapping documents from jar: " + jar.getName(), "jar", jar.getName(),
- ioe
- );
- }
- Enumeration jarEntries = jarFile.entries();
- while ( jarEntries.hasMoreElements() ) {
- ZipEntry ze = (ZipEntry) jarEntries.nextElement();
- if ( ze.getName().endsWith( ".hbm.xml" ) ) {
- log.info( "Found mapping document in jar: " + ze.getName() );
- try {
- addInputStream( jarFile.getInputStream( ze ) );
- }
- catch (Exception e) {
- throw new InvalidMappingException(
- "Could not read mapping documents from jar: " + jar.getName(),
- "jar",
- jar.getName(),
- e
- );
- }
- }
- }
- }
- finally {
- try {
- if ( jarFile != null ) {
- jarFile.close();
- }
- }
- catch (IOException ioe) {
- log.error("could not close jar", ioe);
- }
- }
-
- return this;
- }
-
- /**
- * Read all mapping documents from a directory tree.
- * <p/>
- * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
- *
- * @param dir The directory
- * @return this (for method chaining purposes)
- * @throws MappingException Indicates problems reading the jar file or
- * processing the contained mapping documents.
- */
- public Configuration addDirectory(File dir) throws MappingException {
- File[] files = dir.listFiles();
- for ( int i = 0; i < files.length ; i++ ) {
- if ( files[i].isDirectory() ) {
- addDirectory( files[i] );
- }
- else if ( files[i].getName().endsWith( ".hbm.xml" ) ) {
- addFile( files[i] );
- }
- }
- return this;
- }
-
- protected void add(org.dom4j.Document doc) throws MappingException {
- HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
- }
-
- /**
- * Create a new <tt>Mappings</tt> to add class and collection
- * mappings to.
- */
- public Mappings createMappings() {
- return new Mappings(
- classes,
- collections,
- tables,
- namedQueries,
- namedSqlQueries,
- sqlResultSetMappings,
- imports,
- secondPasses,
- propertyReferences,
- namingStrategy,
- typeDefs,
- filterDefinitions,
- extendsQueue,
- auxiliaryDatabaseObjects,
- tableNameBinding,
- columnNameBindingPerTable
- );
- }
-
-
- private Iterator iterateGenerators(Dialect dialect) throws MappingException {
-
- TreeMap generators = new TreeMap();
- String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
- String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
-
- Iterator iter = classes.values().iterator();
- while ( iter.hasNext() ) {
- PersistentClass pc = (PersistentClass) iter.next();
-
- if ( !pc.isInherited() ) {
-
- IdentifierGenerator ig = pc.getIdentifier()
- .createIdentifierGenerator(
- dialect,
- defaultCatalog,
- defaultSchema,
- (RootClass) pc
- );
-
- if ( ig instanceof PersistentIdentifierGenerator ) {
- generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
- }
-
- }
- }
-
- iter = collections.values().iterator();
- while ( iter.hasNext() ) {
- Collection collection = (Collection) iter.next();
-
- if ( collection.isIdentified() ) {
-
- IdentifierGenerator ig = ( (IdentifierCollection) collection ).getIdentifier()
- .createIdentifierGenerator(
- dialect,
- defaultCatalog,
- defaultSchema,
- null
- );
-
- if ( ig instanceof PersistentIdentifierGenerator ) {
- generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
- }
-
- }
- }
-
- return generators.values().iterator();
- }
-
- /**
- * Generate DDL for dropping tables
- *
- * @see org.hibernate.tool.hbm2ddl.SchemaExport
- */
- public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException {
-
- secondPassCompile();
-
- String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
- String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
-
- ArrayList script = new ArrayList( 50 );
-
- // drop them in reverse order in case db needs it done that way...
- ListIterator itr = auxiliaryDatabaseObjects.listIterator( auxiliaryDatabaseObjects.size() );
- while ( itr.hasPrevious() ) {
- AuxiliaryDatabaseObject object = (AuxiliaryDatabaseObject) itr.previous();
- if ( object.appliesToDialect( dialect ) ) {
- script.add( object.sqlDropString( dialect, defaultCatalog, defaultSchema ) );
- }
- }
-
- if ( dialect.dropConstraints() ) {
- Iterator iter = getTableMappings();
- while ( iter.hasNext() ) {
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
- Iterator subIter = table.getForeignKeyIterator();
- while ( subIter.hasNext() ) {
- ForeignKey fk = (ForeignKey) subIter.next();
- if ( fk.isPhysicalConstraint() ) {
- script.add(
- fk.sqlDropString(
- dialect,
- defaultCatalog,
- defaultSchema
- )
- );
- }
- }
- }
- }
- }
-
-
- Iterator iter = getTableMappings();
- while ( iter.hasNext() ) {
-
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
-
- /*Iterator subIter = table.getIndexIterator();
- while ( subIter.hasNext() ) {
- Index index = (Index) subIter.next();
- if ( !index.isForeignKey() || !dialect.hasImplicitIndexForForeignKey() ) {
- script.add( index.sqlDropString(dialect) );
- }
- }*/
-
- script.add(
- table.sqlDropString(
- dialect,
- defaultCatalog,
- defaultSchema
- )
- );
-
- }
-
- }
-
- iter = iterateGenerators( dialect );
- while ( iter.hasNext() ) {
- String[] lines = ( (PersistentIdentifierGenerator) iter.next() ).sqlDropStrings( dialect );
- for ( int i = 0; i < lines.length ; i++ ) {
- script.add( lines[i] );
- }
- }
-
- return ArrayHelper.toStringArray( script );
- }
-
- /**
- * Generate DDL for creating tables
- *
- * @see org.hibernate.tool.hbm2ddl.SchemaExport
- */
- public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException {
- secondPassCompile();
-
- ArrayList script = new ArrayList( 50 );
- String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
- String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
-
- Iterator iter = getTableMappings();
- while ( iter.hasNext() ) {
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
- script.add(
- table.sqlCreateString(
- dialect,
- mapping,
- defaultCatalog,
- defaultSchema
- )
- );
- Iterator comments = table.sqlCommentStrings( dialect, defaultCatalog, defaultSchema );
- while ( comments.hasNext() ) {
- script.add( comments.next() );
- }
- }
- }
-
- iter = getTableMappings();
- while ( iter.hasNext() ) {
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
-
- if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) {
- Iterator subIter = table.getUniqueKeyIterator();
- while ( subIter.hasNext() ) {
- UniqueKey uk = (UniqueKey) subIter.next();
- String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema );
- if (constraintString != null) script.add( constraintString );
- }
- }
-
-
- Iterator subIter = table.getIndexIterator();
- while ( subIter.hasNext() ) {
- Index index = (Index) subIter.next();
- script.add(
- index.sqlCreateString(
- dialect,
- mapping,
- defaultCatalog,
- defaultSchema
- )
- );
- }
-
- if ( dialect.hasAlterTable() ) {
- subIter = table.getForeignKeyIterator();
- while ( subIter.hasNext() ) {
- ForeignKey fk = (ForeignKey) subIter.next();
- if ( fk.isPhysicalConstraint() ) {
- script.add(
- fk.sqlCreateString(
- dialect, mapping,
- defaultCatalog,
- defaultSchema
- )
- );
- }
- }
- }
-
- }
- }
-
- iter = iterateGenerators( dialect );
- while ( iter.hasNext() ) {
- String[] lines = ( (PersistentIdentifierGenerator) iter.next() ).sqlCreateStrings( dialect );
- for ( int i = 0; i < lines.length ; i++ ) {
- script.add( lines[i] );
- }
- }
-
- Iterator itr = auxiliaryDatabaseObjects.iterator();
- while ( itr.hasNext() ) {
- AuxiliaryDatabaseObject object = (AuxiliaryDatabaseObject) itr.next();
- if ( object.appliesToDialect( dialect ) ) {
- script.add( object.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema ) );
- }
- }
-
- return ArrayHelper.toStringArray( script );
- }
-
- /**
- * Generate DDL for altering tables
- *
- * @see org.hibernate.tool.hbm2ddl.SchemaUpdate
- */
- public String[] generateSchemaUpdateScript(Dialect dialect, DatabaseMetadata databaseMetadata)
- throws HibernateException {
- secondPassCompile();
-
- String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
- String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
-
- ArrayList script = new ArrayList( 50 );
-
- Iterator iter = getTableMappings();
- while ( iter.hasNext() ) {
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
-
- TableMetadata tableInfo = databaseMetadata.getTableMetadata(
- table.getName(),
- ( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
- ( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
- table.isQuoted()
-
- );
- if ( tableInfo == null ) {
- script.add(
- table.sqlCreateString(
- dialect,
- mapping,
- defaultCatalog,
- defaultSchema
- )
- );
- }
- else {
- Iterator subiter = table.sqlAlterStrings(
- dialect,
- mapping,
- tableInfo,
- defaultCatalog,
- defaultSchema
- );
- while ( subiter.hasNext() ) {
- script.add( subiter.next() );
- }
- }
-
- Iterator comments = table.sqlCommentStrings( dialect, defaultCatalog, defaultSchema );
- while ( comments.hasNext() ) {
- script.add( comments.next() );
- }
-
- }
- }
-
- iter = getTableMappings();
- while ( iter.hasNext() ) {
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
-
- TableMetadata tableInfo = databaseMetadata.getTableMetadata(
- table.getName(),
- table.getSchema(),
- table.getCatalog(),
- table.isQuoted()
- );
-
- if ( dialect.hasAlterTable() ) {
- Iterator subIter = table.getForeignKeyIterator();
- while ( subIter.hasNext() ) {
- ForeignKey fk = (ForeignKey) subIter.next();
- if ( fk.isPhysicalConstraint() ) {
- boolean create = tableInfo == null || (
- tableInfo.getForeignKeyMetadata( fk.getName() ) == null && (
- //Icky workaround for MySQL bug:
- !( dialect instanceof MySQLDialect ) ||
- tableInfo.getIndexMetadata( fk.getName() ) == null
- )
- );
- if ( create ) {
- script.add(
- fk.sqlCreateString(
- dialect,
- mapping,
- defaultCatalog,
- defaultSchema
- )
- );
- }
- }
- }
- }
-
- }
-
- /*//broken, 'cos we don't generate these with names in SchemaExport
- subIter = table.getIndexIterator();
- while ( subIter.hasNext() ) {
- Index index = (Index) subIter.next();
- if ( !index.isForeignKey() || !dialect.hasImplicitIndexForForeignKey() ) {
- if ( tableInfo==null || tableInfo.getIndexMetadata( index.getFilterName() ) == null ) {
- script.add( index.sqlCreateString(dialect, mapping) );
- }
- }
- }
- //broken, 'cos we don't generate these with names in SchemaExport
- subIter = table.getUniqueKeyIterator();
- while ( subIter.hasNext() ) {
- UniqueKey uk = (UniqueKey) subIter.next();
- if ( tableInfo==null || tableInfo.getIndexMetadata( uk.getFilterName() ) == null ) {
- script.add( uk.sqlCreateString(dialect, mapping) );
- }
- }*/
- }
-
- iter = iterateGenerators( dialect );
- while ( iter.hasNext() ) {
- PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
- Object key = generator.generatorKey();
- if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
- String[] lines = generator.sqlCreateStrings( dialect );
- for ( int i = 0; i < lines.length ; i++ ) {
- script.add( lines[i] );
- }
- }
- }
-
- return ArrayHelper.toStringArray( script );
- }
-
- public void validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)
- throws HibernateException {
- secondPassCompile();
-
- String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
- String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
-
- Iterator iter = getTableMappings();
- while ( iter.hasNext() ) {
- Table table = (Table) iter.next();
- if ( table.isPhysicalTable() ) {
-
-
- TableMetadata tableInfo = databaseMetadata.getTableMetadata(
- table.getName(),
- ( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
- ( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
- table.isQuoted());
- if ( tableInfo == null ) {
- throw new HibernateException( "Missing table: " + table.getName() );
- }
- else {
- table.validateColumns( dialect, mapping, tableInfo );
- }
-
- }
- }
-
- iter = iterateGenerators( dialect );
- while ( iter.hasNext() ) {
- PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
- Object key = generator.generatorKey();
- if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
- throw new HibernateException( "Missing sequence or table: " + key );
- }
- }
- }
-
- private void validate() throws MappingException {
- Iterator iter = classes.values().iterator();
- while ( iter.hasNext() ) {
- ( (PersistentClass) iter.next() ).validate( mapping );
- }
- iter = collections.values().iterator();
- while ( iter.hasNext() ) {
- ( (Collection) iter.next() ).validate( mapping );
- }
- }
-
- /**
- * Call this to ensure the mappings are fully compiled/built. Usefull to ensure getting
- * access to all information in the metamodel when calling e.g. getClassMappings().
- */
- public void buildMappings() {
- secondPassCompile();
- }
-
- // This method may be called many times!!
- protected void secondPassCompile() throws MappingException {
- log.debug( "processing extends queue" );
-
- processExtendsQueue();
-
- log.debug( "processing collection mappings" );
-
- Iterator iter = secondPasses.iterator();
- while ( iter.hasNext() ) {
- SecondPass sp = (SecondPass) iter.next();
- if ( ! (sp instanceof QuerySecondPass) ) {
- sp.doSecondPass( classes );
- iter.remove();
- }
- }
-
- log.debug( "processing native query and ResultSetMapping mappings" );
- iter = secondPasses.iterator();
- while ( iter.hasNext() ) {
- SecondPass sp = (SecondPass) iter.next();
- sp.doSecondPass( classes );
- iter.remove();
- }
-
- log.debug( "processing association property references" );
-
- iter = propertyReferences.iterator();
- while ( iter.hasNext() ) {
- Mappings.PropertyReference upr = (Mappings.PropertyReference) iter.next();
-
- PersistentClass clazz = getClassMapping( upr.referencedClass );
- if ( clazz == null ) {
- throw new MappingException(
- "property-ref to unmapped class: " +
- upr.referencedClass
- );
- }
-
- Property prop = clazz.getReferencedProperty( upr.propertyName );
- if ( upr.unique ) {
- ( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true );
- }
- }
-
- //TODO: Somehow add the newly created foreign keys to the internal collection
-
- log.debug( "processing foreign key constraints" );
-
- iter = getTableMappings();
- Set done = new HashSet();
- while ( iter.hasNext() ) {
- secondPassCompileForeignKeys( (Table) iter.next(), done );
- }
-
- }
-
- /**
- * Try to empty the extends queue.
- */
- private void processExtendsQueue() {
- // todo : would love to have this work on a notification basis
- // where the successful binding of an entity/subclass would
- // emit a notification which the extendsQueue entries could
- // react to...
- org.dom4j.Document document = findPossibleExtends();
- while ( document != null ) {
- add( document );
- document = findPossibleExtends();
- }
-
- if ( extendsQueue.size() > 0 ) {
-// Iterator iterator = extendsQueue.iterator();
- Iterator iterator = extendsQueue.keySet().iterator();
- StringBuffer buf = new StringBuffer( "Following superclasses referenced in extends not found: " );
- while ( iterator.hasNext() ) {
- final ExtendsQueueEntry entry = ( ExtendsQueueEntry ) iterator.next();
- buf.append( entry.getExplicitName() );
- if ( entry.getMappingPackage() != null ) {
- buf.append( "[" ).append( entry.getMappingPackage() ).append( "]" );
- }
- if ( iterator.hasNext() ) {
- buf.append( "," );
- }
- }
- throw new MappingException( buf.toString() );
- }
- }
-
- /**
- * Find the first possible element in the queue of extends.
- */
- protected org.dom4j.Document findPossibleExtends() {
-// Iterator iter = extendsQueue.iterator();
- Iterator iter = extendsQueue.keySet().iterator();
- while ( iter.hasNext() ) {
- final ExtendsQueueEntry entry = ( ExtendsQueueEntry ) iter.next();
- if ( getClassMapping( entry.getExplicitName() ) != null ) {
- // found
- iter.remove();
- return entry.getDocument();
- }
- else if ( getClassMapping( HbmBinder.getClassName( entry.getExplicitName(), entry.getMappingPackage() ) ) != null ) {
- // found
- iter.remove();
- return entry.getDocument();
- }
- }
- return null;
- }
-
- protected void secondPassCompileForeignKeys(Table table, Set done) throws MappingException {
-
- table.createForeignKeys();
-
- Iterator iter = table.getForeignKeyIterator();
- while ( iter.hasNext() ) {
-
- ForeignKey fk = (ForeignKey) iter.next();
- if ( !done.contains( fk ) ) {
- done.add( fk );
- final String referencedEntityName = fk.getReferencedEntityName();
- if ( referencedEntityName == null ) {
- throw new MappingException(
- "An association from the table " +
- fk.getTable().getName() +
- " does not specify the referenced entity"
- );
- }
- if ( log.isDebugEnabled() ) {
- log.debug( "resolving reference to class: " + referencedEntityName );
- }
- PersistentClass referencedClass = (PersistentClass) classes.get( referencedEntityName );
- if ( referencedClass == null ) {
- throw new MappingException(
- "An association from the table " +
- fk.getTable().getName() +
- " refers to an unmapped class: " +
- referencedEntityName
- );
- }
- if ( referencedClass.isJoinedSubclass() ) {
- secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done );
- }
- fk.setReferencedTable( referencedClass.getTable() );
- fk.alignColumns();
- }
- }
- }
-
- /**
- * Get the named queries
- */
- public Map getNamedQueries() {
- return namedQueries;
- }
-
- /**
- * Instantiate a new <tt>SessionFactory</tt>, using the properties and
- * mappings in this configuration. The <tt>SessionFactory</tt> will be
- * immutable, so changes made to the <tt>Configuration</tt> after
- * building the <tt>SessionFactory</tt> will not affect it.
- *
- * @return a new factory for <tt>Session</tt>s
- * @see org.hibernate.SessionFactory
- */
- public SessionFactory buildSessionFactory() throws HibernateException {
- log.debug( "Preparing to build session factory with filters : " + filterDefinitions );
- secondPassCompile();
- validate();
- Environment.verifyProperties( properties );
- Properties copy = new Properties();
- copy.putAll( properties );
- PropertiesHelper.resolvePlaceHolders( copy );
- Settings settings = buildSettings( copy );
-
- return new SessionFactoryImpl(
- this,
- mapping,
- settings,
- getInitializedEventListeners(),
- sessionFactoryObserver
- );
- }
-
- private EventListeners getInitializedEventListeners() {
- EventListeners result = (EventListeners) eventListeners.shallowCopy();
- result.initializeListeners( this );
- return result;
- }
-
- /**
- * Return the configured <tt>Interceptor</tt>
- */
- public Interceptor getInterceptor() {
- return interceptor;
- }
-
- /**
- * Get all properties
- */
- public Properties getProperties() {
- return properties;
- }
-
- /**
- * Configure an <tt>Interceptor</tt>
- */
- public Configuration setInterceptor(Interceptor interceptor) {
- this.interceptor = interceptor;
- return this;
- }
-
- /**
- * Specify a completely new set of properties
- */
- public Configuration setProperties(Properties properties) {
- this.properties = properties;
- return this;
- }
-
- /**
- * Set the given properties
- */
- public Configuration addProperties(Properties extraProperties) {
- this.properties.putAll( extraProperties );
- return this;
- }
-
- /**
- * Adds the incoming properties to the internap properties structure,
- * as long as the internal structure does not already contain an
- * entry for the given key.
- *
- * @param properties
- * @return this
- */
- public Configuration mergeProperties(Properties properties) {
- Iterator itr = properties.entrySet().iterator();
- while ( itr.hasNext() ) {
- final Map.Entry entry = ( Map.Entry ) itr.next();
- if ( this.properties.containsKey( entry.getKey() ) ) {
- continue;
- }
- this.properties.setProperty( ( String ) entry.getKey(), ( String ) entry.getValue() );
- }
- return this;
- }
-
- /**
- * Set a property
- */
- public Configuration setProperty(String propertyName, String value) {
- properties.setProperty( propertyName, value );
- return this;
- }
-
- /**
- * Get a property
- */
- public String getProperty(String propertyName) {
- return properties.getProperty( propertyName );
- }
-
- private void addProperties(Element parent) {
- Iterator iter = parent.elementIterator( "property" );
- while ( iter.hasNext() ) {
- Element node = (Element) iter.next();
- String name = node.attributeValue( "name" );
- String value = node.getText().trim();
- log.debug( name + "=" + value );
- properties.setProperty( name, value );
- if ( !name.startsWith( "hibernate" ) ) {
- properties.setProperty( "hibernate." + name, value );
- }
- }
- Environment.verifyProperties( properties );
- }
-
- /**
- * Get the configuration file as an <tt>InputStream</tt>. Might be overridden
- * by subclasses to allow the configuration to be located by some arbitrary
- * mechanism.
- */
- protected InputStream getConfigurationInputStream(String resource) throws HibernateException {
-
- log.info( "Configuration resource: " + resource );
-
- return ConfigHelper.getResourceAsStream( resource );
-
- }
-
- /**
- * Use the mappings and properties specified in an application
- * resource named <tt>hibernate.cfg.xml</tt>.
- */
- public Configuration configure() throws HibernateException {
- configure( "/hibernate.cfg.xml" );
- return this;
- }
-
- /**
- * Use the mappings and properties specified in the given application
- * resource. The format of the resource is defined in
- * <tt>hibernate-configuration-3.0.dtd</tt>.
- * <p/>
- * The resource is found via <tt>getConfigurationInputStream(resource)</tt>.
- */
- public Configuration configure(String resource) throws HibernateException {
- log.info( "configuring from resource: " + resource );
- InputStream stream = getConfigurationInputStream( resource );
- return doConfigure( stream, resource );
- }
-
- /**
- * Use the mappings and properties specified in the given document.
- * The format of the document is defined in
- * <tt>hibernate-configuration-3.0.dtd</tt>.
- *
- * @param url URL from which you wish to load the configuration
- * @return A configuration configured via the file
- * @throws HibernateException
- */
- public Configuration configure(URL url) throws HibernateException {
- log.info( "configuring from url: " + url.toString() );
- try {
- return doConfigure( url.openStream(), url.toString() );
- }
- catch (IOException ioe) {
- throw new HibernateException( "could not configure from URL: " + url, ioe );
- }
- }
-
- /**
- * Use the mappings and properties specified in the given application
- * file. The format of the file is defined in
- * <tt>hibernate-configuration-3.0.dtd</tt>.
- *
- * @param configFile <tt>File</tt> from which you wish to load the configuration
- * @return A configuration configured via the file
- * @throws HibernateException
- */
- public Configuration configure(File configFile) throws HibernateException {
- log.info( "configuring from file: " + configFile.getName() );
- try {
- return doConfigure( new FileInputStream( configFile ), configFile.toString() );
- }
- catch (FileNotFoundException fnfe) {
- throw new HibernateException( "could not find file: " + configFile, fnfe );
- }
- }
-
- /**
- * Use the mappings and properties specified in the given application
- * resource. The format of the resource is defined in
- * <tt>hibernate-configuration-3.0.dtd</tt>.
- *
- * @param stream Inputstream to be read from
- * @param resourceName The name to use in warning/error messages
- * @return A configuration configured via the stream
- * @throws HibernateException
- */
- protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException {
-
- org.dom4j.Document doc;
- try {
- List errors = new ArrayList();
- doc = xmlHelper.createSAXReader( resourceName, errors, entityResolver )
- .read( new InputSource( stream ) );
- if ( errors.size() != 0 ) {
- throw new MappingException(
- "invalid configuration",
- (Throwable) errors.get( 0 )
- );
- }
- }
- catch (DocumentException e) {
- throw new HibernateException(
- "Could not parse configuration: " + resourceName,
- e
- );
- }
- finally {
- try {
- stream.close();
- }
- catch (IOException ioe) {
- log.warn( "could not close input stream for: " + resourceName, ioe );
- }
- }
-
- return doConfigure( doc );
-
- }
-
- /**
- * Use the mappings and properties specified in the given XML document.
- * The format of the file is defined in
- * <tt>hibernate-configuration-3.0.dtd</tt>.
- *
- * @param document an XML document from which you wish to load the configuration
- * @return A configuration configured via the <tt>Document</tt>
- * @throws HibernateException if there is problem in accessing the file.
- */
- public Configuration configure(Document document) throws HibernateException {
- log.info( "configuring from XML document" );
- return doConfigure( xmlHelper.createDOMReader().read( document ) );
- }
-
- protected Configuration doConfigure(org.dom4j.Document doc) throws HibernateException {
-
- Element sfNode = doc.getRootElement().element( "session-factory" );
- String name = sfNode.attributeValue( "name" );
- if ( name != null ) {
- properties.setProperty( Environment.SESSION_FACTORY_NAME, name );
- }
- addProperties( sfNode );
- parseSessionFactory( sfNode, name );
-
- Element secNode = doc.getRootElement().element( "security" );
- if ( secNode != null ) {
- parseSecurity( secNode );
- }
-
- log.info( "Configured SessionFactory: " + name );
- log.debug( "properties: " + properties );
-
- return this;
-
- }
-
-
- private void parseSessionFactory(Element sfNode, String name) {
- Iterator elements = sfNode.elementIterator();
- while ( elements.hasNext() ) {
- Element subelement = (Element) elements.next();
- String subelementName = subelement.getName();
- if ( "mapping".equals( subelementName ) ) {
- parseMappingElement( subelement, name );
- }
- else if ( "class-cache".equals( subelementName ) ) {
- String className = subelement.attributeValue( "class" );
- Attribute regionNode = subelement.attribute( "region" );
- final String region = ( regionNode == null ) ? className : regionNode.getValue();
- boolean includeLazy = !"non-lazy".equals( subelement.attributeValue( "include" ) );
- setCacheConcurrencyStrategy( className, subelement.attributeValue( "usage" ), region, includeLazy );
- }
- else if ( "collection-cache".equals( subelementName ) ) {
- String role = subelement.attributeValue( "collection" );
- Attribute regionNode = subelement.attribute( "region" );
- final String region = ( regionNode == null ) ? role : regionNode.getValue();
- setCollectionCacheConcurrencyStrategy( role, subelement.attributeValue( "usage" ), region );
- }
- else if ( "listener".equals( subelementName ) ) {
- parseListener( subelement );
- }
- else if ( "event".equals( subelementName ) ) {
- parseEvent( subelement );
- }
- }
- }
-
- protected void parseMappingElement(Element subelement, String name) {
- Attribute rsrc = subelement.attribute( "resource" );
- Attribute file = subelement.attribute( "file" );
- Attribute jar = subelement.attribute( "jar" );
- Attribute pkg = subelement.attribute( "package" );
- Attribute clazz = subelement.attribute( "class" );
- if ( rsrc != null ) {
- log.debug( name + "<-" + rsrc );
- addResource( rsrc.getValue() );
- }
- else if ( jar != null ) {
- log.debug( name + "<-" + jar );
- addJar( new File( jar.getValue() ) );
- }
- else if ( pkg != null ) {
- throw new MappingException(
- "An AnnotationConfiguration instance is required to use <mapping package=\"" +
- pkg.getValue() + "\"/>"
- );
- }
- else if ( clazz != null ) {
- throw new MappingException(
- "An AnnotationConfiguration instance is required to use <mapping class=\"" +
- clazz.getValue() + "\"/>"
- );
- }
- else {
- if ( file == null ) {
- throw new MappingException(
- "<mapping> element in configuration specifies no attributes"
- );
- }
- log.debug( name + "<-" + file );
- addFile( file.getValue() );
- }
- }
-
- private void parseSecurity(Element secNode) {
- String contextId = secNode.attributeValue( "context" );
- setProperty(Environment.JACC_CONTEXTID, contextId);
- log.info( "JACC contextID: " + contextId );
- JACCConfiguration jcfg = new JACCConfiguration( contextId );
- Iterator grantElements = secNode.elementIterator();
- while ( grantElements.hasNext() ) {
- Element grantElement = (Element) grantElements.next();
- String elementName = grantElement.getName();
- if ( "grant".equals( elementName ) ) {
- jcfg.addPermission(
- grantElement.attributeValue( "role" ),
- grantElement.attributeValue( "entity-name" ),
- grantElement.attributeValue( "actions" )
- );
- }
- }
- }
-
- private void parseEvent(Element element) {
- String type = element.attributeValue( "type" );
- List listeners = element.elements();
- String[] listenerClasses = new String[ listeners.size() ];
- for ( int i = 0; i < listeners.size() ; i++ ) {
- listenerClasses[i] = ( (Element) listeners.get( i ) ).attributeValue( "class" );
- }
- log.debug( "Event listeners: " + type + "=" + StringHelper.toString( listenerClasses ) );
- setListeners( type, listenerClasses );
- }
-
- private void parseListener(Element element) {
- String type = element.attributeValue( "type" );
- if ( type == null ) {
- throw new MappingException( "No type specified for listener" );
- }
- String impl = element.attributeValue( "class" );
- log.debug( "Event listener: " + type + "=" + impl );
- setListeners( type, new String[]{impl} );
- }
-
- public void setListener(String type, String listener) {
- String[] listeners = null;
- if ( listener != null ) {
- listeners = (String[]) Array.newInstance( String.class, 1 );
- listeners[0] = listener;
- }
- setListeners( type, listeners );
- }
-
- public void setListeners(String type, String[] listenerClasses) {
- Object[] listeners = null;
- if ( listenerClasses != null ) {
- listeners = (Object[]) Array.newInstance( eventListeners.getListenerClassFor(type), listenerClasses.length );
- for ( int i = 0; i < listeners.length ; i++ ) {
- try {
- listeners[i] = ReflectHelper.classForName( listenerClasses[i] ).newInstance();
- }
- catch (Exception e) {
- throw new MappingException(
- "Unable to instantiate specified event (" + type + ") listener class: " + listenerClasses[i],
- e
- );
- }
- }
- }
- setListeners( type, listeners );
- }
-
- public void setListener(String type, Object listener) {
- Object[] listeners = null;
- if ( listener != null ) {
- listeners = (Object[]) Array.newInstance( eventListeners.getListenerClassFor(type), 1 );
- listeners[0] = listener;
- }
- setListeners( type, listeners );
- }
-
- public void setListeners(String type, Object[] listeners) {
- if ( "auto-flush".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setAutoFlushEventListeners( new AutoFlushEventListener[]{} );
- }
- else {
- eventListeners.setAutoFlushEventListeners( (AutoFlushEventListener[]) listeners );
- }
- }
- else if ( "merge".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setMergeEventListeners( new MergeEventListener[]{} );
- }
- else {
- eventListeners.setMergeEventListeners( (MergeEventListener[]) listeners );
- }
- }
- else if ( "create".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPersistEventListeners( new PersistEventListener[]{} );
- }
- else {
- eventListeners.setPersistEventListeners( (PersistEventListener[]) listeners );
- }
- }
- else if ( "create-onflush".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPersistOnFlushEventListeners( new PersistEventListener[]{} );
- }
- else {
- eventListeners.setPersistOnFlushEventListeners( (PersistEventListener[]) listeners );
- }
- }
- else if ( "delete".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setDeleteEventListeners( new DeleteEventListener[]{} );
- }
- else {
- eventListeners.setDeleteEventListeners( (DeleteEventListener[]) listeners );
- }
- }
- else if ( "dirty-check".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setDirtyCheckEventListeners( new DirtyCheckEventListener[]{} );
- }
- else {
- eventListeners.setDirtyCheckEventListeners( (DirtyCheckEventListener[]) listeners );
- }
- }
- else if ( "evict".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setEvictEventListeners( new EvictEventListener[]{} );
- }
- else {
- eventListeners.setEvictEventListeners( (EvictEventListener[]) listeners );
- }
- }
- else if ( "flush".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setFlushEventListeners( new FlushEventListener[]{} );
- }
- else {
- eventListeners.setFlushEventListeners( (FlushEventListener[]) listeners );
- }
- }
- else if ( "flush-entity".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setFlushEntityEventListeners( new FlushEntityEventListener[]{} );
- }
- else {
- eventListeners.setFlushEntityEventListeners( (FlushEntityEventListener[]) listeners );
- }
- }
- else if ( "load".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setLoadEventListeners( new LoadEventListener[]{} );
- }
- else {
- eventListeners.setLoadEventListeners( (LoadEventListener[]) listeners );
- }
- }
- else if ( "load-collection".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setInitializeCollectionEventListeners(
- new InitializeCollectionEventListener[]{}
- );
- }
- else {
- eventListeners.setInitializeCollectionEventListeners(
- (InitializeCollectionEventListener[]) listeners
- );
- }
- }
- else if ( "lock".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setLockEventListeners( new LockEventListener[]{} );
- }
- else {
- eventListeners.setLockEventListeners( (LockEventListener[]) listeners );
- }
- }
- else if ( "refresh".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setRefreshEventListeners( new RefreshEventListener[]{} );
- }
- else {
- eventListeners.setRefreshEventListeners( (RefreshEventListener[]) listeners );
- }
- }
- else if ( "replicate".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setReplicateEventListeners( new ReplicateEventListener[]{} );
- }
- else {
- eventListeners.setReplicateEventListeners( (ReplicateEventListener[]) listeners );
- }
- }
- else if ( "save-update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setSaveOrUpdateEventListeners( new SaveOrUpdateEventListener[]{} );
- }
- else {
- eventListeners.setSaveOrUpdateEventListeners( (SaveOrUpdateEventListener[]) listeners );
- }
- }
- else if ( "save".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setSaveEventListeners( new SaveOrUpdateEventListener[]{} );
- }
- else {
- eventListeners.setSaveEventListeners( (SaveOrUpdateEventListener[]) listeners );
- }
- }
- else if ( "update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setUpdateEventListeners( new SaveOrUpdateEventListener[]{} );
- }
- else {
- eventListeners.setUpdateEventListeners( (SaveOrUpdateEventListener[]) listeners );
- }
- }
- else if ( "pre-load".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreLoadEventListeners( new PreLoadEventListener[]{} );
- }
- else {
- eventListeners.setPreLoadEventListeners( (PreLoadEventListener[]) listeners );
- }
- }
- else if ( "pre-update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreUpdateEventListeners( new PreUpdateEventListener[]{} );
- }
- else {
- eventListeners.setPreUpdateEventListeners( (PreUpdateEventListener[]) listeners );
- }
- }
- else if ( "pre-delete".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreDeleteEventListeners( new PreDeleteEventListener[]{} );
- }
- else {
- eventListeners.setPreDeleteEventListeners( (PreDeleteEventListener[]) listeners );
- }
- }
- else if ( "pre-insert".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreInsertEventListeners( new PreInsertEventListener[]{} );
- }
- else {
- eventListeners.setPreInsertEventListeners( (PreInsertEventListener[]) listeners );
- }
- }
- else if ( "pre-collection-recreate".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreCollectionRecreateEventListeners( new PreCollectionRecreateEventListener[]{} );
- }
- else {
- eventListeners.setPreCollectionRecreateEventListeners( (PreCollectionRecreateEventListener[]) listeners );
- }
- }
- else if ( "pre-collection-remove".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreCollectionRemoveEventListeners( new PreCollectionRemoveEventListener[]{} );
- }
- else {
- eventListeners.setPreCollectionRemoveEventListeners( ( PreCollectionRemoveEventListener[]) listeners );
- }
- }
- else if ( "pre-collection-update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPreCollectionUpdateEventListeners( new PreCollectionUpdateEventListener[]{} );
- }
- else {
- eventListeners.setPreCollectionUpdateEventListeners( ( PreCollectionUpdateEventListener[]) listeners );
- }
- }
- else if ( "post-load".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostLoadEventListeners( new PostLoadEventListener[]{} );
- }
- else {
- eventListeners.setPostLoadEventListeners( (PostLoadEventListener[]) listeners );
- }
- }
- else if ( "post-update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostUpdateEventListeners( new PostUpdateEventListener[]{} );
- }
- else {
- eventListeners.setPostUpdateEventListeners( (PostUpdateEventListener[]) listeners );
- }
- }
- else if ( "post-delete".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostDeleteEventListeners( new PostDeleteEventListener[]{} );
- }
- else {
- eventListeners.setPostDeleteEventListeners( (PostDeleteEventListener[]) listeners );
- }
- }
- else if ( "post-insert".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostInsertEventListeners( new PostInsertEventListener[]{} );
- }
- else {
- eventListeners.setPostInsertEventListeners( (PostInsertEventListener[]) listeners );
- }
- }
- else if ( "post-commit-update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostCommitUpdateEventListeners(
- new PostUpdateEventListener[]{}
- );
- }
- else {
- eventListeners.setPostCommitUpdateEventListeners( (PostUpdateEventListener[]) listeners );
- }
- }
- else if ( "post-commit-delete".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostCommitDeleteEventListeners(
- new PostDeleteEventListener[]{}
- );
- }
- else {
- eventListeners.setPostCommitDeleteEventListeners( (PostDeleteEventListener[]) listeners );
- }
- }
- else if ( "post-commit-insert".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostCommitInsertEventListeners(
- new PostInsertEventListener[]{}
- );
- }
- else {
- eventListeners.setPostCommitInsertEventListeners( (PostInsertEventListener[]) listeners );
- }
- }
- else if ( "post-collection-recreate".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostCollectionRecreateEventListeners( new PostCollectionRecreateEventListener[]{} );
- }
- else {
- eventListeners.setPostCollectionRecreateEventListeners( (PostCollectionRecreateEventListener[]) listeners );
- }
- }
- else if ( "post-collection-remove".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostCollectionRemoveEventListeners( new PostCollectionRemoveEventListener[]{} );
- }
- else {
- eventListeners.setPostCollectionRemoveEventListeners( ( PostCollectionRemoveEventListener[]) listeners );
- }
- }
- else if ( "post-collection-update".equals( type ) ) {
- if ( listeners == null ) {
- eventListeners.setPostCollectionUpdateEventListeners( new PostCollectionUpdateEventListener[]{} );
- }
- else {
- eventListeners.setPostCollectionUpdateEventListeners( ( PostCollectionUpdateEventListener[]) listeners );
- }
- }
- else {
- throw new MappingException("Unrecognized listener type [" + type + "]");
- }
- }
-
- public EventListeners getEventListeners() {
- return eventListeners;
- }
-
- RootClass getRootClassMapping(String clazz) throws MappingException {
- try {
- return (RootClass) getClassMapping( clazz );
- }
- catch (ClassCastException cce) {
- throw new MappingException( "You may only specify a cache for root <class> mappings" );
- }
- }
-
- /**
- * Set up a cache for an entity class
- *
- * @param clazz
- * @param concurrencyStrategy
- * @return Configuration
- * @throws MappingException
- */
- public Configuration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy)
- throws MappingException {
- setCacheConcurrencyStrategy( clazz, concurrencyStrategy, clazz );
- return this;
- }
-
- public void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region)
- throws MappingException {
- setCacheConcurrencyStrategy( clazz, concurrencyStrategy, region, true );
- }
-
- void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region, boolean includeLazy)
- throws MappingException {
- RootClass rootClass = getRootClassMapping( clazz );
- if ( rootClass == null ) {
- throw new MappingException( "Cannot cache an unknown entity: " + clazz );
- }
- rootClass.setCacheConcurrencyStrategy( concurrencyStrategy );
- rootClass.setCacheRegionName( region );
- rootClass.setLazyPropertiesCacheable( includeLazy );
- }
-
- /**
- * Set up a cache for a collection role
- *
- * @param collectionRole
- * @param concurrencyStrategy
- * @return Configuration
- * @throws MappingException
- */
- public Configuration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
- throws MappingException {
- setCollectionCacheConcurrencyStrategy( collectionRole, concurrencyStrategy, collectionRole );
- return this;
- }
-
- public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region)
- throws MappingException {
- Collection collection = getCollectionMapping( collectionRole );
- if ( collection == null ) {
- throw new MappingException( "Cannot cache an unknown collection: " + collectionRole );
- }
- collection.setCacheConcurrencyStrategy( concurrencyStrategy );
- collection.setCacheRegionName( region );
- }
-
- /**
- * Get the query language imports
- *
- * @return a mapping from "import" names to fully qualified class names
- */
- public Map getImports() {
- return imports;
- }
-
- /**
- * Create an object-oriented view of the configuration properties
- */
- public Settings buildSettings() throws HibernateException {
- Properties clone = ( Properties ) properties.clone();
- PropertiesHelper.resolvePlaceHolders( clone );
- return settingsFactory.buildSettings( clone );
- }
-
- public Settings buildSettings(Properties props) throws HibernateException {
- return settingsFactory.buildSettings( props );
- }
-
- public Map getNamedSQLQueries() {
- return namedSqlQueries;
- }
-
- public Map getSqlResultSetMappings() {
- return sqlResultSetMappings;
- }
-
- /**
- * @return the NamingStrategy.
- */
- public NamingStrategy getNamingStrategy() {
- return namingStrategy;
- }
-
- /**
- * Set a custom naming strategy
- *
- * @param namingStrategy the NamingStrategy to set
- */
- public Configuration setNamingStrategy(NamingStrategy namingStrategy) {
- this.namingStrategy = namingStrategy;
- return this;
- }
-
- public Mapping buildMapping() {
- return new Mapping() {
- /**
- * Returns the identifier type of a mapped class
- */
- public Type getIdentifierType(String persistentClass) throws MappingException {
- PersistentClass pc = ( (PersistentClass) classes.get( persistentClass ) );
- if ( pc == null ) {
- throw new MappingException( "persistent class not known: " + persistentClass );
- }
- return pc.getIdentifier().getType();
- }
-
- public String getIdentifierPropertyName(String persistentClass) throws MappingException {
- final PersistentClass pc = (PersistentClass) classes.get( persistentClass );
- if ( pc == null ) {
- throw new MappingException( "persistent class not known: " + persistentClass );
- }
- if ( !pc.hasIdentifierProperty() ) {
- return null;
- }
- return pc.getIdentifierProperty().getName();
- }
-
- public Type getReferencedPropertyType(String persistentClass, String propertyName) throws MappingException {
- final PersistentClass pc = (PersistentClass) classes.get( persistentClass );
- if ( pc == null ) {
- throw new MappingException( "persistent class not known: " + persistentClass );
- }
- Property prop = pc.getReferencedProperty( propertyName );
- if ( prop == null ) {
- throw new MappingException(
- "property not known: " +
- persistentClass + '.' + propertyName
- );
- }
- return prop.getType();
- }
- };
- }
-
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- ois.defaultReadObject();
- this.mapping = buildMapping();
- xmlHelper = new XMLHelper();
- }
-
- public Map getFilterDefinitions() {
- return filterDefinitions;
- }
-
- public void addFilterDefinition(FilterDefinition definition) {
- filterDefinitions.put( definition.getFilterName(), definition );
- }
-
- public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object) {
- auxiliaryDatabaseObjects.add( object );
- }
-
- public Map getSqlFunctions() {
- return sqlFunctions;
- }
-
- public void addSqlFunction(String functionName, SQLFunction function) {
- sqlFunctions.put( functionName, function );
- }
-
- public SessionFactoryObserver getSessionFactoryObserver() {
- return sessionFactoryObserver;
- }
-
- public void setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver) {
- this.sessionFactoryObserver = sessionFactoryObserver;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/Configuration.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Configuration.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,2203 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.lang.reflect.Array;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+import org.dom4j.Attribute;
+import org.dom4j.DocumentException;
+import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+import org.hibernate.EmptyInterceptor;
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.InvalidMappingException;
+import org.hibernate.MappingException;
+import org.hibernate.MappingNotFoundException;
+import org.hibernate.SessionFactory;
+import org.hibernate.SessionFactoryObserver;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.engine.FilterDefinition;
+import org.hibernate.engine.Mapping;
+import org.hibernate.event.AutoFlushEventListener;
+import org.hibernate.event.DeleteEventListener;
+import org.hibernate.event.DirtyCheckEventListener;
+import org.hibernate.event.EventListeners;
+import org.hibernate.event.EvictEventListener;
+import org.hibernate.event.FlushEntityEventListener;
+import org.hibernate.event.FlushEventListener;
+import org.hibernate.event.InitializeCollectionEventListener;
+import org.hibernate.event.LoadEventListener;
+import org.hibernate.event.LockEventListener;
+import org.hibernate.event.MergeEventListener;
+import org.hibernate.event.PersistEventListener;
+import org.hibernate.event.PostCollectionRecreateEventListener;
+import org.hibernate.event.PostCollectionRemoveEventListener;
+import org.hibernate.event.PostCollectionUpdateEventListener;
+import org.hibernate.event.PostDeleteEventListener;
+import org.hibernate.event.PostInsertEventListener;
+import org.hibernate.event.PostLoadEventListener;
+import org.hibernate.event.PostUpdateEventListener;
+import org.hibernate.event.PreCollectionRecreateEventListener;
+import org.hibernate.event.PreCollectionRemoveEventListener;
+import org.hibernate.event.PreCollectionUpdateEventListener;
+import org.hibernate.event.PreDeleteEventListener;
+import org.hibernate.event.PreInsertEventListener;
+import org.hibernate.event.PreLoadEventListener;
+import org.hibernate.event.PreUpdateEventListener;
+import org.hibernate.event.RefreshEventListener;
+import org.hibernate.event.ReplicateEventListener;
+import org.hibernate.event.SaveOrUpdateEventListener;
+import org.hibernate.id.IdentifierGenerator;
+import org.hibernate.id.PersistentIdentifierGenerator;
+import org.hibernate.impl.SessionFactoryImpl;
+import org.hibernate.mapping.AuxiliaryDatabaseObject;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.IdentifierCollection;
+import org.hibernate.mapping.Index;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.UniqueKey;
+import org.hibernate.proxy.EntityNotFoundDelegate;
+import org.hibernate.secure.JACCConfiguration;
+import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
+import org.hibernate.tool.hbm2ddl.TableMetadata;
+import org.hibernate.type.SerializationException;
+import org.hibernate.type.Type;
+import org.hibernate.util.ArrayHelper;
+import org.hibernate.util.CollectionHelper;
+import org.hibernate.util.ConfigHelper;
+import org.hibernate.util.PropertiesHelper;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.util.SerializationHelper;
+import org.hibernate.util.StringHelper;
+import org.hibernate.util.XMLHelper;
+
+/**
+ * An instance of <tt>Configuration</tt> allows the application
+ * to specify properties and mapping documents to be used when
+ * creating a <tt>SessionFactory</tt>. Usually an application will create
+ * a single <tt>Configuration</tt>, build a single instance of
+ * <tt>SessionFactory</tt> and then instantiate <tt>Session</tt>s in
+ * threads servicing client requests. The <tt>Configuration</tt> is meant
+ * only as an initialization-time object. <tt>SessionFactory</tt>s are
+ * immutable and do not retain any association back to the
+ * <tt>Configuration</tt>.<br>
+ * <br>
+ * A new <tt>Configuration</tt> will use the properties specified in
+ * <tt>hibernate.properties</tt> by default.
+ *
+ * @author Gavin King
+ * @see org.hibernate.SessionFactory
+ */
+public class Configuration implements Serializable {
+
+ private static Logger log = LoggerFactory.getLogger( Configuration.class );
+
+ protected Map classes;
+ protected Map imports;
+ protected Map collections;
+ protected Map tables;
+ protected List auxiliaryDatabaseObjects;
+ protected Map sqlFunctions;
+ protected Map namedQueries;
+ protected Map namedSqlQueries;
+ /**
+ * Map<String, SqlResultSetMapping> result set name, result set description
+ */
+ protected Map sqlResultSetMappings;
+ protected Map filterDefinitions;
+ protected List secondPasses;
+ protected List propertyReferences;
+// protected List extendsQueue;
+ protected Map extendsQueue;
+ protected Map tableNameBinding;
+ protected Map columnNameBindingPerTable;
+ private Interceptor interceptor;
+ private Properties properties;
+ private EntityResolver entityResolver;
+ private EntityNotFoundDelegate entityNotFoundDelegate;
+
+ protected transient XMLHelper xmlHelper;
+ protected transient Map typeDefs;
+
+ protected NamingStrategy namingStrategy;
+
+ private EventListeners eventListeners;
+
+ protected final SettingsFactory settingsFactory;
+
+ private SessionFactoryObserver sessionFactoryObserver;
+
+ protected void reset() {
+ classes = new HashMap();
+ imports = new HashMap();
+ collections = new HashMap();
+ tables = new TreeMap();
+ namedQueries = new HashMap();
+ namedSqlQueries = new HashMap();
+ sqlResultSetMappings = new HashMap();
+ xmlHelper = new XMLHelper();
+ typeDefs = new HashMap();
+ propertyReferences = new ArrayList();
+ secondPasses = new ArrayList();
+ interceptor = EmptyInterceptor.INSTANCE;
+ properties = Environment.getProperties();
+ entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
+ eventListeners = new EventListeners();
+ filterDefinitions = new HashMap();
+// extendsQueue = new ArrayList();
+ extendsQueue = new HashMap();
+ auxiliaryDatabaseObjects = new ArrayList();
+ tableNameBinding = new HashMap();
+ columnNameBindingPerTable = new HashMap();
+ namingStrategy = DefaultNamingStrategy.INSTANCE;
+ sqlFunctions = new HashMap();
+ }
+
+ private transient Mapping mapping = buildMapping();
+
+
+
+ protected Configuration(SettingsFactory settingsFactory) {
+ this.settingsFactory = settingsFactory;
+ reset();
+ }
+
+ public Configuration() {
+ this( new SettingsFactory() );
+ }
+
+ /**
+ * Iterate the entity mappings
+ *
+ * @return Iterator of the entity mappings currently contained in the configuration.
+ */
+ public Iterator getClassMappings() {
+ return classes.values().iterator();
+ }
+
+ /**
+ * Iterate the collection mappings
+ *
+ * @return Iterator of the collection mappings currently contained in the configuration.
+ */
+ public Iterator getCollectionMappings() {
+ return collections.values().iterator();
+ }
+
+ /**
+ * Iterate the table mappings
+ *
+ * @return Iterator of the table mappings currently contained in the configuration.
+ */
+ public Iterator getTableMappings() {
+ return tables.values().iterator();
+ }
+
+ /**
+ * Get the mapping for a particular entity
+ *
+ * @param entityName An entity name.
+ * @return the entity mapping information
+ */
+ public PersistentClass getClassMapping(String entityName) {
+ return (PersistentClass) classes.get( entityName );
+ }
+
+ /**
+ * Get the mapping for a particular collection role
+ *
+ * @param role a collection role
+ * @return The collection mapping information
+ */
+ public Collection getCollectionMapping(String role) {
+ return (Collection) collections.get( role );
+ }
+
+ /**
+ * Set a custom entity resolver. This entity resolver must be
+ * set before addXXX(misc) call.
+ * Default value is {@link org.hibernate.util.DTDEntityResolver}
+ *
+ * @param entityResolver entity resolver to use
+ */
+ public void setEntityResolver(EntityResolver entityResolver) {
+ this.entityResolver = entityResolver;
+ }
+
+ public EntityResolver getEntityResolver() {
+ return entityResolver;
+ }
+
+ /**
+ * Retrieve the user-supplied delegate to handle non-existent entity
+ * scenarios. May be null.
+ *
+ * @return The user-supplied delegate
+ */
+ public EntityNotFoundDelegate getEntityNotFoundDelegate() {
+ return entityNotFoundDelegate;
+ }
+
+ /**
+ * Specify a user-supplied delegate to be used to handle scenarios where an entity could not be
+ * located by specified id. This is mainly intended for EJB3 implementations to be able to
+ * control how proxy initialization errors should be handled...
+ *
+ * @param entityNotFoundDelegate The delegate to use
+ */
+ public void setEntityNotFoundDelegate(EntityNotFoundDelegate entityNotFoundDelegate) {
+ this.entityNotFoundDelegate = entityNotFoundDelegate;
+ }
+
+ /**
+ * Read mappings from a particular XML file
+ *
+ * @param xmlFile a path to a file
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates inability to locate or parse
+ * the specified mapping file.
+ * @see #addFile(java.io.File)
+ */
+ public Configuration addFile(String xmlFile) throws MappingException {
+ return addFile( new File( xmlFile ) );
+ }
+
+ /**
+ * Read mappings from a particular XML file
+ *
+ * @param xmlFile a path to a file
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates inability to locate or parse
+ * the specified mapping file.
+ */
+ public Configuration addFile(File xmlFile) throws MappingException {
+ log.info( "Reading mappings from file: " + xmlFile.getPath() );
+ if ( !xmlFile.exists() ) {
+ throw new MappingNotFoundException( "file", xmlFile.toString() );
+ }
+ try {
+ List errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile.toString(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), ( Throwable ) errors.get( 0 ) );
+ }
+ add( doc );
+ return this;
+ }
+ catch ( InvalidMappingException e ) {
+ throw e;
+ }
+ catch ( MappingNotFoundException e ) {
+ throw e;
+ }
+ catch ( Exception e ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), e );
+ }
+ }
+
+ /**
+ * Add a cached mapping file. A cached file is a serialized representation
+ * of the DOM structure of a particular mapping. It is saved from a previous
+ * call as a file with the name <tt>xmlFile + ".bin"</tt> where xmlFile is
+ * the name of the original mapping file.
+ * </p>
+ * If a cached <tt>xmlFile + ".bin"</tt> exists and is newer than
+ * <tt>xmlFile</tt> the <tt>".bin"</tt> file will be read directly. Otherwise
+ * xmlFile is read and then serialized to <tt>xmlFile + ".bin"</tt> for use
+ * the next time.
+ *
+ * @param xmlFile The cacheable mapping file to be added.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the cached file or processing
+ * the non-cached file.
+ */
+ public Configuration addCacheableFile(File xmlFile) throws MappingException {
+ try {
+ File cachedFile = new File( xmlFile.getAbsolutePath() + ".bin" );
+ org.dom4j.Document doc = null;
+
+ final boolean useCachedFile = xmlFile.exists() &&
+ cachedFile.exists() &&
+ xmlFile.lastModified() < cachedFile.lastModified();
+
+ if ( useCachedFile ) {
+ try {
+ log.info( "Reading mappings from cache file: " + cachedFile );
+ doc = ( org.dom4j.Document ) SerializationHelper.deserialize( new FileInputStream( cachedFile ) );
+ }
+ catch ( SerializationException e ) {
+ log.warn( "Could not deserialize cache file: " + cachedFile.getPath(), e );
+ }
+ catch ( FileNotFoundException e ) {
+ log.warn( "I/O reported cached file could not be found : " + cachedFile.getPath(), e );
+ }
+ }
+
+ // if doc is null, then for whatever reason, the cached file cannot be used...
+ if ( doc == null ) {
+ if ( !xmlFile.exists() ) {
+ throw new MappingNotFoundException( "file", xmlFile.toString() );
+ }
+
+ log.info( "Reading mappings from file: " + xmlFile );
+ List errors = new ArrayList();
+ try {
+ doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile );
+ if ( errors.size() != 0 ) {
+ throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );
+ }
+ }
+ catch( DocumentException e){
+ throw new MappingException( "invalid mapping", e );
+ }
+
+ try {
+ log.debug( "Writing cache file for: " + xmlFile + " to: " + cachedFile );
+ SerializationHelper.serialize( ( Serializable ) doc, new FileOutputStream( cachedFile ) );
+ }
+ catch ( SerializationException e ) {
+ log.warn( "Could not write cached file: " + cachedFile, e );
+ }
+ catch ( FileNotFoundException e ) {
+ log.warn( "I/O reported error writing cached file : " + cachedFile.getPath(), e );
+ }
+ }
+
+ add( doc );
+ return this;
+
+ }
+ catch ( InvalidMappingException e ) {
+ throw e;
+ }
+ catch ( MappingNotFoundException e ) {
+ throw e;
+ }
+ catch ( Exception e ) {
+ throw new InvalidMappingException( "file", xmlFile.toString(), e );
+ }
+ }
+
+ /**
+ * Add a cacheable mapping file.
+ *
+ * @param xmlFile The name of the file to be added. This must be in a form
+ * useable to simply construct a {@link java.io.File} instance.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the cached file or processing
+ * the non-cached file.
+ * @see #addCacheableFile(java.io.File)
+ */
+ public Configuration addCacheableFile(String xmlFile) throws MappingException {
+ return addCacheableFile( new File( xmlFile ) );
+ }
+
+
+ /**
+ * Read mappings from a <tt>String</tt>
+ *
+ * @param xml an XML string
+ * @return this (for method chaining purposes)
+ * @throws org.hibernate.MappingException Indicates problems parsing the
+ * given XML string
+ */
+ public Configuration addXML(String xml) throws MappingException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Mapping XML:\n" + xml );
+ }
+ try {
+ List errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( "XML String", errors, entityResolver )
+ .read( new StringReader( xml ) );
+ if ( errors.size() != 0 ) {
+ throw new MappingException( "invalid mapping", (Throwable) errors.get( 0 ) );
+ }
+ add( doc );
+ }
+ catch (DocumentException e) {
+ throw new MappingException( "Could not parse mapping document in XML string", e );
+ }
+ return this;
+ }
+
+ /**
+ * Read mappings from a <tt>URL</tt>
+ *
+ * @param url The url for the mapping document to be read.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the URL or processing
+ * the mapping document.
+ */
+ public Configuration addURL(URL url) throws MappingException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Reading mapping document from URL:" + url.toExternalForm() );
+ }
+ try {
+ addInputStream( url.openStream() );
+ }
+ catch ( InvalidMappingException e ) {
+ throw new InvalidMappingException( "URL", url.toExternalForm(), e.getCause() );
+ }
+ catch (Exception e) {
+ throw new InvalidMappingException( "URL", url.toExternalForm(), e );
+ }
+ return this;
+ }
+
+ /**
+ * Read mappings from a DOM <tt>Document</tt>
+ *
+ * @param doc The DOM document
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the DOM or processing
+ * the mapping document.
+ */
+ public Configuration addDocument(Document doc) throws MappingException {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Mapping document:\n" + doc );
+ }
+ add( xmlHelper.createDOMReader().read( doc ) );
+ return this;
+ }
+
+ /**
+ * Read mappings from an {@link java.io.InputStream}.
+ *
+ * @param xmlInputStream The input stream containing a DOM.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the stream, or
+ * processing the contained mapping document.
+ */
+ public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
+ try {
+ List errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, entityResolver )
+ .read( new InputSource( xmlInputStream ) );
+ if ( errors.size() != 0 ) {
+ throw new InvalidMappingException( "invalid mapping", null, (Throwable) errors.get( 0 ) );
+ }
+ add( doc );
+ return this;
+ }
+ catch (DocumentException e) {
+ throw new InvalidMappingException( "input stream", null, e );
+ }
+ finally {
+ try {
+ xmlInputStream.close();
+ }
+ catch (IOException ioe) {
+ log.warn( "Could not close input stream", ioe );
+ }
+ }
+ }
+
+ /**
+ * Read mappings as a application resource (i.e. classpath lookup).
+ *
+ * @param resourceName The resource name
+ * @param classLoader The class loader to use.
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
+ */
+ public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
+ log.info( "Reading mappings from resource: " + resourceName );
+ InputStream rsrc = classLoader.getResourceAsStream( resourceName );
+ if ( rsrc == null ) {
+ throw new MappingNotFoundException( "resource", resourceName );
+ }
+ try {
+ return addInputStream( rsrc );
+ }
+ catch (MappingException me) {
+ throw new InvalidMappingException( "resource", resourceName, me );
+ }
+ }
+
+ /**
+ * Read mappings as a application resourceName (i.e. classpath lookup)
+ * trying different classloaders.
+ *
+ * @param resourceName The resource name
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
+ */
+ public Configuration addResource(String resourceName) throws MappingException {
+ log.info( "Reading mappings from resource : " + resourceName );
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ InputStream rsrc = null;
+ if (contextClassLoader!=null) {
+ rsrc = contextClassLoader.getResourceAsStream( resourceName );
+ }
+ if ( rsrc == null ) {
+ rsrc = Environment.class.getClassLoader().getResourceAsStream( resourceName );
+ }
+ if ( rsrc == null ) {
+ throw new MappingNotFoundException( "resource", resourceName );
+ }
+ try {
+ return addInputStream( rsrc );
+ }
+ catch (MappingException me) {
+ throw new InvalidMappingException( "resource", resourceName, me );
+ }
+ }
+
+ /**
+ * Read a mapping as an application resouurce using the convention that a class
+ * named <tt>foo.bar.Foo</tt> is mapped by a file <tt>foo/bar/Foo.hbm.xml</tt>
+ * which can be resolved as a classpath resource.
+ *
+ * @param persistentClass The mapped class
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems locating the resource or
+ * processing the contained mapping document.
+ */
+ public Configuration addClass(Class persistentClass) throws MappingException {
+ String mappingResourceName = persistentClass.getName().replace( '.', '/' ) + ".hbm.xml";
+ log.info( "Reading mappings from resource: " + mappingResourceName );
+ return addResource( mappingResourceName, persistentClass.getClassLoader() );
+ }
+
+ /**
+ * Read all mappings from a jar file
+ * <p/>
+ * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
+ *
+ * @param jar a jar file
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the jar file or
+ * processing the contained mapping documents.
+ */
+ public Configuration addJar(File jar) throws MappingException {
+ log.info( "Searching for mapping documents in jar: " + jar.getName() );
+ JarFile jarFile = null;
+ try {
+ try {
+ jarFile = new JarFile( jar );
+ }
+ catch (IOException ioe) {
+ throw new InvalidMappingException(
+ "Could not read mapping documents from jar: " + jar.getName(), "jar", jar.getName(),
+ ioe
+ );
+ }
+ Enumeration jarEntries = jarFile.entries();
+ while ( jarEntries.hasMoreElements() ) {
+ ZipEntry ze = (ZipEntry) jarEntries.nextElement();
+ if ( ze.getName().endsWith( ".hbm.xml" ) ) {
+ log.info( "Found mapping document in jar: " + ze.getName() );
+ try {
+ addInputStream( jarFile.getInputStream( ze ) );
+ }
+ catch (Exception e) {
+ throw new InvalidMappingException(
+ "Could not read mapping documents from jar: " + jar.getName(),
+ "jar",
+ jar.getName(),
+ e
+ );
+ }
+ }
+ }
+ }
+ finally {
+ try {
+ if ( jarFile != null ) {
+ jarFile.close();
+ }
+ }
+ catch (IOException ioe) {
+ log.error("could not close jar", ioe);
+ }
+ }
+
+ return this;
+ }
+
+ /**
+ * Read all mapping documents from a directory tree.
+ * <p/>
+ * Assumes that any file named <tt>*.hbm.xml</tt> is a mapping document.
+ *
+ * @param dir The directory
+ * @return this (for method chaining purposes)
+ * @throws MappingException Indicates problems reading the jar file or
+ * processing the contained mapping documents.
+ */
+ public Configuration addDirectory(File dir) throws MappingException {
+ File[] files = dir.listFiles();
+ for ( int i = 0; i < files.length ; i++ ) {
+ if ( files[i].isDirectory() ) {
+ addDirectory( files[i] );
+ }
+ else if ( files[i].getName().endsWith( ".hbm.xml" ) ) {
+ addFile( files[i] );
+ }
+ }
+ return this;
+ }
+
+ protected void add(org.dom4j.Document doc) throws MappingException {
+ HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
+ }
+
+ /**
+ * Create a new <tt>Mappings</tt> to add class and collection
+ * mappings to.
+ */
+ public Mappings createMappings() {
+ return new Mappings(
+ classes,
+ collections,
+ tables,
+ namedQueries,
+ namedSqlQueries,
+ sqlResultSetMappings,
+ imports,
+ secondPasses,
+ propertyReferences,
+ namingStrategy,
+ typeDefs,
+ filterDefinitions,
+ extendsQueue,
+ auxiliaryDatabaseObjects,
+ tableNameBinding,
+ columnNameBindingPerTable
+ );
+ }
+
+
+ private Iterator iterateGenerators(Dialect dialect) throws MappingException {
+
+ TreeMap generators = new TreeMap();
+ String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
+ String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
+
+ Iterator iter = classes.values().iterator();
+ while ( iter.hasNext() ) {
+ PersistentClass pc = (PersistentClass) iter.next();
+
+ if ( !pc.isInherited() ) {
+
+ IdentifierGenerator ig = pc.getIdentifier()
+ .createIdentifierGenerator(
+ dialect,
+ defaultCatalog,
+ defaultSchema,
+ (RootClass) pc
+ );
+
+ if ( ig instanceof PersistentIdentifierGenerator ) {
+ generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
+ }
+
+ }
+ }
+
+ iter = collections.values().iterator();
+ while ( iter.hasNext() ) {
+ Collection collection = (Collection) iter.next();
+
+ if ( collection.isIdentified() ) {
+
+ IdentifierGenerator ig = ( (IdentifierCollection) collection ).getIdentifier()
+ .createIdentifierGenerator(
+ dialect,
+ defaultCatalog,
+ defaultSchema,
+ null
+ );
+
+ if ( ig instanceof PersistentIdentifierGenerator ) {
+ generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
+ }
+
+ }
+ }
+
+ return generators.values().iterator();
+ }
+
+ /**
+ * Generate DDL for dropping tables
+ *
+ * @see org.hibernate.tool.hbm2ddl.SchemaExport
+ */
+ public String[] generateDropSchemaScript(Dialect dialect) throws HibernateException {
+
+ secondPassCompile();
+
+ String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
+ String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
+
+ ArrayList script = new ArrayList( 50 );
+
+ // drop them in reverse order in case db needs it done that way...
+ ListIterator itr = auxiliaryDatabaseObjects.listIterator( auxiliaryDatabaseObjects.size() );
+ while ( itr.hasPrevious() ) {
+ AuxiliaryDatabaseObject object = (AuxiliaryDatabaseObject) itr.previous();
+ if ( object.appliesToDialect( dialect ) ) {
+ script.add( object.sqlDropString( dialect, defaultCatalog, defaultSchema ) );
+ }
+ }
+
+ if ( dialect.dropConstraints() ) {
+ Iterator iter = getTableMappings();
+ while ( iter.hasNext() ) {
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+ Iterator subIter = table.getForeignKeyIterator();
+ while ( subIter.hasNext() ) {
+ ForeignKey fk = (ForeignKey) subIter.next();
+ if ( fk.isPhysicalConstraint() ) {
+ script.add(
+ fk.sqlDropString(
+ dialect,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+ }
+ }
+ }
+ }
+ }
+
+
+ Iterator iter = getTableMappings();
+ while ( iter.hasNext() ) {
+
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+
+ /*Iterator subIter = table.getIndexIterator();
+ while ( subIter.hasNext() ) {
+ Index index = (Index) subIter.next();
+ if ( !index.isForeignKey() || !dialect.hasImplicitIndexForForeignKey() ) {
+ script.add( index.sqlDropString(dialect) );
+ }
+ }*/
+
+ script.add(
+ table.sqlDropString(
+ dialect,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+
+ }
+
+ }
+
+ iter = iterateGenerators( dialect );
+ while ( iter.hasNext() ) {
+ String[] lines = ( (PersistentIdentifierGenerator) iter.next() ).sqlDropStrings( dialect );
+ for ( int i = 0; i < lines.length ; i++ ) {
+ script.add( lines[i] );
+ }
+ }
+
+ return ArrayHelper.toStringArray( script );
+ }
+
+ /**
+ * Generate DDL for creating tables
+ *
+ * @see org.hibernate.tool.hbm2ddl.SchemaExport
+ */
+ public String[] generateSchemaCreationScript(Dialect dialect) throws HibernateException {
+ secondPassCompile();
+
+ ArrayList script = new ArrayList( 50 );
+ String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
+ String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
+
+ Iterator iter = getTableMappings();
+ while ( iter.hasNext() ) {
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+ script.add(
+ table.sqlCreateString(
+ dialect,
+ mapping,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+ Iterator comments = table.sqlCommentStrings( dialect, defaultCatalog, defaultSchema );
+ while ( comments.hasNext() ) {
+ script.add( comments.next() );
+ }
+ }
+ }
+
+ iter = getTableMappings();
+ while ( iter.hasNext() ) {
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+
+ if ( !dialect.supportsUniqueConstraintInCreateAlterTable() ) {
+ Iterator subIter = table.getUniqueKeyIterator();
+ while ( subIter.hasNext() ) {
+ UniqueKey uk = (UniqueKey) subIter.next();
+ String constraintString = uk.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema );
+ if (constraintString != null) script.add( constraintString );
+ }
+ }
+
+
+ Iterator subIter = table.getIndexIterator();
+ while ( subIter.hasNext() ) {
+ Index index = (Index) subIter.next();
+ script.add(
+ index.sqlCreateString(
+ dialect,
+ mapping,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+ }
+
+ if ( dialect.hasAlterTable() ) {
+ subIter = table.getForeignKeyIterator();
+ while ( subIter.hasNext() ) {
+ ForeignKey fk = (ForeignKey) subIter.next();
+ if ( fk.isPhysicalConstraint() ) {
+ script.add(
+ fk.sqlCreateString(
+ dialect, mapping,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+ }
+ }
+ }
+
+ }
+ }
+
+ iter = iterateGenerators( dialect );
+ while ( iter.hasNext() ) {
+ String[] lines = ( (PersistentIdentifierGenerator) iter.next() ).sqlCreateStrings( dialect );
+ for ( int i = 0; i < lines.length ; i++ ) {
+ script.add( lines[i] );
+ }
+ }
+
+ Iterator itr = auxiliaryDatabaseObjects.iterator();
+ while ( itr.hasNext() ) {
+ AuxiliaryDatabaseObject object = (AuxiliaryDatabaseObject) itr.next();
+ if ( object.appliesToDialect( dialect ) ) {
+ script.add( object.sqlCreateString( dialect, mapping, defaultCatalog, defaultSchema ) );
+ }
+ }
+
+ return ArrayHelper.toStringArray( script );
+ }
+
+ /**
+ * Generate DDL for altering tables
+ *
+ * @see org.hibernate.tool.hbm2ddl.SchemaUpdate
+ */
+ public String[] generateSchemaUpdateScript(Dialect dialect, DatabaseMetadata databaseMetadata)
+ throws HibernateException {
+ secondPassCompile();
+
+ String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
+ String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
+
+ ArrayList script = new ArrayList( 50 );
+
+ Iterator iter = getTableMappings();
+ while ( iter.hasNext() ) {
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+
+ TableMetadata tableInfo = databaseMetadata.getTableMetadata(
+ table.getName(),
+ ( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
+ ( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
+ table.isQuoted()
+
+ );
+ if ( tableInfo == null ) {
+ script.add(
+ table.sqlCreateString(
+ dialect,
+ mapping,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+ }
+ else {
+ Iterator subiter = table.sqlAlterStrings(
+ dialect,
+ mapping,
+ tableInfo,
+ defaultCatalog,
+ defaultSchema
+ );
+ while ( subiter.hasNext() ) {
+ script.add( subiter.next() );
+ }
+ }
+
+ Iterator comments = table.sqlCommentStrings( dialect, defaultCatalog, defaultSchema );
+ while ( comments.hasNext() ) {
+ script.add( comments.next() );
+ }
+
+ }
+ }
+
+ iter = getTableMappings();
+ while ( iter.hasNext() ) {
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+
+ TableMetadata tableInfo = databaseMetadata.getTableMetadata(
+ table.getName(),
+ table.getSchema(),
+ table.getCatalog(),
+ table.isQuoted()
+ );
+
+ if ( dialect.hasAlterTable() ) {
+ Iterator subIter = table.getForeignKeyIterator();
+ while ( subIter.hasNext() ) {
+ ForeignKey fk = (ForeignKey) subIter.next();
+ if ( fk.isPhysicalConstraint() ) {
+ boolean create = tableInfo == null || (
+ tableInfo.getForeignKeyMetadata( fk.getName() ) == null && (
+ //Icky workaround for MySQL bug:
+ !( dialect instanceof MySQLDialect ) ||
+ tableInfo.getIndexMetadata( fk.getName() ) == null
+ )
+ );
+ if ( create ) {
+ script.add(
+ fk.sqlCreateString(
+ dialect,
+ mapping,
+ defaultCatalog,
+ defaultSchema
+ )
+ );
+ }
+ }
+ }
+ }
+
+ }
+
+ /*//broken, 'cos we don't generate these with names in SchemaExport
+ subIter = table.getIndexIterator();
+ while ( subIter.hasNext() ) {
+ Index index = (Index) subIter.next();
+ if ( !index.isForeignKey() || !dialect.hasImplicitIndexForForeignKey() ) {
+ if ( tableInfo==null || tableInfo.getIndexMetadata( index.getFilterName() ) == null ) {
+ script.add( index.sqlCreateString(dialect, mapping) );
+ }
+ }
+ }
+ //broken, 'cos we don't generate these with names in SchemaExport
+ subIter = table.getUniqueKeyIterator();
+ while ( subIter.hasNext() ) {
+ UniqueKey uk = (UniqueKey) subIter.next();
+ if ( tableInfo==null || tableInfo.getIndexMetadata( uk.getFilterName() ) == null ) {
+ script.add( uk.sqlCreateString(dialect, mapping) );
+ }
+ }*/
+ }
+
+ iter = iterateGenerators( dialect );
+ while ( iter.hasNext() ) {
+ PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
+ Object key = generator.generatorKey();
+ if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
+ String[] lines = generator.sqlCreateStrings( dialect );
+ for ( int i = 0; i < lines.length ; i++ ) {
+ script.add( lines[i] );
+ }
+ }
+ }
+
+ return ArrayHelper.toStringArray( script );
+ }
+
+ public void validateSchema(Dialect dialect, DatabaseMetadata databaseMetadata)
+ throws HibernateException {
+ secondPassCompile();
+
+ String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
+ String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );
+
+ Iterator iter = getTableMappings();
+ while ( iter.hasNext() ) {
+ Table table = (Table) iter.next();
+ if ( table.isPhysicalTable() ) {
+
+
+ TableMetadata tableInfo = databaseMetadata.getTableMetadata(
+ table.getName(),
+ ( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
+ ( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
+ table.isQuoted());
+ if ( tableInfo == null ) {
+ throw new HibernateException( "Missing table: " + table.getName() );
+ }
+ else {
+ table.validateColumns( dialect, mapping, tableInfo );
+ }
+
+ }
+ }
+
+ iter = iterateGenerators( dialect );
+ while ( iter.hasNext() ) {
+ PersistentIdentifierGenerator generator = (PersistentIdentifierGenerator) iter.next();
+ Object key = generator.generatorKey();
+ if ( !databaseMetadata.isSequence( key ) && !databaseMetadata.isTable( key ) ) {
+ throw new HibernateException( "Missing sequence or table: " + key );
+ }
+ }
+ }
+
+ private void validate() throws MappingException {
+ Iterator iter = classes.values().iterator();
+ while ( iter.hasNext() ) {
+ ( (PersistentClass) iter.next() ).validate( mapping );
+ }
+ iter = collections.values().iterator();
+ while ( iter.hasNext() ) {
+ ( (Collection) iter.next() ).validate( mapping );
+ }
+ }
+
+ /**
+ * Call this to ensure the mappings are fully compiled/built. Usefull to ensure getting
+ * access to all information in the metamodel when calling e.g. getClassMappings().
+ */
+ public void buildMappings() {
+ secondPassCompile();
+ }
+
+ // This method may be called many times!!
+ protected void secondPassCompile() throws MappingException {
+ log.debug( "processing extends queue" );
+
+ processExtendsQueue();
+
+ log.debug( "processing collection mappings" );
+
+ Iterator iter = secondPasses.iterator();
+ while ( iter.hasNext() ) {
+ SecondPass sp = (SecondPass) iter.next();
+ if ( ! (sp instanceof QuerySecondPass) ) {
+ sp.doSecondPass( classes );
+ iter.remove();
+ }
+ }
+
+ log.debug( "processing native query and ResultSetMapping mappings" );
+ iter = secondPasses.iterator();
+ while ( iter.hasNext() ) {
+ SecondPass sp = (SecondPass) iter.next();
+ sp.doSecondPass( classes );
+ iter.remove();
+ }
+
+ log.debug( "processing association property references" );
+
+ iter = propertyReferences.iterator();
+ while ( iter.hasNext() ) {
+ Mappings.PropertyReference upr = (Mappings.PropertyReference) iter.next();
+
+ PersistentClass clazz = getClassMapping( upr.referencedClass );
+ if ( clazz == null ) {
+ throw new MappingException(
+ "property-ref to unmapped class: " +
+ upr.referencedClass
+ );
+ }
+
+ Property prop = clazz.getReferencedProperty( upr.propertyName );
+ if ( upr.unique ) {
+ ( (SimpleValue) prop.getValue() ).setAlternateUniqueKey( true );
+ }
+ }
+
+ //TODO: Somehow add the newly created foreign keys to the internal collection
+
+ log.debug( "processing foreign key constraints" );
+
+ iter = getTableMappings();
+ Set done = new HashSet();
+ while ( iter.hasNext() ) {
+ secondPassCompileForeignKeys( (Table) iter.next(), done );
+ }
+
+ }
+
+ /**
+ * Try to empty the extends queue.
+ */
+ private void processExtendsQueue() {
+ // todo : would love to have this work on a notification basis
+ // where the successful binding of an entity/subclass would
+ // emit a notification which the extendsQueue entries could
+ // react to...
+ org.dom4j.Document document = findPossibleExtends();
+ while ( document != null ) {
+ add( document );
+ document = findPossibleExtends();
+ }
+
+ if ( extendsQueue.size() > 0 ) {
+// Iterator iterator = extendsQueue.iterator();
+ Iterator iterator = extendsQueue.keySet().iterator();
+ StringBuffer buf = new StringBuffer( "Following superclasses referenced in extends not found: " );
+ while ( iterator.hasNext() ) {
+ final ExtendsQueueEntry entry = ( ExtendsQueueEntry ) iterator.next();
+ buf.append( entry.getExplicitName() );
+ if ( entry.getMappingPackage() != null ) {
+ buf.append( "[" ).append( entry.getMappingPackage() ).append( "]" );
+ }
+ if ( iterator.hasNext() ) {
+ buf.append( "," );
+ }
+ }
+ throw new MappingException( buf.toString() );
+ }
+ }
+
+ /**
+ * Find the first possible element in the queue of extends.
+ */
+ protected org.dom4j.Document findPossibleExtends() {
+// Iterator iter = extendsQueue.iterator();
+ Iterator iter = extendsQueue.keySet().iterator();
+ while ( iter.hasNext() ) {
+ final ExtendsQueueEntry entry = ( ExtendsQueueEntry ) iter.next();
+ if ( getClassMapping( entry.getExplicitName() ) != null ) {
+ // found
+ iter.remove();
+ return entry.getDocument();
+ }
+ else if ( getClassMapping( HbmBinder.getClassName( entry.getExplicitName(), entry.getMappingPackage() ) ) != null ) {
+ // found
+ iter.remove();
+ return entry.getDocument();
+ }
+ }
+ return null;
+ }
+
+ protected void secondPassCompileForeignKeys(Table table, Set done) throws MappingException {
+
+ table.createForeignKeys();
+
+ Iterator iter = table.getForeignKeyIterator();
+ while ( iter.hasNext() ) {
+
+ ForeignKey fk = (ForeignKey) iter.next();
+ if ( !done.contains( fk ) ) {
+ done.add( fk );
+ final String referencedEntityName = fk.getReferencedEntityName();
+ if ( referencedEntityName == null ) {
+ throw new MappingException(
+ "An association from the table " +
+ fk.getTable().getName() +
+ " does not specify the referenced entity"
+ );
+ }
+ if ( log.isDebugEnabled() ) {
+ log.debug( "resolving reference to class: " + referencedEntityName );
+ }
+ PersistentClass referencedClass = (PersistentClass) classes.get( referencedEntityName );
+ if ( referencedClass == null ) {
+ throw new MappingException(
+ "An association from the table " +
+ fk.getTable().getName() +
+ " refers to an unmapped class: " +
+ referencedEntityName
+ );
+ }
+ if ( referencedClass.isJoinedSubclass() ) {
+ secondPassCompileForeignKeys( referencedClass.getSuperclass().getTable(), done );
+ }
+ fk.setReferencedTable( referencedClass.getTable() );
+ fk.alignColumns();
+ }
+ }
+ }
+
+ /**
+ * Get the named queries
+ */
+ public Map getNamedQueries() {
+ return namedQueries;
+ }
+
+ /**
+ * Instantiate a new <tt>SessionFactory</tt>, using the properties and
+ * mappings in this configuration. The <tt>SessionFactory</tt> will be
+ * immutable, so changes made to the <tt>Configuration</tt> after
+ * building the <tt>SessionFactory</tt> will not affect it.
+ *
+ * @return a new factory for <tt>Session</tt>s
+ * @see org.hibernate.SessionFactory
+ */
+ public SessionFactory buildSessionFactory() throws HibernateException {
+ log.debug( "Preparing to build session factory with filters : " + filterDefinitions );
+ secondPassCompile();
+ validate();
+ Environment.verifyProperties( properties );
+ Properties copy = new Properties();
+ copy.putAll( properties );
+ PropertiesHelper.resolvePlaceHolders( copy );
+ Settings settings = buildSettings( copy );
+
+ return new SessionFactoryImpl(
+ this,
+ mapping,
+ settings,
+ getInitializedEventListeners(),
+ sessionFactoryObserver
+ );
+ }
+
+ private EventListeners getInitializedEventListeners() {
+ EventListeners result = (EventListeners) eventListeners.shallowCopy();
+ result.initializeListeners( this );
+ return result;
+ }
+
+ /**
+ * Return the configured <tt>Interceptor</tt>
+ */
+ public Interceptor getInterceptor() {
+ return interceptor;
+ }
+
+ /**
+ * Get all properties
+ */
+ public Properties getProperties() {
+ return properties;
+ }
+
+ /**
+ * Configure an <tt>Interceptor</tt>
+ */
+ public Configuration setInterceptor(Interceptor interceptor) {
+ this.interceptor = interceptor;
+ return this;
+ }
+
+ /**
+ * Specify a completely new set of properties
+ */
+ public Configuration setProperties(Properties properties) {
+ this.properties = properties;
+ return this;
+ }
+
+ /**
+ * Set the given properties
+ */
+ public Configuration addProperties(Properties extraProperties) {
+ this.properties.putAll( extraProperties );
+ return this;
+ }
+
+ /**
+ * Adds the incoming properties to the internap properties structure,
+ * as long as the internal structure does not already contain an
+ * entry for the given key.
+ *
+ * @param properties
+ * @return this
+ */
+ public Configuration mergeProperties(Properties properties) {
+ Iterator itr = properties.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ final Map.Entry entry = ( Map.Entry ) itr.next();
+ if ( this.properties.containsKey( entry.getKey() ) ) {
+ continue;
+ }
+ this.properties.setProperty( ( String ) entry.getKey(), ( String ) entry.getValue() );
+ }
+ return this;
+ }
+
+ /**
+ * Set a property
+ */
+ public Configuration setProperty(String propertyName, String value) {
+ properties.setProperty( propertyName, value );
+ return this;
+ }
+
+ /**
+ * Get a property
+ */
+ public String getProperty(String propertyName) {
+ return properties.getProperty( propertyName );
+ }
+
+ private void addProperties(Element parent) {
+ Iterator iter = parent.elementIterator( "property" );
+ while ( iter.hasNext() ) {
+ Element node = (Element) iter.next();
+ String name = node.attributeValue( "name" );
+ String value = node.getText().trim();
+ log.debug( name + "=" + value );
+ properties.setProperty( name, value );
+ if ( !name.startsWith( "hibernate" ) ) {
+ properties.setProperty( "hibernate." + name, value );
+ }
+ }
+ Environment.verifyProperties( properties );
+ }
+
+ /**
+ * Get the configuration file as an <tt>InputStream</tt>. Might be overridden
+ * by subclasses to allow the configuration to be located by some arbitrary
+ * mechanism.
+ */
+ protected InputStream getConfigurationInputStream(String resource) throws HibernateException {
+
+ log.info( "Configuration resource: " + resource );
+
+ return ConfigHelper.getResourceAsStream( resource );
+
+ }
+
+ /**
+ * Use the mappings and properties specified in an application
+ * resource named <tt>hibernate.cfg.xml</tt>.
+ */
+ public Configuration configure() throws HibernateException {
+ configure( "/hibernate.cfg.xml" );
+ return this;
+ }
+
+ /**
+ * Use the mappings and properties specified in the given application
+ * resource. The format of the resource is defined in
+ * <tt>hibernate-configuration-3.0.dtd</tt>.
+ * <p/>
+ * The resource is found via <tt>getConfigurationInputStream(resource)</tt>.
+ */
+ public Configuration configure(String resource) throws HibernateException {
+ log.info( "configuring from resource: " + resource );
+ InputStream stream = getConfigurationInputStream( resource );
+ return doConfigure( stream, resource );
+ }
+
+ /**
+ * Use the mappings and properties specified in the given document.
+ * The format of the document is defined in
+ * <tt>hibernate-configuration-3.0.dtd</tt>.
+ *
+ * @param url URL from which you wish to load the configuration
+ * @return A configuration configured via the file
+ * @throws HibernateException
+ */
+ public Configuration configure(URL url) throws HibernateException {
+ log.info( "configuring from url: " + url.toString() );
+ try {
+ return doConfigure( url.openStream(), url.toString() );
+ }
+ catch (IOException ioe) {
+ throw new HibernateException( "could not configure from URL: " + url, ioe );
+ }
+ }
+
+ /**
+ * Use the mappings and properties specified in the given application
+ * file. The format of the file is defined in
+ * <tt>hibernate-configuration-3.0.dtd</tt>.
+ *
+ * @param configFile <tt>File</tt> from which you wish to load the configuration
+ * @return A configuration configured via the file
+ * @throws HibernateException
+ */
+ public Configuration configure(File configFile) throws HibernateException {
+ log.info( "configuring from file: " + configFile.getName() );
+ try {
+ return doConfigure( new FileInputStream( configFile ), configFile.toString() );
+ }
+ catch (FileNotFoundException fnfe) {
+ throw new HibernateException( "could not find file: " + configFile, fnfe );
+ }
+ }
+
+ /**
+ * Use the mappings and properties specified in the given application
+ * resource. The format of the resource is defined in
+ * <tt>hibernate-configuration-3.0.dtd</tt>.
+ *
+ * @param stream Inputstream to be read from
+ * @param resourceName The name to use in warning/error messages
+ * @return A configuration configured via the stream
+ * @throws HibernateException
+ */
+ protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException {
+
+ org.dom4j.Document doc;
+ try {
+ List errors = new ArrayList();
+ doc = xmlHelper.createSAXReader( resourceName, errors, entityResolver )
+ .read( new InputSource( stream ) );
+ if ( errors.size() != 0 ) {
+ throw new MappingException(
+ "invalid configuration",
+ (Throwable) errors.get( 0 )
+ );
+ }
+ }
+ catch (DocumentException e) {
+ throw new HibernateException(
+ "Could not parse configuration: " + resourceName,
+ e
+ );
+ }
+ finally {
+ try {
+ stream.close();
+ }
+ catch (IOException ioe) {
+ log.warn( "could not close input stream for: " + resourceName, ioe );
+ }
+ }
+
+ return doConfigure( doc );
+
+ }
+
+ /**
+ * Use the mappings and properties specified in the given XML document.
+ * The format of the file is defined in
+ * <tt>hibernate-configuration-3.0.dtd</tt>.
+ *
+ * @param document an XML document from which you wish to load the configuration
+ * @return A configuration configured via the <tt>Document</tt>
+ * @throws HibernateException if there is problem in accessing the file.
+ */
+ public Configuration configure(Document document) throws HibernateException {
+ log.info( "configuring from XML document" );
+ return doConfigure( xmlHelper.createDOMReader().read( document ) );
+ }
+
+ protected Configuration doConfigure(org.dom4j.Document doc) throws HibernateException {
+
+ Element sfNode = doc.getRootElement().element( "session-factory" );
+ String name = sfNode.attributeValue( "name" );
+ if ( name != null ) {
+ properties.setProperty( Environment.SESSION_FACTORY_NAME, name );
+ }
+ addProperties( sfNode );
+ parseSessionFactory( sfNode, name );
+
+ Element secNode = doc.getRootElement().element( "security" );
+ if ( secNode != null ) {
+ parseSecurity( secNode );
+ }
+
+ log.info( "Configured SessionFactory: " + name );
+ log.debug( "properties: " + properties );
+
+ return this;
+
+ }
+
+
+ private void parseSessionFactory(Element sfNode, String name) {
+ Iterator elements = sfNode.elementIterator();
+ while ( elements.hasNext() ) {
+ Element subelement = (Element) elements.next();
+ String subelementName = subelement.getName();
+ if ( "mapping".equals( subelementName ) ) {
+ parseMappingElement( subelement, name );
+ }
+ else if ( "class-cache".equals( subelementName ) ) {
+ String className = subelement.attributeValue( "class" );
+ Attribute regionNode = subelement.attribute( "region" );
+ final String region = ( regionNode == null ) ? className : regionNode.getValue();
+ boolean includeLazy = !"non-lazy".equals( subelement.attributeValue( "include" ) );
+ setCacheConcurrencyStrategy( className, subelement.attributeValue( "usage" ), region, includeLazy );
+ }
+ else if ( "collection-cache".equals( subelementName ) ) {
+ String role = subelement.attributeValue( "collection" );
+ Attribute regionNode = subelement.attribute( "region" );
+ final String region = ( regionNode == null ) ? role : regionNode.getValue();
+ setCollectionCacheConcurrencyStrategy( role, subelement.attributeValue( "usage" ), region );
+ }
+ else if ( "listener".equals( subelementName ) ) {
+ parseListener( subelement );
+ }
+ else if ( "event".equals( subelementName ) ) {
+ parseEvent( subelement );
+ }
+ }
+ }
+
+ protected void parseMappingElement(Element subelement, String name) {
+ Attribute rsrc = subelement.attribute( "resource" );
+ Attribute file = subelement.attribute( "file" );
+ Attribute jar = subelement.attribute( "jar" );
+ Attribute pkg = subelement.attribute( "package" );
+ Attribute clazz = subelement.attribute( "class" );
+ if ( rsrc != null ) {
+ log.debug( name + "<-" + rsrc );
+ addResource( rsrc.getValue() );
+ }
+ else if ( jar != null ) {
+ log.debug( name + "<-" + jar );
+ addJar( new File( jar.getValue() ) );
+ }
+ else if ( pkg != null ) {
+ throw new MappingException(
+ "An AnnotationConfiguration instance is required to use <mapping package=\"" +
+ pkg.getValue() + "\"/>"
+ );
+ }
+ else if ( clazz != null ) {
+ throw new MappingException(
+ "An AnnotationConfiguration instance is required to use <mapping class=\"" +
+ clazz.getValue() + "\"/>"
+ );
+ }
+ else {
+ if ( file == null ) {
+ throw new MappingException(
+ "<mapping> element in configuration specifies no attributes"
+ );
+ }
+ log.debug( name + "<-" + file );
+ addFile( file.getValue() );
+ }
+ }
+
+ private void parseSecurity(Element secNode) {
+ String contextId = secNode.attributeValue( "context" );
+ setProperty(Environment.JACC_CONTEXTID, contextId);
+ log.info( "JACC contextID: " + contextId );
+ JACCConfiguration jcfg = new JACCConfiguration( contextId );
+ Iterator grantElements = secNode.elementIterator();
+ while ( grantElements.hasNext() ) {
+ Element grantElement = (Element) grantElements.next();
+ String elementName = grantElement.getName();
+ if ( "grant".equals( elementName ) ) {
+ jcfg.addPermission(
+ grantElement.attributeValue( "role" ),
+ grantElement.attributeValue( "entity-name" ),
+ grantElement.attributeValue( "actions" )
+ );
+ }
+ }
+ }
+
+ private void parseEvent(Element element) {
+ String type = element.attributeValue( "type" );
+ List listeners = element.elements();
+ String[] listenerClasses = new String[ listeners.size() ];
+ for ( int i = 0; i < listeners.size() ; i++ ) {
+ listenerClasses[i] = ( (Element) listeners.get( i ) ).attributeValue( "class" );
+ }
+ log.debug( "Event listeners: " + type + "=" + StringHelper.toString( listenerClasses ) );
+ setListeners( type, listenerClasses );
+ }
+
+ private void parseListener(Element element) {
+ String type = element.attributeValue( "type" );
+ if ( type == null ) {
+ throw new MappingException( "No type specified for listener" );
+ }
+ String impl = element.attributeValue( "class" );
+ log.debug( "Event listener: " + type + "=" + impl );
+ setListeners( type, new String[]{impl} );
+ }
+
+ public void setListener(String type, String listener) {
+ String[] listeners = null;
+ if ( listener != null ) {
+ listeners = (String[]) Array.newInstance( String.class, 1 );
+ listeners[0] = listener;
+ }
+ setListeners( type, listeners );
+ }
+
+ public void setListeners(String type, String[] listenerClasses) {
+ Object[] listeners = null;
+ if ( listenerClasses != null ) {
+ listeners = (Object[]) Array.newInstance( eventListeners.getListenerClassFor(type), listenerClasses.length );
+ for ( int i = 0; i < listeners.length ; i++ ) {
+ try {
+ listeners[i] = ReflectHelper.classForName( listenerClasses[i] ).newInstance();
+ }
+ catch (Exception e) {
+ throw new MappingException(
+ "Unable to instantiate specified event (" + type + ") listener class: " + listenerClasses[i],
+ e
+ );
+ }
+ }
+ }
+ setListeners( type, listeners );
+ }
+
+ public void setListener(String type, Object listener) {
+ Object[] listeners = null;
+ if ( listener != null ) {
+ listeners = (Object[]) Array.newInstance( eventListeners.getListenerClassFor(type), 1 );
+ listeners[0] = listener;
+ }
+ setListeners( type, listeners );
+ }
+
+ public void setListeners(String type, Object[] listeners) {
+ if ( "auto-flush".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setAutoFlushEventListeners( new AutoFlushEventListener[]{} );
+ }
+ else {
+ eventListeners.setAutoFlushEventListeners( (AutoFlushEventListener[]) listeners );
+ }
+ }
+ else if ( "merge".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setMergeEventListeners( new MergeEventListener[]{} );
+ }
+ else {
+ eventListeners.setMergeEventListeners( (MergeEventListener[]) listeners );
+ }
+ }
+ else if ( "create".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPersistEventListeners( new PersistEventListener[]{} );
+ }
+ else {
+ eventListeners.setPersistEventListeners( (PersistEventListener[]) listeners );
+ }
+ }
+ else if ( "create-onflush".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPersistOnFlushEventListeners( new PersistEventListener[]{} );
+ }
+ else {
+ eventListeners.setPersistOnFlushEventListeners( (PersistEventListener[]) listeners );
+ }
+ }
+ else if ( "delete".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setDeleteEventListeners( new DeleteEventListener[]{} );
+ }
+ else {
+ eventListeners.setDeleteEventListeners( (DeleteEventListener[]) listeners );
+ }
+ }
+ else if ( "dirty-check".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setDirtyCheckEventListeners( new DirtyCheckEventListener[]{} );
+ }
+ else {
+ eventListeners.setDirtyCheckEventListeners( (DirtyCheckEventListener[]) listeners );
+ }
+ }
+ else if ( "evict".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setEvictEventListeners( new EvictEventListener[]{} );
+ }
+ else {
+ eventListeners.setEvictEventListeners( (EvictEventListener[]) listeners );
+ }
+ }
+ else if ( "flush".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setFlushEventListeners( new FlushEventListener[]{} );
+ }
+ else {
+ eventListeners.setFlushEventListeners( (FlushEventListener[]) listeners );
+ }
+ }
+ else if ( "flush-entity".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setFlushEntityEventListeners( new FlushEntityEventListener[]{} );
+ }
+ else {
+ eventListeners.setFlushEntityEventListeners( (FlushEntityEventListener[]) listeners );
+ }
+ }
+ else if ( "load".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setLoadEventListeners( new LoadEventListener[]{} );
+ }
+ else {
+ eventListeners.setLoadEventListeners( (LoadEventListener[]) listeners );
+ }
+ }
+ else if ( "load-collection".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setInitializeCollectionEventListeners(
+ new InitializeCollectionEventListener[]{}
+ );
+ }
+ else {
+ eventListeners.setInitializeCollectionEventListeners(
+ (InitializeCollectionEventListener[]) listeners
+ );
+ }
+ }
+ else if ( "lock".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setLockEventListeners( new LockEventListener[]{} );
+ }
+ else {
+ eventListeners.setLockEventListeners( (LockEventListener[]) listeners );
+ }
+ }
+ else if ( "refresh".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setRefreshEventListeners( new RefreshEventListener[]{} );
+ }
+ else {
+ eventListeners.setRefreshEventListeners( (RefreshEventListener[]) listeners );
+ }
+ }
+ else if ( "replicate".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setReplicateEventListeners( new ReplicateEventListener[]{} );
+ }
+ else {
+ eventListeners.setReplicateEventListeners( (ReplicateEventListener[]) listeners );
+ }
+ }
+ else if ( "save-update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setSaveOrUpdateEventListeners( new SaveOrUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setSaveOrUpdateEventListeners( (SaveOrUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "save".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setSaveEventListeners( new SaveOrUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setSaveEventListeners( (SaveOrUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setUpdateEventListeners( new SaveOrUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setUpdateEventListeners( (SaveOrUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-load".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreLoadEventListeners( new PreLoadEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreLoadEventListeners( (PreLoadEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreUpdateEventListeners( new PreUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreUpdateEventListeners( (PreUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-delete".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreDeleteEventListeners( new PreDeleteEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreDeleteEventListeners( (PreDeleteEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-insert".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreInsertEventListeners( new PreInsertEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreInsertEventListeners( (PreInsertEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-collection-recreate".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreCollectionRecreateEventListeners( new PreCollectionRecreateEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreCollectionRecreateEventListeners( (PreCollectionRecreateEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-collection-remove".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreCollectionRemoveEventListeners( new PreCollectionRemoveEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreCollectionRemoveEventListeners( ( PreCollectionRemoveEventListener[]) listeners );
+ }
+ }
+ else if ( "pre-collection-update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPreCollectionUpdateEventListeners( new PreCollectionUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setPreCollectionUpdateEventListeners( ( PreCollectionUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "post-load".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostLoadEventListeners( new PostLoadEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostLoadEventListeners( (PostLoadEventListener[]) listeners );
+ }
+ }
+ else if ( "post-update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostUpdateEventListeners( new PostUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostUpdateEventListeners( (PostUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "post-delete".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostDeleteEventListeners( new PostDeleteEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostDeleteEventListeners( (PostDeleteEventListener[]) listeners );
+ }
+ }
+ else if ( "post-insert".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostInsertEventListeners( new PostInsertEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostInsertEventListeners( (PostInsertEventListener[]) listeners );
+ }
+ }
+ else if ( "post-commit-update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostCommitUpdateEventListeners(
+ new PostUpdateEventListener[]{}
+ );
+ }
+ else {
+ eventListeners.setPostCommitUpdateEventListeners( (PostUpdateEventListener[]) listeners );
+ }
+ }
+ else if ( "post-commit-delete".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostCommitDeleteEventListeners(
+ new PostDeleteEventListener[]{}
+ );
+ }
+ else {
+ eventListeners.setPostCommitDeleteEventListeners( (PostDeleteEventListener[]) listeners );
+ }
+ }
+ else if ( "post-commit-insert".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostCommitInsertEventListeners(
+ new PostInsertEventListener[]{}
+ );
+ }
+ else {
+ eventListeners.setPostCommitInsertEventListeners( (PostInsertEventListener[]) listeners );
+ }
+ }
+ else if ( "post-collection-recreate".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostCollectionRecreateEventListeners( new PostCollectionRecreateEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostCollectionRecreateEventListeners( (PostCollectionRecreateEventListener[]) listeners );
+ }
+ }
+ else if ( "post-collection-remove".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostCollectionRemoveEventListeners( new PostCollectionRemoveEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostCollectionRemoveEventListeners( ( PostCollectionRemoveEventListener[]) listeners );
+ }
+ }
+ else if ( "post-collection-update".equals( type ) ) {
+ if ( listeners == null ) {
+ eventListeners.setPostCollectionUpdateEventListeners( new PostCollectionUpdateEventListener[]{} );
+ }
+ else {
+ eventListeners.setPostCollectionUpdateEventListeners( ( PostCollectionUpdateEventListener[]) listeners );
+ }
+ }
+ else {
+ throw new MappingException("Unrecognized listener type [" + type + "]");
+ }
+ }
+
+ public EventListeners getEventListeners() {
+ return eventListeners;
+ }
+
+ RootClass getRootClassMapping(String clazz) throws MappingException {
+ try {
+ return (RootClass) getClassMapping( clazz );
+ }
+ catch (ClassCastException cce) {
+ throw new MappingException( "You may only specify a cache for root <class> mappings" );
+ }
+ }
+
+ /**
+ * Set up a cache for an entity class
+ *
+ * @param clazz
+ * @param concurrencyStrategy
+ * @return Configuration
+ * @throws MappingException
+ */
+ public Configuration setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy)
+ throws MappingException {
+ setCacheConcurrencyStrategy( clazz, concurrencyStrategy, clazz );
+ return this;
+ }
+
+ public void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region)
+ throws MappingException {
+ setCacheConcurrencyStrategy( clazz, concurrencyStrategy, region, true );
+ }
+
+ void setCacheConcurrencyStrategy(String clazz, String concurrencyStrategy, String region, boolean includeLazy)
+ throws MappingException {
+ RootClass rootClass = getRootClassMapping( clazz );
+ if ( rootClass == null ) {
+ throw new MappingException( "Cannot cache an unknown entity: " + clazz );
+ }
+ rootClass.setCacheConcurrencyStrategy( concurrencyStrategy );
+ rootClass.setCacheRegionName( region );
+ rootClass.setLazyPropertiesCacheable( includeLazy );
+ }
+
+ /**
+ * Set up a cache for a collection role
+ *
+ * @param collectionRole
+ * @param concurrencyStrategy
+ * @return Configuration
+ * @throws MappingException
+ */
+ public Configuration setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy)
+ throws MappingException {
+ setCollectionCacheConcurrencyStrategy( collectionRole, concurrencyStrategy, collectionRole );
+ return this;
+ }
+
+ public void setCollectionCacheConcurrencyStrategy(String collectionRole, String concurrencyStrategy, String region)
+ throws MappingException {
+ Collection collection = getCollectionMapping( collectionRole );
+ if ( collection == null ) {
+ throw new MappingException( "Cannot cache an unknown collection: " + collectionRole );
+ }
+ collection.setCacheConcurrencyStrategy( concurrencyStrategy );
+ collection.setCacheRegionName( region );
+ }
+
+ /**
+ * Get the query language imports
+ *
+ * @return a mapping from "import" names to fully qualified class names
+ */
+ public Map getImports() {
+ return imports;
+ }
+
+ /**
+ * Create an object-oriented view of the configuration properties
+ */
+ public Settings buildSettings() throws HibernateException {
+ Properties clone = ( Properties ) properties.clone();
+ PropertiesHelper.resolvePlaceHolders( clone );
+ return settingsFactory.buildSettings( clone );
+ }
+
+ public Settings buildSettings(Properties props) throws HibernateException {
+ return settingsFactory.buildSettings( props );
+ }
+
+ public Map getNamedSQLQueries() {
+ return namedSqlQueries;
+ }
+
+ public Map getSqlResultSetMappings() {
+ return sqlResultSetMappings;
+ }
+
+ /**
+ * @return the NamingStrategy.
+ */
+ public NamingStrategy getNamingStrategy() {
+ return namingStrategy;
+ }
+
+ /**
+ * Set a custom naming strategy
+ *
+ * @param namingStrategy the NamingStrategy to set
+ */
+ public Configuration setNamingStrategy(NamingStrategy namingStrategy) {
+ this.namingStrategy = namingStrategy;
+ return this;
+ }
+
+ public Mapping buildMapping() {
+ return new Mapping() {
+ /**
+ * Returns the identifier type of a mapped class
+ */
+ public Type getIdentifierType(String persistentClass) throws MappingException {
+ PersistentClass pc = ( (PersistentClass) classes.get( persistentClass ) );
+ if ( pc == null ) {
+ throw new MappingException( "persistent class not known: " + persistentClass );
+ }
+ return pc.getIdentifier().getType();
+ }
+
+ public String getIdentifierPropertyName(String persistentClass) throws MappingException {
+ final PersistentClass pc = (PersistentClass) classes.get( persistentClass );
+ if ( pc == null ) {
+ throw new MappingException( "persistent class not known: " + persistentClass );
+ }
+ if ( !pc.hasIdentifierProperty() ) {
+ return null;
+ }
+ return pc.getIdentifierProperty().getName();
+ }
+
+ public Type getReferencedPropertyType(String persistentClass, String propertyName) throws MappingException {
+ final PersistentClass pc = (PersistentClass) classes.get( persistentClass );
+ if ( pc == null ) {
+ throw new MappingException( "persistent class not known: " + persistentClass );
+ }
+ Property prop = pc.getReferencedProperty( propertyName );
+ if ( prop == null ) {
+ throw new MappingException(
+ "property not known: " +
+ persistentClass + '.' + propertyName
+ );
+ }
+ return prop.getType();
+ }
+ };
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ ois.defaultReadObject();
+ this.mapping = buildMapping();
+ xmlHelper = new XMLHelper();
+ }
+
+ public Map getFilterDefinitions() {
+ return filterDefinitions;
+ }
+
+ public void addFilterDefinition(FilterDefinition definition) {
+ filterDefinitions.put( definition.getFilterName(), definition );
+ }
+
+ public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object) {
+ auxiliaryDatabaseObjects.add( object );
+ }
+
+ public Map getSqlFunctions() {
+ return sqlFunctions;
+ }
+
+ public void addSqlFunction(String functionName, SQLFunction function) {
+ sqlFunctions.put( functionName, function );
+ }
+
+ public SessionFactoryObserver getSessionFactoryObserver() {
+ return sessionFactoryObserver;
+ }
+
+ public void setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver) {
+ this.sessionFactoryObserver = sessionFactoryObserver;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,110 +0,0 @@
-//$Id: DefaultNamingStrategy.java 9874 2006-05-04 15:10:22Z epbernard $
-package org.hibernate.cfg;
-
-import java.io.Serializable;
-
-import org.hibernate.util.StringHelper;
-import org.hibernate.AssertionFailure;
-
-/**
- * The default <tt>NamingStrategy</tt>
- * @see ImprovedNamingStrategy a better alternative
- * @author Gavin King
- */
-public class DefaultNamingStrategy implements NamingStrategy, Serializable {
-
- /**
- * The singleton instance
- */
- public static final NamingStrategy INSTANCE = new DefaultNamingStrategy();
-
- /**
- * Return the unqualified class name
- */
- public String classToTableName(String className) {
- return StringHelper.unqualify(className);
- }
- /**
- * Return the unqualified property name
- */
- public String propertyToColumnName(String propertyName) {
- return StringHelper.unqualify(propertyName);
- }
- /**
- * Return the argument
- */
- public String tableName(String tableName) {
- return tableName;
- }
- /**
- * Return the argument
- */
- public String columnName(String columnName) {
- return columnName;
- }
-
- /**
- * Return the unqualified property name, not the best strategy but a backward compatible one
- */
- public String collectionTableName(
- String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
- String propertyName
- ) {
- //use a degenerated strategy for backward compatibility
- return StringHelper.unqualify(propertyName);
- }
-
- /**
- * Return the argument
- */
- public String joinKeyColumnName(String joinedColumn, String joinedTable) {
- return columnName( joinedColumn );
- }
-
- /**
- * Return the property name or propertyTableName
- */
- public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
- ) {
- String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
- if (header == null) throw new AssertionFailure("NammingStrategy not properly filled");
- return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
- }
-
- /**
- * Return the column name or the unqualified property name
- */
- public String logicalColumnName(String columnName, String propertyName) {
- return StringHelper.isNotEmpty( columnName ) ? columnName : StringHelper.unqualify( propertyName );
- }
-
- /**
- * Returns either the table name if explicit or
- * if there is an associated table, the concatenation of owner entity table and associated table
- * otherwise the concatenation of owner entity table and the unqualified property name
- */
- public String logicalCollectionTableName(String tableName,
- String ownerEntityTable, String associatedEntityTable, String propertyName
- ) {
- if ( tableName != null ) {
- return tableName;
- }
- else {
- //use of a stringbuffer to workaround a JDK bug
- return new StringBuffer(ownerEntityTable).append("_")
- .append(
- associatedEntityTable != null ?
- associatedEntityTable :
- StringHelper.unqualify( propertyName )
- ).toString();
- }
- }
- /**
- * Return the column name if explicit or the concatenation of the property name and the referenced column
- *
- */
- public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
- return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName + "_" + referencedColumn;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,133 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.Serializable;
+
+import org.hibernate.util.StringHelper;
+import org.hibernate.AssertionFailure;
+
+/**
+ * The default <tt>NamingStrategy</tt>
+ * @see ImprovedNamingStrategy a better alternative
+ * @author Gavin King
+ */
+public class DefaultNamingStrategy implements NamingStrategy, Serializable {
+
+ /**
+ * The singleton instance
+ */
+ public static final NamingStrategy INSTANCE = new DefaultNamingStrategy();
+
+ /**
+ * Return the unqualified class name
+ */
+ public String classToTableName(String className) {
+ return StringHelper.unqualify(className);
+ }
+ /**
+ * Return the unqualified property name
+ */
+ public String propertyToColumnName(String propertyName) {
+ return StringHelper.unqualify(propertyName);
+ }
+ /**
+ * Return the argument
+ */
+ public String tableName(String tableName) {
+ return tableName;
+ }
+ /**
+ * Return the argument
+ */
+ public String columnName(String columnName) {
+ return columnName;
+ }
+
+ /**
+ * Return the unqualified property name, not the best strategy but a backward compatible one
+ */
+ public String collectionTableName(
+ String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
+ String propertyName
+ ) {
+ //use a degenerated strategy for backward compatibility
+ return StringHelper.unqualify(propertyName);
+ }
+
+ /**
+ * Return the argument
+ */
+ public String joinKeyColumnName(String joinedColumn, String joinedTable) {
+ return columnName( joinedColumn );
+ }
+
+ /**
+ * Return the property name or propertyTableName
+ */
+ public String foreignKeyColumnName(
+ String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
+ ) {
+ String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
+ if (header == null) throw new AssertionFailure("NammingStrategy not properly filled");
+ return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
+ }
+
+ /**
+ * Return the column name or the unqualified property name
+ */
+ public String logicalColumnName(String columnName, String propertyName) {
+ return StringHelper.isNotEmpty( columnName ) ? columnName : StringHelper.unqualify( propertyName );
+ }
+
+ /**
+ * Returns either the table name if explicit or
+ * if there is an associated table, the concatenation of owner entity table and associated table
+ * otherwise the concatenation of owner entity table and the unqualified property name
+ */
+ public String logicalCollectionTableName(String tableName,
+ String ownerEntityTable, String associatedEntityTable, String propertyName
+ ) {
+ if ( tableName != null ) {
+ return tableName;
+ }
+ else {
+ //use of a stringbuffer to workaround a JDK bug
+ return new StringBuffer(ownerEntityTable).append("_")
+ .append(
+ associatedEntityTable != null ?
+ associatedEntityTable :
+ StringHelper.unqualify( propertyName )
+ ).toString();
+ }
+ }
+ /**
+ * Return the column name if explicit or the concatenation of the property name and the referenced column
+ *
+ */
+ public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
+ return StringHelper.isNotEmpty( columnName ) ? columnName : propertyName + "_" + referencedColumn;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,702 +0,0 @@
-//$Id: Environment.java 11402 2007-04-11 14:24:35Z steve.ebersole(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.Timestamp;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.HibernateException;
-import org.hibernate.bytecode.BytecodeProvider;
-import org.hibernate.util.ConfigHelper;
-import org.hibernate.util.PropertiesHelper;
-
-
-/**
- * Provides access to configuration info passed in <tt>Properties</tt> objects.
- * <br><br>
- * Hibernate has two property scopes:
- * <ul>
- * <li><b>Factory-level</b> properties may be passed to the <tt>SessionFactory</tt> when it
- * instantiated. Each instance might have different property values. If no
- * properties are specified, the factory calls <tt>Environment.getProperties()</tt>.
- * <li><b>System-level</b> properties are shared by all factory instances and are always
- * determined by the <tt>Environment</tt> properties.
- * </ul>
- * The only system-level properties are
- * <ul>
- * <li><tt>hibernate.jdbc.use_streams_for_binary</tt>
- * <li><tt>hibernate.cglib.use_reflection_optimizer</tt>
- * </ul>
- * <tt>Environment</tt> properties are populated by calling <tt>System.getProperties()</tt>
- * and then from a resource named <tt>/hibernate.properties</tt> if it exists. System
- * properties override properties specified in <tt>hibernate.properties</tt>.<br>
- * <br>
- * The <tt>SessionFactory</tt> is controlled by the following properties.
- * Properties may be either be <tt>System</tt> properties, properties
- * defined in a resource named <tt>/hibernate.properties</tt> or an instance of
- * <tt>java.util.Properties</tt> passed to
- * <tt>Configuration.buildSessionFactory()</tt><br>
- * <br>
- * <table>
- * <tr><td><b>property</b></td><td><b>meaning</b></td></tr>
- * <tr>
- * <td><tt>hibernate.dialect</tt></td>
- * <td>classname of <tt>org.hibernate.dialect.Dialect</tt> subclass</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.cache.provider_class</tt></td>
- * <td>classname of <tt>org.hibernate.cache.CacheProvider</tt>
- * subclass (if not specified EHCache is used)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.connection.provider_class</tt></td>
- * <td>classname of <tt>org.hibernate.connection.ConnectionProvider</tt>
- * subclass (if not specified hueristics are used)</td>
- * </tr>
- * <tr><td><tt>hibernate.connection.username</tt></td><td>database username</td></tr>
- * <tr><td><tt>hibernate.connection.password</tt></td><td>database password</td></tr>
- * <tr>
- * <td><tt>hibernate.connection.url</tt></td>
- * <td>JDBC URL (when using <tt>java.sql.DriverManager</tt>)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.connection.driver_class</tt></td>
- * <td>classname of JDBC driver</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.connection.isolation</tt></td>
- * <td>JDBC transaction isolation level (only when using
- * <tt>java.sql.DriverManager</tt>)
- * </td>
- * </tr>
- * <td><tt>hibernate.connection.pool_size</tt></td>
- * <td>the maximum size of the connection pool (only when using
- * <tt>java.sql.DriverManager</tt>)
- * </td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.connection.datasource</tt></td>
- * <td>databasource JNDI name (when using <tt>javax.sql.Datasource</tt>)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.jndi.url</tt></td><td>JNDI <tt>InitialContext</tt> URL</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.jndi.class</tt></td><td>JNDI <tt>InitialContext</tt> classname</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.max_fetch_depth</tt></td>
- * <td>maximum depth of outer join fetching</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.jdbc.batch_size</tt></td>
- * <td>enable use of JDBC2 batch API for drivers which support it</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.jdbc.fetch_size</tt></td>
- * <td>set the JDBC fetch size</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.jdbc.use_scrollable_resultset</tt></td>
- * <td>enable use of JDBC2 scrollable resultsets (you only need this specify
- * this property when using user supplied connections)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.jdbc.use_getGeneratedKeys</tt></td>
- * <td>enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve
- * natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.hbm2ddl.auto</tt></td>
- * <td>enable auto DDL export</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.default_schema</tt></td>
- * <td>use given schema name for unqualified tables (always optional)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.default_catalog</tt></td>
- * <td>use given catalog name for unqualified tables (always optional)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.session_factory_name</tt></td>
- * <td>If set, the factory attempts to bind this name to itself in the
- * JNDI context. This name is also used to support cross JVM <tt>
- * Session</tt> (de)serialization.</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.transaction.manager_lookup_class</tt></td>
- * <td>classname of <tt>org.hibernate.transaction.TransactionManagerLookup</tt>
- * implementor</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.transaction.factory_class</tt></td>
- * <td>the factory to use for instantiating <tt>Transaction</tt>s.
- * (Defaults to <tt>JDBCTransactionFactory</tt>.)</td>
- * </tr>
- * <tr>
- * <td><tt>hibernate.query.substitutions</tt></td><td>query language token substitutions</td>
- * </tr>
- * </table>
- *
- * @see org.hibernate.SessionFactory
- * @author Gavin King
- */
-public final class Environment {
-
- public static final String VERSION = "3.3.0.CR1";
-
- /**
- * <tt>ConnectionProvider</tt> implementor to use when obtaining connections
- */
- public static final String CONNECTION_PROVIDER ="hibernate.connection.provider_class";
- /**
- * JDBC driver class
- */
- public static final String DRIVER ="hibernate.connection.driver_class";
- /**
- * JDBC transaction isolation level
- */
- public static final String ISOLATION ="hibernate.connection.isolation";
- /**
- * JDBC URL
- */
- public static final String URL ="hibernate.connection.url";
- /**
- * JDBC user
- */
- public static final String USER ="hibernate.connection.username";
- /**
- * JDBC password
- */
- public static final String PASS ="hibernate.connection.password";
- /**
- * JDBC autocommit mode
- */
- public static final String AUTOCOMMIT ="hibernate.connection.autocommit";
- /**
- * Maximum number of inactive connections for Hibernate's connection pool
- */
- public static final String POOL_SIZE ="hibernate.connection.pool_size";
- /**
- * <tt>java.sql.Datasource</tt> JNDI name
- */
- public static final String DATASOURCE ="hibernate.connection.datasource";
- /**
- * prefix for arbitrary JDBC connection properties
- */
- public static final String CONNECTION_PREFIX = "hibernate.connection";
-
- /**
- * JNDI initial context class, <tt>Context.INITIAL_CONTEXT_FACTORY</tt>
- */
- public static final String JNDI_CLASS ="hibernate.jndi.class";
- /**
- * JNDI provider URL, <tt>Context.PROVIDER_URL</tt>
- */
- public static final String JNDI_URL ="hibernate.jndi.url";
- /**
- * prefix for arbitrary JNDI <tt>InitialContext</tt> properties
- */
- public static final String JNDI_PREFIX = "hibernate.jndi";
- /**
- * JNDI name to bind to <tt>SessionFactory</tt>
- */
- public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name";
-
- /**
- * Hibernate SQL <tt>Dialect</tt> class
- */
- public static final String DIALECT ="hibernate.dialect";
- /**
- * A default database schema (owner) name to use for unqualified tablenames
- */
- public static final String DEFAULT_SCHEMA = "hibernate.default_schema";
- /**
- * A default database catalog name to use for unqualified tablenames
- */
- public static final String DEFAULT_CATALOG = "hibernate.default_catalog";
-
- /**
- * Enable logging of generated SQL to the console
- */
- public static final String SHOW_SQL ="hibernate.show_sql";
- /**
- * Enable formatting of SQL logged to the console
- */
- public static final String FORMAT_SQL ="hibernate.format_sql";
- /**
- * Add comments to the generated SQL
- */
- public static final String USE_SQL_COMMENTS ="hibernate.use_sql_comments";
- /**
- * Maximum depth of outer join fetching
- */
- public static final String MAX_FETCH_DEPTH = "hibernate.max_fetch_depth";
- /**
- * The default batch size for batch fetching
- */
- public static final String DEFAULT_BATCH_FETCH_SIZE = "hibernate.default_batch_fetch_size";
- /**
- * Use <tt>java.io</tt> streams to read / write binary data from / to JDBC
- */
- public static final String USE_STREAMS_FOR_BINARY = "hibernate.jdbc.use_streams_for_binary";
- /**
- * Use JDBC scrollable <tt>ResultSet</tt>s. This property is only necessary when there is
- * no <tt>ConnectionProvider</tt>, ie. the user is supplying JDBC connections.
- */
- public static final String USE_SCROLLABLE_RESULTSET = "hibernate.jdbc.use_scrollable_resultset";
- /**
- * Tells the JDBC driver to attempt to retrieve row Id with the JDBC 3.0 PreparedStatement.getGeneratedKeys()
- * method. In general, performance will be better if this property is set to true and the underlying
- * JDBC driver supports getGeneratedKeys().
- */
- public static final String USE_GET_GENERATED_KEYS = "hibernate.jdbc.use_get_generated_keys";
- /**
- * Gives the JDBC driver a hint as to the number of rows that should be fetched from the database
- * when more rows are needed. If <tt>0</tt>, JDBC driver default settings will be used.
- */
- public static final String STATEMENT_FETCH_SIZE = "hibernate.jdbc.fetch_size";
- /**
- * Maximum JDBC batch size. A nonzero value enables batch updates.
- */
- public static final String STATEMENT_BATCH_SIZE = "hibernate.jdbc.batch_size";
- /**
- * Select a custom batcher.
- */
- public static final String BATCH_STRATEGY = "hibernate.jdbc.factory_class";
- /**
- * Should versioned data be included in batching?
- */
- public static final String BATCH_VERSIONED_DATA = "hibernate.jdbc.batch_versioned_data";
- /**
- * An XSLT resource used to generate "custom" XML
- */
- public static final String OUTPUT_STYLESHEET ="hibernate.xml.output_stylesheet";
-
- /**
- * Maximum size of C3P0 connection pool
- */
- public static final String C3P0_MAX_SIZE = "hibernate.c3p0.max_size";
- /**
- * Minimum size of C3P0 connection pool
- */
- public static final String C3P0_MIN_SIZE = "hibernate.c3p0.min_size";
-
- /**
- * Maximum idle time for C3P0 connection pool
- */
- public static final String C3P0_TIMEOUT = "hibernate.c3p0.timeout";
- /**
- * Maximum size of C3P0 statement cache
- */
- public static final String C3P0_MAX_STATEMENTS = "hibernate.c3p0.max_statements";
- /**
- * Number of connections acquired when pool is exhausted
- */
- public static final String C3P0_ACQUIRE_INCREMENT = "hibernate.c3p0.acquire_increment";
- /**
- * Idle time before a C3P0 pooled connection is validated
- */
- public static final String C3P0_IDLE_TEST_PERIOD = "hibernate.c3p0.idle_test_period";
-
- /**
- * Proxool/Hibernate property prefix
- */
- public static final String PROXOOL_PREFIX = "hibernate.proxool";
- /**
- * Proxool property to configure the Proxool Provider using an XML (<tt>/path/to/file.xml</tt>)
- */
- public static final String PROXOOL_XML = "hibernate.proxool.xml";
- /**
- * Proxool property to configure the Proxool Provider using a properties file (<tt>/path/to/proxool.properties</tt>)
- */
- public static final String PROXOOL_PROPERTIES = "hibernate.proxool.properties";
- /**
- * Proxool property to configure the Proxool Provider from an already existing pool (<tt>true</tt> / <tt>false</tt>)
- */
- public static final String PROXOOL_EXISTING_POOL = "hibernate.proxool.existing_pool";
- /**
- * Proxool property with the Proxool pool alias to use
- * (Required for <tt>PROXOOL_EXISTING_POOL</tt>, <tt>PROXOOL_PROPERTIES</tt>, or
- * <tt>PROXOOL_XML</tt>)
- */
- public static final String PROXOOL_POOL_ALIAS = "hibernate.proxool.pool_alias";
-
- /**
- * Enable automatic session close at end of transaction
- */
- public static final String AUTO_CLOSE_SESSION = "hibernate.transaction.auto_close_session";
- /**
- * Enable automatic flush during the JTA <tt>beforeCompletion()</tt> callback
- */
- public static final String FLUSH_BEFORE_COMPLETION = "hibernate.transaction.flush_before_completion";
- /**
- * Specifies how Hibernate should release JDBC connections.
- */
- public static final String RELEASE_CONNECTIONS = "hibernate.connection.release_mode";
- /**
- * Context scoping impl for {@link org.hibernate.SessionFactory#getCurrentSession()} processing.
- */
- public static final String CURRENT_SESSION_CONTEXT_CLASS = "hibernate.current_session_context_class";
- /**
- * <tt>TransactionFactory</tt> implementor to use for creating <tt>Transaction</tt>s
- */
- public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
- /**
- * <tt>TransactionManagerLookup</tt> implementor to use for obtaining the <tt>TransactionManager</tt>
- */
- public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class";
- /**
- * JNDI name of JTA <tt>UserTransaction</tt> object
- */
- public static final String USER_TRANSACTION = "jta.UserTransaction";
-
- /**
- * The <tt>CacheProvider</tt> implementation class
- */
- public static final String CACHE_PROVIDER = "hibernate.cache.provider_class";
-
- /**
- * The {@link org.hibernate.cache.RegionFactory} implementation class
- */
- public static final String CACHE_REGION_FACTORY = "hibernate.cache.region.factory_class";
-
- /**
- * The <tt>CacheProvider</tt> implementation class
- */
- public static final String CACHE_PROVIDER_CONFIG = "hibernate.cache.provider_configuration_file_resource_path";
- /**
- * The <tt>CacheProvider</tt> JNDI namespace, if pre-bound to JNDI.
- */
- public static final String CACHE_NAMESPACE = "hibernate.cache.jndi";
- /**
- * Enable the query cache (disabled by default)
- */
- public static final String USE_QUERY_CACHE = "hibernate.cache.use_query_cache";
- /**
- * The <tt>QueryCacheFactory</tt> implementation class.
- */
- public static final String QUERY_CACHE_FACTORY = "hibernate.cache.query_cache_factory";
- /**
- * Enable the second-level cache (enabled by default)
- */
- public static final String USE_SECOND_LEVEL_CACHE = "hibernate.cache.use_second_level_cache";
- /**
- * Optimize the cache for mimimal puts instead of minimal gets
- */
- public static final String USE_MINIMAL_PUTS = "hibernate.cache.use_minimal_puts";
- /**
- * The <tt>CacheProvider</tt> region name prefix
- */
- public static final String CACHE_REGION_PREFIX = "hibernate.cache.region_prefix";
- /**
- * Enable use of structured second-level cache entries
- */
- public static final String USE_STRUCTURED_CACHE = "hibernate.cache.use_structured_entries";
-
- /**
- * Enable statistics collection
- */
- public static final String GENERATE_STATISTICS = "hibernate.generate_statistics";
-
- public static final String USE_IDENTIFIER_ROLLBACK = "hibernate.use_identifier_rollback";
-
- /**
- * Use bytecode libraries optimized property access
- */
- public static final String USE_REFLECTION_OPTIMIZER = "hibernate.bytecode.use_reflection_optimizer";
-
- /**
- * The classname of the HQL query parser factory
- */
- public static final String QUERY_TRANSLATOR = "hibernate.query.factory_class";
-
- /**
- * A comma-seperated list of token substitutions to use when translating a Hibernate
- * query to SQL
- */
- public static final String QUERY_SUBSTITUTIONS = "hibernate.query.substitutions";
-
- /**
- * Should named queries be checked during startup (the default is enabled).
- * <p/>
- * Mainly intended for test environments.
- */
- public static final String QUERY_STARTUP_CHECKING = "hibernate.query.startup_check";
-
- /**
- * Auto export/update schema using hbm2ddl tool. Valid values are <tt>update</tt>,
- * <tt>create</tt>, <tt>create-drop</tt> and <tt>validate</tt>.
- */
- public static final String HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
-
- /**
- * The {@link org.hibernate.exception.SQLExceptionConverter} to use for converting SQLExceptions
- * to Hibernate's JDBCException hierarchy. The default is to use the configured
- * {@link org.hibernate.dialect.Dialect}'s preferred SQLExceptionConverter.
- */
- public static final String SQL_EXCEPTION_CONVERTER = "hibernate.jdbc.sql_exception_converter";
-
- /**
- * Enable wrapping of JDBC result sets in order to speed up column name lookups for
- * broken JDBC drivers
- */
- public static final String WRAP_RESULT_SETS = "hibernate.jdbc.wrap_result_sets";
-
- /**
- * Enable ordering of update statements by primary key value
- */
- public static final String ORDER_UPDATES = "hibernate.order_updates";
-
- /**
- * Enable ordering of insert statements for the purpose of more effecient JDBC batching.
- */
- public static final String ORDER_INSERTS = "hibernate.order_inserts";
-
- /**
- * The EntityMode in which set the Session opened from the SessionFactory.
- */
- public static final String DEFAULT_ENTITY_MODE = "hibernate.default_entity_mode";
-
- /**
- * The jacc context id of the deployment
- */
- public static final String JACC_CONTEXTID = "hibernate.jacc_context_id";
-
- public static final String BYTECODE_PROVIDER = "hibernate.bytecode.provider";
-
- public static final String JPAQL_STRICT_COMPLIANCE= "hibernate.query.jpaql_strict_compliance";
-
- private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
- private static final boolean ENABLE_BINARY_STREAMS;
- private static final boolean ENABLE_REFLECTION_OPTIMIZER;
- private static final boolean JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
- private static final boolean JVM_HAS_TIMESTAMP_BUG;
- private static final boolean JVM_HAS_JDK14_TIMESTAMP;
- private static final boolean JVM_SUPPORTS_GET_GENERATED_KEYS;
-
- private static final Properties GLOBAL_PROPERTIES;
- private static final HashMap ISOLATION_LEVELS = new HashMap();
- private static final Map OBSOLETE_PROPERTIES = new HashMap();
- private static final Map RENAMED_PROPERTIES = new HashMap();
-
- private static final Logger log = LoggerFactory.getLogger(Environment.class);
-
- /**
- * Issues warnings to the user when any obsolete property names are used.
- */
- public static void verifyProperties(Properties props) {
- Iterator iter = props.keySet().iterator();
- Map propertiesToAdd = new HashMap();
- while ( iter.hasNext() ) {
- final Object propertyName = iter.next();
- Object newPropertyName = OBSOLETE_PROPERTIES.get( propertyName );
- if ( newPropertyName != null ) {
- log.warn( "Usage of obsolete property: " + propertyName + " no longer supported, use: " + newPropertyName );
- }
- newPropertyName = RENAMED_PROPERTIES.get( propertyName );
- if ( newPropertyName != null ) {
- log.warn( "Property [" + propertyName + "] has been renamed to [" + newPropertyName + "]; update your properties appropriately" );
- if ( ! props.containsKey( newPropertyName ) ) {
- propertiesToAdd.put( newPropertyName, props.get( propertyName ) );
- }
- }
- }
- props.putAll(propertiesToAdd);
- }
-
- static {
-
- log.info("Hibernate " + VERSION);
-
- RENAMED_PROPERTIES.put( "hibernate.cglib.use_reflection_optimizer", USE_REFLECTION_OPTIMIZER );
-
- ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_NONE), "NONE" );
- ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_READ_UNCOMMITTED), "READ_UNCOMMITTED" );
- ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_READ_COMMITTED), "READ_COMMITTED" );
- ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_REPEATABLE_READ), "REPEATABLE_READ" );
- ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_SERIALIZABLE), "SERIALIZABLE" );
-
- GLOBAL_PROPERTIES = new Properties();
- //Set USE_REFLECTION_OPTIMIZER to false to fix HHH-227
- GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.FALSE.toString() );
-
- try {
- InputStream stream = ConfigHelper.getResourceAsStream("/hibernate.properties");
- try {
- GLOBAL_PROPERTIES.load(stream);
- log.info( "loaded properties from resource hibernate.properties: " + PropertiesHelper.maskOut(GLOBAL_PROPERTIES, PASS) );
- }
- catch (Exception e) {
- log.error("problem loading properties from hibernate.properties");
- }
- finally {
- try{
- stream.close();
- }
- catch (IOException ioe){
- log.error("could not close stream on hibernate.properties", ioe);
- }
- }
- }
- catch (HibernateException he) {
- log.info("hibernate.properties not found");
- }
-
- try {
- GLOBAL_PROPERTIES.putAll( System.getProperties() );
- }
- catch (SecurityException se) {
- log.warn("could not copy system properties, system properties will be ignored");
- }
-
- verifyProperties(GLOBAL_PROPERTIES);
-
- ENABLE_BINARY_STREAMS = PropertiesHelper.getBoolean(USE_STREAMS_FOR_BINARY, GLOBAL_PROPERTIES);
- ENABLE_REFLECTION_OPTIMIZER = PropertiesHelper.getBoolean(USE_REFLECTION_OPTIMIZER, GLOBAL_PROPERTIES);
-
- if (ENABLE_BINARY_STREAMS) {
- log.info("using java.io streams to persist binary types");
- }
- if (ENABLE_REFLECTION_OPTIMIZER) {
- log.info("using bytecode reflection optimizer");
- }
- BYTECODE_PROVIDER_INSTANCE = buildBytecodeProvider( GLOBAL_PROPERTIES );
-
- boolean getGeneratedKeysSupport;
- try {
- Statement.class.getMethod("getGeneratedKeys", null);
- getGeneratedKeysSupport = true;
- }
- catch (NoSuchMethodException nsme) {
- getGeneratedKeysSupport = false;
- }
- JVM_SUPPORTS_GET_GENERATED_KEYS = getGeneratedKeysSupport;
- if (!JVM_SUPPORTS_GET_GENERATED_KEYS) log.info("JVM does not support Statement.getGeneratedKeys()");
-
- boolean linkedHashSupport;
- try {
- Class.forName("java.util.LinkedHashSet");
- linkedHashSupport = true;
- }
- catch (ClassNotFoundException cnfe) {
- linkedHashSupport = false;
- }
- JVM_SUPPORTS_LINKED_HASH_COLLECTIONS = linkedHashSupport;
- if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
-
- JVM_HAS_TIMESTAMP_BUG = new Timestamp(123456789).getTime() != 123456789;
- if (JVM_HAS_TIMESTAMP_BUG) log.info("using workaround for JVM bug in java.sql.Timestamp");
- Timestamp t = new Timestamp(0);
- t.setNanos(5 * 1000000);
- JVM_HAS_JDK14_TIMESTAMP = t.getTime() == 5;
- if (JVM_HAS_JDK14_TIMESTAMP) {
- log.info("using JDK 1.4 java.sql.Timestamp handling");
- }
- else {
- log.info("using pre JDK 1.4 java.sql.Timestamp handling");
- }
- }
-
- public static BytecodeProvider getBytecodeProvider() {
- return BYTECODE_PROVIDER_INSTANCE;
- }
-
- /**
- * Does this JVM have the IBM JDK 1.3.1. The bug is <tt>new Timestamp(x).getTime()!=x</tt>.
- */
- public static boolean jvmHasTimestampBug() {
- return JVM_HAS_TIMESTAMP_BUG;
- }
-
- /**
- * Does this JVM handle <tt>Timestamp</tt> in the JDK 1.4 compliant way?
- */
- public static boolean jvmHasJDK14Timestamp() {
- return JVM_HAS_JDK14_TIMESTAMP;
- }
-
- /**
- * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>.
- * @see java.util.LinkedHashSet
- * @see java.util.LinkedHashMap
- */
- public static boolean jvmSupportsLinkedHashCollections() {
- return JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
- }
-
- public static boolean jvmSupportsGetGeneratedKeys() {
- return JVM_SUPPORTS_GET_GENERATED_KEYS;
- }
-
- /**
- * Should we use streams to bind binary types to JDBC IN parameters.
- * Property <tt>hibernate.jdbc.use_streams_for_binary</tt>.
- * @see Environment#USE_STREAMS_FOR_BINARY
- */
- public static boolean useStreamsForBinary() {
- return ENABLE_BINARY_STREAMS;
- }
-
- /**
- * Should we use CGLIB reflection optimizer.
- * Property <tt>hibernate.jdbc.use_refection_optimizer</tt>.
- * @see Environment#USE_REFLECTION_OPTIMIZER
- */
- public static boolean useReflectionOptimizer() {
- return ENABLE_REFLECTION_OPTIMIZER;
- }
-
- private Environment() { throw new UnsupportedOperationException(); }
-
- /**
- * Return <tt>System</tt> properties, extended by any properties specified
- * in <tt>hibernate.properties</tt>.
- * @return Properties
- */
- public static Properties getProperties() {
- Properties copy = new Properties();
- copy.putAll(GLOBAL_PROPERTIES);
- return copy;
- }
-
- /**
- * Get the name of a JDBC transaction isolation level
- *
- * @see java.sql.Connection
- * @param isolation as defined by <tt>java.sql.Connection</tt>
- * @return a human-readable name
- */
- public static String isolationLevelToString(int isolation) {
- return (String) ISOLATION_LEVELS.get( new Integer(isolation) );
- }
-
- public static BytecodeProvider buildBytecodeProvider(Properties properties) {
- String provider = PropertiesHelper.getString( BYTECODE_PROVIDER, properties, "javassist" );
- log.info( "Bytecode provider name : " + provider );
- return buildBytecodeProvider( provider );
- }
-
- private static BytecodeProvider buildBytecodeProvider(String providerName) {
- if ( "javassist".equals( providerName ) ) {
- return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
- }
- else if ( "cglib".equals( providerName ) ) {
- return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
- }
-
- log.warn( "unrecognized bytecode provider [" + providerName + "], using javassist by default" );
- return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java (from rev 15001, core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Environment.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,725 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.HibernateException;
+import org.hibernate.bytecode.BytecodeProvider;
+import org.hibernate.util.ConfigHelper;
+import org.hibernate.util.PropertiesHelper;
+
+
+/**
+ * Provides access to configuration info passed in <tt>Properties</tt> objects.
+ * <br><br>
+ * Hibernate has two property scopes:
+ * <ul>
+ * <li><b>Factory-level</b> properties may be passed to the <tt>SessionFactory</tt> when it
+ * instantiated. Each instance might have different property values. If no
+ * properties are specified, the factory calls <tt>Environment.getProperties()</tt>.
+ * <li><b>System-level</b> properties are shared by all factory instances and are always
+ * determined by the <tt>Environment</tt> properties.
+ * </ul>
+ * The only system-level properties are
+ * <ul>
+ * <li><tt>hibernate.jdbc.use_streams_for_binary</tt>
+ * <li><tt>hibernate.cglib.use_reflection_optimizer</tt>
+ * </ul>
+ * <tt>Environment</tt> properties are populated by calling <tt>System.getProperties()</tt>
+ * and then from a resource named <tt>/hibernate.properties</tt> if it exists. System
+ * properties override properties specified in <tt>hibernate.properties</tt>.<br>
+ * <br>
+ * The <tt>SessionFactory</tt> is controlled by the following properties.
+ * Properties may be either be <tt>System</tt> properties, properties
+ * defined in a resource named <tt>/hibernate.properties</tt> or an instance of
+ * <tt>java.util.Properties</tt> passed to
+ * <tt>Configuration.buildSessionFactory()</tt><br>
+ * <br>
+ * <table>
+ * <tr><td><b>property</b></td><td><b>meaning</b></td></tr>
+ * <tr>
+ * <td><tt>hibernate.dialect</tt></td>
+ * <td>classname of <tt>org.hibernate.dialect.Dialect</tt> subclass</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.cache.provider_class</tt></td>
+ * <td>classname of <tt>org.hibernate.cache.CacheProvider</tt>
+ * subclass (if not specified EHCache is used)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.connection.provider_class</tt></td>
+ * <td>classname of <tt>org.hibernate.connection.ConnectionProvider</tt>
+ * subclass (if not specified hueristics are used)</td>
+ * </tr>
+ * <tr><td><tt>hibernate.connection.username</tt></td><td>database username</td></tr>
+ * <tr><td><tt>hibernate.connection.password</tt></td><td>database password</td></tr>
+ * <tr>
+ * <td><tt>hibernate.connection.url</tt></td>
+ * <td>JDBC URL (when using <tt>java.sql.DriverManager</tt>)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.connection.driver_class</tt></td>
+ * <td>classname of JDBC driver</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.connection.isolation</tt></td>
+ * <td>JDBC transaction isolation level (only when using
+ * <tt>java.sql.DriverManager</tt>)
+ * </td>
+ * </tr>
+ * <td><tt>hibernate.connection.pool_size</tt></td>
+ * <td>the maximum size of the connection pool (only when using
+ * <tt>java.sql.DriverManager</tt>)
+ * </td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.connection.datasource</tt></td>
+ * <td>databasource JNDI name (when using <tt>javax.sql.Datasource</tt>)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.jndi.url</tt></td><td>JNDI <tt>InitialContext</tt> URL</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.jndi.class</tt></td><td>JNDI <tt>InitialContext</tt> classname</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.max_fetch_depth</tt></td>
+ * <td>maximum depth of outer join fetching</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.jdbc.batch_size</tt></td>
+ * <td>enable use of JDBC2 batch API for drivers which support it</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.jdbc.fetch_size</tt></td>
+ * <td>set the JDBC fetch size</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.jdbc.use_scrollable_resultset</tt></td>
+ * <td>enable use of JDBC2 scrollable resultsets (you only need this specify
+ * this property when using user supplied connections)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.jdbc.use_getGeneratedKeys</tt></td>
+ * <td>enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve
+ * natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.hbm2ddl.auto</tt></td>
+ * <td>enable auto DDL export</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.default_schema</tt></td>
+ * <td>use given schema name for unqualified tables (always optional)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.default_catalog</tt></td>
+ * <td>use given catalog name for unqualified tables (always optional)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.session_factory_name</tt></td>
+ * <td>If set, the factory attempts to bind this name to itself in the
+ * JNDI context. This name is also used to support cross JVM <tt>
+ * Session</tt> (de)serialization.</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.transaction.manager_lookup_class</tt></td>
+ * <td>classname of <tt>org.hibernate.transaction.TransactionManagerLookup</tt>
+ * implementor</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.transaction.factory_class</tt></td>
+ * <td>the factory to use for instantiating <tt>Transaction</tt>s.
+ * (Defaults to <tt>JDBCTransactionFactory</tt>.)</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hibernate.query.substitutions</tt></td><td>query language token substitutions</td>
+ * </tr>
+ * </table>
+ *
+ * @see org.hibernate.SessionFactory
+ * @author Gavin King
+ */
+public final class Environment {
+
+ public static final String VERSION = "3.3.0.CR2";
+
+ /**
+ * <tt>ConnectionProvider</tt> implementor to use when obtaining connections
+ */
+ public static final String CONNECTION_PROVIDER ="hibernate.connection.provider_class";
+ /**
+ * JDBC driver class
+ */
+ public static final String DRIVER ="hibernate.connection.driver_class";
+ /**
+ * JDBC transaction isolation level
+ */
+ public static final String ISOLATION ="hibernate.connection.isolation";
+ /**
+ * JDBC URL
+ */
+ public static final String URL ="hibernate.connection.url";
+ /**
+ * JDBC user
+ */
+ public static final String USER ="hibernate.connection.username";
+ /**
+ * JDBC password
+ */
+ public static final String PASS ="hibernate.connection.password";
+ /**
+ * JDBC autocommit mode
+ */
+ public static final String AUTOCOMMIT ="hibernate.connection.autocommit";
+ /**
+ * Maximum number of inactive connections for Hibernate's connection pool
+ */
+ public static final String POOL_SIZE ="hibernate.connection.pool_size";
+ /**
+ * <tt>java.sql.Datasource</tt> JNDI name
+ */
+ public static final String DATASOURCE ="hibernate.connection.datasource";
+ /**
+ * prefix for arbitrary JDBC connection properties
+ */
+ public static final String CONNECTION_PREFIX = "hibernate.connection";
+
+ /**
+ * JNDI initial context class, <tt>Context.INITIAL_CONTEXT_FACTORY</tt>
+ */
+ public static final String JNDI_CLASS ="hibernate.jndi.class";
+ /**
+ * JNDI provider URL, <tt>Context.PROVIDER_URL</tt>
+ */
+ public static final String JNDI_URL ="hibernate.jndi.url";
+ /**
+ * prefix for arbitrary JNDI <tt>InitialContext</tt> properties
+ */
+ public static final String JNDI_PREFIX = "hibernate.jndi";
+ /**
+ * JNDI name to bind to <tt>SessionFactory</tt>
+ */
+ public static final String SESSION_FACTORY_NAME = "hibernate.session_factory_name";
+
+ /**
+ * Hibernate SQL <tt>Dialect</tt> class
+ */
+ public static final String DIALECT ="hibernate.dialect";
+ /**
+ * A default database schema (owner) name to use for unqualified tablenames
+ */
+ public static final String DEFAULT_SCHEMA = "hibernate.default_schema";
+ /**
+ * A default database catalog name to use for unqualified tablenames
+ */
+ public static final String DEFAULT_CATALOG = "hibernate.default_catalog";
+
+ /**
+ * Enable logging of generated SQL to the console
+ */
+ public static final String SHOW_SQL ="hibernate.show_sql";
+ /**
+ * Enable formatting of SQL logged to the console
+ */
+ public static final String FORMAT_SQL ="hibernate.format_sql";
+ /**
+ * Add comments to the generated SQL
+ */
+ public static final String USE_SQL_COMMENTS ="hibernate.use_sql_comments";
+ /**
+ * Maximum depth of outer join fetching
+ */
+ public static final String MAX_FETCH_DEPTH = "hibernate.max_fetch_depth";
+ /**
+ * The default batch size for batch fetching
+ */
+ public static final String DEFAULT_BATCH_FETCH_SIZE = "hibernate.default_batch_fetch_size";
+ /**
+ * Use <tt>java.io</tt> streams to read / write binary data from / to JDBC
+ */
+ public static final String USE_STREAMS_FOR_BINARY = "hibernate.jdbc.use_streams_for_binary";
+ /**
+ * Use JDBC scrollable <tt>ResultSet</tt>s. This property is only necessary when there is
+ * no <tt>ConnectionProvider</tt>, ie. the user is supplying JDBC connections.
+ */
+ public static final String USE_SCROLLABLE_RESULTSET = "hibernate.jdbc.use_scrollable_resultset";
+ /**
+ * Tells the JDBC driver to attempt to retrieve row Id with the JDBC 3.0 PreparedStatement.getGeneratedKeys()
+ * method. In general, performance will be better if this property is set to true and the underlying
+ * JDBC driver supports getGeneratedKeys().
+ */
+ public static final String USE_GET_GENERATED_KEYS = "hibernate.jdbc.use_get_generated_keys";
+ /**
+ * Gives the JDBC driver a hint as to the number of rows that should be fetched from the database
+ * when more rows are needed. If <tt>0</tt>, JDBC driver default settings will be used.
+ */
+ public static final String STATEMENT_FETCH_SIZE = "hibernate.jdbc.fetch_size";
+ /**
+ * Maximum JDBC batch size. A nonzero value enables batch updates.
+ */
+ public static final String STATEMENT_BATCH_SIZE = "hibernate.jdbc.batch_size";
+ /**
+ * Select a custom batcher.
+ */
+ public static final String BATCH_STRATEGY = "hibernate.jdbc.factory_class";
+ /**
+ * Should versioned data be included in batching?
+ */
+ public static final String BATCH_VERSIONED_DATA = "hibernate.jdbc.batch_versioned_data";
+ /**
+ * An XSLT resource used to generate "custom" XML
+ */
+ public static final String OUTPUT_STYLESHEET ="hibernate.xml.output_stylesheet";
+
+ /**
+ * Maximum size of C3P0 connection pool
+ */
+ public static final String C3P0_MAX_SIZE = "hibernate.c3p0.max_size";
+ /**
+ * Minimum size of C3P0 connection pool
+ */
+ public static final String C3P0_MIN_SIZE = "hibernate.c3p0.min_size";
+
+ /**
+ * Maximum idle time for C3P0 connection pool
+ */
+ public static final String C3P0_TIMEOUT = "hibernate.c3p0.timeout";
+ /**
+ * Maximum size of C3P0 statement cache
+ */
+ public static final String C3P0_MAX_STATEMENTS = "hibernate.c3p0.max_statements";
+ /**
+ * Number of connections acquired when pool is exhausted
+ */
+ public static final String C3P0_ACQUIRE_INCREMENT = "hibernate.c3p0.acquire_increment";
+ /**
+ * Idle time before a C3P0 pooled connection is validated
+ */
+ public static final String C3P0_IDLE_TEST_PERIOD = "hibernate.c3p0.idle_test_period";
+
+ /**
+ * Proxool/Hibernate property prefix
+ */
+ public static final String PROXOOL_PREFIX = "hibernate.proxool";
+ /**
+ * Proxool property to configure the Proxool Provider using an XML (<tt>/path/to/file.xml</tt>)
+ */
+ public static final String PROXOOL_XML = "hibernate.proxool.xml";
+ /**
+ * Proxool property to configure the Proxool Provider using a properties file (<tt>/path/to/proxool.properties</tt>)
+ */
+ public static final String PROXOOL_PROPERTIES = "hibernate.proxool.properties";
+ /**
+ * Proxool property to configure the Proxool Provider from an already existing pool (<tt>true</tt> / <tt>false</tt>)
+ */
+ public static final String PROXOOL_EXISTING_POOL = "hibernate.proxool.existing_pool";
+ /**
+ * Proxool property with the Proxool pool alias to use
+ * (Required for <tt>PROXOOL_EXISTING_POOL</tt>, <tt>PROXOOL_PROPERTIES</tt>, or
+ * <tt>PROXOOL_XML</tt>)
+ */
+ public static final String PROXOOL_POOL_ALIAS = "hibernate.proxool.pool_alias";
+
+ /**
+ * Enable automatic session close at end of transaction
+ */
+ public static final String AUTO_CLOSE_SESSION = "hibernate.transaction.auto_close_session";
+ /**
+ * Enable automatic flush during the JTA <tt>beforeCompletion()</tt> callback
+ */
+ public static final String FLUSH_BEFORE_COMPLETION = "hibernate.transaction.flush_before_completion";
+ /**
+ * Specifies how Hibernate should release JDBC connections.
+ */
+ public static final String RELEASE_CONNECTIONS = "hibernate.connection.release_mode";
+ /**
+ * Context scoping impl for {@link org.hibernate.SessionFactory#getCurrentSession()} processing.
+ */
+ public static final String CURRENT_SESSION_CONTEXT_CLASS = "hibernate.current_session_context_class";
+ /**
+ * <tt>TransactionFactory</tt> implementor to use for creating <tt>Transaction</tt>s
+ */
+ public static final String TRANSACTION_STRATEGY = "hibernate.transaction.factory_class";
+ /**
+ * <tt>TransactionManagerLookup</tt> implementor to use for obtaining the <tt>TransactionManager</tt>
+ */
+ public static final String TRANSACTION_MANAGER_STRATEGY = "hibernate.transaction.manager_lookup_class";
+ /**
+ * JNDI name of JTA <tt>UserTransaction</tt> object
+ */
+ public static final String USER_TRANSACTION = "jta.UserTransaction";
+
+ /**
+ * The <tt>CacheProvider</tt> implementation class
+ */
+ public static final String CACHE_PROVIDER = "hibernate.cache.provider_class";
+
+ /**
+ * The {@link org.hibernate.cache.RegionFactory} implementation class
+ */
+ public static final String CACHE_REGION_FACTORY = "hibernate.cache.region.factory_class";
+
+ /**
+ * The <tt>CacheProvider</tt> implementation class
+ */
+ public static final String CACHE_PROVIDER_CONFIG = "hibernate.cache.provider_configuration_file_resource_path";
+ /**
+ * The <tt>CacheProvider</tt> JNDI namespace, if pre-bound to JNDI.
+ */
+ public static final String CACHE_NAMESPACE = "hibernate.cache.jndi";
+ /**
+ * Enable the query cache (disabled by default)
+ */
+ public static final String USE_QUERY_CACHE = "hibernate.cache.use_query_cache";
+ /**
+ * The <tt>QueryCacheFactory</tt> implementation class.
+ */
+ public static final String QUERY_CACHE_FACTORY = "hibernate.cache.query_cache_factory";
+ /**
+ * Enable the second-level cache (enabled by default)
+ */
+ public static final String USE_SECOND_LEVEL_CACHE = "hibernate.cache.use_second_level_cache";
+ /**
+ * Optimize the cache for mimimal puts instead of minimal gets
+ */
+ public static final String USE_MINIMAL_PUTS = "hibernate.cache.use_minimal_puts";
+ /**
+ * The <tt>CacheProvider</tt> region name prefix
+ */
+ public static final String CACHE_REGION_PREFIX = "hibernate.cache.region_prefix";
+ /**
+ * Enable use of structured second-level cache entries
+ */
+ public static final String USE_STRUCTURED_CACHE = "hibernate.cache.use_structured_entries";
+
+ /**
+ * Enable statistics collection
+ */
+ public static final String GENERATE_STATISTICS = "hibernate.generate_statistics";
+
+ public static final String USE_IDENTIFIER_ROLLBACK = "hibernate.use_identifier_rollback";
+
+ /**
+ * Use bytecode libraries optimized property access
+ */
+ public static final String USE_REFLECTION_OPTIMIZER = "hibernate.bytecode.use_reflection_optimizer";
+
+ /**
+ * The classname of the HQL query parser factory
+ */
+ public static final String QUERY_TRANSLATOR = "hibernate.query.factory_class";
+
+ /**
+ * A comma-seperated list of token substitutions to use when translating a Hibernate
+ * query to SQL
+ */
+ public static final String QUERY_SUBSTITUTIONS = "hibernate.query.substitutions";
+
+ /**
+ * Should named queries be checked during startup (the default is enabled).
+ * <p/>
+ * Mainly intended for test environments.
+ */
+ public static final String QUERY_STARTUP_CHECKING = "hibernate.query.startup_check";
+
+ /**
+ * Auto export/update schema using hbm2ddl tool. Valid values are <tt>update</tt>,
+ * <tt>create</tt>, <tt>create-drop</tt> and <tt>validate</tt>.
+ */
+ public static final String HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
+
+ /**
+ * The {@link org.hibernate.exception.SQLExceptionConverter} to use for converting SQLExceptions
+ * to Hibernate's JDBCException hierarchy. The default is to use the configured
+ * {@link org.hibernate.dialect.Dialect}'s preferred SQLExceptionConverter.
+ */
+ public static final String SQL_EXCEPTION_CONVERTER = "hibernate.jdbc.sql_exception_converter";
+
+ /**
+ * Enable wrapping of JDBC result sets in order to speed up column name lookups for
+ * broken JDBC drivers
+ */
+ public static final String WRAP_RESULT_SETS = "hibernate.jdbc.wrap_result_sets";
+
+ /**
+ * Enable ordering of update statements by primary key value
+ */
+ public static final String ORDER_UPDATES = "hibernate.order_updates";
+
+ /**
+ * Enable ordering of insert statements for the purpose of more effecient JDBC batching.
+ */
+ public static final String ORDER_INSERTS = "hibernate.order_inserts";
+
+ /**
+ * The EntityMode in which set the Session opened from the SessionFactory.
+ */
+ public static final String DEFAULT_ENTITY_MODE = "hibernate.default_entity_mode";
+
+ /**
+ * The jacc context id of the deployment
+ */
+ public static final String JACC_CONTEXTID = "hibernate.jacc_context_id";
+
+ public static final String BYTECODE_PROVIDER = "hibernate.bytecode.provider";
+
+ public static final String JPAQL_STRICT_COMPLIANCE= "hibernate.query.jpaql_strict_compliance";
+
+ private static final BytecodeProvider BYTECODE_PROVIDER_INSTANCE;
+ private static final boolean ENABLE_BINARY_STREAMS;
+ private static final boolean ENABLE_REFLECTION_OPTIMIZER;
+ private static final boolean JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
+ private static final boolean JVM_HAS_TIMESTAMP_BUG;
+ private static final boolean JVM_HAS_JDK14_TIMESTAMP;
+ private static final boolean JVM_SUPPORTS_GET_GENERATED_KEYS;
+
+ private static final Properties GLOBAL_PROPERTIES;
+ private static final HashMap ISOLATION_LEVELS = new HashMap();
+ private static final Map OBSOLETE_PROPERTIES = new HashMap();
+ private static final Map RENAMED_PROPERTIES = new HashMap();
+
+ private static final Logger log = LoggerFactory.getLogger(Environment.class);
+
+ /**
+ * Issues warnings to the user when any obsolete property names are used.
+ */
+ public static void verifyProperties(Properties props) {
+ Iterator iter = props.keySet().iterator();
+ Map propertiesToAdd = new HashMap();
+ while ( iter.hasNext() ) {
+ final Object propertyName = iter.next();
+ Object newPropertyName = OBSOLETE_PROPERTIES.get( propertyName );
+ if ( newPropertyName != null ) {
+ log.warn( "Usage of obsolete property: " + propertyName + " no longer supported, use: " + newPropertyName );
+ }
+ newPropertyName = RENAMED_PROPERTIES.get( propertyName );
+ if ( newPropertyName != null ) {
+ log.warn( "Property [" + propertyName + "] has been renamed to [" + newPropertyName + "]; update your properties appropriately" );
+ if ( ! props.containsKey( newPropertyName ) ) {
+ propertiesToAdd.put( newPropertyName, props.get( propertyName ) );
+ }
+ }
+ }
+ props.putAll(propertiesToAdd);
+ }
+
+ static {
+
+ log.info("Hibernate " + VERSION);
+
+ RENAMED_PROPERTIES.put( "hibernate.cglib.use_reflection_optimizer", USE_REFLECTION_OPTIMIZER );
+
+ ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_NONE), "NONE" );
+ ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_READ_UNCOMMITTED), "READ_UNCOMMITTED" );
+ ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_READ_COMMITTED), "READ_COMMITTED" );
+ ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_REPEATABLE_READ), "REPEATABLE_READ" );
+ ISOLATION_LEVELS.put( new Integer(Connection.TRANSACTION_SERIALIZABLE), "SERIALIZABLE" );
+
+ GLOBAL_PROPERTIES = new Properties();
+ //Set USE_REFLECTION_OPTIMIZER to false to fix HHH-227
+ GLOBAL_PROPERTIES.setProperty( USE_REFLECTION_OPTIMIZER, Boolean.FALSE.toString() );
+
+ try {
+ InputStream stream = ConfigHelper.getResourceAsStream("/hibernate.properties");
+ try {
+ GLOBAL_PROPERTIES.load(stream);
+ log.info( "loaded properties from resource hibernate.properties: " + PropertiesHelper.maskOut(GLOBAL_PROPERTIES, PASS) );
+ }
+ catch (Exception e) {
+ log.error("problem loading properties from hibernate.properties");
+ }
+ finally {
+ try{
+ stream.close();
+ }
+ catch (IOException ioe){
+ log.error("could not close stream on hibernate.properties", ioe);
+ }
+ }
+ }
+ catch (HibernateException he) {
+ log.info("hibernate.properties not found");
+ }
+
+ try {
+ GLOBAL_PROPERTIES.putAll( System.getProperties() );
+ }
+ catch (SecurityException se) {
+ log.warn("could not copy system properties, system properties will be ignored");
+ }
+
+ verifyProperties(GLOBAL_PROPERTIES);
+
+ ENABLE_BINARY_STREAMS = PropertiesHelper.getBoolean(USE_STREAMS_FOR_BINARY, GLOBAL_PROPERTIES);
+ ENABLE_REFLECTION_OPTIMIZER = PropertiesHelper.getBoolean(USE_REFLECTION_OPTIMIZER, GLOBAL_PROPERTIES);
+
+ if (ENABLE_BINARY_STREAMS) {
+ log.info("using java.io streams to persist binary types");
+ }
+ if (ENABLE_REFLECTION_OPTIMIZER) {
+ log.info("using bytecode reflection optimizer");
+ }
+ BYTECODE_PROVIDER_INSTANCE = buildBytecodeProvider( GLOBAL_PROPERTIES );
+
+ boolean getGeneratedKeysSupport;
+ try {
+ Statement.class.getMethod("getGeneratedKeys", null);
+ getGeneratedKeysSupport = true;
+ }
+ catch (NoSuchMethodException nsme) {
+ getGeneratedKeysSupport = false;
+ }
+ JVM_SUPPORTS_GET_GENERATED_KEYS = getGeneratedKeysSupport;
+ if (!JVM_SUPPORTS_GET_GENERATED_KEYS) log.info("JVM does not support Statement.getGeneratedKeys()");
+
+ boolean linkedHashSupport;
+ try {
+ Class.forName("java.util.LinkedHashSet");
+ linkedHashSupport = true;
+ }
+ catch (ClassNotFoundException cnfe) {
+ linkedHashSupport = false;
+ }
+ JVM_SUPPORTS_LINKED_HASH_COLLECTIONS = linkedHashSupport;
+ if (!JVM_SUPPORTS_LINKED_HASH_COLLECTIONS) log.info("JVM does not support LinkedHasMap, LinkedHashSet - ordered maps and sets disabled");
+
+ JVM_HAS_TIMESTAMP_BUG = new Timestamp(123456789).getTime() != 123456789;
+ if (JVM_HAS_TIMESTAMP_BUG) log.info("using workaround for JVM bug in java.sql.Timestamp");
+ Timestamp t = new Timestamp(0);
+ t.setNanos(5 * 1000000);
+ JVM_HAS_JDK14_TIMESTAMP = t.getTime() == 5;
+ if (JVM_HAS_JDK14_TIMESTAMP) {
+ log.info("using JDK 1.4 java.sql.Timestamp handling");
+ }
+ else {
+ log.info("using pre JDK 1.4 java.sql.Timestamp handling");
+ }
+ }
+
+ public static BytecodeProvider getBytecodeProvider() {
+ return BYTECODE_PROVIDER_INSTANCE;
+ }
+
+ /**
+ * Does this JVM have the IBM JDK 1.3.1. The bug is <tt>new Timestamp(x).getTime()!=x</tt>.
+ */
+ public static boolean jvmHasTimestampBug() {
+ return JVM_HAS_TIMESTAMP_BUG;
+ }
+
+ /**
+ * Does this JVM handle <tt>Timestamp</tt> in the JDK 1.4 compliant way?
+ */
+ public static boolean jvmHasJDK14Timestamp() {
+ return JVM_HAS_JDK14_TIMESTAMP;
+ }
+
+ /**
+ * Does this JVM support <tt>LinkedHashSet</tt>, <tt>LinkedHashMap</tt>.
+ * @see java.util.LinkedHashSet
+ * @see java.util.LinkedHashMap
+ */
+ public static boolean jvmSupportsLinkedHashCollections() {
+ return JVM_SUPPORTS_LINKED_HASH_COLLECTIONS;
+ }
+
+ public static boolean jvmSupportsGetGeneratedKeys() {
+ return JVM_SUPPORTS_GET_GENERATED_KEYS;
+ }
+
+ /**
+ * Should we use streams to bind binary types to JDBC IN parameters.
+ * Property <tt>hibernate.jdbc.use_streams_for_binary</tt>.
+ * @see Environment#USE_STREAMS_FOR_BINARY
+ */
+ public static boolean useStreamsForBinary() {
+ return ENABLE_BINARY_STREAMS;
+ }
+
+ /**
+ * Should we use CGLIB reflection optimizer.
+ * Property <tt>hibernate.jdbc.use_refection_optimizer</tt>.
+ * @see Environment#USE_REFLECTION_OPTIMIZER
+ */
+ public static boolean useReflectionOptimizer() {
+ return ENABLE_REFLECTION_OPTIMIZER;
+ }
+
+ private Environment() { throw new UnsupportedOperationException(); }
+
+ /**
+ * Return <tt>System</tt> properties, extended by any properties specified
+ * in <tt>hibernate.properties</tt>.
+ * @return Properties
+ */
+ public static Properties getProperties() {
+ Properties copy = new Properties();
+ copy.putAll(GLOBAL_PROPERTIES);
+ return copy;
+ }
+
+ /**
+ * Get the name of a JDBC transaction isolation level
+ *
+ * @see java.sql.Connection
+ * @param isolation as defined by <tt>java.sql.Connection</tt>
+ * @return a human-readable name
+ */
+ public static String isolationLevelToString(int isolation) {
+ return (String) ISOLATION_LEVELS.get( new Integer(isolation) );
+ }
+
+ public static BytecodeProvider buildBytecodeProvider(Properties properties) {
+ String provider = PropertiesHelper.getString( BYTECODE_PROVIDER, properties, "javassist" );
+ log.info( "Bytecode provider name : " + provider );
+ return buildBytecodeProvider( provider );
+ }
+
+ private static BytecodeProvider buildBytecodeProvider(String providerName) {
+ if ( "javassist".equals( providerName ) ) {
+ return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
+ }
+ else if ( "cglib".equals( providerName ) ) {
+ return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
+ }
+
+ log.warn( "unrecognized bytecode provider [" + providerName + "], using javassist by default" );
+ return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,33 +0,0 @@
-package org.hibernate.cfg;
-
-import org.dom4j.Document;
-
-/**
- * Represents a mapping queued for delayed processing to await
- * processing of an extends entity upon which it depends.
- *
- * @author Steve Ebersole
- */
-public class ExtendsQueueEntry {
- private final String explicitName;
- private final String mappingPackage;
- private final Document document;
-
- public ExtendsQueueEntry(String explicitName, String mappingPackage, Document document) {
- this.explicitName = explicitName;
- this.mappingPackage = mappingPackage;
- this.document = document;
- }
-
- public String getExplicitName() {
- return explicitName;
- }
-
- public String getMappingPackage() {
- return mappingPackage;
- }
-
- public Document getDocument() {
- return document;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ExtendsQueueEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import org.dom4j.Document;
+
+/**
+ * Represents a mapping queued for delayed processing to await
+ * processing of an extends entity upon which it depends.
+ *
+ * @author Steve Ebersole
+ */
+public class ExtendsQueueEntry {
+ private final String explicitName;
+ private final String mappingPackage;
+ private final Document document;
+
+ public ExtendsQueueEntry(String explicitName, String mappingPackage, Document document) {
+ this.explicitName = explicitName;
+ this.mappingPackage = mappingPackage;
+ this.document = document;
+ }
+
+ public String getExplicitName() {
+ return explicitName;
+ }
+
+ public String getMappingPackage() {
+ return mappingPackage;
+ }
+
+ public Document getDocument() {
+ return document;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,3056 +0,0 @@
-// $Id: HbmBinder.java 11496 2007-05-09 03:54:06Z steve.ebersole(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.hibernate.CacheMode;
-import org.hibernate.EntityMode;
-import org.hibernate.FetchMode;
-import org.hibernate.FlushMode;
-import org.hibernate.MappingException;
-import org.hibernate.engine.FilterDefinition;
-import org.hibernate.engine.NamedQueryDefinition;
-import org.hibernate.engine.Versioning;
-import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
-import org.hibernate.id.PersistentIdentifierGenerator;
-import org.hibernate.mapping.Any;
-import org.hibernate.mapping.Array;
-import org.hibernate.mapping.AuxiliaryDatabaseObject;
-import org.hibernate.mapping.Backref;
-import org.hibernate.mapping.Bag;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.Component;
-import org.hibernate.mapping.DependantValue;
-import org.hibernate.mapping.Fetchable;
-import org.hibernate.mapping.Filterable;
-import org.hibernate.mapping.Formula;
-import org.hibernate.mapping.IdentifierBag;
-import org.hibernate.mapping.IdentifierCollection;
-import org.hibernate.mapping.IndexBackref;
-import org.hibernate.mapping.IndexedCollection;
-import org.hibernate.mapping.Join;
-import org.hibernate.mapping.JoinedSubclass;
-import org.hibernate.mapping.KeyValue;
-import org.hibernate.mapping.List;
-import org.hibernate.mapping.ManyToOne;
-import org.hibernate.mapping.Map;
-import org.hibernate.mapping.MetaAttribute;
-import org.hibernate.mapping.OneToMany;
-import org.hibernate.mapping.OneToOne;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.PrimitiveArray;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.PropertyGeneration;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.mapping.Selectable;
-import org.hibernate.mapping.Set;
-import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
-import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.SingleTableSubclass;
-import org.hibernate.mapping.Subclass;
-import org.hibernate.mapping.Table;
-import org.hibernate.mapping.ToOne;
-import org.hibernate.mapping.TypeDef;
-import org.hibernate.mapping.UnionSubclass;
-import org.hibernate.mapping.UniqueKey;
-import org.hibernate.mapping.Value;
-import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
-import org.hibernate.persister.entity.SingleTableEntityPersister;
-import org.hibernate.persister.entity.UnionSubclassEntityPersister;
-import org.hibernate.type.DiscriminatorType;
-import org.hibernate.type.ForeignKeyDirection;
-import org.hibernate.type.Type;
-import org.hibernate.type.TypeFactory;
-import org.hibernate.util.JoinedIterator;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * Walks an XML mapping document and produces the Hibernate configuration-time metamodel (the
- * classes in the <tt>mapping</tt> package)
- *
- * @author Gavin King
- */
-public final class HbmBinder {
-
- private static final Logger log = LoggerFactory.getLogger( HbmBinder.class );
-
- /**
- * Private constructor to disallow instantiation.
- */
- private HbmBinder() {
- }
-
- /**
- * The main contract into the hbm.xml-based binder. Performs necessary binding operations
- * represented by the given DOM.
- *
- * @param doc The DOM to be parsed and bound.
- * @param mappings Current bind state.
- * @param inheritedMetas Any inherited meta-tag information.
- * @throws MappingException
- */
- public static void bindRoot(Document doc, Mappings mappings, java.util.Map inheritedMetas)
- throws MappingException {
-
- java.util.List names = HbmBinder.getExtendsNeeded( doc, mappings );
- if ( !names.isEmpty() ) {
- // classes mentioned in extends not available - so put it in queue
- Element hmNode = doc.getRootElement();
- Attribute packNode = hmNode.attribute( "package" );
- String packageName = null;
- if ( packNode != null ) {
- packageName = packNode.getValue();
- }
- Iterator itr = names.iterator();
- while ( itr.hasNext() ) {
- String extendsName = (String) itr.next();
- mappings.addToExtendsQueue( new ExtendsQueueEntry( extendsName, packageName, doc ) );
- }
- return;
- }
-
- Element hmNode = doc.getRootElement();
- // get meta's from <hibernate-mapping>
- inheritedMetas = getMetas( hmNode, inheritedMetas, true );
- extractRootAttributes( hmNode, mappings );
-
- Iterator rootChildren = hmNode.elementIterator();
- while ( rootChildren.hasNext() ) {
- final Element element = (Element) rootChildren.next();
- final String elementName = element.getName();
-
- if ( "filter-def".equals( elementName ) ) {
- parseFilterDef( element, mappings );
- }
- else if ( "typedef".equals( elementName ) ) {
- bindTypeDef( element, mappings );
- }
- else if ( "class".equals( elementName ) ) {
- RootClass rootclass = new RootClass();
- bindRootClass( element, rootclass, mappings, inheritedMetas );
- mappings.addClass( rootclass );
- }
- else if ( "subclass".equals( elementName ) ) {
- PersistentClass superModel = getSuperclass( mappings, element );
- handleSubclass( superModel, mappings, element, inheritedMetas );
- }
- else if ( "joined-subclass".equals( elementName ) ) {
- PersistentClass superModel = getSuperclass( mappings, element );
- handleJoinedSubclass( superModel, mappings, element, inheritedMetas );
- }
- else if ( "union-subclass".equals( elementName ) ) {
- PersistentClass superModel = getSuperclass( mappings, element );
- handleUnionSubclass( superModel, mappings, element, inheritedMetas );
- }
- else if ( "query".equals( elementName ) ) {
- bindNamedQuery( element, null, mappings );
- }
- else if ( "sql-query".equals( elementName ) ) {
- bindNamedSQLQuery( element, null, mappings );
- }
- else if ( "resultset".equals( elementName ) ) {
- bindResultSetMappingDefinition( element, null, mappings );
- }
- else if ( "import".equals( elementName ) ) {
- bindImport( element, mappings );
- }
- else if ( "database-object".equals( elementName ) ) {
- bindAuxiliaryDatabaseObject( element, mappings );
- }
- }
- }
-
- private static void bindImport(Element importNode, Mappings mappings) {
- String className = getClassName( importNode.attribute( "class" ), mappings );
- Attribute renameNode = importNode.attribute( "rename" );
- String rename = ( renameNode == null ) ?
- StringHelper.unqualify( className ) :
- renameNode.getValue();
- log.debug( "Import: " + rename + " -> " + className );
- mappings.addImport( className, rename );
- }
-
- private static void bindTypeDef(Element typedefNode, Mappings mappings) {
- String typeClass = typedefNode.attributeValue( "class" );
- String typeName = typedefNode.attributeValue( "name" );
- Iterator paramIter = typedefNode.elementIterator( "param" );
- Properties parameters = new Properties();
- while ( paramIter.hasNext() ) {
- Element param = (Element) paramIter.next();
- parameters.setProperty( param.attributeValue( "name" ), param.getTextTrim() );
- }
- mappings.addTypeDef( typeName, typeClass, parameters );
- }
-
- private static void bindAuxiliaryDatabaseObject(Element auxDbObjectNode, Mappings mappings) {
- AuxiliaryDatabaseObject auxDbObject = null;
- Element definitionNode = auxDbObjectNode.element( "definition" );
- if ( definitionNode != null ) {
- try {
- auxDbObject = ( AuxiliaryDatabaseObject ) ReflectHelper
- .classForName( definitionNode.attributeValue( "class" ) )
- .newInstance();
- }
- catch( ClassNotFoundException e ) {
- throw new MappingException(
- "could not locate custom database object class [" +
- definitionNode.attributeValue( "class" ) + "]"
- );
- }
- catch( Throwable t ) {
- throw new MappingException(
- "could not instantiate custom database object class [" +
- definitionNode.attributeValue( "class" ) + "]"
- );
- }
- }
- else {
- auxDbObject = new SimpleAuxiliaryDatabaseObject(
- auxDbObjectNode.elementTextTrim( "create" ),
- auxDbObjectNode.elementTextTrim( "drop" )
- );
- }
-
- Iterator dialectScopings = auxDbObjectNode.elementIterator( "dialect-scope" );
- while ( dialectScopings.hasNext() ) {
- Element dialectScoping = ( Element ) dialectScopings.next();
- auxDbObject.addDialectScope( dialectScoping.attributeValue( "name" ) );
- }
-
- mappings.addAuxiliaryDatabaseObject( auxDbObject );
- }
-
- private static void extractRootAttributes(Element hmNode, Mappings mappings) {
- Attribute schemaNode = hmNode.attribute( "schema" );
- mappings.setSchemaName( ( schemaNode == null ) ? null : schemaNode.getValue() );
-
- Attribute catalogNode = hmNode.attribute( "catalog" );
- mappings.setCatalogName( ( catalogNode == null ) ? null : catalogNode.getValue() );
-
- Attribute dcNode = hmNode.attribute( "default-cascade" );
- mappings.setDefaultCascade( ( dcNode == null ) ? "none" : dcNode.getValue() );
-
- Attribute daNode = hmNode.attribute( "default-access" );
- mappings.setDefaultAccess( ( daNode == null ) ? "property" : daNode.getValue() );
-
- Attribute dlNode = hmNode.attribute( "default-lazy" );
- mappings.setDefaultLazy( dlNode == null || dlNode.getValue().equals( "true" ) );
-
- Attribute aiNode = hmNode.attribute( "auto-import" );
- mappings.setAutoImport( ( aiNode == null ) || "true".equals( aiNode.getValue() ) );
-
- Attribute packNode = hmNode.attribute( "package" );
- if ( packNode != null ) mappings.setDefaultPackage( packNode.getValue() );
- }
-
- /**
- * Responsible for perfoming the bind operation related to an <class/> mapping element.
- *
- * @param node The DOM Element for the <class/> element.
- * @param rootClass The mapping instance to which to bind the information.
- * @param mappings The current bind state.
- * @param inheritedMetas Any inherited meta-tag information.
- * @throws MappingException
- */
- public static void bindRootClass(Element node, RootClass rootClass, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
- bindClass( node, rootClass, mappings, inheritedMetas );
- inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <class>
- bindRootPersistentClassCommonValues( node, inheritedMetas, mappings, rootClass );
- }
-
- private static void bindRootPersistentClassCommonValues(Element node,
- java.util.Map inheritedMetas, Mappings mappings, RootClass entity)
- throws MappingException {
-
- // DB-OBJECTNAME
-
- Attribute schemaNode = node.attribute( "schema" );
- String schema = schemaNode == null ?
- mappings.getSchemaName() : schemaNode.getValue();
-
- Attribute catalogNode = node.attribute( "catalog" );
- String catalog = catalogNode == null ?
- mappings.getCatalogName() : catalogNode.getValue();
-
- Table table = mappings.addTable(
- schema,
- catalog,
- getClassTableName( entity, node, schema, catalog, null, mappings ),
- getSubselect( node ),
- entity.isAbstract() != null && entity.isAbstract().booleanValue()
- );
- entity.setTable( table );
- bindComment(table, node);
-
- log.info(
- "Mapping class: " + entity.getEntityName() +
- " -> " + entity.getTable().getName()
- );
-
- // MUTABLE
- Attribute mutableNode = node.attribute( "mutable" );
- entity.setMutable( ( mutableNode == null ) || mutableNode.getValue().equals( "true" ) );
-
- // WHERE
- Attribute whereNode = node.attribute( "where" );
- if ( whereNode != null ) entity.setWhere( whereNode.getValue() );
-
- // CHECK
- Attribute chNode = node.attribute( "check" );
- if ( chNode != null ) table.addCheckConstraint( chNode.getValue() );
-
- // POLYMORPHISM
- Attribute polyNode = node.attribute( "polymorphism" );
- entity.setExplicitPolymorphism( ( polyNode != null )
- && polyNode.getValue().equals( "explicit" ) );
-
- // ROW ID
- Attribute rowidNode = node.attribute( "rowid" );
- if ( rowidNode != null ) table.setRowId( rowidNode.getValue() );
-
- Iterator subnodes = node.elementIterator();
- while ( subnodes.hasNext() ) {
-
- Element subnode = (Element) subnodes.next();
- String name = subnode.getName();
-
- if ( "id".equals( name ) ) {
- // ID
- bindSimpleId( subnode, entity, mappings, inheritedMetas );
- }
- else if ( "composite-id".equals( name ) ) {
- // COMPOSITE-ID
- bindCompositeId( subnode, entity, mappings, inheritedMetas );
- }
- else if ( "version".equals( name ) || "timestamp".equals( name ) ) {
- // VERSION / TIMESTAMP
- bindVersioningProperty( table, subnode, mappings, name, entity, inheritedMetas );
- }
- else if ( "discriminator".equals( name ) ) {
- // DISCRIMINATOR
- bindDiscriminatorProperty( table, entity, subnode, mappings );
- }
- else if ( "cache".equals( name ) ) {
- entity.setCacheConcurrencyStrategy( subnode.attributeValue( "usage" ) );
- entity.setCacheRegionName( subnode.attributeValue( "region" ) );
- entity.setLazyPropertiesCacheable( !"non-lazy".equals( subnode.attributeValue( "include" ) ) );
- }
-
- }
-
- // Primary key constraint
- entity.createPrimaryKey();
-
- createClassProperties( node, entity, mappings, inheritedMetas );
- }
-
- private static void bindSimpleId(Element idNode, RootClass entity, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
- String propertyName = idNode.attributeValue( "name" );
-
- SimpleValue id = new SimpleValue( entity.getTable() );
- entity.setIdentifier( id );
-
- // if ( propertyName == null || entity.getPojoRepresentation() == null ) {
- // bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
- // if ( !id.isTypeSpecified() ) {
- // throw new MappingException( "must specify an identifier type: " + entity.getEntityName()
- // );
- // }
- // }
- // else {
- // bindSimpleValue( idNode, id, false, propertyName, mappings );
- // PojoRepresentation pojo = entity.getPojoRepresentation();
- // id.setTypeUsingReflection( pojo.getClassName(), propertyName );
- //
- // Property prop = new Property();
- // prop.setValue( id );
- // bindProperty( idNode, prop, mappings, inheritedMetas );
- // entity.setIdentifierProperty( prop );
- // }
-
- if ( propertyName == null ) {
- bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
- }
- else {
- bindSimpleValue( idNode, id, false, propertyName, mappings );
- }
-
- if ( propertyName == null || !entity.hasPojoRepresentation() ) {
- if ( !id.isTypeSpecified() ) {
- throw new MappingException( "must specify an identifier type: "
- + entity.getEntityName() );
- }
- }
- else {
- id.setTypeUsingReflection( entity.getClassName(), propertyName );
- }
-
- if ( propertyName != null ) {
- Property prop = new Property();
- prop.setValue( id );
- bindProperty( idNode, prop, mappings, inheritedMetas );
- entity.setIdentifierProperty( prop );
- }
-
- // TODO:
- /*
- * if ( id.getHibernateType().getReturnedClass().isArray() ) throw new MappingException(
- * "illegal use of an array as an identifier (arrays don't reimplement equals)" );
- */
- makeIdentifier( idNode, id, mappings );
- }
-
- private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
- String propertyName = idNode.attributeValue( "name" );
- Component id = new Component( entity );
- entity.setIdentifier( id );
- bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
- if ( propertyName == null ) {
- entity.setEmbeddedIdentifier( id.isEmbedded() );
- if ( id.isEmbedded() ) {
- // todo : what is the implication of this?
- id.setDynamic( !entity.hasPojoRepresentation() );
- /*
- * Property prop = new Property(); prop.setName("id");
- * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
- * entity.setIdentifierProperty(prop);
- */
- }
- }
- else {
- Property prop = new Property();
- prop.setValue( id );
- bindProperty( idNode, prop, mappings, inheritedMetas );
- entity.setIdentifierProperty( prop );
- }
-
- makeIdentifier( idNode, id, mappings );
-
- }
-
- private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings,
- String name, RootClass entity, java.util.Map inheritedMetas) {
-
- String propertyName = subnode.attributeValue( "name" );
- SimpleValue val = new SimpleValue( table );
- bindSimpleValue( subnode, val, false, propertyName, mappings );
- if ( !val.isTypeSpecified() ) {
- // this is either a <version/> tag with no type attribute,
- // or a <timestamp/> tag
- if ( "version".equals( name ) ) {
- val.setTypeName( "integer" );
- }
- else {
- if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
- val.setTypeName( "dbtimestamp" );
- }
- else {
- val.setTypeName( "timestamp" );
- }
- }
- }
- Property prop = new Property();
- prop.setValue( val );
- bindProperty( subnode, prop, mappings, inheritedMetas );
- // for version properties marked as being generated, make sure they are "always"
- // generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
- // but just to make sure...
- if ( prop.getGeneration() == PropertyGeneration.INSERT ) {
- throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
- }
- makeVersion( subnode, val );
- entity.setVersion( prop );
- entity.addProperty( prop );
- }
-
- private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
- Mappings mappings) {
- SimpleValue discrim = new SimpleValue( table );
- entity.setDiscriminator( discrim );
- bindSimpleValue(
- subnode,
- discrim,
- false,
- RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
- mappings
- );
- if ( !discrim.isTypeSpecified() ) {
- discrim.setTypeName( "string" );
- // ( (Column) discrim.getColumnIterator().next() ).setType(type);
- }
- entity.setPolymorphic( true );
- if ( "true".equals( subnode.attributeValue( "force" ) ) )
- entity.setForceDiscriminator( true );
- if ( "false".equals( subnode.attributeValue( "insert" ) ) )
- entity.setDiscriminatorInsertable( false );
- }
-
- public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
- // transfer an explicitly defined entity name
- // handle the lazy attribute
- Attribute lazyNode = node.attribute( "lazy" );
- boolean lazy = lazyNode == null ?
- mappings.isDefaultLazy() :
- "true".equals( lazyNode.getValue() );
- // go ahead and set the lazy here, since pojo.proxy can override it.
- persistentClass.setLazy( lazy );
-
- String entityName = node.attributeValue( "entity-name" );
- if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
- if ( entityName==null ) {
- throw new MappingException( "Unable to determine entity name" );
- }
- persistentClass.setEntityName( entityName );
-
- bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
- bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
- bindMapRepresentation( node, persistentClass, mappings, inheritedMetas );
-
- bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas );
-
- }
-
- private static void bindPojoRepresentation(Element node, PersistentClass entity,
- Mappings mappings, java.util.Map metaTags) {
-
- String className = getClassName( node.attribute( "name" ), mappings );
- String proxyName = getClassName( node.attribute( "proxy" ), mappings );
-
- entity.setClassName( className );
-
- if ( proxyName != null ) {
- entity.setProxyInterfaceName( proxyName );
- entity.setLazy( true );
- }
- else if ( entity.isLazy() ) {
- entity.setProxyInterfaceName( className );
- }
-
- Element tuplizer = locateTuplizerDefinition( node, EntityMode.POJO );
- if ( tuplizer != null ) {
- entity.addTuplizer( EntityMode.POJO, tuplizer.attributeValue( "class" ) );
- }
- }
-
- private static void bindDom4jRepresentation(Element node, PersistentClass entity,
- Mappings mappings, java.util.Map inheritedMetas) {
- String nodeName = node.attributeValue( "node" );
- if (nodeName==null) nodeName = StringHelper.unqualify( entity.getEntityName() );
- entity.setNodeName(nodeName);
-
- Element tuplizer = locateTuplizerDefinition( node, EntityMode.DOM4J );
- if ( tuplizer != null ) {
- entity.addTuplizer( EntityMode.DOM4J, tuplizer.attributeValue( "class" ) );
- }
- }
-
- private static void bindMapRepresentation(Element node, PersistentClass entity,
- Mappings mappings, java.util.Map inheritedMetas) {
- Element tuplizer = locateTuplizerDefinition( node, EntityMode.MAP );
- if ( tuplizer != null ) {
- entity.addTuplizer( EntityMode.MAP, tuplizer.attributeValue( "class" ) );
- }
- }
-
- /**
- * Locate any explicit tuplizer definition in the metadata, for the given entity-mode.
- *
- * @param container The containing element (representing the entity/component)
- * @param entityMode The entity-mode for which to locate the tuplizer element
- * @return The tuplizer element, or null.
- */
- private static Element locateTuplizerDefinition(Element container, EntityMode entityMode) {
- Iterator itr = container.elements( "tuplizer" ).iterator();
- while( itr.hasNext() ) {
- final Element tuplizerElem = ( Element ) itr.next();
- if ( entityMode.toString().equals( tuplizerElem.attributeValue( "entity-mode") ) ) {
- return tuplizerElem;
- }
- }
- return null;
- }
-
- private static void bindPersistentClassCommonValues(Element node, PersistentClass entity,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- // DISCRIMINATOR
- Attribute discriminatorNode = node.attribute( "discriminator-value" );
- entity.setDiscriminatorValue( ( discriminatorNode == null )
- ? entity.getEntityName()
- : discriminatorNode.getValue() );
-
- // DYNAMIC UPDATE
- Attribute dynamicNode = node.attribute( "dynamic-update" );
- entity.setDynamicUpdate(
- dynamicNode != null && "true".equals( dynamicNode.getValue() )
- );
-
- // DYNAMIC INSERT
- Attribute insertNode = node.attribute( "dynamic-insert" );
- entity.setDynamicInsert(
- insertNode != null && "true".equals( insertNode.getValue() )
- );
-
- // IMPORT
- mappings.addImport( entity.getEntityName(), entity.getEntityName() );
- if ( mappings.isAutoImport() && entity.getEntityName().indexOf( '.' ) > 0 ) {
- mappings.addImport(
- entity.getEntityName(),
- StringHelper.unqualify( entity.getEntityName() )
- );
- }
-
- // BATCH SIZE
- Attribute batchNode = node.attribute( "batch-size" );
- if ( batchNode != null ) entity.setBatchSize( Integer.parseInt( batchNode.getValue() ) );
-
- // SELECT BEFORE UPDATE
- Attribute sbuNode = node.attribute( "select-before-update" );
- if ( sbuNode != null ) entity.setSelectBeforeUpdate( "true".equals( sbuNode.getValue() ) );
-
- // OPTIMISTIC LOCK MODE
- Attribute olNode = node.attribute( "optimistic-lock" );
- entity.setOptimisticLockMode( getOptimisticLockMode( olNode ) );
-
- entity.setMetaAttributes( getMetas( node, inheritedMetas ) );
-
- // PERSISTER
- Attribute persisterNode = node.attribute( "persister" );
- if ( persisterNode != null ) {
- try {
- entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode
- .getValue() ) );
- }
- catch (ClassNotFoundException cnfe) {
- throw new MappingException( "Could not find persister class: "
- + persisterNode.getValue() );
- }
- }
-
- // CUSTOM SQL
- handleCustomSQL( node, entity );
-
- Iterator tables = node.elementIterator( "synchronize" );
- while ( tables.hasNext() ) {
- entity.addSynchronizedTable( ( (Element) tables.next() ).attributeValue( "table" ) );
- }
-
- Attribute abstractNode = node.attribute( "abstract" );
- Boolean isAbstract = abstractNode == null
- ? null
- : "true".equals( abstractNode.getValue() )
- ? Boolean.TRUE
- : "false".equals( abstractNode.getValue() )
- ? Boolean.FALSE
- : null;
- entity.setAbstract( isAbstract );
- }
-
- private static void handleCustomSQL(Element node, PersistentClass model)
- throws MappingException {
- Element element = node.element( "sql-insert" );
- if ( element != null ) {
- boolean callable = isCallable( element );
- model.setCustomSQLInsert( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-delete" );
- if ( element != null ) {
- boolean callable = isCallable( element );
- model.setCustomSQLDelete( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-update" );
- if ( element != null ) {
- boolean callable = isCallable( element );
- model.setCustomSQLUpdate( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "loader" );
- if ( element != null ) {
- model.setLoaderName( element.attributeValue( "query-ref" ) );
- }
- }
-
- private static void handleCustomSQL(Element node, Join model) throws MappingException {
- Element element = node.element( "sql-insert" );
- if ( element != null ) {
- boolean callable = isCallable( element );
- model.setCustomSQLInsert( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-delete" );
- if ( element != null ) {
- boolean callable = isCallable( element );
- model.setCustomSQLDelete( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-update" );
- if ( element != null ) {
- boolean callable = isCallable( element );
- model.setCustomSQLUpdate( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
- }
-
- private static void handleCustomSQL(Element node, Collection model) throws MappingException {
- Element element = node.element( "sql-insert" );
- if ( element != null ) {
- boolean callable = isCallable( element, true );
- model.setCustomSQLInsert( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-delete" );
- if ( element != null ) {
- boolean callable = isCallable( element, true );
- model.setCustomSQLDelete( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-update" );
- if ( element != null ) {
- boolean callable = isCallable( element, true );
- model.setCustomSQLUpdate( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
-
- element = node.element( "sql-delete-all" );
- if ( element != null ) {
- boolean callable = isCallable( element, true );
- model.setCustomSQLDeleteAll( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
- }
- }
-
- private static boolean isCallable(Element e) throws MappingException {
- return isCallable( e, true );
- }
-
- private static boolean isCallable(Element element, boolean supportsCallable)
- throws MappingException {
- Attribute attrib = element.attribute( "callable" );
- if ( attrib != null && "true".equals( attrib.getValue() ) ) {
- if ( !supportsCallable ) {
- throw new MappingException( "callable attribute not supported yet!" );
- }
- return true;
- }
- return false;
- }
-
- private static ExecuteUpdateResultCheckStyle getResultCheckStyle(Element element, boolean callable) throws MappingException {
- Attribute attr = element.attribute( "check" );
- if ( attr == null ) {
- // use COUNT as the default. This mimics the old behavior, although
- // NONE might be a better option moving forward in the case of callable
- return ExecuteUpdateResultCheckStyle.COUNT;
- }
- return ExecuteUpdateResultCheckStyle.parse( attr.getValue() );
- }
-
- public static void bindUnionSubclass(Element node, UnionSubclass unionSubclass,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
-
- bindClass( node, unionSubclass, mappings, inheritedMetas );
- inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <subclass>
-
- if ( unionSubclass.getEntityPersisterClass() == null ) {
- unionSubclass.getRootClass().setEntityPersisterClass(
- UnionSubclassEntityPersister.class );
- }
-
- Attribute schemaNode = node.attribute( "schema" );
- String schema = schemaNode == null ?
- mappings.getSchemaName() : schemaNode.getValue();
-
- Attribute catalogNode = node.attribute( "catalog" );
- String catalog = catalogNode == null ?
- mappings.getCatalogName() : catalogNode.getValue();
-
- Table denormalizedSuperTable = unionSubclass.getSuperclass().getTable();
- Table mytable = mappings.addDenormalizedTable(
- schema,
- catalog,
- getClassTableName(unionSubclass, node, schema, catalog, denormalizedSuperTable, mappings ),
- unionSubclass.isAbstract() != null && unionSubclass.isAbstract().booleanValue(),
- getSubselect( node ),
- denormalizedSuperTable
- );
- unionSubclass.setTable( mytable );
-
- log.info(
- "Mapping union-subclass: " + unionSubclass.getEntityName() +
- " -> " + unionSubclass.getTable().getName()
- );
-
- createClassProperties( node, unionSubclass, mappings, inheritedMetas );
-
- }
-
- public static void bindSubclass(Element node, Subclass subclass, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
-
- bindClass( node, subclass, mappings, inheritedMetas );
- inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <subclass>
-
- if ( subclass.getEntityPersisterClass() == null ) {
- subclass.getRootClass()
- .setEntityPersisterClass( SingleTableEntityPersister.class );
- }
-
- log.info(
- "Mapping subclass: " + subclass.getEntityName() +
- " -> " + subclass.getTable().getName()
- );
-
- // properties
- createClassProperties( node, subclass, mappings, inheritedMetas );
- }
-
- private static String getClassTableName(
- PersistentClass model, Element node, String schema, String catalog, Table denormalizedSuperTable,
- Mappings mappings
- ) {
- Attribute tableNameNode = node.attribute( "table" );
- String logicalTableName;
- String physicalTableName;
- if ( tableNameNode == null ) {
- logicalTableName = StringHelper.unqualify( model.getEntityName() );
- physicalTableName = mappings.getNamingStrategy().classToTableName( model.getEntityName() );
- }
- else {
- logicalTableName = tableNameNode.getValue();
- physicalTableName = mappings.getNamingStrategy().tableName( logicalTableName );
- }
- mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
- return physicalTableName;
- }
-
- public static void bindJoinedSubclass(Element node, JoinedSubclass joinedSubclass,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
-
- bindClass( node, joinedSubclass, mappings, inheritedMetas );
- inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from
- // <joined-subclass>
-
- // joined subclasses
- if ( joinedSubclass.getEntityPersisterClass() == null ) {
- joinedSubclass.getRootClass()
- .setEntityPersisterClass( JoinedSubclassEntityPersister.class );
- }
-
- Attribute schemaNode = node.attribute( "schema" );
- String schema = schemaNode == null ?
- mappings.getSchemaName() : schemaNode.getValue();
-
- Attribute catalogNode = node.attribute( "catalog" );
- String catalog = catalogNode == null ?
- mappings.getCatalogName() : catalogNode.getValue();
-
- Table mytable = mappings.addTable(
- schema,
- catalog,
- getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ),
- getSubselect( node ),
- false
- );
- joinedSubclass.setTable( mytable );
- bindComment(mytable, node);
-
- log.info(
- "Mapping joined-subclass: " + joinedSubclass.getEntityName() +
- " -> " + joinedSubclass.getTable().getName()
- );
-
- // KEY
- Element keyNode = node.element( "key" );
- SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() );
- joinedSubclass.setKey( key );
- key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
- bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings );
-
- // model.getKey().setType( new Type( model.getIdentifier() ) );
- joinedSubclass.createPrimaryKey();
- joinedSubclass.createForeignKey();
-
- // CHECK
- Attribute chNode = node.attribute( "check" );
- if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() );
-
- // properties
- createClassProperties( node, joinedSubclass, mappings, inheritedMetas );
-
- }
-
- private static void bindJoin(Element node, Join join, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
-
- PersistentClass persistentClass = join.getPersistentClass();
- String path = persistentClass.getEntityName();
-
- // TABLENAME
-
- Attribute schemaNode = node.attribute( "schema" );
- String schema = schemaNode == null ?
- mappings.getSchemaName() : schemaNode.getValue();
- Attribute catalogNode = node.attribute( "catalog" );
- String catalog = catalogNode == null ?
- mappings.getCatalogName() : catalogNode.getValue();
- Table primaryTable = persistentClass.getTable();
- Table table = mappings.addTable(
- schema,
- catalog,
- getClassTableName( persistentClass, node, schema, catalog, primaryTable, mappings ),
- getSubselect( node ),
- false
- );
- join.setTable( table );
- bindComment(table, node);
-
- Attribute fetchNode = node.attribute( "fetch" );
- if ( fetchNode != null ) {
- join.setSequentialSelect( "select".equals( fetchNode.getValue() ) );
- }
-
- Attribute invNode = node.attribute( "inverse" );
- if ( invNode != null ) {
- join.setInverse( "true".equals( invNode.getValue() ) );
- }
-
- Attribute nullNode = node.attribute( "optional" );
- if ( nullNode != null ) {
- join.setOptional( "true".equals( nullNode.getValue() ) );
- }
-
- log.info(
- "Mapping class join: " + persistentClass.getEntityName() +
- " -> " + join.getTable().getName()
- );
-
- // KEY
- Element keyNode = node.element( "key" );
- SimpleValue key = new DependantValue( table, persistentClass.getIdentifier() );
- join.setKey( key );
- key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
- bindSimpleValue( keyNode, key, false, persistentClass.getEntityName(), mappings );
-
- // join.getKey().setType( new Type( lazz.getIdentifier() ) );
- join.createPrimaryKey();
- join.createForeignKey();
-
- // PROPERTIES
- Iterator iter = node.elementIterator();
- while ( iter.hasNext() ) {
- Element subnode = (Element) iter.next();
- String name = subnode.getName();
- String propertyName = subnode.attributeValue( "name" );
-
- Value value = null;
- if ( "many-to-one".equals( name ) ) {
- value = new ManyToOne( table );
- bindManyToOne( subnode, (ManyToOne) value, propertyName, true, mappings );
- }
- else if ( "any".equals( name ) ) {
- value = new Any( table );
- bindAny( subnode, (Any) value, true, mappings );
- }
- else if ( "property".equals( name ) ) {
- value = new SimpleValue( table );
- bindSimpleValue( subnode, (SimpleValue) value, true, propertyName, mappings );
- }
- else if ( "component".equals( name ) || "dynamic-component".equals( name ) ) {
- String subpath = StringHelper.qualify( path, propertyName );
- value = new Component( join );
- bindComponent(
- subnode,
- (Component) value,
- join.getPersistentClass().getClassName(),
- propertyName,
- subpath,
- true,
- false,
- mappings,
- inheritedMetas,
- false
- );
- }
-
- if ( value != null ) {
- Property prop = createProperty( value, propertyName, persistentClass
- .getEntityName(), subnode, mappings, inheritedMetas );
- prop.setOptional( join.isOptional() );
- join.addProperty( prop );
- }
-
- }
-
- // CUSTOM SQL
- handleCustomSQL( node, join );
-
- }
-
- public static void bindColumns(final Element node, final SimpleValue simpleValue,
- final boolean isNullable, final boolean autoColumn, final String propertyPath,
- final Mappings mappings) throws MappingException {
-
- Table table = simpleValue.getTable();
-
- // COLUMN(S)
- Attribute columnAttribute = node.attribute( "column" );
- if ( columnAttribute == null ) {
- Iterator iter = node.elementIterator();
- int count = 0;
- while ( iter.hasNext() ) {
- Element columnElement = (Element) iter.next();
- if ( columnElement.getName().equals( "column" ) ) {
- Column column = new Column();
- column.setValue( simpleValue );
- column.setTypeIndex( count++ );
- bindColumn( columnElement, column, isNullable );
- String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
- columnElement.attributeValue( "name" ), propertyPath
- );
- column.setName( mappings.getNamingStrategy().columnName(
- logicalColumnName ) );
- if ( table != null ) {
- table.addColumn( column ); // table=null -> an association
- // - fill it in later
- //TODO fill in the mappings for table == null
- mappings.addColumnBinding( logicalColumnName, column, table );
- }
-
-
- simpleValue.addColumn( column );
- // column index
- bindIndex( columnElement.attribute( "index" ), table, column, mappings );
- bindIndex( node.attribute( "index" ), table, column, mappings );
- //column unique-key
- bindUniqueKey( columnElement.attribute( "unique-key" ), table, column, mappings );
- bindUniqueKey( node.attribute( "unique-key" ), table, column, mappings );
- }
- else if ( columnElement.getName().equals( "formula" ) ) {
- Formula formula = new Formula();
- formula.setFormula( columnElement.getText() );
- simpleValue.addFormula( formula );
- }
- }
- }
- else {
- if ( node.elementIterator( "column" ).hasNext() ) {
- throw new MappingException(
- "column attribute may not be used together with <column> subelement" );
- }
- if ( node.elementIterator( "formula" ).hasNext() ) {
- throw new MappingException(
- "column attribute may not be used together with <formula> subelement" );
- }
-
- Column column = new Column();
- column.setValue( simpleValue );
- bindColumn( node, column, isNullable );
- String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
- columnAttribute.getValue(), propertyPath
- );
- column.setName( mappings.getNamingStrategy().columnName( logicalColumnName ) );
- if ( table != null ) {
- table.addColumn( column ); // table=null -> an association - fill
- // it in later
- //TODO fill in the mappings for table == null
- mappings.addColumnBinding( logicalColumnName, column, table );
- }
- simpleValue.addColumn( column );
- bindIndex( node.attribute( "index" ), table, column, mappings );
- bindUniqueKey( node.attribute( "unique-key" ), table, column, mappings );
- }
-
- if ( autoColumn && simpleValue.getColumnSpan() == 0 ) {
- Column column = new Column();
- column.setValue( simpleValue );
- bindColumn( node, column, isNullable );
- column.setName( mappings.getNamingStrategy().propertyToColumnName( propertyPath ) );
- String logicalName = mappings.getNamingStrategy().logicalColumnName( null, propertyPath );
- mappings.addColumnBinding( logicalName, column, table );
- /* TODO: joinKeyColumnName & foreignKeyColumnName should be called either here or at a
- * slightly higer level in the stack (to get all the information we need)
- * Right now HbmBinder does not support the
- */
- simpleValue.getTable().addColumn( column );
- simpleValue.addColumn( column );
- bindIndex( node.attribute( "index" ), table, column, mappings );
- bindUniqueKey( node.attribute( "unique-key" ), table, column, mappings );
- }
-
- }
-
- private static void bindIndex(Attribute indexAttribute, Table table, Column column, Mappings mappings) {
- if ( indexAttribute != null && table != null ) {
- StringTokenizer tokens = new StringTokenizer( indexAttribute.getValue(), ", " );
- while ( tokens.hasMoreTokens() ) {
- table.getOrCreateIndex( tokens.nextToken() ).addColumn( column );
- }
- }
- }
-
- private static void bindUniqueKey(Attribute uniqueKeyAttribute, Table table, Column column, Mappings mappings) {
- if ( uniqueKeyAttribute != null && table != null ) {
- StringTokenizer tokens = new StringTokenizer( uniqueKeyAttribute.getValue(), ", " );
- while ( tokens.hasMoreTokens() ) {
- table.getOrCreateUniqueKey( tokens.nextToken() ).addColumn( column );
- }
- }
- }
-
- // automatically makes a column with the default name if none is specifed by XML
- public static void bindSimpleValue(Element node, SimpleValue simpleValue, boolean isNullable,
- String path, Mappings mappings) throws MappingException {
- bindSimpleValueType( node, simpleValue, mappings );
-
- bindColumnsOrFormula( node, simpleValue, path, isNullable, mappings );
-
- Attribute fkNode = node.attribute( "foreign-key" );
- if ( fkNode != null ) simpleValue.setForeignKeyName( fkNode.getValue() );
- }
-
- private static void bindSimpleValueType(Element node, SimpleValue simpleValue, Mappings mappings)
- throws MappingException {
- String typeName = null;
-
- Properties parameters = new Properties();
-
- Attribute typeNode = node.attribute( "type" );
- if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any
- if ( typeNode != null ) typeName = typeNode.getValue();
-
- Element typeChild = node.element( "type" );
- if ( typeName == null && typeChild != null ) {
- typeName = typeChild.attribute( "name" ).getValue();
- Iterator typeParameters = typeChild.elementIterator( "param" );
-
- while ( typeParameters.hasNext() ) {
- Element paramElement = (Element) typeParameters.next();
- parameters.setProperty(
- paramElement.attributeValue( "name" ),
- paramElement.getTextTrim()
- );
- }
- }
-
- TypeDef typeDef = mappings.getTypeDef( typeName );
- if ( typeDef != null ) {
- typeName = typeDef.getTypeClass();
- // parameters on the property mapping should
- // override parameters in the typedef
- Properties allParameters = new Properties();
- allParameters.putAll( typeDef.getParameters() );
- allParameters.putAll( parameters );
- parameters = allParameters;
- }
-
- if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters );
-
- if ( typeName != null ) simpleValue.setTypeName( typeName );
- }
-
- public static void bindProperty(
- Element node,
- Property property,
- Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
-
- String propName = node.attributeValue( "name" );
- property.setName( propName );
- String nodeName = node.attributeValue( "node" );
- if (nodeName==null) nodeName = propName;
- property.setNodeName( nodeName );
-
- // TODO:
- //Type type = model.getValue().getType();
- //if (type==null) throw new MappingException(
- //"Could not determine a property type for: " + model.getName() );
-
- Attribute accessNode = node.attribute( "access" );
- if ( accessNode != null ) {
- property.setPropertyAccessorName( accessNode.getValue() );
- }
- else if ( node.getName().equals( "properties" ) ) {
- property.setPropertyAccessorName( "embedded" );
- }
- else {
- property.setPropertyAccessorName( mappings.getDefaultAccess() );
- }
-
- Attribute cascadeNode = node.attribute( "cascade" );
- property.setCascade( cascadeNode == null ? mappings.getDefaultCascade() : cascadeNode
- .getValue() );
-
- Attribute updateNode = node.attribute( "update" );
- property.setUpdateable( updateNode == null || "true".equals( updateNode.getValue() ) );
-
- Attribute insertNode = node.attribute( "insert" );
- property.setInsertable( insertNode == null || "true".equals( insertNode.getValue() ) );
-
- Attribute lockNode = node.attribute( "optimistic-lock" );
- property.setOptimisticLocked( lockNode == null || "true".equals( lockNode.getValue() ) );
-
- Attribute generatedNode = node.attribute( "generated" );
- String generationName = generatedNode == null ? null : generatedNode.getValue();
- PropertyGeneration generation = PropertyGeneration.parse( generationName );
- property.setGeneration( generation );
-
- if ( generation == PropertyGeneration.ALWAYS || generation == PropertyGeneration.INSERT ) {
- // generated properties can *never* be insertable...
- if ( property.isInsertable() ) {
- if ( insertNode == null ) {
- // insertable simply because that is the user did not specify
- // anything; just override it
- property.setInsertable( false );
- }
- else {
- // the user specifically supplied insert="true",
- // which constitutes an illegal combo
- throw new MappingException(
- "cannot specify both insert=\"true\" and generated=\"" + generation.getName() +
- "\" for property: " +
- propName
- );
- }
- }
-
- // properties generated on update can never be updateable...
- if ( property.isUpdateable() && generation == PropertyGeneration.ALWAYS ) {
- if ( updateNode == null ) {
- // updateable only because the user did not specify
- // anything; just override it
- property.setUpdateable( false );
- }
- else {
- // the user specifically supplied update="true",
- // which constitutes an illegal combo
- throw new MappingException(
- "cannot specify both update=\"true\" and generated=\"" + generation.getName() +
- "\" for property: " +
- propName
- );
- }
- }
- }
-
- boolean isLazyable = "property".equals( node.getName() ) ||
- "component".equals( node.getName() ) ||
- "many-to-one".equals( node.getName() ) ||
- "one-to-one".equals( node.getName() ) ||
- "any".equals( node.getName() );
- if ( isLazyable ) {
- Attribute lazyNode = node.attribute( "lazy" );
- property.setLazy( lazyNode != null && "true".equals( lazyNode.getValue() ) );
- }
-
- if ( log.isDebugEnabled() ) {
- String msg = "Mapped property: " + property.getName();
- String columns = columns( property.getValue() );
- if ( columns.length() > 0 ) msg += " -> " + columns;
- // TODO: this fails if we run with debug on!
- // if ( model.getType()!=null ) msg += ", type: " + model.getType().getName();
- log.debug( msg );
- }
-
- property.setMetaAttributes( getMetas( node, inheritedMetas ) );
-
- }
-
- private static String columns(Value val) {
- StringBuffer columns = new StringBuffer();
- Iterator iter = val.getColumnIterator();
- while ( iter.hasNext() ) {
- columns.append( ( (Selectable) iter.next() ).getText() );
- if ( iter.hasNext() ) columns.append( ", " );
- }
- return columns.toString();
- }
-
- /**
- * Called for all collections
- */
- public static void bindCollection(Element node, Collection collection, String className,
- String path, Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
-
- // ROLENAME
- collection.setRole(path);
-
- Attribute inverseNode = node.attribute( "inverse" );
- if ( inverseNode != null ) {
- collection.setInverse( "true".equals( inverseNode.getValue() ) );
- }
-
- Attribute mutableNode = node.attribute( "mutable" );
- if ( mutableNode != null ) {
- collection.setMutable( !"false".equals( mutableNode.getValue() ) );
- }
-
- Attribute olNode = node.attribute( "optimistic-lock" );
- collection.setOptimisticLocked( olNode == null || "true".equals( olNode.getValue() ) );
-
- Attribute orderNode = node.attribute( "order-by" );
- if ( orderNode != null ) {
- if ( Environment.jvmSupportsLinkedHashCollections() || ( collection instanceof Bag ) ) {
- collection.setOrderBy( orderNode.getValue() );
- }
- else {
- log.warn( "Attribute \"order-by\" ignored in JDK1.3 or less" );
- }
- }
- Attribute whereNode = node.attribute( "where" );
- if ( whereNode != null ) {
- collection.setWhere( whereNode.getValue() );
- }
- Attribute batchNode = node.attribute( "batch-size" );
- if ( batchNode != null ) {
- collection.setBatchSize( Integer.parseInt( batchNode.getValue() ) );
- }
-
- String nodeName = node.attributeValue( "node" );
- if ( nodeName == null ) nodeName = node.attributeValue( "name" );
- collection.setNodeName( nodeName );
- String embed = node.attributeValue( "embed-xml" );
- collection.setEmbedded( embed==null || "true".equals(embed) );
-
-
- // PERSISTER
- Attribute persisterNode = node.attribute( "persister" );
- if ( persisterNode != null ) {
- try {
- collection.setCollectionPersisterClass( ReflectHelper.classForName( persisterNode
- .getValue() ) );
- }
- catch (ClassNotFoundException cnfe) {
- throw new MappingException( "Could not find collection persister class: "
- + persisterNode.getValue() );
- }
- }
-
- Attribute typeNode = node.attribute( "collection-type" );
- if ( typeNode != null ) {
- String typeName = typeNode.getValue();
- TypeDef typeDef = mappings.getTypeDef( typeName );
- if ( typeDef != null ) {
- collection.setTypeName( typeDef.getTypeClass() );
- collection.setTypeParameters( typeDef.getParameters() );
- }
- else {
- collection.setTypeName( typeName );
- }
- }
-
- // FETCH STRATEGY
-
- initOuterJoinFetchSetting( node, collection );
-
- if ( "subselect".equals( node.attributeValue("fetch") ) ) {
- collection.setSubselectLoadable(true);
- collection.getOwner().setSubselectLoadableCollections(true);
- }
-
- initLaziness( node, collection, mappings, "true", mappings.isDefaultLazy() );
- //TODO: suck this into initLaziness!
- if ( "extra".equals( node.attributeValue("lazy") ) ) {
- collection.setLazy(true);
- collection.setExtraLazy(true);
- }
-
- Element oneToManyNode = node.element( "one-to-many" );
- if ( oneToManyNode != null ) {
- OneToMany oneToMany = new OneToMany( collection.getOwner() );
- collection.setElement( oneToMany );
- bindOneToMany( oneToManyNode, oneToMany, mappings );
- // we have to set up the table later!! yuck
- }
- else {
- // TABLE
- Attribute tableNode = node.attribute( "table" );
- String tableName;
- if ( tableNode != null ) {
- tableName = mappings.getNamingStrategy().tableName( tableNode.getValue() );
- }
- else {
- //tableName = mappings.getNamingStrategy().propertyToTableName( className, path );
- Table ownerTable = collection.getOwner().getTable();
- //TODO mappings.getLogicalTableName(ownerTable)
- String logicalOwnerTableName = ownerTable.getName();
- //FIXME we don't have the associated entity table name here, has to be done in a second pass
- tableName = mappings.getNamingStrategy().collectionTableName(
- collection.getOwner().getEntityName(),
- logicalOwnerTableName ,
- null,
- null,
- path
- );
- }
- Attribute schemaNode = node.attribute( "schema" );
- String schema = schemaNode == null ?
- mappings.getSchemaName() : schemaNode.getValue();
-
- Attribute catalogNode = node.attribute( "catalog" );
- String catalog = catalogNode == null ?
- mappings.getCatalogName() : catalogNode.getValue();
-
- Table table = mappings.addTable(
- schema,
- catalog,
- tableName,
- getSubselect( node ),
- false
- );
- collection.setCollectionTable( table );
- bindComment(table, node);
-
- log.info(
- "Mapping collection: " + collection.getRole() +
- " -> " + collection.getCollectionTable().getName()
- );
- }
-
- // SORT
- Attribute sortedAtt = node.attribute( "sort" );
- // unsorted, natural, comparator.class.name
- if ( sortedAtt == null || sortedAtt.getValue().equals( "unsorted" ) ) {
- collection.setSorted( false );
- }
- else {
- collection.setSorted( true );
- String comparatorClassName = sortedAtt.getValue();
- if ( !comparatorClassName.equals( "natural" ) ) {
- collection.setComparatorClassName(comparatorClassName);
- }
- }
-
- // ORPHAN DELETE (used for programmer error detection)
- Attribute cascadeAtt = node.attribute( "cascade" );
- if ( cascadeAtt != null && cascadeAtt.getValue().indexOf( "delete-orphan" ) >= 0 ) {
- collection.setOrphanDelete( true );
- }
-
- // CUSTOM SQL
- handleCustomSQL( node, collection );
- // set up second pass
- if ( collection instanceof List ) {
- mappings.addSecondPass( new ListSecondPass( node, mappings, (List) collection, inheritedMetas ) );
- }
- else if ( collection instanceof Map ) {
- mappings.addSecondPass( new MapSecondPass( node, mappings, (Map) collection, inheritedMetas ) );
- }
- else if ( collection instanceof IdentifierCollection ) {
- mappings.addSecondPass( new IdentifierCollectionSecondPass(
- node,
- mappings,
- collection,
- inheritedMetas
- ) );
- }
- else {
- mappings.addSecondPass( new CollectionSecondPass( node, mappings, collection, inheritedMetas ) );
- }
-
- Iterator iter = node.elementIterator( "filter" );
- while ( iter.hasNext() ) {
- final Element filter = (Element) iter.next();
- parseFilter( filter, collection, mappings );
- }
-
- Iterator tables = node.elementIterator( "synchronize" );
- while ( tables.hasNext() ) {
- collection.getSynchronizedTables().add(
- ( (Element) tables.next() ).attributeValue( "table" ) );
- }
-
- Element element = node.element( "loader" );
- if ( element != null ) {
- collection.setLoaderName( element.attributeValue( "query-ref" ) );
- }
-
- collection.setReferencedPropertyName( node.element( "key" ).attributeValue( "property-ref" ) );
- }
-
- private static void initLaziness(
- Element node,
- Fetchable fetchable,
- Mappings mappings,
- String proxyVal,
- boolean defaultLazy
- ) {
- Attribute lazyNode = node.attribute( "lazy" );
- boolean isLazyTrue = lazyNode == null ?
- defaultLazy && fetchable.isLazy() : //fetch="join" overrides default laziness
- lazyNode.getValue().equals(proxyVal); //fetch="join" overrides default laziness
- fetchable.setLazy( isLazyTrue );
- }
-
- private static void initLaziness(
- Element node,
- ToOne fetchable,
- Mappings mappings,
- boolean defaultLazy
- ) {
- if ( "no-proxy".equals( node.attributeValue( "lazy" ) ) ) {
- fetchable.setUnwrapProxy(true);
- fetchable.setLazy(true);
- //TODO: better to degrade to lazy="false" if uninstrumented
- }
- else {
- initLaziness(node, fetchable, mappings, "proxy", defaultLazy);
- }
- }
-
- private static void bindColumnsOrFormula(Element node, SimpleValue simpleValue, String path,
- boolean isNullable, Mappings mappings) {
- Attribute formulaNode = node.attribute( "formula" );
- if ( formulaNode != null ) {
- Formula f = new Formula();
- f.setFormula( formulaNode.getText() );
- simpleValue.addFormula( f );
- }
- else {
- bindColumns( node, simpleValue, isNullable, true, path, mappings );
- }
- }
-
- private static void bindComment(Table table, Element node) {
- Element comment = node.element("comment");
- if (comment!=null) table.setComment( comment.getTextTrim() );
- }
-
- public static void bindManyToOne(Element node, ManyToOne manyToOne, String path,
- boolean isNullable, Mappings mappings) throws MappingException {
-
- bindColumnsOrFormula( node, manyToOne, path, isNullable, mappings );
- initOuterJoinFetchSetting( node, manyToOne );
- initLaziness( node, manyToOne, mappings, true );
-
- Attribute ukName = node.attribute( "property-ref" );
- if ( ukName != null ) {
- manyToOne.setReferencedPropertyName( ukName.getValue() );
- }
-
- manyToOne.setReferencedEntityName( getEntityName( node, mappings ) );
-
- String embed = node.attributeValue( "embed-xml" );
- manyToOne.setEmbedded( embed == null || "true".equals( embed ) );
-
- String notFound = node.attributeValue( "not-found" );
- manyToOne.setIgnoreNotFound( "ignore".equals( notFound ) );
-
- if( ukName != null && !manyToOne.isIgnoreNotFound() ) {
- if ( !node.getName().equals("many-to-many") ) { //TODO: really bad, evil hack to fix!!!
- mappings.addSecondPass( new ManyToOneSecondPass(manyToOne) );
- }
- }
-
- Attribute fkNode = node.attribute( "foreign-key" );
- if ( fkNode != null ) manyToOne.setForeignKeyName( fkNode.getValue() );
-
- validateCascade( node, path );
- }
-
- private static void validateCascade(Element node, String path) {
- String cascade = node.attributeValue( "cascade" );
- if ( cascade != null && cascade.indexOf( "delete-orphan" ) >= 0 ) {
- throw new MappingException( "single-valued associations do not support orphan delete: " + path );
- }
- }
-
- public static void bindAny(Element node, Any any, boolean isNullable, Mappings mappings)
- throws MappingException {
- any.setIdentifierType( getTypeFromXML( node ) );
- Attribute metaAttribute = node.attribute( "meta-type" );
- if ( metaAttribute != null ) {
- any.setMetaType( metaAttribute.getValue() );
-
- Iterator iter = node.elementIterator( "meta-value" );
- if ( iter.hasNext() ) {
- HashMap values = new HashMap();
- org.hibernate.type.Type metaType = TypeFactory.heuristicType( any.getMetaType() );
- while ( iter.hasNext() ) {
- Element metaValue = (Element) iter.next();
- try {
- Object value = ( (DiscriminatorType) metaType ).stringToObject( metaValue
- .attributeValue( "value" ) );
- String entityName = getClassName( metaValue.attribute( "class" ), mappings );
- values.put( value, entityName );
- }
- catch (ClassCastException cce) {
- throw new MappingException( "meta-type was not a DiscriminatorType: "
- + metaType.getName() );
- }
- catch (Exception e) {
- throw new MappingException( "could not interpret meta-value", e );
- }
- }
- any.setMetaValues( values );
- }
-
- }
-
- bindColumns( node, any, isNullable, false, null, mappings );
- }
-
- public static void bindOneToOne(Element node, OneToOne oneToOne, String path, boolean isNullable,
- Mappings mappings) throws MappingException {
-
- bindColumns( node, oneToOne, isNullable, false, null, mappings );
-
- Attribute constrNode = node.attribute( "constrained" );
- boolean constrained = constrNode != null && constrNode.getValue().equals( "true" );
- oneToOne.setConstrained( constrained );
-
- oneToOne.setForeignKeyType( constrained ?
- ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT :
- ForeignKeyDirection.FOREIGN_KEY_TO_PARENT );
-
- initOuterJoinFetchSetting( node, oneToOne );
- initLaziness( node, oneToOne, mappings, true );
-
- oneToOne.setEmbedded( "true".equals( node.attributeValue( "embed-xml" ) ) );
-
- Attribute fkNode = node.attribute( "foreign-key" );
- if ( fkNode != null ) oneToOne.setForeignKeyName( fkNode.getValue() );
-
- Attribute ukName = node.attribute( "property-ref" );
- if ( ukName != null ) oneToOne.setReferencedPropertyName( ukName.getValue() );
-
- oneToOne.setPropertyName( node.attributeValue( "name" ) );
-
- oneToOne.setReferencedEntityName( getEntityName( node, mappings ) );
-
- validateCascade( node, path );
- }
-
- public static void bindOneToMany(Element node, OneToMany oneToMany, Mappings mappings)
- throws MappingException {
-
- oneToMany.setReferencedEntityName( getEntityName( node, mappings ) );
-
- String embed = node.attributeValue( "embed-xml" );
- oneToMany.setEmbedded( embed == null || "true".equals( embed ) );
-
- String notFound = node.attributeValue( "not-found" );
- oneToMany.setIgnoreNotFound( "ignore".equals( notFound ) );
-
- }
-
- public static void bindColumn(Element node, Column column, boolean isNullable) {
- Attribute lengthNode = node.attribute( "length" );
- if ( lengthNode != null ) column.setLength( Integer.parseInt( lengthNode.getValue() ) );
- Attribute scalNode = node.attribute( "scale" );
- if ( scalNode != null ) column.setScale( Integer.parseInt( scalNode.getValue() ) );
- Attribute precNode = node.attribute( "precision" );
- if ( precNode != null ) column.setPrecision( Integer.parseInt( precNode.getValue() ) );
-
- Attribute nullNode = node.attribute( "not-null" );
- column.setNullable( nullNode == null ? isNullable : nullNode.getValue().equals( "false" ) );
-
- Attribute unqNode = node.attribute( "unique" );
- if ( unqNode != null ) column.setUnique( unqNode.getValue().equals( "true" ) );
-
- column.setCheckConstraint( node.attributeValue( "check" ) );
- column.setDefaultValue( node.attributeValue( "default" ) );
-
- Attribute typeNode = node.attribute( "sql-type" );
- if ( typeNode != null ) column.setSqlType( typeNode.getValue() );
-
- Element comment = node.element("comment");
- if (comment!=null) column.setComment( comment.getTextTrim() );
-
- }
-
- /**
- * Called for arrays and primitive arrays
- */
- public static void bindArray(Element node, Array array, String prefix, String path,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
-
- bindCollection( node, array, prefix, path, mappings, inheritedMetas );
-
- Attribute att = node.attribute( "element-class" );
- if ( att != null ) array.setElementClassName( getClassName( att, mappings ) );
-
- }
-
- private static Class reflectedPropertyClass(String className, String propertyName)
- throws MappingException {
- if ( className == null ) return null;
- return ReflectHelper.reflectedPropertyClass( className, propertyName );
- }
-
- public static void bindComposite(Element node, Component component, String path,
- boolean isNullable, Mappings mappings, java.util.Map inheritedMetas)
- throws MappingException {
- bindComponent(
- node,
- component,
- null,
- null,
- path,
- isNullable,
- false,
- mappings,
- inheritedMetas,
- false
- );
- }
-
- public static void bindCompositeId(Element node, Component component,
- PersistentClass persistentClass, String propertyName, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
-
- component.setKey( true );
-
- String path = StringHelper.qualify(
- persistentClass.getEntityName(),
- propertyName == null ? "id" : propertyName );
-
- bindComponent(
- node,
- component,
- persistentClass.getClassName(),
- propertyName,
- path,
- false,
- node.attribute( "class" ) == null
- && propertyName == null,
- mappings,
- inheritedMetas,
- false
- );
-
- if ( "true".equals( node.attributeValue("mapped") ) ) {
- if ( propertyName!=null ) {
- throw new MappingException("cannot combine mapped=\"true\" with specified name");
- }
- Component mapper = new Component(persistentClass);
- bindComponent(
- node,
- mapper,
- persistentClass.getClassName(),
- null,
- path,
- false,
- true,
- mappings,
- inheritedMetas,
- true
- );
- persistentClass.setIdentifierMapper(mapper);
- Property property = new Property();
- property.setName("_identifierMapper");
- property.setNodeName("id");
- property.setUpdateable(false);
- property.setInsertable(false);
- property.setValue(mapper);
- property.setPropertyAccessorName( "embedded" );
- persistentClass.addProperty(property);
- }
-
- }
-
- public static void bindComponent(
- Element node,
- Component component,
- String ownerClassName,
- String parentProperty,
- String path,
- boolean isNullable,
- boolean isEmbedded,
- Mappings mappings,
- java.util.Map inheritedMetas,
- boolean isIdentifierMapper) throws MappingException {
-
- component.setEmbedded( isEmbedded );
- component.setRoleName( path );
-
- inheritedMetas = getMetas( node, inheritedMetas );
- component.setMetaAttributes( inheritedMetas );
-
- Attribute classNode = isIdentifierMapper ? null : node.attribute( "class" );
- if ( classNode != null ) {
- component.setComponentClassName( getClassName( classNode, mappings ) );
- }
- else if ( "dynamic-component".equals( node.getName() ) ) {
- component.setDynamic( true );
- }
- else if ( isEmbedded ) {
- // an "embedded" component (composite ids and unique)
- // note that this does not handle nested components
- if ( component.getOwner().hasPojoRepresentation() ) {
- component.setComponentClassName( component.getOwner().getClassName() );
- }
- else {
- component.setDynamic(true);
- }
- }
- else {
- // todo : again, how *should* this work for non-pojo entities?
- if ( component.getOwner().hasPojoRepresentation() ) {
- Class reflectedClass = reflectedPropertyClass( ownerClassName, parentProperty );
- if ( reflectedClass != null ) {
- component.setComponentClassName( reflectedClass.getName() );
- }
- }
- else {
- component.setDynamic(true);
- }
- }
-
- String nodeName = node.attributeValue( "node" );
- if ( nodeName == null ) nodeName = node.attributeValue( "name" );
- if ( nodeName == null ) nodeName = component.getOwner().getNodeName();
- component.setNodeName( nodeName );
-
- Iterator iter = node.elementIterator();
- while ( iter.hasNext() ) {
-
- Element subnode = (Element) iter.next();
- String name = subnode.getName();
- String propertyName = getPropertyName( subnode );
- String subpath = propertyName == null ? null : StringHelper
- .qualify( path, propertyName );
-
- CollectionType collectType = CollectionType.collectionTypeFromString( name );
- Value value = null;
- if ( collectType != null ) {
- Collection collection = collectType.create(
- subnode,
- subpath,
- component.getOwner(),
- mappings, inheritedMetas
- );
- mappings.addCollection( collection );
- value = collection;
- }
- else if ( "many-to-one".equals( name ) || "key-many-to-one".equals( name ) ) {
- value = new ManyToOne( component.getTable() );
- String relativePath;
- if (isEmbedded) {
- relativePath = propertyName;
- }
- else {
- relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
- }
- bindManyToOne( subnode, (ManyToOne) value, relativePath, isNullable, mappings );
- }
- else if ( "one-to-one".equals( name ) ) {
- value = new OneToOne( component.getTable(), component.getOwner() );
- String relativePath;
- if (isEmbedded) {
- relativePath = propertyName;
- }
- else {
- relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
- }
- bindOneToOne( subnode, (OneToOne) value, relativePath, isNullable, mappings );
- }
- else if ( "any".equals( name ) ) {
- value = new Any( component.getTable() );
- bindAny( subnode, (Any) value, isNullable, mappings );
- }
- else if ( "property".equals( name ) || "key-property".equals( name ) ) {
- value = new SimpleValue( component.getTable() );
- String relativePath;
- if (isEmbedded) {
- relativePath = propertyName;
- }
- else {
- relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
- }
- bindSimpleValue( subnode, (SimpleValue) value, isNullable, relativePath, mappings );
- }
- else if ( "component".equals( name )
- || "dynamic-component".equals( name )
- || "nested-composite-element".equals( name ) ) {
- value = new Component( component ); // a nested composite element
- bindComponent(
- subnode,
- (Component) value,
- component.getComponentClassName(),
- propertyName,
- subpath,
- isNullable,
- isEmbedded,
- mappings,
- inheritedMetas,
- isIdentifierMapper
- );
- }
- else if ( "parent".equals( name ) ) {
- component.setParentProperty( propertyName );
- }
-
- if ( value != null ) {
- Property property = createProperty( value, propertyName, component
- .getComponentClassName(), subnode, mappings, inheritedMetas );
- if (isIdentifierMapper) {
- property.setInsertable(false);
- property.setUpdateable(false);
- }
- component.addProperty( property );
- }
- }
-
- if ( "true".equals( node.attributeValue( "unique" ) ) ) {
- iter = component.getColumnIterator();
- ArrayList cols = new ArrayList();
- while ( iter.hasNext() ) {
- cols.add( iter.next() );
- }
- component.getOwner().getTable().createUniqueKey( cols );
- }
-
- iter = node.elementIterator( "tuplizer" );
- while ( iter.hasNext() ) {
- final Element tuplizerElem = ( Element ) iter.next();
- EntityMode mode = EntityMode.parse( tuplizerElem.attributeValue( "entity-mode" ) );
- component.addTuplizer( mode, tuplizerElem.attributeValue( "class" ) );
- }
- }
-
- public static String getTypeFromXML(Element node) throws MappingException {
- // TODO: handle TypeDefs
- Attribute typeNode = node.attribute( "type" );
- if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any
- if ( typeNode == null ) return null; // we will have to use reflection
- return typeNode.getValue();
- }
-
- private static void initOuterJoinFetchSetting(Element node, Fetchable model) {
- Attribute fetchNode = node.attribute( "fetch" );
- final FetchMode fetchStyle;
- boolean lazy = true;
- if ( fetchNode == null ) {
- Attribute jfNode = node.attribute( "outer-join" );
- if ( jfNode == null ) {
- if ( "many-to-many".equals( node.getName() ) ) {
- //NOTE SPECIAL CASE:
- // default to join and non-lazy for the "second join"
- // of the many-to-many
- lazy = false;
- fetchStyle = FetchMode.JOIN;
- }
- else if ( "one-to-one".equals( node.getName() ) ) {
- //NOTE SPECIAL CASE:
- // one-to-one constrained=false cannot be proxied,
- // so default to join and non-lazy
- lazy = ( (OneToOne) model ).isConstrained();
- fetchStyle = lazy ? FetchMode.DEFAULT : FetchMode.JOIN;
- }
- else {
- fetchStyle = FetchMode.DEFAULT;
- }
- }
- else {
- // use old (HB 2.1) defaults if outer-join is specified
- String eoj = jfNode.getValue();
- if ( "auto".equals( eoj ) ) {
- fetchStyle = FetchMode.DEFAULT;
- }
- else {
- boolean join = "true".equals( eoj );
- fetchStyle = join ? FetchMode.JOIN : FetchMode.SELECT;
- }
- }
- }
- else {
- boolean join = "join".equals( fetchNode.getValue() );
- //lazy = !join;
- fetchStyle = join ? FetchMode.JOIN : FetchMode.SELECT;
- }
- model.setFetchMode( fetchStyle );
- model.setLazy(lazy);
- }
-
- private static void makeIdentifier(Element node, SimpleValue model, Mappings mappings) {
-
- // GENERATOR
- Element subnode = node.element( "generator" );
- if ( subnode != null ) {
- model.setIdentifierGeneratorStrategy( subnode.attributeValue( "class" ) );
-
- Properties params = new Properties();
-
- if ( mappings.getSchemaName() != null ) {
- params.setProperty( PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName() );
- }
- if ( mappings.getCatalogName() != null ) {
- params.setProperty( PersistentIdentifierGenerator.CATALOG, mappings.getCatalogName() );
- }
-
- Iterator iter = subnode.elementIterator( "param" );
- while ( iter.hasNext() ) {
- Element childNode = (Element) iter.next();
- params.setProperty( childNode.attributeValue( "name" ), childNode.getTextTrim() );
- }
-
- model.setIdentifierGeneratorProperties( params );
- }
-
- model.getTable().setIdentifierValue( model );
-
- // ID UNSAVED-VALUE
- Attribute nullValueNode = node.attribute( "unsaved-value" );
- if ( nullValueNode != null ) {
- model.setNullValue( nullValueNode.getValue() );
- }
- else {
- if ( "assigned".equals( model.getIdentifierGeneratorStrategy() ) ) {
- model.setNullValue( "undefined" );
- }
- else {
- model.setNullValue( null );
- }
- }
- }
-
- private static final void makeVersion(Element node, SimpleValue model) {
-
- // VERSION UNSAVED-VALUE
- Attribute nullValueNode = node.attribute( "unsaved-value" );
- if ( nullValueNode != null ) {
- model.setNullValue( nullValueNode.getValue() );
- }
- else {
- model.setNullValue( "undefined" );
- }
-
- }
-
- protected static void createClassProperties(Element node, PersistentClass persistentClass,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- createClassProperties(node, persistentClass, mappings, inheritedMetas, null, true, true, false);
- }
-
- protected static void createClassProperties(Element node, PersistentClass persistentClass,
- Mappings mappings, java.util.Map inheritedMetas, UniqueKey uniqueKey,
- boolean mutable, boolean nullable, boolean naturalId) throws MappingException {
-
- String entityName = persistentClass.getEntityName();
- Table table = persistentClass.getTable();
-
- Iterator iter = node.elementIterator();
- while ( iter.hasNext() ) {
- Element subnode = (Element) iter.next();
- String name = subnode.getName();
- String propertyName = subnode.attributeValue( "name" );
-
- CollectionType collectType = CollectionType.collectionTypeFromString( name );
- Value value = null;
- if ( collectType != null ) {
- Collection collection = collectType.create(
- subnode,
- StringHelper.qualify( entityName, propertyName ),
- persistentClass,
- mappings, inheritedMetas
- );
- mappings.addCollection( collection );
- value = collection;
- }
- else if ( "many-to-one".equals( name ) ) {
- value = new ManyToOne( table );
- bindManyToOne( subnode, (ManyToOne) value, propertyName, nullable, mappings );
- }
- else if ( "any".equals( name ) ) {
- value = new Any( table );
- bindAny( subnode, (Any) value, nullable, mappings );
- }
- else if ( "one-to-one".equals( name ) ) {
- value = new OneToOne( table, persistentClass );
- bindOneToOne( subnode, (OneToOne) value, propertyName, true, mappings );
- }
- else if ( "property".equals( name ) ) {
- value = new SimpleValue( table );
- bindSimpleValue( subnode, (SimpleValue) value, nullable, propertyName, mappings );
- }
- else if ( "component".equals( name )
- || "dynamic-component".equals( name )
- || "properties".equals( name ) ) {
- String subpath = StringHelper.qualify( entityName, propertyName );
- value = new Component( persistentClass );
-
- bindComponent(
- subnode,
- (Component) value,
- persistentClass.getClassName(),
- propertyName,
- subpath,
- true,
- "properties".equals( name ),
- mappings,
- inheritedMetas,
- false
- );
- }
- else if ( "join".equals( name ) ) {
- Join join = new Join();
- join.setPersistentClass( persistentClass );
- bindJoin( subnode, join, mappings, inheritedMetas );
- persistentClass.addJoin( join );
- }
- else if ( "subclass".equals( name ) ) {
- handleSubclass( persistentClass, mappings, subnode, inheritedMetas );
- }
- else if ( "joined-subclass".equals( name ) ) {
- handleJoinedSubclass( persistentClass, mappings, subnode, inheritedMetas );
- }
- else if ( "union-subclass".equals( name ) ) {
- handleUnionSubclass( persistentClass, mappings, subnode, inheritedMetas );
- }
- else if ( "filter".equals( name ) ) {
- parseFilter( subnode, persistentClass, mappings );
- }
- else if ( "natural-id".equals( name ) ) {
- UniqueKey uk = new UniqueKey();
- uk.setName("_UniqueKey");
- uk.setTable(table);
- //by default, natural-ids are "immutable" (constant)
- boolean mutableId = "true".equals( subnode.attributeValue("mutable") );
- createClassProperties(
- subnode,
- persistentClass,
- mappings,
- inheritedMetas,
- uk,
- mutableId,
- false,
- true
- );
- table.addUniqueKey(uk);
- }
- else if ( "query".equals(name) ) {
- bindNamedQuery(subnode, persistentClass.getEntityName(), mappings);
- }
- else if ( "sql-query".equals(name) ) {
- bindNamedSQLQuery(subnode, persistentClass.getEntityName(), mappings);
- }
- else if ( "resultset".equals(name) ) {
- bindResultSetMappingDefinition( subnode, persistentClass.getEntityName(), mappings );
- }
-
- if ( value != null ) {
- Property property = createProperty( value, propertyName, persistentClass
- .getClassName(), subnode, mappings, inheritedMetas );
- if ( !mutable ) property.setUpdateable(false);
- if ( naturalId ) property.setNaturalIdentifier(true);
- persistentClass.addProperty( property );
- if ( uniqueKey!=null ) uniqueKey.addColumns( property.getColumnIterator() );
- }
-
- }
- }
-
- private static Property createProperty(
- final Value value,
- final String propertyName,
- final String className,
- final Element subnode,
- final Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
-
- if ( StringHelper.isEmpty( propertyName ) ) {
- throw new MappingException( subnode.getName() + " mapping must defined a name attribute [" + className + "]" );
- }
-
- value.setTypeUsingReflection( className, propertyName );
-
- // this is done here 'cos we might only know the type here (ugly!)
- // TODO: improve this a lot:
- if ( value instanceof ToOne ) {
- ToOne toOne = (ToOne) value;
- String propertyRef = toOne.getReferencedPropertyName();
- if ( propertyRef != null ) {
- mappings.addUniquePropertyReference( toOne.getReferencedEntityName(), propertyRef );
- }
- }
- else if ( value instanceof Collection ) {
- Collection coll = (Collection) value;
- String propertyRef = coll.getReferencedPropertyName();
- // not necessarily a *unique* property reference
- if ( propertyRef != null ) {
- mappings.addPropertyReference( coll.getOwnerEntityName(), propertyRef );
- }
- }
-
- value.createForeignKey();
- Property prop = new Property();
- prop.setValue( value );
- bindProperty( subnode, prop, mappings, inheritedMetas );
- return prop;
- }
-
- private static void handleUnionSubclass(PersistentClass model, Mappings mappings,
- Element subnode, java.util.Map inheritedMetas) throws MappingException {
- UnionSubclass subclass = new UnionSubclass( model );
- bindUnionSubclass( subnode, subclass, mappings, inheritedMetas );
- model.addSubclass( subclass );
- mappings.addClass( subclass );
- }
-
- private static void handleJoinedSubclass(PersistentClass model, Mappings mappings,
- Element subnode, java.util.Map inheritedMetas) throws MappingException {
- JoinedSubclass subclass = new JoinedSubclass( model );
- bindJoinedSubclass( subnode, subclass, mappings, inheritedMetas );
- model.addSubclass( subclass );
- mappings.addClass( subclass );
- }
-
- private static void handleSubclass(PersistentClass model, Mappings mappings, Element subnode,
- java.util.Map inheritedMetas) throws MappingException {
- Subclass subclass = new SingleTableSubclass( model );
- bindSubclass( subnode, subclass, mappings, inheritedMetas );
- model.addSubclass( subclass );
- mappings.addClass( subclass );
- }
-
- /**
- * Called for Lists, arrays, primitive arrays
- */
- public static void bindListSecondPass(Element node, List list, java.util.Map classes,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
-
- bindCollectionSecondPass( node, list, classes, mappings, inheritedMetas );
-
- Element subnode = node.element( "list-index" );
- if ( subnode == null ) subnode = node.element( "index" );
- SimpleValue iv = new SimpleValue( list.getCollectionTable() );
- bindSimpleValue(
- subnode,
- iv,
- list.isOneToMany(),
- IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
- mappings
- );
- iv.setTypeName( "integer" );
- list.setIndex( iv );
- String baseIndex = subnode.attributeValue( "base" );
- if ( baseIndex != null ) list.setBaseIndex( Integer.parseInt( baseIndex ) );
- list.setIndexNodeName( subnode.attributeValue("node") );
-
- if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
- String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
- PersistentClass referenced = mappings.getClass( entityName );
- IndexBackref ib = new IndexBackref();
- ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
- ib.setUpdateable( false );
- ib.setSelectable( false );
- ib.setCollectionRole( list.getRole() );
- ib.setEntityName( list.getOwner().getEntityName() );
- ib.setValue( list.getIndex() );
- // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
- // ).setNullable(false);
- referenced.addProperty( ib );
- }
- }
-
- public static void bindIdentifierCollectionSecondPass(Element node,
- IdentifierCollection collection, java.util.Map persistentClasses, Mappings mappings,
- java.util.Map inheritedMetas) throws MappingException {
-
- bindCollectionSecondPass( node, collection, persistentClasses, mappings, inheritedMetas );
-
- Element subnode = node.element( "collection-id" );
- SimpleValue id = new SimpleValue( collection.getCollectionTable() );
- bindSimpleValue(
- subnode,
- id,
- false,
- IdentifierCollection.DEFAULT_IDENTIFIER_COLUMN_NAME,
- mappings
- );
- collection.setIdentifier( id );
- makeIdentifier( subnode, id, mappings );
-
- }
-
- /**
- * Called for Maps
- */
- public static void bindMapSecondPass(Element node, Map map, java.util.Map classes,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
-
- bindCollectionSecondPass( node, map, classes, mappings, inheritedMetas );
-
- Iterator iter = node.elementIterator();
- while ( iter.hasNext() ) {
- Element subnode = (Element) iter.next();
- String name = subnode.getName();
-
- if ( "index".equals( name ) || "map-key".equals( name ) ) {
- SimpleValue value = new SimpleValue( map.getCollectionTable() );
- bindSimpleValue(
- subnode,
- value,
- map.isOneToMany(),
- IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
- mappings
- );
- if ( !value.isTypeSpecified() ) {
- throw new MappingException( "map index element must specify a type: "
- + map.getRole() );
- }
- map.setIndex( value );
- map.setIndexNodeName( subnode.attributeValue("node") );
- }
- else if ( "index-many-to-many".equals( name ) || "map-key-many-to-many".equals( name ) ) {
- ManyToOne mto = new ManyToOne( map.getCollectionTable() );
- bindManyToOne(
- subnode,
- mto,
- IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
- map.isOneToMany(),
- mappings
- );
- map.setIndex( mto );
-
- }
- else if ( "composite-index".equals( name ) || "composite-map-key".equals( name ) ) {
- Component component = new Component( map );
- bindComposite(
- subnode,
- component,
- map.getRole() + ".index",
- map.isOneToMany(),
- mappings,
- inheritedMetas
- );
- map.setIndex( component );
- }
- else if ( "index-many-to-any".equals( name ) ) {
- Any any = new Any( map.getCollectionTable() );
- bindAny( subnode, any, map.isOneToMany(), mappings );
- map.setIndex( any );
- }
- }
-
- // TODO: this is a bit of copy/paste from IndexedCollection.createPrimaryKey()
- boolean indexIsFormula = false;
- Iterator colIter = map.getIndex().getColumnIterator();
- while ( colIter.hasNext() ) {
- if ( ( (Selectable) colIter.next() ).isFormula() ) indexIsFormula = true;
- }
-
- if ( map.isOneToMany() && !map.getKey().isNullable() && !map.isInverse() && !indexIsFormula ) {
- String entityName = ( (OneToMany) map.getElement() ).getReferencedEntityName();
- PersistentClass referenced = mappings.getClass( entityName );
- IndexBackref ib = new IndexBackref();
- ib.setName( '_' + map.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
- ib.setUpdateable( false );
- ib.setSelectable( false );
- ib.setCollectionRole( map.getRole() );
- ib.setEntityName( map.getOwner().getEntityName() );
- ib.setValue( map.getIndex() );
- // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
- // ).setNullable(false);
- referenced.addProperty( ib );
- }
- }
-
- /**
- * Called for all collections
- */
- public static void bindCollectionSecondPass(Element node, Collection collection,
- java.util.Map persistentClasses, Mappings mappings, java.util.Map inheritedMetas)
- throws MappingException {
-
- if ( collection.isOneToMany() ) {
- OneToMany oneToMany = (OneToMany) collection.getElement();
- String assocClass = oneToMany.getReferencedEntityName();
- PersistentClass persistentClass = (PersistentClass) persistentClasses.get( assocClass );
- if ( persistentClass == null ) {
- throw new MappingException( "Association references unmapped class: " + assocClass );
- }
- oneToMany.setAssociatedClass( persistentClass );
- collection.setCollectionTable( persistentClass.getTable() );
-
- log.info(
- "Mapping collection: " + collection.getRole() +
- " -> " + collection.getCollectionTable().getName()
- );
- }
-
- // CHECK
- Attribute chNode = node.attribute( "check" );
- if ( chNode != null ) {
- collection.getCollectionTable().addCheckConstraint( chNode.getValue() );
- }
-
- // contained elements:
- Iterator iter = node.elementIterator();
- while ( iter.hasNext() ) {
- Element subnode = (Element) iter.next();
- String name = subnode.getName();
-
- if ( "key".equals( name ) ) {
- KeyValue keyVal;
- String propRef = collection.getReferencedPropertyName();
- if ( propRef == null ) {
- keyVal = collection.getOwner().getIdentifier();
- }
- else {
- keyVal = (KeyValue) collection.getOwner().getRecursiveProperty( propRef ).getValue();
- }
- SimpleValue key = new DependantValue( collection.getCollectionTable(), keyVal );
- key.setCascadeDeleteEnabled( "cascade"
- .equals( subnode.attributeValue( "on-delete" ) ) );
- bindSimpleValue(
- subnode,
- key,
- collection.isOneToMany(),
- Collection.DEFAULT_KEY_COLUMN_NAME,
- mappings
- );
- collection.setKey( key );
-
- Attribute notNull = subnode.attribute( "not-null" );
- ( (DependantValue) key ).setNullable( notNull == null
- || notNull.getValue().equals( "false" ) );
- Attribute updateable = subnode.attribute( "update" );
- ( (DependantValue) key ).setUpdateable( updateable == null
- || updateable.getValue().equals( "true" ) );
-
- }
- else if ( "element".equals( name ) ) {
- SimpleValue elt = new SimpleValue( collection.getCollectionTable() );
- collection.setElement( elt );
- bindSimpleValue(
- subnode,
- elt,
- true,
- Collection.DEFAULT_ELEMENT_COLUMN_NAME,
- mappings
- );
- }
- else if ( "many-to-many".equals( name ) ) {
- ManyToOne element = new ManyToOne( collection.getCollectionTable() );
- collection.setElement( element );
- bindManyToOne(
- subnode,
- element,
- Collection.DEFAULT_ELEMENT_COLUMN_NAME,
- false,
- mappings
- );
- bindManyToManySubelements( collection, subnode, mappings );
- }
- else if ( "composite-element".equals( name ) ) {
- Component element = new Component( collection );
- collection.setElement( element );
- bindComposite(
- subnode,
- element,
- collection.getRole() + ".element",
- true,
- mappings,
- inheritedMetas
- );
- }
- else if ( "many-to-any".equals( name ) ) {
- Any element = new Any( collection.getCollectionTable() );
- collection.setElement( element );
- bindAny( subnode, element, true, mappings );
- }
- else if ( "cache".equals( name ) ) {
- collection.setCacheConcurrencyStrategy( subnode.attributeValue( "usage" ) );
- collection.setCacheRegionName( subnode.attributeValue( "region" ) );
- }
-
- String nodeName = subnode.attributeValue( "node" );
- if ( nodeName != null ) collection.setElementNodeName( nodeName );
-
- }
-
- if ( collection.isOneToMany()
- && !collection.isInverse()
- && !collection.getKey().isNullable() ) {
- // for non-inverse one-to-many, with a not-null fk, add a backref!
- String entityName = ( (OneToMany) collection.getElement() ).getReferencedEntityName();
- PersistentClass referenced = mappings.getClass( entityName );
- Backref prop = new Backref();
- prop.setName( '_' + collection.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "Backref" );
- prop.setUpdateable( false );
- prop.setSelectable( false );
- prop.setCollectionRole( collection.getRole() );
- prop.setEntityName( collection.getOwner().getEntityName() );
- prop.setValue( collection.getKey() );
- referenced.addProperty( prop );
- }
- }
-
- private static void bindManyToManySubelements(
- Collection collection,
- Element manyToManyNode,
- Mappings model) throws MappingException {
- // Bind the where
- Attribute where = manyToManyNode.attribute( "where" );
- String whereCondition = where == null ? null : where.getValue();
- collection.setManyToManyWhere( whereCondition );
-
- // Bind the order-by
- Attribute order = manyToManyNode.attribute( "order-by" );
- String orderFragment = order == null ? null : order.getValue();
- collection.setManyToManyOrdering( orderFragment );
-
- // Bind the filters
- Iterator filters = manyToManyNode.elementIterator( "filter" );
- if ( ( filters.hasNext() || whereCondition != null ) &&
- collection.getFetchMode() == FetchMode.JOIN &&
- collection.getElement().getFetchMode() != FetchMode.JOIN ) {
- throw new MappingException(
- "many-to-many defining filter or where without join fetching " +
- "not valid within collection using join fetching [" + collection.getRole() + "]"
- );
- }
- while ( filters.hasNext() ) {
- final Element filterElement = ( Element ) filters.next();
- final String name = filterElement.attributeValue( "name" );
- String condition = filterElement.getTextTrim();
- if ( StringHelper.isEmpty(condition) ) condition = filterElement.attributeValue( "condition" );
- if ( StringHelper.isEmpty(condition) ) {
- condition = model.getFilterDefinition(name).getDefaultFilterCondition();
- }
- if ( condition==null) {
- throw new MappingException("no filter condition found for filter: " + name);
- }
- log.debug(
- "Applying many-to-many filter [" + name +
- "] as [" + condition +
- "] to role [" + collection.getRole() + "]"
- );
- collection.addManyToManyFilter( name, condition );
- }
- }
-
- public static final FlushMode getFlushMode(String flushMode) {
- if ( flushMode == null ) {
- return null;
- }
- else if ( "auto".equals( flushMode ) ) {
- return FlushMode.AUTO;
- }
- else if ( "commit".equals( flushMode ) ) {
- return FlushMode.COMMIT;
- }
- else if ( "never".equals( flushMode ) ) {
- return FlushMode.NEVER;
- }
- else if ( "manual".equals( flushMode ) ) {
- return FlushMode.MANUAL;
- }
- else if ( "always".equals( flushMode ) ) {
- return FlushMode.ALWAYS;
- }
- else {
- throw new MappingException( "unknown flushmode" );
- }
- }
-
- private static void bindNamedQuery(Element queryElem, String path, Mappings mappings) {
- String queryName = queryElem.attributeValue( "name" );
- if (path!=null) queryName = path + '.' + queryName;
- String query = queryElem.getText();
- log.debug( "Named query: " + queryName + " -> " + query );
-
- boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
- String region = queryElem.attributeValue( "cache-region" );
- Attribute tAtt = queryElem.attribute( "timeout" );
- Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
- Attribute fsAtt = queryElem.attribute( "fetch-size" );
- Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
- Attribute roAttr = queryElem.attribute( "read-only" );
- boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
- Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
- String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
- Attribute cmAtt = queryElem.attribute( "comment" );
- String comment = cmAtt == null ? null : cmAtt.getValue();
-
- NamedQueryDefinition namedQuery = new NamedQueryDefinition(
- query,
- cacheable,
- region,
- timeout,
- fetchSize,
- getFlushMode( queryElem.attributeValue( "flush-mode" ) ) ,
- getCacheMode( cacheMode ),
- readOnly,
- comment,
- getParameterTypes(queryElem)
- );
-
- mappings.addQuery( queryName, namedQuery );
- }
-
- public static CacheMode getCacheMode(String cacheMode) {
- if (cacheMode == null) return null;
- if ( "get".equals( cacheMode ) ) return CacheMode.GET;
- if ( "ignore".equals( cacheMode ) ) return CacheMode.IGNORE;
- if ( "normal".equals( cacheMode ) ) return CacheMode.NORMAL;
- if ( "put".equals( cacheMode ) ) return CacheMode.PUT;
- if ( "refresh".equals( cacheMode ) ) return CacheMode.REFRESH;
- throw new MappingException("Unknown Cache Mode: " + cacheMode);
- }
-
- public static java.util.Map getParameterTypes(Element queryElem) {
- java.util.Map result = new java.util.LinkedHashMap();
- Iterator iter = queryElem.elementIterator("query-param");
- while ( iter.hasNext() ) {
- Element element = (Element) iter.next();
- result.put( element.attributeValue("name"), element.attributeValue("type") );
- }
- return result;
- }
-
- private static void bindResultSetMappingDefinition(Element resultSetElem, String path, Mappings mappings) {
- mappings.addSecondPass( new ResultSetMappingSecondPass( resultSetElem, path, mappings ) );
- }
-
- private static void bindNamedSQLQuery(Element queryElem, String path, Mappings mappings) {
- mappings.addSecondPass( new NamedSQLQuerySecondPass( queryElem, path, mappings ) );
- }
-
- private static String getPropertyName(Element node) {
- return node.attributeValue( "name" );
- }
-
- private static PersistentClass getSuperclass(Mappings mappings, Element subnode)
- throws MappingException {
- String extendsName = subnode.attributeValue( "extends" );
- PersistentClass superModel = mappings.getClass( extendsName );
- if ( superModel == null ) {
- String qualifiedExtendsName = getClassName( extendsName, mappings );
- superModel = mappings.getClass( qualifiedExtendsName );
- }
-
- if ( superModel == null ) {
- throw new MappingException( "Cannot extend unmapped class " + extendsName );
- }
- return superModel;
- }
-
- static class CollectionSecondPass extends org.hibernate.cfg.CollectionSecondPass {
- Element node;
-
- CollectionSecondPass(Element node, Mappings mappings, Collection collection, java.util.Map inheritedMetas) {
- super(mappings, collection, inheritedMetas);
- this.node = node;
- }
-
- public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
- throws MappingException {
- HbmBinder.bindCollectionSecondPass(
- node,
- collection,
- persistentClasses,
- mappings,
- inheritedMetas
- );
- }
- }
-
- static class IdentifierCollectionSecondPass extends CollectionSecondPass {
- IdentifierCollectionSecondPass(Element node, Mappings mappings, Collection collection, java.util.Map inheritedMetas) {
- super( node, mappings, collection, inheritedMetas );
- }
-
- public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
- throws MappingException {
- HbmBinder.bindIdentifierCollectionSecondPass(
- node,
- (IdentifierCollection) collection,
- persistentClasses,
- mappings,
- inheritedMetas
- );
- }
-
- }
-
- static class MapSecondPass extends CollectionSecondPass {
- MapSecondPass(Element node, Mappings mappings, Map collection, java.util.Map inheritedMetas) {
- super( node, mappings, collection, inheritedMetas );
- }
-
- public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
- throws MappingException {
- HbmBinder.bindMapSecondPass(
- node,
- (Map) collection,
- persistentClasses,
- mappings,
- inheritedMetas
- );
- }
-
- }
-
-
- static class ManyToOneSecondPass implements SecondPass {
- private final ManyToOne manyToOne;
-
- ManyToOneSecondPass(ManyToOne manyToOne) {
- this.manyToOne = manyToOne;
- }
-
- public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
- manyToOne.createPropertyRefConstraints(persistentClasses);
- }
-
- }
-
- static class ListSecondPass extends CollectionSecondPass {
- ListSecondPass(Element node, Mappings mappings, List collection, java.util.Map inheritedMetas) {
- super( node, mappings, collection, inheritedMetas );
- }
-
- public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
- throws MappingException {
- HbmBinder.bindListSecondPass(
- node,
- (List) collection,
- persistentClasses,
- mappings,
- inheritedMetas
- );
- }
-
- }
-
- // This inner class implements a case statement....perhaps im being a bit over-clever here
- abstract static class CollectionType {
- private String xmlTag;
-
- public abstract Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException;
-
- CollectionType(String xmlTag) {
- this.xmlTag = xmlTag;
- }
-
- public String toString() {
- return xmlTag;
- }
-
- private static final CollectionType MAP = new CollectionType( "map" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- Map map = new Map( owner );
- bindCollection( node, map, owner.getEntityName(), path, mappings, inheritedMetas );
- return map;
- }
- };
- private static final CollectionType SET = new CollectionType( "set" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- Set set = new Set( owner );
- bindCollection( node, set, owner.getEntityName(), path, mappings, inheritedMetas );
- return set;
- }
- };
- private static final CollectionType LIST = new CollectionType( "list" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- List list = new List( owner );
- bindCollection( node, list, owner.getEntityName(), path, mappings, inheritedMetas );
- return list;
- }
- };
- private static final CollectionType BAG = new CollectionType( "bag" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- Bag bag = new Bag( owner );
- bindCollection( node, bag, owner.getEntityName(), path, mappings, inheritedMetas );
- return bag;
- }
- };
- private static final CollectionType IDBAG = new CollectionType( "idbag" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- IdentifierBag bag = new IdentifierBag( owner );
- bindCollection( node, bag, owner.getEntityName(), path, mappings, inheritedMetas );
- return bag;
- }
- };
- private static final CollectionType ARRAY = new CollectionType( "array" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- Array array = new Array( owner );
- bindArray( node, array, owner.getEntityName(), path, mappings, inheritedMetas );
- return array;
- }
- };
- private static final CollectionType PRIMITIVE_ARRAY = new CollectionType( "primitive-array" ) {
- public Collection create(Element node, String path, PersistentClass owner,
- Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
- PrimitiveArray array = new PrimitiveArray( owner );
- bindArray( node, array, owner.getEntityName(), path, mappings, inheritedMetas );
- return array;
- }
- };
- private static final HashMap INSTANCES = new HashMap();
-
- static {
- INSTANCES.put( MAP.toString(), MAP );
- INSTANCES.put( BAG.toString(), BAG );
- INSTANCES.put( IDBAG.toString(), IDBAG );
- INSTANCES.put( SET.toString(), SET );
- INSTANCES.put( LIST.toString(), LIST );
- INSTANCES.put( ARRAY.toString(), ARRAY );
- INSTANCES.put( PRIMITIVE_ARRAY.toString(), PRIMITIVE_ARRAY );
- }
-
- public static CollectionType collectionTypeFromString(String xmlTagName) {
- return (CollectionType) INSTANCES.get( xmlTagName );
- }
- }
-
- private static int getOptimisticLockMode(Attribute olAtt) throws MappingException {
-
- if ( olAtt == null ) return Versioning.OPTIMISTIC_LOCK_VERSION;
- String olMode = olAtt.getValue();
- if ( olMode == null || "version".equals( olMode ) ) {
- return Versioning.OPTIMISTIC_LOCK_VERSION;
- }
- else if ( "dirty".equals( olMode ) ) {
- return Versioning.OPTIMISTIC_LOCK_DIRTY;
- }
- else if ( "all".equals( olMode ) ) {
- return Versioning.OPTIMISTIC_LOCK_ALL;
- }
- else if ( "none".equals( olMode ) ) {
- return Versioning.OPTIMISTIC_LOCK_NONE;
- }
- else {
- throw new MappingException( "Unsupported optimistic-lock style: " + olMode );
- }
- }
-
- private static final java.util.Map getMetas(Element node, java.util.Map inheritedMeta) {
- return getMetas( node, inheritedMeta, false );
- }
-
- public static final java.util.Map getMetas(Element node, java.util.Map inheritedMeta,
- boolean onlyInheritable) {
- java.util.Map map = new HashMap();
- map.putAll( inheritedMeta );
-
- Iterator iter = node.elementIterator( "meta" );
- while ( iter.hasNext() ) {
- Element metaNode = (Element) iter.next();
- boolean inheritable = Boolean
- .valueOf( metaNode.attributeValue( "inherit" ) )
- .booleanValue();
- if ( onlyInheritable & !inheritable ) {
- continue;
- }
- String name = metaNode.attributeValue( "attribute" );
-
- MetaAttribute meta = (MetaAttribute) map.get( name );
- MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
- if ( meta == null ) {
- meta = new MetaAttribute( name );
- map.put( name, meta );
- } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793
- meta = new MetaAttribute( name );
- map.put( name, meta );
- }
- meta.addValue( metaNode.getText() );
- }
- return map;
- }
-
- public static String getEntityName(Element elem, Mappings model) {
- String entityName = elem.attributeValue( "entity-name" );
- return entityName == null ? getClassName( elem.attribute( "class" ), model ) : entityName;
- }
-
- private static String getClassName(Attribute att, Mappings model) {
- if ( att == null ) return null;
- return getClassName( att.getValue(), model );
- }
-
- public static String getClassName(String unqualifiedName, Mappings model) {
- return getClassName( unqualifiedName, model.getDefaultPackage() );
- }
-
- public static String getClassName(String unqualifiedName, String defaultPackage) {
- if ( unqualifiedName == null ) return null;
- if ( unqualifiedName.indexOf( '.' ) < 0 && defaultPackage != null ) {
- return defaultPackage + '.' + unqualifiedName;
- }
- return unqualifiedName;
- }
-
- private static void parseFilterDef(Element element, Mappings mappings) {
- String name = element.attributeValue( "name" );
- log.debug( "Parsing filter-def [" + name + "]" );
- String defaultCondition = element.getTextTrim();
- if ( StringHelper.isEmpty( defaultCondition ) ) {
- defaultCondition = element.attributeValue( "condition" );
- }
- HashMap paramMappings = new HashMap();
- Iterator params = element.elementIterator( "filter-param" );
- while ( params.hasNext() ) {
- final Element param = (Element) params.next();
- final String paramName = param.attributeValue( "name" );
- final String paramType = param.attributeValue( "type" );
- log.debug( "adding filter parameter : " + paramName + " -> " + paramType );
- final Type heuristicType = TypeFactory.heuristicType( paramType );
- log.debug( "parameter heuristic type : " + heuristicType );
- paramMappings.put( paramName, heuristicType );
- }
- log.debug( "Parsed filter-def [" + name + "]" );
- FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
- mappings.addFilterDefinition( def );
- }
-
- private static void parseFilter(Element filterElement, Filterable filterable, Mappings model) {
- final String name = filterElement.attributeValue( "name" );
- String condition = filterElement.getTextTrim();
- if ( StringHelper.isEmpty(condition) ) {
- condition = filterElement.attributeValue( "condition" );
- }
- //TODO: bad implementation, cos it depends upon ordering of mapping doc
- // fixing this requires that Collection/PersistentClass gain access
- // to the Mappings reference from Configuration (or the filterDefinitions
- // map directly) sometime during Configuration.buildSessionFactory
- // (after all the types/filter-defs are known and before building
- // persisters).
- if ( StringHelper.isEmpty(condition) ) {
- condition = model.getFilterDefinition(name).getDefaultFilterCondition();
- }
- if ( condition==null) {
- throw new MappingException("no filter condition found for filter: " + name);
- }
- log.debug( "Applying filter [" + name + "] as [" + condition + "]" );
- filterable.addFilter( name, condition );
- }
-
- private static String getSubselect(Element element) {
- String subselect = element.attributeValue( "subselect" );
- if ( subselect != null ) {
- return subselect;
- }
- else {
- Element subselectElement = element.element( "subselect" );
- return subselectElement == null ? null : subselectElement.getText();
- }
- }
-
- /**
- * For the given document, locate all extends attributes which refer to
- * entities (entity-name or class-name) not defined within said document.
- *
- * @param doc The document to check
- * @param mappings The already processed mappings.
- * @return The list of unresolved extends names.
- */
- public static java.util.List getExtendsNeeded(Document doc, Mappings mappings) {
- java.util.List extendz = new ArrayList();
- Iterator[] subclasses = new Iterator[3];
- final Element hmNode = doc.getRootElement();
-
- Attribute packNode = hmNode.attribute( "package" );
- final String packageName = packNode == null ? null : packNode.getValue();
- if ( packageName != null ) {
- mappings.setDefaultPackage( packageName );
- }
-
- // first, iterate over all elements capable of defining an extends attribute
- // collecting all found extends references if they cannot be resolved
- // against the already processed mappings.
- subclasses[0] = hmNode.elementIterator( "subclass" );
- subclasses[1] = hmNode.elementIterator( "joined-subclass" );
- subclasses[2] = hmNode.elementIterator( "union-subclass" );
-
- Iterator iterator = new JoinedIterator( subclasses );
- while ( iterator.hasNext() ) {
- final Element element = (Element) iterator.next();
- final String extendsName = element.attributeValue( "extends" );
- // mappings might contain either the "raw" extends name (in the case of
- // an entity-name mapping) or a FQN (in the case of a POJO mapping).
- if ( mappings.getClass( extendsName ) == null && mappings.getClass( getClassName( extendsName, mappings ) ) == null ) {
- extendz.add( extendsName );
- }
- }
-
- if ( !extendz.isEmpty() ) {
- // we found some extends attributes referencing entities which were
- // not already processed. here we need to locate all entity-names
- // and class-names contained in this document itself, making sure
- // that these get removed from the extendz list such that only
- // extends names which require us to delay processing (i.e.
- // external to this document and not yet processed) are contained
- // in the returned result
- final java.util.Set set = new HashSet( extendz );
- EntityElementHandler handler = new EntityElementHandler() {
- public void handleEntity(String entityName, String className, Mappings mappings) {
- if ( entityName != null ) {
- set.remove( entityName );
- }
- else {
- String fqn = getClassName( className, packageName );
- set.remove( fqn );
- if ( packageName != null ) {
- set.remove( StringHelper.unqualify( fqn ) );
- }
- }
- }
- };
- recognizeEntities( mappings, hmNode, handler );
- extendz.clear();
- extendz.addAll( set );
- }
-
- return extendz;
- }
-
- /**
- * Given an entity-containing-element (startNode) recursively locate all
- * entity names defined within that element.
- *
- * @param mappings The already processed mappings
- * @param startNode The containing element
- * @param handler The thing that knows what to do whenever we recognize an
- * entity-name
- */
- private static void recognizeEntities(
- Mappings mappings,
- final Element startNode,
- EntityElementHandler handler) {
- Iterator[] classes = new Iterator[4];
- classes[0] = startNode.elementIterator( "class" );
- classes[1] = startNode.elementIterator( "subclass" );
- classes[2] = startNode.elementIterator( "joined-subclass" );
- classes[3] = startNode.elementIterator( "union-subclass" );
-
- Iterator classIterator = new JoinedIterator( classes );
- while ( classIterator.hasNext() ) {
- Element element = (Element) classIterator.next();
- handler.handleEntity(
- element.attributeValue( "entity-name" ),
- element.attributeValue( "name" ),
- mappings
- );
- recognizeEntities( mappings, element, handler );
- }
- }
-
- private static interface EntityElementHandler {
- public void handleEntity(String entityName, String className, Mappings mappings);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/HbmBinder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,3079 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.hibernate.CacheMode;
+import org.hibernate.EntityMode;
+import org.hibernate.FetchMode;
+import org.hibernate.FlushMode;
+import org.hibernate.MappingException;
+import org.hibernate.engine.FilterDefinition;
+import org.hibernate.engine.NamedQueryDefinition;
+import org.hibernate.engine.Versioning;
+import org.hibernate.engine.ExecuteUpdateResultCheckStyle;
+import org.hibernate.id.PersistentIdentifierGenerator;
+import org.hibernate.mapping.Any;
+import org.hibernate.mapping.Array;
+import org.hibernate.mapping.AuxiliaryDatabaseObject;
+import org.hibernate.mapping.Backref;
+import org.hibernate.mapping.Bag;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.DependantValue;
+import org.hibernate.mapping.Fetchable;
+import org.hibernate.mapping.Filterable;
+import org.hibernate.mapping.Formula;
+import org.hibernate.mapping.IdentifierBag;
+import org.hibernate.mapping.IdentifierCollection;
+import org.hibernate.mapping.IndexBackref;
+import org.hibernate.mapping.IndexedCollection;
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.KeyValue;
+import org.hibernate.mapping.List;
+import org.hibernate.mapping.ManyToOne;
+import org.hibernate.mapping.Map;
+import org.hibernate.mapping.MetaAttribute;
+import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.OneToOne;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.PrimitiveArray;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.PropertyGeneration;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.Selectable;
+import org.hibernate.mapping.Set;
+import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SingleTableSubclass;
+import org.hibernate.mapping.Subclass;
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.ToOne;
+import org.hibernate.mapping.TypeDef;
+import org.hibernate.mapping.UnionSubclass;
+import org.hibernate.mapping.UniqueKey;
+import org.hibernate.mapping.Value;
+import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
+import org.hibernate.persister.entity.SingleTableEntityPersister;
+import org.hibernate.persister.entity.UnionSubclassEntityPersister;
+import org.hibernate.type.DiscriminatorType;
+import org.hibernate.type.ForeignKeyDirection;
+import org.hibernate.type.Type;
+import org.hibernate.type.TypeFactory;
+import org.hibernate.util.JoinedIterator;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Walks an XML mapping document and produces the Hibernate configuration-time metamodel (the
+ * classes in the <tt>mapping</tt> package)
+ *
+ * @author Gavin King
+ */
+public final class HbmBinder {
+
+ private static final Logger log = LoggerFactory.getLogger( HbmBinder.class );
+
+ /**
+ * Private constructor to disallow instantiation.
+ */
+ private HbmBinder() {
+ }
+
+ /**
+ * The main contract into the hbm.xml-based binder. Performs necessary binding operations
+ * represented by the given DOM.
+ *
+ * @param doc The DOM to be parsed and bound.
+ * @param mappings Current bind state.
+ * @param inheritedMetas Any inherited meta-tag information.
+ * @throws MappingException
+ */
+ public static void bindRoot(Document doc, Mappings mappings, java.util.Map inheritedMetas)
+ throws MappingException {
+
+ java.util.List names = HbmBinder.getExtendsNeeded( doc, mappings );
+ if ( !names.isEmpty() ) {
+ // classes mentioned in extends not available - so put it in queue
+ Element hmNode = doc.getRootElement();
+ Attribute packNode = hmNode.attribute( "package" );
+ String packageName = null;
+ if ( packNode != null ) {
+ packageName = packNode.getValue();
+ }
+ Iterator itr = names.iterator();
+ while ( itr.hasNext() ) {
+ String extendsName = (String) itr.next();
+ mappings.addToExtendsQueue( new ExtendsQueueEntry( extendsName, packageName, doc ) );
+ }
+ return;
+ }
+
+ Element hmNode = doc.getRootElement();
+ // get meta's from <hibernate-mapping>
+ inheritedMetas = getMetas( hmNode, inheritedMetas, true );
+ extractRootAttributes( hmNode, mappings );
+
+ Iterator rootChildren = hmNode.elementIterator();
+ while ( rootChildren.hasNext() ) {
+ final Element element = (Element) rootChildren.next();
+ final String elementName = element.getName();
+
+ if ( "filter-def".equals( elementName ) ) {
+ parseFilterDef( element, mappings );
+ }
+ else if ( "typedef".equals( elementName ) ) {
+ bindTypeDef( element, mappings );
+ }
+ else if ( "class".equals( elementName ) ) {
+ RootClass rootclass = new RootClass();
+ bindRootClass( element, rootclass, mappings, inheritedMetas );
+ mappings.addClass( rootclass );
+ }
+ else if ( "subclass".equals( elementName ) ) {
+ PersistentClass superModel = getSuperclass( mappings, element );
+ handleSubclass( superModel, mappings, element, inheritedMetas );
+ }
+ else if ( "joined-subclass".equals( elementName ) ) {
+ PersistentClass superModel = getSuperclass( mappings, element );
+ handleJoinedSubclass( superModel, mappings, element, inheritedMetas );
+ }
+ else if ( "union-subclass".equals( elementName ) ) {
+ PersistentClass superModel = getSuperclass( mappings, element );
+ handleUnionSubclass( superModel, mappings, element, inheritedMetas );
+ }
+ else if ( "query".equals( elementName ) ) {
+ bindNamedQuery( element, null, mappings );
+ }
+ else if ( "sql-query".equals( elementName ) ) {
+ bindNamedSQLQuery( element, null, mappings );
+ }
+ else if ( "resultset".equals( elementName ) ) {
+ bindResultSetMappingDefinition( element, null, mappings );
+ }
+ else if ( "import".equals( elementName ) ) {
+ bindImport( element, mappings );
+ }
+ else if ( "database-object".equals( elementName ) ) {
+ bindAuxiliaryDatabaseObject( element, mappings );
+ }
+ }
+ }
+
+ private static void bindImport(Element importNode, Mappings mappings) {
+ String className = getClassName( importNode.attribute( "class" ), mappings );
+ Attribute renameNode = importNode.attribute( "rename" );
+ String rename = ( renameNode == null ) ?
+ StringHelper.unqualify( className ) :
+ renameNode.getValue();
+ log.debug( "Import: " + rename + " -> " + className );
+ mappings.addImport( className, rename );
+ }
+
+ private static void bindTypeDef(Element typedefNode, Mappings mappings) {
+ String typeClass = typedefNode.attributeValue( "class" );
+ String typeName = typedefNode.attributeValue( "name" );
+ Iterator paramIter = typedefNode.elementIterator( "param" );
+ Properties parameters = new Properties();
+ while ( paramIter.hasNext() ) {
+ Element param = (Element) paramIter.next();
+ parameters.setProperty( param.attributeValue( "name" ), param.getTextTrim() );
+ }
+ mappings.addTypeDef( typeName, typeClass, parameters );
+ }
+
+ private static void bindAuxiliaryDatabaseObject(Element auxDbObjectNode, Mappings mappings) {
+ AuxiliaryDatabaseObject auxDbObject = null;
+ Element definitionNode = auxDbObjectNode.element( "definition" );
+ if ( definitionNode != null ) {
+ try {
+ auxDbObject = ( AuxiliaryDatabaseObject ) ReflectHelper
+ .classForName( definitionNode.attributeValue( "class" ) )
+ .newInstance();
+ }
+ catch( ClassNotFoundException e ) {
+ throw new MappingException(
+ "could not locate custom database object class [" +
+ definitionNode.attributeValue( "class" ) + "]"
+ );
+ }
+ catch( Throwable t ) {
+ throw new MappingException(
+ "could not instantiate custom database object class [" +
+ definitionNode.attributeValue( "class" ) + "]"
+ );
+ }
+ }
+ else {
+ auxDbObject = new SimpleAuxiliaryDatabaseObject(
+ auxDbObjectNode.elementTextTrim( "create" ),
+ auxDbObjectNode.elementTextTrim( "drop" )
+ );
+ }
+
+ Iterator dialectScopings = auxDbObjectNode.elementIterator( "dialect-scope" );
+ while ( dialectScopings.hasNext() ) {
+ Element dialectScoping = ( Element ) dialectScopings.next();
+ auxDbObject.addDialectScope( dialectScoping.attributeValue( "name" ) );
+ }
+
+ mappings.addAuxiliaryDatabaseObject( auxDbObject );
+ }
+
+ private static void extractRootAttributes(Element hmNode, Mappings mappings) {
+ Attribute schemaNode = hmNode.attribute( "schema" );
+ mappings.setSchemaName( ( schemaNode == null ) ? null : schemaNode.getValue() );
+
+ Attribute catalogNode = hmNode.attribute( "catalog" );
+ mappings.setCatalogName( ( catalogNode == null ) ? null : catalogNode.getValue() );
+
+ Attribute dcNode = hmNode.attribute( "default-cascade" );
+ mappings.setDefaultCascade( ( dcNode == null ) ? "none" : dcNode.getValue() );
+
+ Attribute daNode = hmNode.attribute( "default-access" );
+ mappings.setDefaultAccess( ( daNode == null ) ? "property" : daNode.getValue() );
+
+ Attribute dlNode = hmNode.attribute( "default-lazy" );
+ mappings.setDefaultLazy( dlNode == null || dlNode.getValue().equals( "true" ) );
+
+ Attribute aiNode = hmNode.attribute( "auto-import" );
+ mappings.setAutoImport( ( aiNode == null ) || "true".equals( aiNode.getValue() ) );
+
+ Attribute packNode = hmNode.attribute( "package" );
+ if ( packNode != null ) mappings.setDefaultPackage( packNode.getValue() );
+ }
+
+ /**
+ * Responsible for perfoming the bind operation related to an <class/> mapping element.
+ *
+ * @param node The DOM Element for the <class/> element.
+ * @param rootClass The mapping instance to which to bind the information.
+ * @param mappings The current bind state.
+ * @param inheritedMetas Any inherited meta-tag information.
+ * @throws MappingException
+ */
+ public static void bindRootClass(Element node, RootClass rootClass, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+ bindClass( node, rootClass, mappings, inheritedMetas );
+ inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <class>
+ bindRootPersistentClassCommonValues( node, inheritedMetas, mappings, rootClass );
+ }
+
+ private static void bindRootPersistentClassCommonValues(Element node,
+ java.util.Map inheritedMetas, Mappings mappings, RootClass entity)
+ throws MappingException {
+
+ // DB-OBJECTNAME
+
+ Attribute schemaNode = node.attribute( "schema" );
+ String schema = schemaNode == null ?
+ mappings.getSchemaName() : schemaNode.getValue();
+
+ Attribute catalogNode = node.attribute( "catalog" );
+ String catalog = catalogNode == null ?
+ mappings.getCatalogName() : catalogNode.getValue();
+
+ Table table = mappings.addTable(
+ schema,
+ catalog,
+ getClassTableName( entity, node, schema, catalog, null, mappings ),
+ getSubselect( node ),
+ entity.isAbstract() != null && entity.isAbstract().booleanValue()
+ );
+ entity.setTable( table );
+ bindComment(table, node);
+
+ log.info(
+ "Mapping class: " + entity.getEntityName() +
+ " -> " + entity.getTable().getName()
+ );
+
+ // MUTABLE
+ Attribute mutableNode = node.attribute( "mutable" );
+ entity.setMutable( ( mutableNode == null ) || mutableNode.getValue().equals( "true" ) );
+
+ // WHERE
+ Attribute whereNode = node.attribute( "where" );
+ if ( whereNode != null ) entity.setWhere( whereNode.getValue() );
+
+ // CHECK
+ Attribute chNode = node.attribute( "check" );
+ if ( chNode != null ) table.addCheckConstraint( chNode.getValue() );
+
+ // POLYMORPHISM
+ Attribute polyNode = node.attribute( "polymorphism" );
+ entity.setExplicitPolymorphism( ( polyNode != null )
+ && polyNode.getValue().equals( "explicit" ) );
+
+ // ROW ID
+ Attribute rowidNode = node.attribute( "rowid" );
+ if ( rowidNode != null ) table.setRowId( rowidNode.getValue() );
+
+ Iterator subnodes = node.elementIterator();
+ while ( subnodes.hasNext() ) {
+
+ Element subnode = (Element) subnodes.next();
+ String name = subnode.getName();
+
+ if ( "id".equals( name ) ) {
+ // ID
+ bindSimpleId( subnode, entity, mappings, inheritedMetas );
+ }
+ else if ( "composite-id".equals( name ) ) {
+ // COMPOSITE-ID
+ bindCompositeId( subnode, entity, mappings, inheritedMetas );
+ }
+ else if ( "version".equals( name ) || "timestamp".equals( name ) ) {
+ // VERSION / TIMESTAMP
+ bindVersioningProperty( table, subnode, mappings, name, entity, inheritedMetas );
+ }
+ else if ( "discriminator".equals( name ) ) {
+ // DISCRIMINATOR
+ bindDiscriminatorProperty( table, entity, subnode, mappings );
+ }
+ else if ( "cache".equals( name ) ) {
+ entity.setCacheConcurrencyStrategy( subnode.attributeValue( "usage" ) );
+ entity.setCacheRegionName( subnode.attributeValue( "region" ) );
+ entity.setLazyPropertiesCacheable( !"non-lazy".equals( subnode.attributeValue( "include" ) ) );
+ }
+
+ }
+
+ // Primary key constraint
+ entity.createPrimaryKey();
+
+ createClassProperties( node, entity, mappings, inheritedMetas );
+ }
+
+ private static void bindSimpleId(Element idNode, RootClass entity, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+ String propertyName = idNode.attributeValue( "name" );
+
+ SimpleValue id = new SimpleValue( entity.getTable() );
+ entity.setIdentifier( id );
+
+ // if ( propertyName == null || entity.getPojoRepresentation() == null ) {
+ // bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
+ // if ( !id.isTypeSpecified() ) {
+ // throw new MappingException( "must specify an identifier type: " + entity.getEntityName()
+ // );
+ // }
+ // }
+ // else {
+ // bindSimpleValue( idNode, id, false, propertyName, mappings );
+ // PojoRepresentation pojo = entity.getPojoRepresentation();
+ // id.setTypeUsingReflection( pojo.getClassName(), propertyName );
+ //
+ // Property prop = new Property();
+ // prop.setValue( id );
+ // bindProperty( idNode, prop, mappings, inheritedMetas );
+ // entity.setIdentifierProperty( prop );
+ // }
+
+ if ( propertyName == null ) {
+ bindSimpleValue( idNode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME, mappings );
+ }
+ else {
+ bindSimpleValue( idNode, id, false, propertyName, mappings );
+ }
+
+ if ( propertyName == null || !entity.hasPojoRepresentation() ) {
+ if ( !id.isTypeSpecified() ) {
+ throw new MappingException( "must specify an identifier type: "
+ + entity.getEntityName() );
+ }
+ }
+ else {
+ id.setTypeUsingReflection( entity.getClassName(), propertyName );
+ }
+
+ if ( propertyName != null ) {
+ Property prop = new Property();
+ prop.setValue( id );
+ bindProperty( idNode, prop, mappings, inheritedMetas );
+ entity.setIdentifierProperty( prop );
+ }
+
+ // TODO:
+ /*
+ * if ( id.getHibernateType().getReturnedClass().isArray() ) throw new MappingException(
+ * "illegal use of an array as an identifier (arrays don't reimplement equals)" );
+ */
+ makeIdentifier( idNode, id, mappings );
+ }
+
+ private static void bindCompositeId(Element idNode, RootClass entity, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+ String propertyName = idNode.attributeValue( "name" );
+ Component id = new Component( entity );
+ entity.setIdentifier( id );
+ bindCompositeId( idNode, id, entity, propertyName, mappings, inheritedMetas );
+ if ( propertyName == null ) {
+ entity.setEmbeddedIdentifier( id.isEmbedded() );
+ if ( id.isEmbedded() ) {
+ // todo : what is the implication of this?
+ id.setDynamic( !entity.hasPojoRepresentation() );
+ /*
+ * Property prop = new Property(); prop.setName("id");
+ * prop.setPropertyAccessorName("embedded"); prop.setValue(id);
+ * entity.setIdentifierProperty(prop);
+ */
+ }
+ }
+ else {
+ Property prop = new Property();
+ prop.setValue( id );
+ bindProperty( idNode, prop, mappings, inheritedMetas );
+ entity.setIdentifierProperty( prop );
+ }
+
+ makeIdentifier( idNode, id, mappings );
+
+ }
+
+ private static void bindVersioningProperty(Table table, Element subnode, Mappings mappings,
+ String name, RootClass entity, java.util.Map inheritedMetas) {
+
+ String propertyName = subnode.attributeValue( "name" );
+ SimpleValue val = new SimpleValue( table );
+ bindSimpleValue( subnode, val, false, propertyName, mappings );
+ if ( !val.isTypeSpecified() ) {
+ // this is either a <version/> tag with no type attribute,
+ // or a <timestamp/> tag
+ if ( "version".equals( name ) ) {
+ val.setTypeName( "integer" );
+ }
+ else {
+ if ( "db".equals( subnode.attributeValue( "source" ) ) ) {
+ val.setTypeName( "dbtimestamp" );
+ }
+ else {
+ val.setTypeName( "timestamp" );
+ }
+ }
+ }
+ Property prop = new Property();
+ prop.setValue( val );
+ bindProperty( subnode, prop, mappings, inheritedMetas );
+ // for version properties marked as being generated, make sure they are "always"
+ // generated; aka, "insert" is invalid; this is dis-allowed by the DTD,
+ // but just to make sure...
+ if ( prop.getGeneration() == PropertyGeneration.INSERT ) {
+ throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
+ }
+ makeVersion( subnode, val );
+ entity.setVersion( prop );
+ entity.addProperty( prop );
+ }
+
+ private static void bindDiscriminatorProperty(Table table, RootClass entity, Element subnode,
+ Mappings mappings) {
+ SimpleValue discrim = new SimpleValue( table );
+ entity.setDiscriminator( discrim );
+ bindSimpleValue(
+ subnode,
+ discrim,
+ false,
+ RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME,
+ mappings
+ );
+ if ( !discrim.isTypeSpecified() ) {
+ discrim.setTypeName( "string" );
+ // ( (Column) discrim.getColumnIterator().next() ).setType(type);
+ }
+ entity.setPolymorphic( true );
+ if ( "true".equals( subnode.attributeValue( "force" ) ) )
+ entity.setForceDiscriminator( true );
+ if ( "false".equals( subnode.attributeValue( "insert" ) ) )
+ entity.setDiscriminatorInsertable( false );
+ }
+
+ public static void bindClass(Element node, PersistentClass persistentClass, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+ // transfer an explicitly defined entity name
+ // handle the lazy attribute
+ Attribute lazyNode = node.attribute( "lazy" );
+ boolean lazy = lazyNode == null ?
+ mappings.isDefaultLazy() :
+ "true".equals( lazyNode.getValue() );
+ // go ahead and set the lazy here, since pojo.proxy can override it.
+ persistentClass.setLazy( lazy );
+
+ String entityName = node.attributeValue( "entity-name" );
+ if ( entityName == null ) entityName = getClassName( node.attribute("name"), mappings );
+ if ( entityName==null ) {
+ throw new MappingException( "Unable to determine entity name" );
+ }
+ persistentClass.setEntityName( entityName );
+
+ bindPojoRepresentation( node, persistentClass, mappings, inheritedMetas );
+ bindDom4jRepresentation( node, persistentClass, mappings, inheritedMetas );
+ bindMapRepresentation( node, persistentClass, mappings, inheritedMetas );
+
+ bindPersistentClassCommonValues( node, persistentClass, mappings, inheritedMetas );
+
+ }
+
+ private static void bindPojoRepresentation(Element node, PersistentClass entity,
+ Mappings mappings, java.util.Map metaTags) {
+
+ String className = getClassName( node.attribute( "name" ), mappings );
+ String proxyName = getClassName( node.attribute( "proxy" ), mappings );
+
+ entity.setClassName( className );
+
+ if ( proxyName != null ) {
+ entity.setProxyInterfaceName( proxyName );
+ entity.setLazy( true );
+ }
+ else if ( entity.isLazy() ) {
+ entity.setProxyInterfaceName( className );
+ }
+
+ Element tuplizer = locateTuplizerDefinition( node, EntityMode.POJO );
+ if ( tuplizer != null ) {
+ entity.addTuplizer( EntityMode.POJO, tuplizer.attributeValue( "class" ) );
+ }
+ }
+
+ private static void bindDom4jRepresentation(Element node, PersistentClass entity,
+ Mappings mappings, java.util.Map inheritedMetas) {
+ String nodeName = node.attributeValue( "node" );
+ if (nodeName==null) nodeName = StringHelper.unqualify( entity.getEntityName() );
+ entity.setNodeName(nodeName);
+
+ Element tuplizer = locateTuplizerDefinition( node, EntityMode.DOM4J );
+ if ( tuplizer != null ) {
+ entity.addTuplizer( EntityMode.DOM4J, tuplizer.attributeValue( "class" ) );
+ }
+ }
+
+ private static void bindMapRepresentation(Element node, PersistentClass entity,
+ Mappings mappings, java.util.Map inheritedMetas) {
+ Element tuplizer = locateTuplizerDefinition( node, EntityMode.MAP );
+ if ( tuplizer != null ) {
+ entity.addTuplizer( EntityMode.MAP, tuplizer.attributeValue( "class" ) );
+ }
+ }
+
+ /**
+ * Locate any explicit tuplizer definition in the metadata, for the given entity-mode.
+ *
+ * @param container The containing element (representing the entity/component)
+ * @param entityMode The entity-mode for which to locate the tuplizer element
+ * @return The tuplizer element, or null.
+ */
+ private static Element locateTuplizerDefinition(Element container, EntityMode entityMode) {
+ Iterator itr = container.elements( "tuplizer" ).iterator();
+ while( itr.hasNext() ) {
+ final Element tuplizerElem = ( Element ) itr.next();
+ if ( entityMode.toString().equals( tuplizerElem.attributeValue( "entity-mode") ) ) {
+ return tuplizerElem;
+ }
+ }
+ return null;
+ }
+
+ private static void bindPersistentClassCommonValues(Element node, PersistentClass entity,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ // DISCRIMINATOR
+ Attribute discriminatorNode = node.attribute( "discriminator-value" );
+ entity.setDiscriminatorValue( ( discriminatorNode == null )
+ ? entity.getEntityName()
+ : discriminatorNode.getValue() );
+
+ // DYNAMIC UPDATE
+ Attribute dynamicNode = node.attribute( "dynamic-update" );
+ entity.setDynamicUpdate(
+ dynamicNode != null && "true".equals( dynamicNode.getValue() )
+ );
+
+ // DYNAMIC INSERT
+ Attribute insertNode = node.attribute( "dynamic-insert" );
+ entity.setDynamicInsert(
+ insertNode != null && "true".equals( insertNode.getValue() )
+ );
+
+ // IMPORT
+ mappings.addImport( entity.getEntityName(), entity.getEntityName() );
+ if ( mappings.isAutoImport() && entity.getEntityName().indexOf( '.' ) > 0 ) {
+ mappings.addImport(
+ entity.getEntityName(),
+ StringHelper.unqualify( entity.getEntityName() )
+ );
+ }
+
+ // BATCH SIZE
+ Attribute batchNode = node.attribute( "batch-size" );
+ if ( batchNode != null ) entity.setBatchSize( Integer.parseInt( batchNode.getValue() ) );
+
+ // SELECT BEFORE UPDATE
+ Attribute sbuNode = node.attribute( "select-before-update" );
+ if ( sbuNode != null ) entity.setSelectBeforeUpdate( "true".equals( sbuNode.getValue() ) );
+
+ // OPTIMISTIC LOCK MODE
+ Attribute olNode = node.attribute( "optimistic-lock" );
+ entity.setOptimisticLockMode( getOptimisticLockMode( olNode ) );
+
+ entity.setMetaAttributes( getMetas( node, inheritedMetas ) );
+
+ // PERSISTER
+ Attribute persisterNode = node.attribute( "persister" );
+ if ( persisterNode != null ) {
+ try {
+ entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode
+ .getValue() ) );
+ }
+ catch (ClassNotFoundException cnfe) {
+ throw new MappingException( "Could not find persister class: "
+ + persisterNode.getValue() );
+ }
+ }
+
+ // CUSTOM SQL
+ handleCustomSQL( node, entity );
+
+ Iterator tables = node.elementIterator( "synchronize" );
+ while ( tables.hasNext() ) {
+ entity.addSynchronizedTable( ( (Element) tables.next() ).attributeValue( "table" ) );
+ }
+
+ Attribute abstractNode = node.attribute( "abstract" );
+ Boolean isAbstract = abstractNode == null
+ ? null
+ : "true".equals( abstractNode.getValue() )
+ ? Boolean.TRUE
+ : "false".equals( abstractNode.getValue() )
+ ? Boolean.FALSE
+ : null;
+ entity.setAbstract( isAbstract );
+ }
+
+ private static void handleCustomSQL(Element node, PersistentClass model)
+ throws MappingException {
+ Element element = node.element( "sql-insert" );
+ if ( element != null ) {
+ boolean callable = isCallable( element );
+ model.setCustomSQLInsert( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-delete" );
+ if ( element != null ) {
+ boolean callable = isCallable( element );
+ model.setCustomSQLDelete( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-update" );
+ if ( element != null ) {
+ boolean callable = isCallable( element );
+ model.setCustomSQLUpdate( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "loader" );
+ if ( element != null ) {
+ model.setLoaderName( element.attributeValue( "query-ref" ) );
+ }
+ }
+
+ private static void handleCustomSQL(Element node, Join model) throws MappingException {
+ Element element = node.element( "sql-insert" );
+ if ( element != null ) {
+ boolean callable = isCallable( element );
+ model.setCustomSQLInsert( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-delete" );
+ if ( element != null ) {
+ boolean callable = isCallable( element );
+ model.setCustomSQLDelete( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-update" );
+ if ( element != null ) {
+ boolean callable = isCallable( element );
+ model.setCustomSQLUpdate( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+ }
+
+ private static void handleCustomSQL(Element node, Collection model) throws MappingException {
+ Element element = node.element( "sql-insert" );
+ if ( element != null ) {
+ boolean callable = isCallable( element, true );
+ model.setCustomSQLInsert( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-delete" );
+ if ( element != null ) {
+ boolean callable = isCallable( element, true );
+ model.setCustomSQLDelete( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-update" );
+ if ( element != null ) {
+ boolean callable = isCallable( element, true );
+ model.setCustomSQLUpdate( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+
+ element = node.element( "sql-delete-all" );
+ if ( element != null ) {
+ boolean callable = isCallable( element, true );
+ model.setCustomSQLDeleteAll( element.getTextTrim(), callable, getResultCheckStyle( element, callable ) );
+ }
+ }
+
+ private static boolean isCallable(Element e) throws MappingException {
+ return isCallable( e, true );
+ }
+
+ private static boolean isCallable(Element element, boolean supportsCallable)
+ throws MappingException {
+ Attribute attrib = element.attribute( "callable" );
+ if ( attrib != null && "true".equals( attrib.getValue() ) ) {
+ if ( !supportsCallable ) {
+ throw new MappingException( "callable attribute not supported yet!" );
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private static ExecuteUpdateResultCheckStyle getResultCheckStyle(Element element, boolean callable) throws MappingException {
+ Attribute attr = element.attribute( "check" );
+ if ( attr == null ) {
+ // use COUNT as the default. This mimics the old behavior, although
+ // NONE might be a better option moving forward in the case of callable
+ return ExecuteUpdateResultCheckStyle.COUNT;
+ }
+ return ExecuteUpdateResultCheckStyle.parse( attr.getValue() );
+ }
+
+ public static void bindUnionSubclass(Element node, UnionSubclass unionSubclass,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+
+ bindClass( node, unionSubclass, mappings, inheritedMetas );
+ inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <subclass>
+
+ if ( unionSubclass.getEntityPersisterClass() == null ) {
+ unionSubclass.getRootClass().setEntityPersisterClass(
+ UnionSubclassEntityPersister.class );
+ }
+
+ Attribute schemaNode = node.attribute( "schema" );
+ String schema = schemaNode == null ?
+ mappings.getSchemaName() : schemaNode.getValue();
+
+ Attribute catalogNode = node.attribute( "catalog" );
+ String catalog = catalogNode == null ?
+ mappings.getCatalogName() : catalogNode.getValue();
+
+ Table denormalizedSuperTable = unionSubclass.getSuperclass().getTable();
+ Table mytable = mappings.addDenormalizedTable(
+ schema,
+ catalog,
+ getClassTableName(unionSubclass, node, schema, catalog, denormalizedSuperTable, mappings ),
+ unionSubclass.isAbstract() != null && unionSubclass.isAbstract().booleanValue(),
+ getSubselect( node ),
+ denormalizedSuperTable
+ );
+ unionSubclass.setTable( mytable );
+
+ log.info(
+ "Mapping union-subclass: " + unionSubclass.getEntityName() +
+ " -> " + unionSubclass.getTable().getName()
+ );
+
+ createClassProperties( node, unionSubclass, mappings, inheritedMetas );
+
+ }
+
+ public static void bindSubclass(Element node, Subclass subclass, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+
+ bindClass( node, subclass, mappings, inheritedMetas );
+ inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from <subclass>
+
+ if ( subclass.getEntityPersisterClass() == null ) {
+ subclass.getRootClass()
+ .setEntityPersisterClass( SingleTableEntityPersister.class );
+ }
+
+ log.info(
+ "Mapping subclass: " + subclass.getEntityName() +
+ " -> " + subclass.getTable().getName()
+ );
+
+ // properties
+ createClassProperties( node, subclass, mappings, inheritedMetas );
+ }
+
+ private static String getClassTableName(
+ PersistentClass model, Element node, String schema, String catalog, Table denormalizedSuperTable,
+ Mappings mappings
+ ) {
+ Attribute tableNameNode = node.attribute( "table" );
+ String logicalTableName;
+ String physicalTableName;
+ if ( tableNameNode == null ) {
+ logicalTableName = StringHelper.unqualify( model.getEntityName() );
+ physicalTableName = mappings.getNamingStrategy().classToTableName( model.getEntityName() );
+ }
+ else {
+ logicalTableName = tableNameNode.getValue();
+ physicalTableName = mappings.getNamingStrategy().tableName( logicalTableName );
+ }
+ mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
+ return physicalTableName;
+ }
+
+ public static void bindJoinedSubclass(Element node, JoinedSubclass joinedSubclass,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+
+ bindClass( node, joinedSubclass, mappings, inheritedMetas );
+ inheritedMetas = getMetas( node, inheritedMetas, true ); // get meta's from
+ // <joined-subclass>
+
+ // joined subclasses
+ if ( joinedSubclass.getEntityPersisterClass() == null ) {
+ joinedSubclass.getRootClass()
+ .setEntityPersisterClass( JoinedSubclassEntityPersister.class );
+ }
+
+ Attribute schemaNode = node.attribute( "schema" );
+ String schema = schemaNode == null ?
+ mappings.getSchemaName() : schemaNode.getValue();
+
+ Attribute catalogNode = node.attribute( "catalog" );
+ String catalog = catalogNode == null ?
+ mappings.getCatalogName() : catalogNode.getValue();
+
+ Table mytable = mappings.addTable(
+ schema,
+ catalog,
+ getClassTableName( joinedSubclass, node, schema, catalog, null, mappings ),
+ getSubselect( node ),
+ false
+ );
+ joinedSubclass.setTable( mytable );
+ bindComment(mytable, node);
+
+ log.info(
+ "Mapping joined-subclass: " + joinedSubclass.getEntityName() +
+ " -> " + joinedSubclass.getTable().getName()
+ );
+
+ // KEY
+ Element keyNode = node.element( "key" );
+ SimpleValue key = new DependantValue( mytable, joinedSubclass.getIdentifier() );
+ joinedSubclass.setKey( key );
+ key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
+ bindSimpleValue( keyNode, key, false, joinedSubclass.getEntityName(), mappings );
+
+ // model.getKey().setType( new Type( model.getIdentifier() ) );
+ joinedSubclass.createPrimaryKey();
+ joinedSubclass.createForeignKey();
+
+ // CHECK
+ Attribute chNode = node.attribute( "check" );
+ if ( chNode != null ) mytable.addCheckConstraint( chNode.getValue() );
+
+ // properties
+ createClassProperties( node, joinedSubclass, mappings, inheritedMetas );
+
+ }
+
+ private static void bindJoin(Element node, Join join, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+
+ PersistentClass persistentClass = join.getPersistentClass();
+ String path = persistentClass.getEntityName();
+
+ // TABLENAME
+
+ Attribute schemaNode = node.attribute( "schema" );
+ String schema = schemaNode == null ?
+ mappings.getSchemaName() : schemaNode.getValue();
+ Attribute catalogNode = node.attribute( "catalog" );
+ String catalog = catalogNode == null ?
+ mappings.getCatalogName() : catalogNode.getValue();
+ Table primaryTable = persistentClass.getTable();
+ Table table = mappings.addTable(
+ schema,
+ catalog,
+ getClassTableName( persistentClass, node, schema, catalog, primaryTable, mappings ),
+ getSubselect( node ),
+ false
+ );
+ join.setTable( table );
+ bindComment(table, node);
+
+ Attribute fetchNode = node.attribute( "fetch" );
+ if ( fetchNode != null ) {
+ join.setSequentialSelect( "select".equals( fetchNode.getValue() ) );
+ }
+
+ Attribute invNode = node.attribute( "inverse" );
+ if ( invNode != null ) {
+ join.setInverse( "true".equals( invNode.getValue() ) );
+ }
+
+ Attribute nullNode = node.attribute( "optional" );
+ if ( nullNode != null ) {
+ join.setOptional( "true".equals( nullNode.getValue() ) );
+ }
+
+ log.info(
+ "Mapping class join: " + persistentClass.getEntityName() +
+ " -> " + join.getTable().getName()
+ );
+
+ // KEY
+ Element keyNode = node.element( "key" );
+ SimpleValue key = new DependantValue( table, persistentClass.getIdentifier() );
+ join.setKey( key );
+ key.setCascadeDeleteEnabled( "cascade".equals( keyNode.attributeValue( "on-delete" ) ) );
+ bindSimpleValue( keyNode, key, false, persistentClass.getEntityName(), mappings );
+
+ // join.getKey().setType( new Type( lazz.getIdentifier() ) );
+ join.createPrimaryKey();
+ join.createForeignKey();
+
+ // PROPERTIES
+ Iterator iter = node.elementIterator();
+ while ( iter.hasNext() ) {
+ Element subnode = (Element) iter.next();
+ String name = subnode.getName();
+ String propertyName = subnode.attributeValue( "name" );
+
+ Value value = null;
+ if ( "many-to-one".equals( name ) ) {
+ value = new ManyToOne( table );
+ bindManyToOne( subnode, (ManyToOne) value, propertyName, true, mappings );
+ }
+ else if ( "any".equals( name ) ) {
+ value = new Any( table );
+ bindAny( subnode, (Any) value, true, mappings );
+ }
+ else if ( "property".equals( name ) ) {
+ value = new SimpleValue( table );
+ bindSimpleValue( subnode, (SimpleValue) value, true, propertyName, mappings );
+ }
+ else if ( "component".equals( name ) || "dynamic-component".equals( name ) ) {
+ String subpath = StringHelper.qualify( path, propertyName );
+ value = new Component( join );
+ bindComponent(
+ subnode,
+ (Component) value,
+ join.getPersistentClass().getClassName(),
+ propertyName,
+ subpath,
+ true,
+ false,
+ mappings,
+ inheritedMetas,
+ false
+ );
+ }
+
+ if ( value != null ) {
+ Property prop = createProperty( value, propertyName, persistentClass
+ .getEntityName(), subnode, mappings, inheritedMetas );
+ prop.setOptional( join.isOptional() );
+ join.addProperty( prop );
+ }
+
+ }
+
+ // CUSTOM SQL
+ handleCustomSQL( node, join );
+
+ }
+
+ public static void bindColumns(final Element node, final SimpleValue simpleValue,
+ final boolean isNullable, final boolean autoColumn, final String propertyPath,
+ final Mappings mappings) throws MappingException {
+
+ Table table = simpleValue.getTable();
+
+ // COLUMN(S)
+ Attribute columnAttribute = node.attribute( "column" );
+ if ( columnAttribute == null ) {
+ Iterator iter = node.elementIterator();
+ int count = 0;
+ while ( iter.hasNext() ) {
+ Element columnElement = (Element) iter.next();
+ if ( columnElement.getName().equals( "column" ) ) {
+ Column column = new Column();
+ column.setValue( simpleValue );
+ column.setTypeIndex( count++ );
+ bindColumn( columnElement, column, isNullable );
+ String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
+ columnElement.attributeValue( "name" ), propertyPath
+ );
+ column.setName( mappings.getNamingStrategy().columnName(
+ logicalColumnName ) );
+ if ( table != null ) {
+ table.addColumn( column ); // table=null -> an association
+ // - fill it in later
+ //TODO fill in the mappings for table == null
+ mappings.addColumnBinding( logicalColumnName, column, table );
+ }
+
+
+ simpleValue.addColumn( column );
+ // column index
+ bindIndex( columnElement.attribute( "index" ), table, column, mappings );
+ bindIndex( node.attribute( "index" ), table, column, mappings );
+ //column unique-key
+ bindUniqueKey( columnElement.attribute( "unique-key" ), table, column, mappings );
+ bindUniqueKey( node.attribute( "unique-key" ), table, column, mappings );
+ }
+ else if ( columnElement.getName().equals( "formula" ) ) {
+ Formula formula = new Formula();
+ formula.setFormula( columnElement.getText() );
+ simpleValue.addFormula( formula );
+ }
+ }
+ }
+ else {
+ if ( node.elementIterator( "column" ).hasNext() ) {
+ throw new MappingException(
+ "column attribute may not be used together with <column> subelement" );
+ }
+ if ( node.elementIterator( "formula" ).hasNext() ) {
+ throw new MappingException(
+ "column attribute may not be used together with <formula> subelement" );
+ }
+
+ Column column = new Column();
+ column.setValue( simpleValue );
+ bindColumn( node, column, isNullable );
+ String logicalColumnName = mappings.getNamingStrategy().logicalColumnName(
+ columnAttribute.getValue(), propertyPath
+ );
+ column.setName( mappings.getNamingStrategy().columnName( logicalColumnName ) );
+ if ( table != null ) {
+ table.addColumn( column ); // table=null -> an association - fill
+ // it in later
+ //TODO fill in the mappings for table == null
+ mappings.addColumnBinding( logicalColumnName, column, table );
+ }
+ simpleValue.addColumn( column );
+ bindIndex( node.attribute( "index" ), table, column, mappings );
+ bindUniqueKey( node.attribute( "unique-key" ), table, column, mappings );
+ }
+
+ if ( autoColumn && simpleValue.getColumnSpan() == 0 ) {
+ Column column = new Column();
+ column.setValue( simpleValue );
+ bindColumn( node, column, isNullable );
+ column.setName( mappings.getNamingStrategy().propertyToColumnName( propertyPath ) );
+ String logicalName = mappings.getNamingStrategy().logicalColumnName( null, propertyPath );
+ mappings.addColumnBinding( logicalName, column, table );
+ /* TODO: joinKeyColumnName & foreignKeyColumnName should be called either here or at a
+ * slightly higer level in the stack (to get all the information we need)
+ * Right now HbmBinder does not support the
+ */
+ simpleValue.getTable().addColumn( column );
+ simpleValue.addColumn( column );
+ bindIndex( node.attribute( "index" ), table, column, mappings );
+ bindUniqueKey( node.attribute( "unique-key" ), table, column, mappings );
+ }
+
+ }
+
+ private static void bindIndex(Attribute indexAttribute, Table table, Column column, Mappings mappings) {
+ if ( indexAttribute != null && table != null ) {
+ StringTokenizer tokens = new StringTokenizer( indexAttribute.getValue(), ", " );
+ while ( tokens.hasMoreTokens() ) {
+ table.getOrCreateIndex( tokens.nextToken() ).addColumn( column );
+ }
+ }
+ }
+
+ private static void bindUniqueKey(Attribute uniqueKeyAttribute, Table table, Column column, Mappings mappings) {
+ if ( uniqueKeyAttribute != null && table != null ) {
+ StringTokenizer tokens = new StringTokenizer( uniqueKeyAttribute.getValue(), ", " );
+ while ( tokens.hasMoreTokens() ) {
+ table.getOrCreateUniqueKey( tokens.nextToken() ).addColumn( column );
+ }
+ }
+ }
+
+ // automatically makes a column with the default name if none is specifed by XML
+ public static void bindSimpleValue(Element node, SimpleValue simpleValue, boolean isNullable,
+ String path, Mappings mappings) throws MappingException {
+ bindSimpleValueType( node, simpleValue, mappings );
+
+ bindColumnsOrFormula( node, simpleValue, path, isNullable, mappings );
+
+ Attribute fkNode = node.attribute( "foreign-key" );
+ if ( fkNode != null ) simpleValue.setForeignKeyName( fkNode.getValue() );
+ }
+
+ private static void bindSimpleValueType(Element node, SimpleValue simpleValue, Mappings mappings)
+ throws MappingException {
+ String typeName = null;
+
+ Properties parameters = new Properties();
+
+ Attribute typeNode = node.attribute( "type" );
+ if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any
+ if ( typeNode != null ) typeName = typeNode.getValue();
+
+ Element typeChild = node.element( "type" );
+ if ( typeName == null && typeChild != null ) {
+ typeName = typeChild.attribute( "name" ).getValue();
+ Iterator typeParameters = typeChild.elementIterator( "param" );
+
+ while ( typeParameters.hasNext() ) {
+ Element paramElement = (Element) typeParameters.next();
+ parameters.setProperty(
+ paramElement.attributeValue( "name" ),
+ paramElement.getTextTrim()
+ );
+ }
+ }
+
+ TypeDef typeDef = mappings.getTypeDef( typeName );
+ if ( typeDef != null ) {
+ typeName = typeDef.getTypeClass();
+ // parameters on the property mapping should
+ // override parameters in the typedef
+ Properties allParameters = new Properties();
+ allParameters.putAll( typeDef.getParameters() );
+ allParameters.putAll( parameters );
+ parameters = allParameters;
+ }
+
+ if ( !parameters.isEmpty() ) simpleValue.setTypeParameters( parameters );
+
+ if ( typeName != null ) simpleValue.setTypeName( typeName );
+ }
+
+ public static void bindProperty(
+ Element node,
+ Property property,
+ Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+
+ String propName = node.attributeValue( "name" );
+ property.setName( propName );
+ String nodeName = node.attributeValue( "node" );
+ if (nodeName==null) nodeName = propName;
+ property.setNodeName( nodeName );
+
+ // TODO:
+ //Type type = model.getValue().getType();
+ //if (type==null) throw new MappingException(
+ //"Could not determine a property type for: " + model.getName() );
+
+ Attribute accessNode = node.attribute( "access" );
+ if ( accessNode != null ) {
+ property.setPropertyAccessorName( accessNode.getValue() );
+ }
+ else if ( node.getName().equals( "properties" ) ) {
+ property.setPropertyAccessorName( "embedded" );
+ }
+ else {
+ property.setPropertyAccessorName( mappings.getDefaultAccess() );
+ }
+
+ Attribute cascadeNode = node.attribute( "cascade" );
+ property.setCascade( cascadeNode == null ? mappings.getDefaultCascade() : cascadeNode
+ .getValue() );
+
+ Attribute updateNode = node.attribute( "update" );
+ property.setUpdateable( updateNode == null || "true".equals( updateNode.getValue() ) );
+
+ Attribute insertNode = node.attribute( "insert" );
+ property.setInsertable( insertNode == null || "true".equals( insertNode.getValue() ) );
+
+ Attribute lockNode = node.attribute( "optimistic-lock" );
+ property.setOptimisticLocked( lockNode == null || "true".equals( lockNode.getValue() ) );
+
+ Attribute generatedNode = node.attribute( "generated" );
+ String generationName = generatedNode == null ? null : generatedNode.getValue();
+ PropertyGeneration generation = PropertyGeneration.parse( generationName );
+ property.setGeneration( generation );
+
+ if ( generation == PropertyGeneration.ALWAYS || generation == PropertyGeneration.INSERT ) {
+ // generated properties can *never* be insertable...
+ if ( property.isInsertable() ) {
+ if ( insertNode == null ) {
+ // insertable simply because that is the user did not specify
+ // anything; just override it
+ property.setInsertable( false );
+ }
+ else {
+ // the user specifically supplied insert="true",
+ // which constitutes an illegal combo
+ throw new MappingException(
+ "cannot specify both insert=\"true\" and generated=\"" + generation.getName() +
+ "\" for property: " +
+ propName
+ );
+ }
+ }
+
+ // properties generated on update can never be updateable...
+ if ( property.isUpdateable() && generation == PropertyGeneration.ALWAYS ) {
+ if ( updateNode == null ) {
+ // updateable only because the user did not specify
+ // anything; just override it
+ property.setUpdateable( false );
+ }
+ else {
+ // the user specifically supplied update="true",
+ // which constitutes an illegal combo
+ throw new MappingException(
+ "cannot specify both update=\"true\" and generated=\"" + generation.getName() +
+ "\" for property: " +
+ propName
+ );
+ }
+ }
+ }
+
+ boolean isLazyable = "property".equals( node.getName() ) ||
+ "component".equals( node.getName() ) ||
+ "many-to-one".equals( node.getName() ) ||
+ "one-to-one".equals( node.getName() ) ||
+ "any".equals( node.getName() );
+ if ( isLazyable ) {
+ Attribute lazyNode = node.attribute( "lazy" );
+ property.setLazy( lazyNode != null && "true".equals( lazyNode.getValue() ) );
+ }
+
+ if ( log.isDebugEnabled() ) {
+ String msg = "Mapped property: " + property.getName();
+ String columns = columns( property.getValue() );
+ if ( columns.length() > 0 ) msg += " -> " + columns;
+ // TODO: this fails if we run with debug on!
+ // if ( model.getType()!=null ) msg += ", type: " + model.getType().getName();
+ log.debug( msg );
+ }
+
+ property.setMetaAttributes( getMetas( node, inheritedMetas ) );
+
+ }
+
+ private static String columns(Value val) {
+ StringBuffer columns = new StringBuffer();
+ Iterator iter = val.getColumnIterator();
+ while ( iter.hasNext() ) {
+ columns.append( ( (Selectable) iter.next() ).getText() );
+ if ( iter.hasNext() ) columns.append( ", " );
+ }
+ return columns.toString();
+ }
+
+ /**
+ * Called for all collections
+ */
+ public static void bindCollection(Element node, Collection collection, String className,
+ String path, Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+
+ // ROLENAME
+ collection.setRole(path);
+
+ Attribute inverseNode = node.attribute( "inverse" );
+ if ( inverseNode != null ) {
+ collection.setInverse( "true".equals( inverseNode.getValue() ) );
+ }
+
+ Attribute mutableNode = node.attribute( "mutable" );
+ if ( mutableNode != null ) {
+ collection.setMutable( !"false".equals( mutableNode.getValue() ) );
+ }
+
+ Attribute olNode = node.attribute( "optimistic-lock" );
+ collection.setOptimisticLocked( olNode == null || "true".equals( olNode.getValue() ) );
+
+ Attribute orderNode = node.attribute( "order-by" );
+ if ( orderNode != null ) {
+ if ( Environment.jvmSupportsLinkedHashCollections() || ( collection instanceof Bag ) ) {
+ collection.setOrderBy( orderNode.getValue() );
+ }
+ else {
+ log.warn( "Attribute \"order-by\" ignored in JDK1.3 or less" );
+ }
+ }
+ Attribute whereNode = node.attribute( "where" );
+ if ( whereNode != null ) {
+ collection.setWhere( whereNode.getValue() );
+ }
+ Attribute batchNode = node.attribute( "batch-size" );
+ if ( batchNode != null ) {
+ collection.setBatchSize( Integer.parseInt( batchNode.getValue() ) );
+ }
+
+ String nodeName = node.attributeValue( "node" );
+ if ( nodeName == null ) nodeName = node.attributeValue( "name" );
+ collection.setNodeName( nodeName );
+ String embed = node.attributeValue( "embed-xml" );
+ collection.setEmbedded( embed==null || "true".equals(embed) );
+
+
+ // PERSISTER
+ Attribute persisterNode = node.attribute( "persister" );
+ if ( persisterNode != null ) {
+ try {
+ collection.setCollectionPersisterClass( ReflectHelper.classForName( persisterNode
+ .getValue() ) );
+ }
+ catch (ClassNotFoundException cnfe) {
+ throw new MappingException( "Could not find collection persister class: "
+ + persisterNode.getValue() );
+ }
+ }
+
+ Attribute typeNode = node.attribute( "collection-type" );
+ if ( typeNode != null ) {
+ String typeName = typeNode.getValue();
+ TypeDef typeDef = mappings.getTypeDef( typeName );
+ if ( typeDef != null ) {
+ collection.setTypeName( typeDef.getTypeClass() );
+ collection.setTypeParameters( typeDef.getParameters() );
+ }
+ else {
+ collection.setTypeName( typeName );
+ }
+ }
+
+ // FETCH STRATEGY
+
+ initOuterJoinFetchSetting( node, collection );
+
+ if ( "subselect".equals( node.attributeValue("fetch") ) ) {
+ collection.setSubselectLoadable(true);
+ collection.getOwner().setSubselectLoadableCollections(true);
+ }
+
+ initLaziness( node, collection, mappings, "true", mappings.isDefaultLazy() );
+ //TODO: suck this into initLaziness!
+ if ( "extra".equals( node.attributeValue("lazy") ) ) {
+ collection.setLazy(true);
+ collection.setExtraLazy(true);
+ }
+
+ Element oneToManyNode = node.element( "one-to-many" );
+ if ( oneToManyNode != null ) {
+ OneToMany oneToMany = new OneToMany( collection.getOwner() );
+ collection.setElement( oneToMany );
+ bindOneToMany( oneToManyNode, oneToMany, mappings );
+ // we have to set up the table later!! yuck
+ }
+ else {
+ // TABLE
+ Attribute tableNode = node.attribute( "table" );
+ String tableName;
+ if ( tableNode != null ) {
+ tableName = mappings.getNamingStrategy().tableName( tableNode.getValue() );
+ }
+ else {
+ //tableName = mappings.getNamingStrategy().propertyToTableName( className, path );
+ Table ownerTable = collection.getOwner().getTable();
+ //TODO mappings.getLogicalTableName(ownerTable)
+ String logicalOwnerTableName = ownerTable.getName();
+ //FIXME we don't have the associated entity table name here, has to be done in a second pass
+ tableName = mappings.getNamingStrategy().collectionTableName(
+ collection.getOwner().getEntityName(),
+ logicalOwnerTableName ,
+ null,
+ null,
+ path
+ );
+ }
+ Attribute schemaNode = node.attribute( "schema" );
+ String schema = schemaNode == null ?
+ mappings.getSchemaName() : schemaNode.getValue();
+
+ Attribute catalogNode = node.attribute( "catalog" );
+ String catalog = catalogNode == null ?
+ mappings.getCatalogName() : catalogNode.getValue();
+
+ Table table = mappings.addTable(
+ schema,
+ catalog,
+ tableName,
+ getSubselect( node ),
+ false
+ );
+ collection.setCollectionTable( table );
+ bindComment(table, node);
+
+ log.info(
+ "Mapping collection: " + collection.getRole() +
+ " -> " + collection.getCollectionTable().getName()
+ );
+ }
+
+ // SORT
+ Attribute sortedAtt = node.attribute( "sort" );
+ // unsorted, natural, comparator.class.name
+ if ( sortedAtt == null || sortedAtt.getValue().equals( "unsorted" ) ) {
+ collection.setSorted( false );
+ }
+ else {
+ collection.setSorted( true );
+ String comparatorClassName = sortedAtt.getValue();
+ if ( !comparatorClassName.equals( "natural" ) ) {
+ collection.setComparatorClassName(comparatorClassName);
+ }
+ }
+
+ // ORPHAN DELETE (used for programmer error detection)
+ Attribute cascadeAtt = node.attribute( "cascade" );
+ if ( cascadeAtt != null && cascadeAtt.getValue().indexOf( "delete-orphan" ) >= 0 ) {
+ collection.setOrphanDelete( true );
+ }
+
+ // CUSTOM SQL
+ handleCustomSQL( node, collection );
+ // set up second pass
+ if ( collection instanceof List ) {
+ mappings.addSecondPass( new ListSecondPass( node, mappings, (List) collection, inheritedMetas ) );
+ }
+ else if ( collection instanceof Map ) {
+ mappings.addSecondPass( new MapSecondPass( node, mappings, (Map) collection, inheritedMetas ) );
+ }
+ else if ( collection instanceof IdentifierCollection ) {
+ mappings.addSecondPass( new IdentifierCollectionSecondPass(
+ node,
+ mappings,
+ collection,
+ inheritedMetas
+ ) );
+ }
+ else {
+ mappings.addSecondPass( new CollectionSecondPass( node, mappings, collection, inheritedMetas ) );
+ }
+
+ Iterator iter = node.elementIterator( "filter" );
+ while ( iter.hasNext() ) {
+ final Element filter = (Element) iter.next();
+ parseFilter( filter, collection, mappings );
+ }
+
+ Iterator tables = node.elementIterator( "synchronize" );
+ while ( tables.hasNext() ) {
+ collection.getSynchronizedTables().add(
+ ( (Element) tables.next() ).attributeValue( "table" ) );
+ }
+
+ Element element = node.element( "loader" );
+ if ( element != null ) {
+ collection.setLoaderName( element.attributeValue( "query-ref" ) );
+ }
+
+ collection.setReferencedPropertyName( node.element( "key" ).attributeValue( "property-ref" ) );
+ }
+
+ private static void initLaziness(
+ Element node,
+ Fetchable fetchable,
+ Mappings mappings,
+ String proxyVal,
+ boolean defaultLazy
+ ) {
+ Attribute lazyNode = node.attribute( "lazy" );
+ boolean isLazyTrue = lazyNode == null ?
+ defaultLazy && fetchable.isLazy() : //fetch="join" overrides default laziness
+ lazyNode.getValue().equals(proxyVal); //fetch="join" overrides default laziness
+ fetchable.setLazy( isLazyTrue );
+ }
+
+ private static void initLaziness(
+ Element node,
+ ToOne fetchable,
+ Mappings mappings,
+ boolean defaultLazy
+ ) {
+ if ( "no-proxy".equals( node.attributeValue( "lazy" ) ) ) {
+ fetchable.setUnwrapProxy(true);
+ fetchable.setLazy(true);
+ //TODO: better to degrade to lazy="false" if uninstrumented
+ }
+ else {
+ initLaziness(node, fetchable, mappings, "proxy", defaultLazy);
+ }
+ }
+
+ private static void bindColumnsOrFormula(Element node, SimpleValue simpleValue, String path,
+ boolean isNullable, Mappings mappings) {
+ Attribute formulaNode = node.attribute( "formula" );
+ if ( formulaNode != null ) {
+ Formula f = new Formula();
+ f.setFormula( formulaNode.getText() );
+ simpleValue.addFormula( f );
+ }
+ else {
+ bindColumns( node, simpleValue, isNullable, true, path, mappings );
+ }
+ }
+
+ private static void bindComment(Table table, Element node) {
+ Element comment = node.element("comment");
+ if (comment!=null) table.setComment( comment.getTextTrim() );
+ }
+
+ public static void bindManyToOne(Element node, ManyToOne manyToOne, String path,
+ boolean isNullable, Mappings mappings) throws MappingException {
+
+ bindColumnsOrFormula( node, manyToOne, path, isNullable, mappings );
+ initOuterJoinFetchSetting( node, manyToOne );
+ initLaziness( node, manyToOne, mappings, true );
+
+ Attribute ukName = node.attribute( "property-ref" );
+ if ( ukName != null ) {
+ manyToOne.setReferencedPropertyName( ukName.getValue() );
+ }
+
+ manyToOne.setReferencedEntityName( getEntityName( node, mappings ) );
+
+ String embed = node.attributeValue( "embed-xml" );
+ manyToOne.setEmbedded( embed == null || "true".equals( embed ) );
+
+ String notFound = node.attributeValue( "not-found" );
+ manyToOne.setIgnoreNotFound( "ignore".equals( notFound ) );
+
+ if( ukName != null && !manyToOne.isIgnoreNotFound() ) {
+ if ( !node.getName().equals("many-to-many") ) { //TODO: really bad, evil hack to fix!!!
+ mappings.addSecondPass( new ManyToOneSecondPass(manyToOne) );
+ }
+ }
+
+ Attribute fkNode = node.attribute( "foreign-key" );
+ if ( fkNode != null ) manyToOne.setForeignKeyName( fkNode.getValue() );
+
+ validateCascade( node, path );
+ }
+
+ private static void validateCascade(Element node, String path) {
+ String cascade = node.attributeValue( "cascade" );
+ if ( cascade != null && cascade.indexOf( "delete-orphan" ) >= 0 ) {
+ throw new MappingException( "single-valued associations do not support orphan delete: " + path );
+ }
+ }
+
+ public static void bindAny(Element node, Any any, boolean isNullable, Mappings mappings)
+ throws MappingException {
+ any.setIdentifierType( getTypeFromXML( node ) );
+ Attribute metaAttribute = node.attribute( "meta-type" );
+ if ( metaAttribute != null ) {
+ any.setMetaType( metaAttribute.getValue() );
+
+ Iterator iter = node.elementIterator( "meta-value" );
+ if ( iter.hasNext() ) {
+ HashMap values = new HashMap();
+ org.hibernate.type.Type metaType = TypeFactory.heuristicType( any.getMetaType() );
+ while ( iter.hasNext() ) {
+ Element metaValue = (Element) iter.next();
+ try {
+ Object value = ( (DiscriminatorType) metaType ).stringToObject( metaValue
+ .attributeValue( "value" ) );
+ String entityName = getClassName( metaValue.attribute( "class" ), mappings );
+ values.put( value, entityName );
+ }
+ catch (ClassCastException cce) {
+ throw new MappingException( "meta-type was not a DiscriminatorType: "
+ + metaType.getName() );
+ }
+ catch (Exception e) {
+ throw new MappingException( "could not interpret meta-value", e );
+ }
+ }
+ any.setMetaValues( values );
+ }
+
+ }
+
+ bindColumns( node, any, isNullable, false, null, mappings );
+ }
+
+ public static void bindOneToOne(Element node, OneToOne oneToOne, String path, boolean isNullable,
+ Mappings mappings) throws MappingException {
+
+ bindColumns( node, oneToOne, isNullable, false, null, mappings );
+
+ Attribute constrNode = node.attribute( "constrained" );
+ boolean constrained = constrNode != null && constrNode.getValue().equals( "true" );
+ oneToOne.setConstrained( constrained );
+
+ oneToOne.setForeignKeyType( constrained ?
+ ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT :
+ ForeignKeyDirection.FOREIGN_KEY_TO_PARENT );
+
+ initOuterJoinFetchSetting( node, oneToOne );
+ initLaziness( node, oneToOne, mappings, true );
+
+ oneToOne.setEmbedded( "true".equals( node.attributeValue( "embed-xml" ) ) );
+
+ Attribute fkNode = node.attribute( "foreign-key" );
+ if ( fkNode != null ) oneToOne.setForeignKeyName( fkNode.getValue() );
+
+ Attribute ukName = node.attribute( "property-ref" );
+ if ( ukName != null ) oneToOne.setReferencedPropertyName( ukName.getValue() );
+
+ oneToOne.setPropertyName( node.attributeValue( "name" ) );
+
+ oneToOne.setReferencedEntityName( getEntityName( node, mappings ) );
+
+ validateCascade( node, path );
+ }
+
+ public static void bindOneToMany(Element node, OneToMany oneToMany, Mappings mappings)
+ throws MappingException {
+
+ oneToMany.setReferencedEntityName( getEntityName( node, mappings ) );
+
+ String embed = node.attributeValue( "embed-xml" );
+ oneToMany.setEmbedded( embed == null || "true".equals( embed ) );
+
+ String notFound = node.attributeValue( "not-found" );
+ oneToMany.setIgnoreNotFound( "ignore".equals( notFound ) );
+
+ }
+
+ public static void bindColumn(Element node, Column column, boolean isNullable) {
+ Attribute lengthNode = node.attribute( "length" );
+ if ( lengthNode != null ) column.setLength( Integer.parseInt( lengthNode.getValue() ) );
+ Attribute scalNode = node.attribute( "scale" );
+ if ( scalNode != null ) column.setScale( Integer.parseInt( scalNode.getValue() ) );
+ Attribute precNode = node.attribute( "precision" );
+ if ( precNode != null ) column.setPrecision( Integer.parseInt( precNode.getValue() ) );
+
+ Attribute nullNode = node.attribute( "not-null" );
+ column.setNullable( nullNode == null ? isNullable : nullNode.getValue().equals( "false" ) );
+
+ Attribute unqNode = node.attribute( "unique" );
+ if ( unqNode != null ) column.setUnique( unqNode.getValue().equals( "true" ) );
+
+ column.setCheckConstraint( node.attributeValue( "check" ) );
+ column.setDefaultValue( node.attributeValue( "default" ) );
+
+ Attribute typeNode = node.attribute( "sql-type" );
+ if ( typeNode != null ) column.setSqlType( typeNode.getValue() );
+
+ Element comment = node.element("comment");
+ if (comment!=null) column.setComment( comment.getTextTrim() );
+
+ }
+
+ /**
+ * Called for arrays and primitive arrays
+ */
+ public static void bindArray(Element node, Array array, String prefix, String path,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+
+ bindCollection( node, array, prefix, path, mappings, inheritedMetas );
+
+ Attribute att = node.attribute( "element-class" );
+ if ( att != null ) array.setElementClassName( getClassName( att, mappings ) );
+
+ }
+
+ private static Class reflectedPropertyClass(String className, String propertyName)
+ throws MappingException {
+ if ( className == null ) return null;
+ return ReflectHelper.reflectedPropertyClass( className, propertyName );
+ }
+
+ public static void bindComposite(Element node, Component component, String path,
+ boolean isNullable, Mappings mappings, java.util.Map inheritedMetas)
+ throws MappingException {
+ bindComponent(
+ node,
+ component,
+ null,
+ null,
+ path,
+ isNullable,
+ false,
+ mappings,
+ inheritedMetas,
+ false
+ );
+ }
+
+ public static void bindCompositeId(Element node, Component component,
+ PersistentClass persistentClass, String propertyName, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+
+ component.setKey( true );
+
+ String path = StringHelper.qualify(
+ persistentClass.getEntityName(),
+ propertyName == null ? "id" : propertyName );
+
+ bindComponent(
+ node,
+ component,
+ persistentClass.getClassName(),
+ propertyName,
+ path,
+ false,
+ node.attribute( "class" ) == null
+ && propertyName == null,
+ mappings,
+ inheritedMetas,
+ false
+ );
+
+ if ( "true".equals( node.attributeValue("mapped") ) ) {
+ if ( propertyName!=null ) {
+ throw new MappingException("cannot combine mapped=\"true\" with specified name");
+ }
+ Component mapper = new Component(persistentClass);
+ bindComponent(
+ node,
+ mapper,
+ persistentClass.getClassName(),
+ null,
+ path,
+ false,
+ true,
+ mappings,
+ inheritedMetas,
+ true
+ );
+ persistentClass.setIdentifierMapper(mapper);
+ Property property = new Property();
+ property.setName("_identifierMapper");
+ property.setNodeName("id");
+ property.setUpdateable(false);
+ property.setInsertable(false);
+ property.setValue(mapper);
+ property.setPropertyAccessorName( "embedded" );
+ persistentClass.addProperty(property);
+ }
+
+ }
+
+ public static void bindComponent(
+ Element node,
+ Component component,
+ String ownerClassName,
+ String parentProperty,
+ String path,
+ boolean isNullable,
+ boolean isEmbedded,
+ Mappings mappings,
+ java.util.Map inheritedMetas,
+ boolean isIdentifierMapper) throws MappingException {
+
+ component.setEmbedded( isEmbedded );
+ component.setRoleName( path );
+
+ inheritedMetas = getMetas( node, inheritedMetas );
+ component.setMetaAttributes( inheritedMetas );
+
+ Attribute classNode = isIdentifierMapper ? null : node.attribute( "class" );
+ if ( classNode != null ) {
+ component.setComponentClassName( getClassName( classNode, mappings ) );
+ }
+ else if ( "dynamic-component".equals( node.getName() ) ) {
+ component.setDynamic( true );
+ }
+ else if ( isEmbedded ) {
+ // an "embedded" component (composite ids and unique)
+ // note that this does not handle nested components
+ if ( component.getOwner().hasPojoRepresentation() ) {
+ component.setComponentClassName( component.getOwner().getClassName() );
+ }
+ else {
+ component.setDynamic(true);
+ }
+ }
+ else {
+ // todo : again, how *should* this work for non-pojo entities?
+ if ( component.getOwner().hasPojoRepresentation() ) {
+ Class reflectedClass = reflectedPropertyClass( ownerClassName, parentProperty );
+ if ( reflectedClass != null ) {
+ component.setComponentClassName( reflectedClass.getName() );
+ }
+ }
+ else {
+ component.setDynamic(true);
+ }
+ }
+
+ String nodeName = node.attributeValue( "node" );
+ if ( nodeName == null ) nodeName = node.attributeValue( "name" );
+ if ( nodeName == null ) nodeName = component.getOwner().getNodeName();
+ component.setNodeName( nodeName );
+
+ Iterator iter = node.elementIterator();
+ while ( iter.hasNext() ) {
+
+ Element subnode = (Element) iter.next();
+ String name = subnode.getName();
+ String propertyName = getPropertyName( subnode );
+ String subpath = propertyName == null ? null : StringHelper
+ .qualify( path, propertyName );
+
+ CollectionType collectType = CollectionType.collectionTypeFromString( name );
+ Value value = null;
+ if ( collectType != null ) {
+ Collection collection = collectType.create(
+ subnode,
+ subpath,
+ component.getOwner(),
+ mappings, inheritedMetas
+ );
+ mappings.addCollection( collection );
+ value = collection;
+ }
+ else if ( "many-to-one".equals( name ) || "key-many-to-one".equals( name ) ) {
+ value = new ManyToOne( component.getTable() );
+ String relativePath;
+ if (isEmbedded) {
+ relativePath = propertyName;
+ }
+ else {
+ relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
+ }
+ bindManyToOne( subnode, (ManyToOne) value, relativePath, isNullable, mappings );
+ }
+ else if ( "one-to-one".equals( name ) ) {
+ value = new OneToOne( component.getTable(), component.getOwner() );
+ String relativePath;
+ if (isEmbedded) {
+ relativePath = propertyName;
+ }
+ else {
+ relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
+ }
+ bindOneToOne( subnode, (OneToOne) value, relativePath, isNullable, mappings );
+ }
+ else if ( "any".equals( name ) ) {
+ value = new Any( component.getTable() );
+ bindAny( subnode, (Any) value, isNullable, mappings );
+ }
+ else if ( "property".equals( name ) || "key-property".equals( name ) ) {
+ value = new SimpleValue( component.getTable() );
+ String relativePath;
+ if (isEmbedded) {
+ relativePath = propertyName;
+ }
+ else {
+ relativePath = subpath.substring( component.getOwner().getEntityName().length() + 1 );
+ }
+ bindSimpleValue( subnode, (SimpleValue) value, isNullable, relativePath, mappings );
+ }
+ else if ( "component".equals( name )
+ || "dynamic-component".equals( name )
+ || "nested-composite-element".equals( name ) ) {
+ value = new Component( component ); // a nested composite element
+ bindComponent(
+ subnode,
+ (Component) value,
+ component.getComponentClassName(),
+ propertyName,
+ subpath,
+ isNullable,
+ isEmbedded,
+ mappings,
+ inheritedMetas,
+ isIdentifierMapper
+ );
+ }
+ else if ( "parent".equals( name ) ) {
+ component.setParentProperty( propertyName );
+ }
+
+ if ( value != null ) {
+ Property property = createProperty( value, propertyName, component
+ .getComponentClassName(), subnode, mappings, inheritedMetas );
+ if (isIdentifierMapper) {
+ property.setInsertable(false);
+ property.setUpdateable(false);
+ }
+ component.addProperty( property );
+ }
+ }
+
+ if ( "true".equals( node.attributeValue( "unique" ) ) ) {
+ iter = component.getColumnIterator();
+ ArrayList cols = new ArrayList();
+ while ( iter.hasNext() ) {
+ cols.add( iter.next() );
+ }
+ component.getOwner().getTable().createUniqueKey( cols );
+ }
+
+ iter = node.elementIterator( "tuplizer" );
+ while ( iter.hasNext() ) {
+ final Element tuplizerElem = ( Element ) iter.next();
+ EntityMode mode = EntityMode.parse( tuplizerElem.attributeValue( "entity-mode" ) );
+ component.addTuplizer( mode, tuplizerElem.attributeValue( "class" ) );
+ }
+ }
+
+ public static String getTypeFromXML(Element node) throws MappingException {
+ // TODO: handle TypeDefs
+ Attribute typeNode = node.attribute( "type" );
+ if ( typeNode == null ) typeNode = node.attribute( "id-type" ); // for an any
+ if ( typeNode == null ) return null; // we will have to use reflection
+ return typeNode.getValue();
+ }
+
+ private static void initOuterJoinFetchSetting(Element node, Fetchable model) {
+ Attribute fetchNode = node.attribute( "fetch" );
+ final FetchMode fetchStyle;
+ boolean lazy = true;
+ if ( fetchNode == null ) {
+ Attribute jfNode = node.attribute( "outer-join" );
+ if ( jfNode == null ) {
+ if ( "many-to-many".equals( node.getName() ) ) {
+ //NOTE SPECIAL CASE:
+ // default to join and non-lazy for the "second join"
+ // of the many-to-many
+ lazy = false;
+ fetchStyle = FetchMode.JOIN;
+ }
+ else if ( "one-to-one".equals( node.getName() ) ) {
+ //NOTE SPECIAL CASE:
+ // one-to-one constrained=false cannot be proxied,
+ // so default to join and non-lazy
+ lazy = ( (OneToOne) model ).isConstrained();
+ fetchStyle = lazy ? FetchMode.DEFAULT : FetchMode.JOIN;
+ }
+ else {
+ fetchStyle = FetchMode.DEFAULT;
+ }
+ }
+ else {
+ // use old (HB 2.1) defaults if outer-join is specified
+ String eoj = jfNode.getValue();
+ if ( "auto".equals( eoj ) ) {
+ fetchStyle = FetchMode.DEFAULT;
+ }
+ else {
+ boolean join = "true".equals( eoj );
+ fetchStyle = join ? FetchMode.JOIN : FetchMode.SELECT;
+ }
+ }
+ }
+ else {
+ boolean join = "join".equals( fetchNode.getValue() );
+ //lazy = !join;
+ fetchStyle = join ? FetchMode.JOIN : FetchMode.SELECT;
+ }
+ model.setFetchMode( fetchStyle );
+ model.setLazy(lazy);
+ }
+
+ private static void makeIdentifier(Element node, SimpleValue model, Mappings mappings) {
+
+ // GENERATOR
+ Element subnode = node.element( "generator" );
+ if ( subnode != null ) {
+ model.setIdentifierGeneratorStrategy( subnode.attributeValue( "class" ) );
+
+ Properties params = new Properties();
+
+ if ( mappings.getSchemaName() != null ) {
+ params.setProperty( PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName() );
+ }
+ if ( mappings.getCatalogName() != null ) {
+ params.setProperty( PersistentIdentifierGenerator.CATALOG, mappings.getCatalogName() );
+ }
+
+ Iterator iter = subnode.elementIterator( "param" );
+ while ( iter.hasNext() ) {
+ Element childNode = (Element) iter.next();
+ params.setProperty( childNode.attributeValue( "name" ), childNode.getTextTrim() );
+ }
+
+ model.setIdentifierGeneratorProperties( params );
+ }
+
+ model.getTable().setIdentifierValue( model );
+
+ // ID UNSAVED-VALUE
+ Attribute nullValueNode = node.attribute( "unsaved-value" );
+ if ( nullValueNode != null ) {
+ model.setNullValue( nullValueNode.getValue() );
+ }
+ else {
+ if ( "assigned".equals( model.getIdentifierGeneratorStrategy() ) ) {
+ model.setNullValue( "undefined" );
+ }
+ else {
+ model.setNullValue( null );
+ }
+ }
+ }
+
+ private static final void makeVersion(Element node, SimpleValue model) {
+
+ // VERSION UNSAVED-VALUE
+ Attribute nullValueNode = node.attribute( "unsaved-value" );
+ if ( nullValueNode != null ) {
+ model.setNullValue( nullValueNode.getValue() );
+ }
+ else {
+ model.setNullValue( "undefined" );
+ }
+
+ }
+
+ protected static void createClassProperties(Element node, PersistentClass persistentClass,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ createClassProperties(node, persistentClass, mappings, inheritedMetas, null, true, true, false);
+ }
+
+ protected static void createClassProperties(Element node, PersistentClass persistentClass,
+ Mappings mappings, java.util.Map inheritedMetas, UniqueKey uniqueKey,
+ boolean mutable, boolean nullable, boolean naturalId) throws MappingException {
+
+ String entityName = persistentClass.getEntityName();
+ Table table = persistentClass.getTable();
+
+ Iterator iter = node.elementIterator();
+ while ( iter.hasNext() ) {
+ Element subnode = (Element) iter.next();
+ String name = subnode.getName();
+ String propertyName = subnode.attributeValue( "name" );
+
+ CollectionType collectType = CollectionType.collectionTypeFromString( name );
+ Value value = null;
+ if ( collectType != null ) {
+ Collection collection = collectType.create(
+ subnode,
+ StringHelper.qualify( entityName, propertyName ),
+ persistentClass,
+ mappings, inheritedMetas
+ );
+ mappings.addCollection( collection );
+ value = collection;
+ }
+ else if ( "many-to-one".equals( name ) ) {
+ value = new ManyToOne( table );
+ bindManyToOne( subnode, (ManyToOne) value, propertyName, nullable, mappings );
+ }
+ else if ( "any".equals( name ) ) {
+ value = new Any( table );
+ bindAny( subnode, (Any) value, nullable, mappings );
+ }
+ else if ( "one-to-one".equals( name ) ) {
+ value = new OneToOne( table, persistentClass );
+ bindOneToOne( subnode, (OneToOne) value, propertyName, true, mappings );
+ }
+ else if ( "property".equals( name ) ) {
+ value = new SimpleValue( table );
+ bindSimpleValue( subnode, (SimpleValue) value, nullable, propertyName, mappings );
+ }
+ else if ( "component".equals( name )
+ || "dynamic-component".equals( name )
+ || "properties".equals( name ) ) {
+ String subpath = StringHelper.qualify( entityName, propertyName );
+ value = new Component( persistentClass );
+
+ bindComponent(
+ subnode,
+ (Component) value,
+ persistentClass.getClassName(),
+ propertyName,
+ subpath,
+ true,
+ "properties".equals( name ),
+ mappings,
+ inheritedMetas,
+ false
+ );
+ }
+ else if ( "join".equals( name ) ) {
+ Join join = new Join();
+ join.setPersistentClass( persistentClass );
+ bindJoin( subnode, join, mappings, inheritedMetas );
+ persistentClass.addJoin( join );
+ }
+ else if ( "subclass".equals( name ) ) {
+ handleSubclass( persistentClass, mappings, subnode, inheritedMetas );
+ }
+ else if ( "joined-subclass".equals( name ) ) {
+ handleJoinedSubclass( persistentClass, mappings, subnode, inheritedMetas );
+ }
+ else if ( "union-subclass".equals( name ) ) {
+ handleUnionSubclass( persistentClass, mappings, subnode, inheritedMetas );
+ }
+ else if ( "filter".equals( name ) ) {
+ parseFilter( subnode, persistentClass, mappings );
+ }
+ else if ( "natural-id".equals( name ) ) {
+ UniqueKey uk = new UniqueKey();
+ uk.setName("_UniqueKey");
+ uk.setTable(table);
+ //by default, natural-ids are "immutable" (constant)
+ boolean mutableId = "true".equals( subnode.attributeValue("mutable") );
+ createClassProperties(
+ subnode,
+ persistentClass,
+ mappings,
+ inheritedMetas,
+ uk,
+ mutableId,
+ false,
+ true
+ );
+ table.addUniqueKey(uk);
+ }
+ else if ( "query".equals(name) ) {
+ bindNamedQuery(subnode, persistentClass.getEntityName(), mappings);
+ }
+ else if ( "sql-query".equals(name) ) {
+ bindNamedSQLQuery(subnode, persistentClass.getEntityName(), mappings);
+ }
+ else if ( "resultset".equals(name) ) {
+ bindResultSetMappingDefinition( subnode, persistentClass.getEntityName(), mappings );
+ }
+
+ if ( value != null ) {
+ Property property = createProperty( value, propertyName, persistentClass
+ .getClassName(), subnode, mappings, inheritedMetas );
+ if ( !mutable ) property.setUpdateable(false);
+ if ( naturalId ) property.setNaturalIdentifier(true);
+ persistentClass.addProperty( property );
+ if ( uniqueKey!=null ) uniqueKey.addColumns( property.getColumnIterator() );
+ }
+
+ }
+ }
+
+ private static Property createProperty(
+ final Value value,
+ final String propertyName,
+ final String className,
+ final Element subnode,
+ final Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+
+ if ( StringHelper.isEmpty( propertyName ) ) {
+ throw new MappingException( subnode.getName() + " mapping must defined a name attribute [" + className + "]" );
+ }
+
+ value.setTypeUsingReflection( className, propertyName );
+
+ // this is done here 'cos we might only know the type here (ugly!)
+ // TODO: improve this a lot:
+ if ( value instanceof ToOne ) {
+ ToOne toOne = (ToOne) value;
+ String propertyRef = toOne.getReferencedPropertyName();
+ if ( propertyRef != null ) {
+ mappings.addUniquePropertyReference( toOne.getReferencedEntityName(), propertyRef );
+ }
+ }
+ else if ( value instanceof Collection ) {
+ Collection coll = (Collection) value;
+ String propertyRef = coll.getReferencedPropertyName();
+ // not necessarily a *unique* property reference
+ if ( propertyRef != null ) {
+ mappings.addPropertyReference( coll.getOwnerEntityName(), propertyRef );
+ }
+ }
+
+ value.createForeignKey();
+ Property prop = new Property();
+ prop.setValue( value );
+ bindProperty( subnode, prop, mappings, inheritedMetas );
+ return prop;
+ }
+
+ private static void handleUnionSubclass(PersistentClass model, Mappings mappings,
+ Element subnode, java.util.Map inheritedMetas) throws MappingException {
+ UnionSubclass subclass = new UnionSubclass( model );
+ bindUnionSubclass( subnode, subclass, mappings, inheritedMetas );
+ model.addSubclass( subclass );
+ mappings.addClass( subclass );
+ }
+
+ private static void handleJoinedSubclass(PersistentClass model, Mappings mappings,
+ Element subnode, java.util.Map inheritedMetas) throws MappingException {
+ JoinedSubclass subclass = new JoinedSubclass( model );
+ bindJoinedSubclass( subnode, subclass, mappings, inheritedMetas );
+ model.addSubclass( subclass );
+ mappings.addClass( subclass );
+ }
+
+ private static void handleSubclass(PersistentClass model, Mappings mappings, Element subnode,
+ java.util.Map inheritedMetas) throws MappingException {
+ Subclass subclass = new SingleTableSubclass( model );
+ bindSubclass( subnode, subclass, mappings, inheritedMetas );
+ model.addSubclass( subclass );
+ mappings.addClass( subclass );
+ }
+
+ /**
+ * Called for Lists, arrays, primitive arrays
+ */
+ public static void bindListSecondPass(Element node, List list, java.util.Map classes,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+
+ bindCollectionSecondPass( node, list, classes, mappings, inheritedMetas );
+
+ Element subnode = node.element( "list-index" );
+ if ( subnode == null ) subnode = node.element( "index" );
+ SimpleValue iv = new SimpleValue( list.getCollectionTable() );
+ bindSimpleValue(
+ subnode,
+ iv,
+ list.isOneToMany(),
+ IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
+ mappings
+ );
+ iv.setTypeName( "integer" );
+ list.setIndex( iv );
+ String baseIndex = subnode.attributeValue( "base" );
+ if ( baseIndex != null ) list.setBaseIndex( Integer.parseInt( baseIndex ) );
+ list.setIndexNodeName( subnode.attributeValue("node") );
+
+ if ( list.isOneToMany() && !list.getKey().isNullable() && !list.isInverse() ) {
+ String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName();
+ PersistentClass referenced = mappings.getClass( entityName );
+ IndexBackref ib = new IndexBackref();
+ ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
+ ib.setUpdateable( false );
+ ib.setSelectable( false );
+ ib.setCollectionRole( list.getRole() );
+ ib.setEntityName( list.getOwner().getEntityName() );
+ ib.setValue( list.getIndex() );
+ // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
+ // ).setNullable(false);
+ referenced.addProperty( ib );
+ }
+ }
+
+ public static void bindIdentifierCollectionSecondPass(Element node,
+ IdentifierCollection collection, java.util.Map persistentClasses, Mappings mappings,
+ java.util.Map inheritedMetas) throws MappingException {
+
+ bindCollectionSecondPass( node, collection, persistentClasses, mappings, inheritedMetas );
+
+ Element subnode = node.element( "collection-id" );
+ SimpleValue id = new SimpleValue( collection.getCollectionTable() );
+ bindSimpleValue(
+ subnode,
+ id,
+ false,
+ IdentifierCollection.DEFAULT_IDENTIFIER_COLUMN_NAME,
+ mappings
+ );
+ collection.setIdentifier( id );
+ makeIdentifier( subnode, id, mappings );
+
+ }
+
+ /**
+ * Called for Maps
+ */
+ public static void bindMapSecondPass(Element node, Map map, java.util.Map classes,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+
+ bindCollectionSecondPass( node, map, classes, mappings, inheritedMetas );
+
+ Iterator iter = node.elementIterator();
+ while ( iter.hasNext() ) {
+ Element subnode = (Element) iter.next();
+ String name = subnode.getName();
+
+ if ( "index".equals( name ) || "map-key".equals( name ) ) {
+ SimpleValue value = new SimpleValue( map.getCollectionTable() );
+ bindSimpleValue(
+ subnode,
+ value,
+ map.isOneToMany(),
+ IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
+ mappings
+ );
+ if ( !value.isTypeSpecified() ) {
+ throw new MappingException( "map index element must specify a type: "
+ + map.getRole() );
+ }
+ map.setIndex( value );
+ map.setIndexNodeName( subnode.attributeValue("node") );
+ }
+ else if ( "index-many-to-many".equals( name ) || "map-key-many-to-many".equals( name ) ) {
+ ManyToOne mto = new ManyToOne( map.getCollectionTable() );
+ bindManyToOne(
+ subnode,
+ mto,
+ IndexedCollection.DEFAULT_INDEX_COLUMN_NAME,
+ map.isOneToMany(),
+ mappings
+ );
+ map.setIndex( mto );
+
+ }
+ else if ( "composite-index".equals( name ) || "composite-map-key".equals( name ) ) {
+ Component component = new Component( map );
+ bindComposite(
+ subnode,
+ component,
+ map.getRole() + ".index",
+ map.isOneToMany(),
+ mappings,
+ inheritedMetas
+ );
+ map.setIndex( component );
+ }
+ else if ( "index-many-to-any".equals( name ) ) {
+ Any any = new Any( map.getCollectionTable() );
+ bindAny( subnode, any, map.isOneToMany(), mappings );
+ map.setIndex( any );
+ }
+ }
+
+ // TODO: this is a bit of copy/paste from IndexedCollection.createPrimaryKey()
+ boolean indexIsFormula = false;
+ Iterator colIter = map.getIndex().getColumnIterator();
+ while ( colIter.hasNext() ) {
+ if ( ( (Selectable) colIter.next() ).isFormula() ) indexIsFormula = true;
+ }
+
+ if ( map.isOneToMany() && !map.getKey().isNullable() && !map.isInverse() && !indexIsFormula ) {
+ String entityName = ( (OneToMany) map.getElement() ).getReferencedEntityName();
+ PersistentClass referenced = mappings.getClass( entityName );
+ IndexBackref ib = new IndexBackref();
+ ib.setName( '_' + map.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" );
+ ib.setUpdateable( false );
+ ib.setSelectable( false );
+ ib.setCollectionRole( map.getRole() );
+ ib.setEntityName( map.getOwner().getEntityName() );
+ ib.setValue( map.getIndex() );
+ // ( (Column) ( (SimpleValue) ic.getIndex() ).getColumnIterator().next()
+ // ).setNullable(false);
+ referenced.addProperty( ib );
+ }
+ }
+
+ /**
+ * Called for all collections
+ */
+ public static void bindCollectionSecondPass(Element node, Collection collection,
+ java.util.Map persistentClasses, Mappings mappings, java.util.Map inheritedMetas)
+ throws MappingException {
+
+ if ( collection.isOneToMany() ) {
+ OneToMany oneToMany = (OneToMany) collection.getElement();
+ String assocClass = oneToMany.getReferencedEntityName();
+ PersistentClass persistentClass = (PersistentClass) persistentClasses.get( assocClass );
+ if ( persistentClass == null ) {
+ throw new MappingException( "Association references unmapped class: " + assocClass );
+ }
+ oneToMany.setAssociatedClass( persistentClass );
+ collection.setCollectionTable( persistentClass.getTable() );
+
+ log.info(
+ "Mapping collection: " + collection.getRole() +
+ " -> " + collection.getCollectionTable().getName()
+ );
+ }
+
+ // CHECK
+ Attribute chNode = node.attribute( "check" );
+ if ( chNode != null ) {
+ collection.getCollectionTable().addCheckConstraint( chNode.getValue() );
+ }
+
+ // contained elements:
+ Iterator iter = node.elementIterator();
+ while ( iter.hasNext() ) {
+ Element subnode = (Element) iter.next();
+ String name = subnode.getName();
+
+ if ( "key".equals( name ) ) {
+ KeyValue keyVal;
+ String propRef = collection.getReferencedPropertyName();
+ if ( propRef == null ) {
+ keyVal = collection.getOwner().getIdentifier();
+ }
+ else {
+ keyVal = (KeyValue) collection.getOwner().getRecursiveProperty( propRef ).getValue();
+ }
+ SimpleValue key = new DependantValue( collection.getCollectionTable(), keyVal );
+ key.setCascadeDeleteEnabled( "cascade"
+ .equals( subnode.attributeValue( "on-delete" ) ) );
+ bindSimpleValue(
+ subnode,
+ key,
+ collection.isOneToMany(),
+ Collection.DEFAULT_KEY_COLUMN_NAME,
+ mappings
+ );
+ collection.setKey( key );
+
+ Attribute notNull = subnode.attribute( "not-null" );
+ ( (DependantValue) key ).setNullable( notNull == null
+ || notNull.getValue().equals( "false" ) );
+ Attribute updateable = subnode.attribute( "update" );
+ ( (DependantValue) key ).setUpdateable( updateable == null
+ || updateable.getValue().equals( "true" ) );
+
+ }
+ else if ( "element".equals( name ) ) {
+ SimpleValue elt = new SimpleValue( collection.getCollectionTable() );
+ collection.setElement( elt );
+ bindSimpleValue(
+ subnode,
+ elt,
+ true,
+ Collection.DEFAULT_ELEMENT_COLUMN_NAME,
+ mappings
+ );
+ }
+ else if ( "many-to-many".equals( name ) ) {
+ ManyToOne element = new ManyToOne( collection.getCollectionTable() );
+ collection.setElement( element );
+ bindManyToOne(
+ subnode,
+ element,
+ Collection.DEFAULT_ELEMENT_COLUMN_NAME,
+ false,
+ mappings
+ );
+ bindManyToManySubelements( collection, subnode, mappings );
+ }
+ else if ( "composite-element".equals( name ) ) {
+ Component element = new Component( collection );
+ collection.setElement( element );
+ bindComposite(
+ subnode,
+ element,
+ collection.getRole() + ".element",
+ true,
+ mappings,
+ inheritedMetas
+ );
+ }
+ else if ( "many-to-any".equals( name ) ) {
+ Any element = new Any( collection.getCollectionTable() );
+ collection.setElement( element );
+ bindAny( subnode, element, true, mappings );
+ }
+ else if ( "cache".equals( name ) ) {
+ collection.setCacheConcurrencyStrategy( subnode.attributeValue( "usage" ) );
+ collection.setCacheRegionName( subnode.attributeValue( "region" ) );
+ }
+
+ String nodeName = subnode.attributeValue( "node" );
+ if ( nodeName != null ) collection.setElementNodeName( nodeName );
+
+ }
+
+ if ( collection.isOneToMany()
+ && !collection.isInverse()
+ && !collection.getKey().isNullable() ) {
+ // for non-inverse one-to-many, with a not-null fk, add a backref!
+ String entityName = ( (OneToMany) collection.getElement() ).getReferencedEntityName();
+ PersistentClass referenced = mappings.getClass( entityName );
+ Backref prop = new Backref();
+ prop.setName( '_' + collection.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "Backref" );
+ prop.setUpdateable( false );
+ prop.setSelectable( false );
+ prop.setCollectionRole( collection.getRole() );
+ prop.setEntityName( collection.getOwner().getEntityName() );
+ prop.setValue( collection.getKey() );
+ referenced.addProperty( prop );
+ }
+ }
+
+ private static void bindManyToManySubelements(
+ Collection collection,
+ Element manyToManyNode,
+ Mappings model) throws MappingException {
+ // Bind the where
+ Attribute where = manyToManyNode.attribute( "where" );
+ String whereCondition = where == null ? null : where.getValue();
+ collection.setManyToManyWhere( whereCondition );
+
+ // Bind the order-by
+ Attribute order = manyToManyNode.attribute( "order-by" );
+ String orderFragment = order == null ? null : order.getValue();
+ collection.setManyToManyOrdering( orderFragment );
+
+ // Bind the filters
+ Iterator filters = manyToManyNode.elementIterator( "filter" );
+ if ( ( filters.hasNext() || whereCondition != null ) &&
+ collection.getFetchMode() == FetchMode.JOIN &&
+ collection.getElement().getFetchMode() != FetchMode.JOIN ) {
+ throw new MappingException(
+ "many-to-many defining filter or where without join fetching " +
+ "not valid within collection using join fetching [" + collection.getRole() + "]"
+ );
+ }
+ while ( filters.hasNext() ) {
+ final Element filterElement = ( Element ) filters.next();
+ final String name = filterElement.attributeValue( "name" );
+ String condition = filterElement.getTextTrim();
+ if ( StringHelper.isEmpty(condition) ) condition = filterElement.attributeValue( "condition" );
+ if ( StringHelper.isEmpty(condition) ) {
+ condition = model.getFilterDefinition(name).getDefaultFilterCondition();
+ }
+ if ( condition==null) {
+ throw new MappingException("no filter condition found for filter: " + name);
+ }
+ log.debug(
+ "Applying many-to-many filter [" + name +
+ "] as [" + condition +
+ "] to role [" + collection.getRole() + "]"
+ );
+ collection.addManyToManyFilter( name, condition );
+ }
+ }
+
+ public static final FlushMode getFlushMode(String flushMode) {
+ if ( flushMode == null ) {
+ return null;
+ }
+ else if ( "auto".equals( flushMode ) ) {
+ return FlushMode.AUTO;
+ }
+ else if ( "commit".equals( flushMode ) ) {
+ return FlushMode.COMMIT;
+ }
+ else if ( "never".equals( flushMode ) ) {
+ return FlushMode.NEVER;
+ }
+ else if ( "manual".equals( flushMode ) ) {
+ return FlushMode.MANUAL;
+ }
+ else if ( "always".equals( flushMode ) ) {
+ return FlushMode.ALWAYS;
+ }
+ else {
+ throw new MappingException( "unknown flushmode" );
+ }
+ }
+
+ private static void bindNamedQuery(Element queryElem, String path, Mappings mappings) {
+ String queryName = queryElem.attributeValue( "name" );
+ if (path!=null) queryName = path + '.' + queryName;
+ String query = queryElem.getText();
+ log.debug( "Named query: " + queryName + " -> " + query );
+
+ boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
+ String region = queryElem.attributeValue( "cache-region" );
+ Attribute tAtt = queryElem.attribute( "timeout" );
+ Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
+ Attribute fsAtt = queryElem.attribute( "fetch-size" );
+ Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
+ Attribute roAttr = queryElem.attribute( "read-only" );
+ boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
+ Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
+ String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
+ Attribute cmAtt = queryElem.attribute( "comment" );
+ String comment = cmAtt == null ? null : cmAtt.getValue();
+
+ NamedQueryDefinition namedQuery = new NamedQueryDefinition(
+ query,
+ cacheable,
+ region,
+ timeout,
+ fetchSize,
+ getFlushMode( queryElem.attributeValue( "flush-mode" ) ) ,
+ getCacheMode( cacheMode ),
+ readOnly,
+ comment,
+ getParameterTypes(queryElem)
+ );
+
+ mappings.addQuery( queryName, namedQuery );
+ }
+
+ public static CacheMode getCacheMode(String cacheMode) {
+ if (cacheMode == null) return null;
+ if ( "get".equals( cacheMode ) ) return CacheMode.GET;
+ if ( "ignore".equals( cacheMode ) ) return CacheMode.IGNORE;
+ if ( "normal".equals( cacheMode ) ) return CacheMode.NORMAL;
+ if ( "put".equals( cacheMode ) ) return CacheMode.PUT;
+ if ( "refresh".equals( cacheMode ) ) return CacheMode.REFRESH;
+ throw new MappingException("Unknown Cache Mode: " + cacheMode);
+ }
+
+ public static java.util.Map getParameterTypes(Element queryElem) {
+ java.util.Map result = new java.util.LinkedHashMap();
+ Iterator iter = queryElem.elementIterator("query-param");
+ while ( iter.hasNext() ) {
+ Element element = (Element) iter.next();
+ result.put( element.attributeValue("name"), element.attributeValue("type") );
+ }
+ return result;
+ }
+
+ private static void bindResultSetMappingDefinition(Element resultSetElem, String path, Mappings mappings) {
+ mappings.addSecondPass( new ResultSetMappingSecondPass( resultSetElem, path, mappings ) );
+ }
+
+ private static void bindNamedSQLQuery(Element queryElem, String path, Mappings mappings) {
+ mappings.addSecondPass( new NamedSQLQuerySecondPass( queryElem, path, mappings ) );
+ }
+
+ private static String getPropertyName(Element node) {
+ return node.attributeValue( "name" );
+ }
+
+ private static PersistentClass getSuperclass(Mappings mappings, Element subnode)
+ throws MappingException {
+ String extendsName = subnode.attributeValue( "extends" );
+ PersistentClass superModel = mappings.getClass( extendsName );
+ if ( superModel == null ) {
+ String qualifiedExtendsName = getClassName( extendsName, mappings );
+ superModel = mappings.getClass( qualifiedExtendsName );
+ }
+
+ if ( superModel == null ) {
+ throw new MappingException( "Cannot extend unmapped class " + extendsName );
+ }
+ return superModel;
+ }
+
+ static class CollectionSecondPass extends org.hibernate.cfg.CollectionSecondPass {
+ Element node;
+
+ CollectionSecondPass(Element node, Mappings mappings, Collection collection, java.util.Map inheritedMetas) {
+ super(mappings, collection, inheritedMetas);
+ this.node = node;
+ }
+
+ public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
+ throws MappingException {
+ HbmBinder.bindCollectionSecondPass(
+ node,
+ collection,
+ persistentClasses,
+ mappings,
+ inheritedMetas
+ );
+ }
+ }
+
+ static class IdentifierCollectionSecondPass extends CollectionSecondPass {
+ IdentifierCollectionSecondPass(Element node, Mappings mappings, Collection collection, java.util.Map inheritedMetas) {
+ super( node, mappings, collection, inheritedMetas );
+ }
+
+ public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
+ throws MappingException {
+ HbmBinder.bindIdentifierCollectionSecondPass(
+ node,
+ (IdentifierCollection) collection,
+ persistentClasses,
+ mappings,
+ inheritedMetas
+ );
+ }
+
+ }
+
+ static class MapSecondPass extends CollectionSecondPass {
+ MapSecondPass(Element node, Mappings mappings, Map collection, java.util.Map inheritedMetas) {
+ super( node, mappings, collection, inheritedMetas );
+ }
+
+ public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
+ throws MappingException {
+ HbmBinder.bindMapSecondPass(
+ node,
+ (Map) collection,
+ persistentClasses,
+ mappings,
+ inheritedMetas
+ );
+ }
+
+ }
+
+
+ static class ManyToOneSecondPass implements SecondPass {
+ private final ManyToOne manyToOne;
+
+ ManyToOneSecondPass(ManyToOne manyToOne) {
+ this.manyToOne = manyToOne;
+ }
+
+ public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
+ manyToOne.createPropertyRefConstraints(persistentClasses);
+ }
+
+ }
+
+ static class ListSecondPass extends CollectionSecondPass {
+ ListSecondPass(Element node, Mappings mappings, List collection, java.util.Map inheritedMetas) {
+ super( node, mappings, collection, inheritedMetas );
+ }
+
+ public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
+ throws MappingException {
+ HbmBinder.bindListSecondPass(
+ node,
+ (List) collection,
+ persistentClasses,
+ mappings,
+ inheritedMetas
+ );
+ }
+
+ }
+
+ // This inner class implements a case statement....perhaps im being a bit over-clever here
+ abstract static class CollectionType {
+ private String xmlTag;
+
+ public abstract Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException;
+
+ CollectionType(String xmlTag) {
+ this.xmlTag = xmlTag;
+ }
+
+ public String toString() {
+ return xmlTag;
+ }
+
+ private static final CollectionType MAP = new CollectionType( "map" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ Map map = new Map( owner );
+ bindCollection( node, map, owner.getEntityName(), path, mappings, inheritedMetas );
+ return map;
+ }
+ };
+ private static final CollectionType SET = new CollectionType( "set" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ Set set = new Set( owner );
+ bindCollection( node, set, owner.getEntityName(), path, mappings, inheritedMetas );
+ return set;
+ }
+ };
+ private static final CollectionType LIST = new CollectionType( "list" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ List list = new List( owner );
+ bindCollection( node, list, owner.getEntityName(), path, mappings, inheritedMetas );
+ return list;
+ }
+ };
+ private static final CollectionType BAG = new CollectionType( "bag" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ Bag bag = new Bag( owner );
+ bindCollection( node, bag, owner.getEntityName(), path, mappings, inheritedMetas );
+ return bag;
+ }
+ };
+ private static final CollectionType IDBAG = new CollectionType( "idbag" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ IdentifierBag bag = new IdentifierBag( owner );
+ bindCollection( node, bag, owner.getEntityName(), path, mappings, inheritedMetas );
+ return bag;
+ }
+ };
+ private static final CollectionType ARRAY = new CollectionType( "array" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ Array array = new Array( owner );
+ bindArray( node, array, owner.getEntityName(), path, mappings, inheritedMetas );
+ return array;
+ }
+ };
+ private static final CollectionType PRIMITIVE_ARRAY = new CollectionType( "primitive-array" ) {
+ public Collection create(Element node, String path, PersistentClass owner,
+ Mappings mappings, java.util.Map inheritedMetas) throws MappingException {
+ PrimitiveArray array = new PrimitiveArray( owner );
+ bindArray( node, array, owner.getEntityName(), path, mappings, inheritedMetas );
+ return array;
+ }
+ };
+ private static final HashMap INSTANCES = new HashMap();
+
+ static {
+ INSTANCES.put( MAP.toString(), MAP );
+ INSTANCES.put( BAG.toString(), BAG );
+ INSTANCES.put( IDBAG.toString(), IDBAG );
+ INSTANCES.put( SET.toString(), SET );
+ INSTANCES.put( LIST.toString(), LIST );
+ INSTANCES.put( ARRAY.toString(), ARRAY );
+ INSTANCES.put( PRIMITIVE_ARRAY.toString(), PRIMITIVE_ARRAY );
+ }
+
+ public static CollectionType collectionTypeFromString(String xmlTagName) {
+ return (CollectionType) INSTANCES.get( xmlTagName );
+ }
+ }
+
+ private static int getOptimisticLockMode(Attribute olAtt) throws MappingException {
+
+ if ( olAtt == null ) return Versioning.OPTIMISTIC_LOCK_VERSION;
+ String olMode = olAtt.getValue();
+ if ( olMode == null || "version".equals( olMode ) ) {
+ return Versioning.OPTIMISTIC_LOCK_VERSION;
+ }
+ else if ( "dirty".equals( olMode ) ) {
+ return Versioning.OPTIMISTIC_LOCK_DIRTY;
+ }
+ else if ( "all".equals( olMode ) ) {
+ return Versioning.OPTIMISTIC_LOCK_ALL;
+ }
+ else if ( "none".equals( olMode ) ) {
+ return Versioning.OPTIMISTIC_LOCK_NONE;
+ }
+ else {
+ throw new MappingException( "Unsupported optimistic-lock style: " + olMode );
+ }
+ }
+
+ private static final java.util.Map getMetas(Element node, java.util.Map inheritedMeta) {
+ return getMetas( node, inheritedMeta, false );
+ }
+
+ public static final java.util.Map getMetas(Element node, java.util.Map inheritedMeta,
+ boolean onlyInheritable) {
+ java.util.Map map = new HashMap();
+ map.putAll( inheritedMeta );
+
+ Iterator iter = node.elementIterator( "meta" );
+ while ( iter.hasNext() ) {
+ Element metaNode = (Element) iter.next();
+ boolean inheritable = Boolean
+ .valueOf( metaNode.attributeValue( "inherit" ) )
+ .booleanValue();
+ if ( onlyInheritable & !inheritable ) {
+ continue;
+ }
+ String name = metaNode.attributeValue( "attribute" );
+
+ MetaAttribute meta = (MetaAttribute) map.get( name );
+ MetaAttribute inheritedAttribute = (MetaAttribute) inheritedMeta.get( name );
+ if ( meta == null ) {
+ meta = new MetaAttribute( name );
+ map.put( name, meta );
+ } else if (meta == inheritedAttribute) { // overriding inherited meta attribute. HBX-621 & HBX-793
+ meta = new MetaAttribute( name );
+ map.put( name, meta );
+ }
+ meta.addValue( metaNode.getText() );
+ }
+ return map;
+ }
+
+ public static String getEntityName(Element elem, Mappings model) {
+ String entityName = elem.attributeValue( "entity-name" );
+ return entityName == null ? getClassName( elem.attribute( "class" ), model ) : entityName;
+ }
+
+ private static String getClassName(Attribute att, Mappings model) {
+ if ( att == null ) return null;
+ return getClassName( att.getValue(), model );
+ }
+
+ public static String getClassName(String unqualifiedName, Mappings model) {
+ return getClassName( unqualifiedName, model.getDefaultPackage() );
+ }
+
+ public static String getClassName(String unqualifiedName, String defaultPackage) {
+ if ( unqualifiedName == null ) return null;
+ if ( unqualifiedName.indexOf( '.' ) < 0 && defaultPackage != null ) {
+ return defaultPackage + '.' + unqualifiedName;
+ }
+ return unqualifiedName;
+ }
+
+ private static void parseFilterDef(Element element, Mappings mappings) {
+ String name = element.attributeValue( "name" );
+ log.debug( "Parsing filter-def [" + name + "]" );
+ String defaultCondition = element.getTextTrim();
+ if ( StringHelper.isEmpty( defaultCondition ) ) {
+ defaultCondition = element.attributeValue( "condition" );
+ }
+ HashMap paramMappings = new HashMap();
+ Iterator params = element.elementIterator( "filter-param" );
+ while ( params.hasNext() ) {
+ final Element param = (Element) params.next();
+ final String paramName = param.attributeValue( "name" );
+ final String paramType = param.attributeValue( "type" );
+ log.debug( "adding filter parameter : " + paramName + " -> " + paramType );
+ final Type heuristicType = TypeFactory.heuristicType( paramType );
+ log.debug( "parameter heuristic type : " + heuristicType );
+ paramMappings.put( paramName, heuristicType );
+ }
+ log.debug( "Parsed filter-def [" + name + "]" );
+ FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
+ mappings.addFilterDefinition( def );
+ }
+
+ private static void parseFilter(Element filterElement, Filterable filterable, Mappings model) {
+ final String name = filterElement.attributeValue( "name" );
+ String condition = filterElement.getTextTrim();
+ if ( StringHelper.isEmpty(condition) ) {
+ condition = filterElement.attributeValue( "condition" );
+ }
+ //TODO: bad implementation, cos it depends upon ordering of mapping doc
+ // fixing this requires that Collection/PersistentClass gain access
+ // to the Mappings reference from Configuration (or the filterDefinitions
+ // map directly) sometime during Configuration.buildSessionFactory
+ // (after all the types/filter-defs are known and before building
+ // persisters).
+ if ( StringHelper.isEmpty(condition) ) {
+ condition = model.getFilterDefinition(name).getDefaultFilterCondition();
+ }
+ if ( condition==null) {
+ throw new MappingException("no filter condition found for filter: " + name);
+ }
+ log.debug( "Applying filter [" + name + "] as [" + condition + "]" );
+ filterable.addFilter( name, condition );
+ }
+
+ private static String getSubselect(Element element) {
+ String subselect = element.attributeValue( "subselect" );
+ if ( subselect != null ) {
+ return subselect;
+ }
+ else {
+ Element subselectElement = element.element( "subselect" );
+ return subselectElement == null ? null : subselectElement.getText();
+ }
+ }
+
+ /**
+ * For the given document, locate all extends attributes which refer to
+ * entities (entity-name or class-name) not defined within said document.
+ *
+ * @param doc The document to check
+ * @param mappings The already processed mappings.
+ * @return The list of unresolved extends names.
+ */
+ public static java.util.List getExtendsNeeded(Document doc, Mappings mappings) {
+ java.util.List extendz = new ArrayList();
+ Iterator[] subclasses = new Iterator[3];
+ final Element hmNode = doc.getRootElement();
+
+ Attribute packNode = hmNode.attribute( "package" );
+ final String packageName = packNode == null ? null : packNode.getValue();
+ if ( packageName != null ) {
+ mappings.setDefaultPackage( packageName );
+ }
+
+ // first, iterate over all elements capable of defining an extends attribute
+ // collecting all found extends references if they cannot be resolved
+ // against the already processed mappings.
+ subclasses[0] = hmNode.elementIterator( "subclass" );
+ subclasses[1] = hmNode.elementIterator( "joined-subclass" );
+ subclasses[2] = hmNode.elementIterator( "union-subclass" );
+
+ Iterator iterator = new JoinedIterator( subclasses );
+ while ( iterator.hasNext() ) {
+ final Element element = (Element) iterator.next();
+ final String extendsName = element.attributeValue( "extends" );
+ // mappings might contain either the "raw" extends name (in the case of
+ // an entity-name mapping) or a FQN (in the case of a POJO mapping).
+ if ( mappings.getClass( extendsName ) == null && mappings.getClass( getClassName( extendsName, mappings ) ) == null ) {
+ extendz.add( extendsName );
+ }
+ }
+
+ if ( !extendz.isEmpty() ) {
+ // we found some extends attributes referencing entities which were
+ // not already processed. here we need to locate all entity-names
+ // and class-names contained in this document itself, making sure
+ // that these get removed from the extendz list such that only
+ // extends names which require us to delay processing (i.e.
+ // external to this document and not yet processed) are contained
+ // in the returned result
+ final java.util.Set set = new HashSet( extendz );
+ EntityElementHandler handler = new EntityElementHandler() {
+ public void handleEntity(String entityName, String className, Mappings mappings) {
+ if ( entityName != null ) {
+ set.remove( entityName );
+ }
+ else {
+ String fqn = getClassName( className, packageName );
+ set.remove( fqn );
+ if ( packageName != null ) {
+ set.remove( StringHelper.unqualify( fqn ) );
+ }
+ }
+ }
+ };
+ recognizeEntities( mappings, hmNode, handler );
+ extendz.clear();
+ extendz.addAll( set );
+ }
+
+ return extendz;
+ }
+
+ /**
+ * Given an entity-containing-element (startNode) recursively locate all
+ * entity names defined within that element.
+ *
+ * @param mappings The already processed mappings
+ * @param startNode The containing element
+ * @param handler The thing that knows what to do whenever we recognize an
+ * entity-name
+ */
+ private static void recognizeEntities(
+ Mappings mappings,
+ final Element startNode,
+ EntityElementHandler handler) {
+ Iterator[] classes = new Iterator[4];
+ classes[0] = startNode.elementIterator( "class" );
+ classes[1] = startNode.elementIterator( "subclass" );
+ classes[2] = startNode.elementIterator( "joined-subclass" );
+ classes[3] = startNode.elementIterator( "union-subclass" );
+
+ Iterator classIterator = new JoinedIterator( classes );
+ while ( classIterator.hasNext() ) {
+ Element element = (Element) classIterator.next();
+ handler.handleEntity(
+ element.attributeValue( "entity-name" ),
+ element.attributeValue( "name" ),
+ mappings
+ );
+ recognizeEntities( mappings, element, handler );
+ }
+ }
+
+ private static interface EntityElementHandler {
+ public void handleEntity(String entityName, String className, Mappings mappings);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,124 +0,0 @@
-//$Id: ImprovedNamingStrategy.java 9941 2006-05-22 18:28:53Z epbernard $
-package org.hibernate.cfg;
-
-import java.io.Serializable;
-
-import org.hibernate.util.StringHelper;
-import org.hibernate.AssertionFailure;
-
-/**
- * An improved naming strategy that prefers embedded
- * underscores to mixed case names
- * @see DefaultNamingStrategy the default strategy
- * @author Gavin King
- */
-public class ImprovedNamingStrategy implements NamingStrategy, Serializable {
-
- /**
- * A convenient singleton instance
- */
- public static final NamingStrategy INSTANCE = new ImprovedNamingStrategy();
-
- /**
- * Return the unqualified class name, mixed case converted to
- * underscores
- */
- public String classToTableName(String className) {
- return addUnderscores( StringHelper.unqualify(className) );
- }
- /**
- * Return the full property path with underscore seperators, mixed
- * case converted to underscores
- */
- public String propertyToColumnName(String propertyName) {
- return addUnderscores( StringHelper.unqualify(propertyName) );
- }
- /**
- * Convert mixed case to underscores
- */
- public String tableName(String tableName) {
- return addUnderscores(tableName);
- }
- /**
- * Convert mixed case to underscores
- */
- public String columnName(String columnName) {
- return addUnderscores(columnName);
- }
-
- protected static String addUnderscores(String name) {
- StringBuffer buf = new StringBuffer( name.replace('.', '_') );
- for (int i=1; i<buf.length()-1; i++) {
- if (
- Character.isLowerCase( buf.charAt(i-1) ) &&
- Character.isUpperCase( buf.charAt(i) ) &&
- Character.isLowerCase( buf.charAt(i+1) )
- ) {
- buf.insert(i++, '_');
- }
- }
- return buf.toString().toLowerCase();
- }
-
- public String collectionTableName(
- String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
- String propertyName
- ) {
- return tableName( ownerEntityTable + '_' + propertyToColumnName(propertyName) );
- }
-
- /**
- * Return the argument
- */
- public String joinKeyColumnName(String joinedColumn, String joinedTable) {
- return columnName( joinedColumn );
- }
-
- /**
- * Return the property name or propertyTableName
- */
- public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
- ) {
- String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
- if (header == null) throw new AssertionFailure("NamingStrategy not properly filled");
- return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
- }
-
- /**
- * Return the column name or the unqualified property name
- */
- public String logicalColumnName(String columnName, String propertyName) {
- return StringHelper.isNotEmpty( columnName ) ? columnName : StringHelper.unqualify( propertyName );
- }
-
- /**
- * Returns either the table name if explicit or
- * if there is an associated table, the concatenation of owner entity table and associated table
- * otherwise the concatenation of owner entity table and the unqualified property name
- */
- public String logicalCollectionTableName(String tableName,
- String ownerEntityTable, String associatedEntityTable, String propertyName
- ) {
- if ( tableName != null ) {
- return tableName;
- }
- else {
- //use of a stringbuffer to workaround a JDK bug
- return new StringBuffer(ownerEntityTable).append("_")
- .append(
- associatedEntityTable != null ?
- associatedEntityTable :
- StringHelper.unqualify( propertyName )
- ).toString();
- }
- }
- /**
- * Return the column name if explicit or the concatenation of the property name and the referenced column
- */
- public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
- return StringHelper.isNotEmpty( columnName ) ?
- columnName :
- StringHelper.unqualify( propertyName ) + "_" + referencedColumn;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,147 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.Serializable;
+
+import org.hibernate.util.StringHelper;
+import org.hibernate.AssertionFailure;
+
+/**
+ * An improved naming strategy that prefers embedded
+ * underscores to mixed case names
+ * @see DefaultNamingStrategy the default strategy
+ * @author Gavin King
+ */
+public class ImprovedNamingStrategy implements NamingStrategy, Serializable {
+
+ /**
+ * A convenient singleton instance
+ */
+ public static final NamingStrategy INSTANCE = new ImprovedNamingStrategy();
+
+ /**
+ * Return the unqualified class name, mixed case converted to
+ * underscores
+ */
+ public String classToTableName(String className) {
+ return addUnderscores( StringHelper.unqualify(className) );
+ }
+ /**
+ * Return the full property path with underscore seperators, mixed
+ * case converted to underscores
+ */
+ public String propertyToColumnName(String propertyName) {
+ return addUnderscores( StringHelper.unqualify(propertyName) );
+ }
+ /**
+ * Convert mixed case to underscores
+ */
+ public String tableName(String tableName) {
+ return addUnderscores(tableName);
+ }
+ /**
+ * Convert mixed case to underscores
+ */
+ public String columnName(String columnName) {
+ return addUnderscores(columnName);
+ }
+
+ protected static String addUnderscores(String name) {
+ StringBuffer buf = new StringBuffer( name.replace('.', '_') );
+ for (int i=1; i<buf.length()-1; i++) {
+ if (
+ Character.isLowerCase( buf.charAt(i-1) ) &&
+ Character.isUpperCase( buf.charAt(i) ) &&
+ Character.isLowerCase( buf.charAt(i+1) )
+ ) {
+ buf.insert(i++, '_');
+ }
+ }
+ return buf.toString().toLowerCase();
+ }
+
+ public String collectionTableName(
+ String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
+ String propertyName
+ ) {
+ return tableName( ownerEntityTable + '_' + propertyToColumnName(propertyName) );
+ }
+
+ /**
+ * Return the argument
+ */
+ public String joinKeyColumnName(String joinedColumn, String joinedTable) {
+ return columnName( joinedColumn );
+ }
+
+ /**
+ * Return the property name or propertyTableName
+ */
+ public String foreignKeyColumnName(
+ String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
+ ) {
+ String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
+ if (header == null) throw new AssertionFailure("NamingStrategy not properly filled");
+ return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
+ }
+
+ /**
+ * Return the column name or the unqualified property name
+ */
+ public String logicalColumnName(String columnName, String propertyName) {
+ return StringHelper.isNotEmpty( columnName ) ? columnName : StringHelper.unqualify( propertyName );
+ }
+
+ /**
+ * Returns either the table name if explicit or
+ * if there is an associated table, the concatenation of owner entity table and associated table
+ * otherwise the concatenation of owner entity table and the unqualified property name
+ */
+ public String logicalCollectionTableName(String tableName,
+ String ownerEntityTable, String associatedEntityTable, String propertyName
+ ) {
+ if ( tableName != null ) {
+ return tableName;
+ }
+ else {
+ //use of a stringbuffer to workaround a JDK bug
+ return new StringBuffer(ownerEntityTable).append("_")
+ .append(
+ associatedEntityTable != null ?
+ associatedEntityTable :
+ StringHelper.unqualify( propertyName )
+ ).toString();
+ }
+ }
+ /**
+ * Return the column name if explicit or the concatenation of the property name and the referenced column
+ */
+ public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
+ return StringHelper.isNotEmpty( columnName ) ?
+ columnName :
+ StringHelper.unqualify( propertyName ) + "_" + referencedColumn;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Mappings.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,542 +0,0 @@
-//$Id: Mappings.java 11051 2007-01-16 23:24:17Z epbernard $
-package org.hibernate.cfg;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.HashMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.DuplicateMappingException;
-import org.hibernate.MappingException;
-import org.hibernate.engine.FilterDefinition;
-import org.hibernate.engine.NamedQueryDefinition;
-import org.hibernate.engine.NamedSQLQueryDefinition;
-import org.hibernate.engine.ResultSetMappingDefinition;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.DenormalizedTable;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Table;
-import org.hibernate.mapping.TypeDef;
-import org.hibernate.mapping.AuxiliaryDatabaseObject;
-import org.hibernate.mapping.Column;
-import org.hibernate.util.StringHelper;
-
-/**
- * A collection of mappings from classes and collections to
- * relational database tables. (Represents a single
- * <tt><hibernate-mapping></tt> element.)
- * @author Gavin King
- */
-public class Mappings implements Serializable {
-
- private static final Logger log = LoggerFactory.getLogger(Mappings.class);
-
- protected final Map classes;
- protected final Map collections;
- protected final Map tables;
- protected final Map queries;
- protected final Map sqlqueries;
- protected final Map resultSetMappings;
- protected final Map typeDefs;
- protected final List secondPasses;
- protected final Map imports;
- protected String schemaName;
- protected String catalogName;
- protected String defaultCascade;
- protected String defaultPackage;
- protected String defaultAccess;
- protected boolean autoImport;
- protected boolean defaultLazy;
- protected final List propertyReferences;
- protected final NamingStrategy namingStrategy;
- protected final Map filterDefinitions;
- protected final List auxiliaryDatabaseObjects;
-
- protected final Map extendsQueue;
-// private final List extendsQueue;
-
- /**
- * binding table between the logical column name and the name out of the naming strategy
- * for each table.
- * According that when the column name is not set, the property name is considered as such
- * This means that while theorically possible through the naming strategy contract, it is
- * forbidden to have 2 real columns having the same logical name
- * <Table, ColumnNames >
- */
- protected final Map columnNameBindingPerTable;
- /**
- * binding between logical table name and physical one (ie after the naming strategy has been applied)
- * <String, TableDescription>
- */
- protected final Map tableNameBinding;
-
-
- Mappings(
- final Map classes,
- final Map collections,
- final Map tables,
- final Map queries,
- final Map sqlqueries,
- final Map sqlResultSetMappings,
- final Map imports,
- final List secondPasses,
- final List propertyReferences,
- final NamingStrategy namingStrategy,
- final Map typeDefs,
- final Map filterDefinitions,
-// final List extendsQueue,
- final Map extendsQueue,
- final List auxiliaryDatabaseObjects,
- final Map tableNamebinding,
- final Map columnNameBindingPerTable
- ) {
- this.classes = classes;
- this.collections = collections;
- this.queries = queries;
- this.sqlqueries = sqlqueries;
- this.resultSetMappings = sqlResultSetMappings;
- this.tables = tables;
- this.imports = imports;
- this.secondPasses = secondPasses;
- this.propertyReferences = propertyReferences;
- this.namingStrategy = namingStrategy;
- this.typeDefs = typeDefs;
- this.filterDefinitions = filterDefinitions;
- this.extendsQueue = extendsQueue;
- this.auxiliaryDatabaseObjects = auxiliaryDatabaseObjects;
- this.tableNameBinding = tableNamebinding;
- this.columnNameBindingPerTable = columnNameBindingPerTable;
- }
-
- public void addClass(PersistentClass persistentClass) throws MappingException {
- Object old = classes.put( persistentClass.getEntityName(), persistentClass );
- if ( old!=null ) {
- throw new DuplicateMappingException( "class/entity", persistentClass.getEntityName() );
- }
- }
- public void addCollection(Collection collection) throws MappingException {
- Object old = collections.put( collection.getRole(), collection );
- if ( old!=null ) {
- throw new DuplicateMappingException( "collection role", collection.getRole() );
- }
- }
- public PersistentClass getClass(String className) {
- return (PersistentClass) classes.get(className);
- }
- public Collection getCollection(String role) {
- return (Collection) collections.get(role);
- }
-
- public void addImport(String className, String rename) throws MappingException {
- String existing = (String) imports.put(rename, className);
- if ( existing!=null ) {
- if ( existing.equals(className) ) {
- log.info( "duplicate import: " + className + "->" + rename );
- }
- else {
- throw new DuplicateMappingException(
- "duplicate import: " + rename +
- " refers to both " + className +
- " and " + existing +
- " (try using auto-import=\"false\")",
- "import",
- rename
- );
- }
- }
- }
-
- public Table addTable(String schema,
- String catalog,
- String name,
- String subselect,
- boolean isAbstract
- ) {
- String key = subselect==null ?
- Table.qualify(catalog, schema, name) :
- subselect;
- Table table = (Table) tables.get(key);
-
- if (table == null) {
- table = new Table();
- table.setAbstract(isAbstract);
- table.setName(name);
- table.setSchema(schema);
- table.setCatalog(catalog);
- table.setSubselect(subselect);
- tables.put(key, table);
- }
- else {
- if (!isAbstract) table.setAbstract(false);
- }
-
- return table;
- }
-
- public Table addDenormalizedTable(
- String schema,
- String catalog,
- String name,
- boolean isAbstract,
- String subselect,
- Table includedTable)
- throws MappingException {
- String key = subselect==null ?
- Table.qualify(catalog, schema, name) :
- subselect;
- if ( tables.containsKey(key) ) {
- throw new DuplicateMappingException("table", name);
- }
-
- Table table = new DenormalizedTable(includedTable);
- table.setAbstract(isAbstract);
- table.setName(name);
- table.setSchema(schema);
- table.setCatalog(catalog);
- table.setSubselect(subselect);
- tables.put(key, table);
- return table;
- }
-
- public Table getTable(String schema, String catalog, String name) {
- String key = Table.qualify(catalog, schema, name);
- return (Table) tables.get(key);
- }
-
- public String getSchemaName() {
- return schemaName;
- }
-
- public String getCatalogName() {
- return catalogName;
- }
-
- public String getDefaultCascade() {
- return defaultCascade;
- }
-
- /**
- * Sets the schemaName.
- * @param schemaName The schemaName to set
- */
- public void setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- }
-
- /**
- * Sets the catalogName.
- * @param catalogName The catalogName to set
- */
- public void setCatalogName(String catalogName) {
- this.catalogName = catalogName;
- }
-
- /**
- * Sets the defaultCascade.
- * @param defaultCascade The defaultCascade to set
- */
- public void setDefaultCascade(String defaultCascade) {
- this.defaultCascade = defaultCascade;
- }
-
- /**
- * sets the default access strategy
- * @param defaultAccess the default access strategy.
- */
- public void setDefaultAccess(String defaultAccess) {
- this.defaultAccess = defaultAccess;
- }
-
- public String getDefaultAccess() {
- return defaultAccess;
- }
-
- public void addQuery(String name, NamedQueryDefinition query) throws MappingException {
- checkQueryExist(name);
- queries.put( name.intern(), query );
- }
-
- public void addSQLQuery(String name, NamedSQLQueryDefinition query) throws MappingException {
- checkQueryExist(name);
- sqlqueries.put( name.intern(), query );
- }
-
- private void checkQueryExist(String name) throws MappingException {
- if ( sqlqueries.containsKey(name) || queries.containsKey(name) ) {
- throw new DuplicateMappingException("query", name);
- }
- }
-
- public void addResultSetMapping(ResultSetMappingDefinition sqlResultSetMapping) {
- final String name = sqlResultSetMapping.getName();
- if ( resultSetMappings.containsKey(name) ) {
- throw new DuplicateMappingException("resultSet", name);
- }
- resultSetMappings.put(name, sqlResultSetMapping);
- }
-
- public ResultSetMappingDefinition getResultSetMapping(String name) {
- return (ResultSetMappingDefinition) resultSetMappings.get(name);
- }
-
-
- public NamedQueryDefinition getQuery(String name) {
- return (NamedQueryDefinition) queries.get(name);
- }
-
- public void addSecondPass(SecondPass sp) {
- addSecondPass(sp, false);
- }
-
- public void addSecondPass(SecondPass sp, boolean onTopOfTheQueue) {
- if (onTopOfTheQueue) {
- secondPasses.add(0, sp);
- }
- else {
- secondPasses.add(sp);
- }
- }
-
- /**
- * Returns the autoImport.
- * @return boolean
- */
- public boolean isAutoImport() {
- return autoImport;
- }
-
- /**
- * Sets the autoImport.
- * @param autoImport The autoImport to set
- */
- public void setAutoImport(boolean autoImport) {
- this.autoImport = autoImport;
- }
-
- void addUniquePropertyReference(String referencedClass, String propertyName) {
- PropertyReference upr = new PropertyReference();
- upr.referencedClass = referencedClass;
- upr.propertyName = propertyName;
- upr.unique = true;
- propertyReferences.add(upr);
- }
-
- void addPropertyReference(String referencedClass, String propertyName) {
- PropertyReference upr = new PropertyReference();
- upr.referencedClass = referencedClass;
- upr.propertyName = propertyName;
- propertyReferences.add(upr);
- }
-
- private String buildTableNameKey(String schema, String catalog, String finalName) {
- StringBuffer keyBuilder = new StringBuffer();
- if (schema != null) keyBuilder.append( schema );
- keyBuilder.append( ".");
- if (catalog != null) keyBuilder.append( catalog );
- keyBuilder.append( ".");
- keyBuilder.append( finalName );
- return keyBuilder.toString();
- }
-
- static final class PropertyReference implements Serializable {
- String referencedClass;
- String propertyName;
- boolean unique;
- }
-
- /**
- * @return Returns the defaultPackage.
- */
- public String getDefaultPackage() {
- return defaultPackage;
- }
-
- /**
- * @param defaultPackage The defaultPackage to set.
- */
- public void setDefaultPackage(String defaultPackage) {
- this.defaultPackage = defaultPackage;
- }
-
- public NamingStrategy getNamingStrategy() {
- return namingStrategy;
- }
-
- public void addTypeDef(String typeName, String typeClass, Properties paramMap) {
- TypeDef def = new TypeDef(typeClass, paramMap);
- typeDefs.put(typeName, def);
- log.debug("Added " + typeName + " with class " + typeClass);
- }
-
- public TypeDef getTypeDef(String typeName) {
- return (TypeDef) typeDefs.get(typeName);
- }
-
- public Iterator iterateCollections() {
- return collections.values().iterator();
- }
-
- public Iterator iterateTables() {
- return tables.values().iterator();
- }
-
- public Map getFilterDefinitions() {
- return filterDefinitions;
- }
-
- public void addFilterDefinition(FilterDefinition definition) {
- filterDefinitions.put( definition.getFilterName(), definition );
- }
-
- public FilterDefinition getFilterDefinition(String name) {
- return (FilterDefinition) filterDefinitions.get(name);
- }
-
- public boolean isDefaultLazy() {
- return defaultLazy;
- }
- public void setDefaultLazy(boolean defaultLazy) {
- this.defaultLazy = defaultLazy;
- }
-
- public void addToExtendsQueue(ExtendsQueueEntry entry) {
- extendsQueue.put( entry, null );
- }
-
- public PersistentClass locatePersistentClassByEntityName(String entityName) {
- PersistentClass persistentClass = ( PersistentClass ) classes.get( entityName );
- if ( persistentClass == null ) {
- String actualEntityName = ( String ) imports.get( entityName );
- if ( StringHelper.isNotEmpty( actualEntityName ) ) {
- persistentClass = ( PersistentClass ) classes.get( actualEntityName );
- }
- }
- return persistentClass;
- }
-
- public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {
- auxiliaryDatabaseObjects.add( auxiliaryDatabaseObject );
- }
-
- public void addTableBinding(
- String schema, String catalog, String logicalName, String physicalName, Table denormalizedSuperTable
- ) {
- String key = buildTableNameKey( schema, catalog, physicalName );
- TableDescription tableDescription = new TableDescription(
- logicalName, denormalizedSuperTable
- );
- TableDescription oldDescriptor = (TableDescription) tableNameBinding.put( key, tableDescription );
- if ( oldDescriptor != null && ! oldDescriptor.logicalName.equals( logicalName ) ) {
- //TODO possibly relax that
- throw new MappingException("Same physical table name reference several logical table names: "
- + physicalName + " => " + "'" + oldDescriptor.logicalName + "' and '" + logicalName + "'");
- }
- }
-
- public void addColumnBinding(String logicalName, Column finalColumn, Table table) {
- ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(table);
- if (binding == null) {
- binding = new ColumnNames();
- columnNameBindingPerTable.put(table, binding);
- }
- String oldFinalName = (String) binding.logicalToPhysical.put(
- logicalName.toLowerCase(),
- finalColumn.getQuotedName()
- );
- if ( oldFinalName != null &&
- ! ( finalColumn.isQuoted() ?
- oldFinalName.equals( finalColumn.getQuotedName() ) :
- oldFinalName.equalsIgnoreCase( finalColumn.getQuotedName() ) ) ) {
- //TODO possibly relax that
- throw new MappingException("Same logical column name referenced by different physical ones: "
- + table.getName() + "." + logicalName + " => '" + oldFinalName + "' and '" + finalColumn.getQuotedName() + "'" );
- }
- String oldLogicalName = (String) binding.physicalToLogical.put(
- finalColumn.getQuotedName(),
- logicalName
- );
- if ( oldLogicalName != null && ! oldLogicalName.equals( logicalName ) ) {
- //TODO possibly relax that
- throw new MappingException("Same physical column represented by different logical column names: "
- + table.getName() + "." + finalColumn.getQuotedName() + " => '" + oldLogicalName + "' and '" + logicalName + "'");
- }
- }
-
- private String getLogicalTableName(String schema, String catalog, String physicalName) {
- String key = buildTableNameKey( schema, catalog, physicalName );
- TableDescription descriptor = (TableDescription) tableNameBinding.get( key );
- if (descriptor == null) {
- throw new MappingException( "Unable to find physical table: " + physicalName);
- }
- return descriptor.logicalName;
- }
-
- public String getPhysicalColumnName(String logicalName, Table table) {
- logicalName = logicalName.toLowerCase();
- String finalName = null;
- Table currentTable = table;
- do {
- ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
- if (binding != null) {
- finalName = (String) binding.logicalToPhysical.get( logicalName );
- }
- String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
- TableDescription description = (TableDescription) tableNameBinding.get(key);
- if (description != null) currentTable = description.denormalizedSupertable;
- }
- while (finalName == null && currentTable != null);
- if (finalName == null) {
- throw new MappingException( "Unable to find column with logical name "
- + logicalName + " in table " + table.getName() );
- }
- return finalName;
- }
-
- public String getLogicalColumnName(String physicalName, Table table) {
- String logical = null;
- Table currentTable = table;
- TableDescription description = null;
- do {
- ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
- if (binding != null) {
- logical = (String) binding.physicalToLogical.get( physicalName );
- }
- String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
- description = (TableDescription) tableNameBinding.get(key);
- if (description != null) currentTable = description.denormalizedSupertable;
- }
- while (logical == null && currentTable != null && description != null);
- if (logical == null) {
- throw new MappingException( "Unable to find logical column name from physical name "
- + physicalName + " in table " + table.getName() );
- }
- return logical;
- }
-
- public String getLogicalTableName(Table table) {
- return getLogicalTableName( table.getQuotedSchema(), table.getCatalog(), table.getQuotedName() );
- }
-
- static public class ColumnNames implements Serializable {
- //<String, String>
- public Map logicalToPhysical = new HashMap();
- //<String, String>
- public Map physicalToLogical = new HashMap();
- public ColumnNames() {
- }
- }
-
- static public class TableDescription implements Serializable {
- public TableDescription(String logicalName, Table denormalizedSupertable) {
- this.logicalName = logicalName;
- this.denormalizedSupertable = denormalizedSupertable;
- }
-
- public String logicalName;
- public Table denormalizedSupertable;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/Mappings.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Mappings.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,565 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.HashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.DuplicateMappingException;
+import org.hibernate.MappingException;
+import org.hibernate.engine.FilterDefinition;
+import org.hibernate.engine.NamedQueryDefinition;
+import org.hibernate.engine.NamedSQLQueryDefinition;
+import org.hibernate.engine.ResultSetMappingDefinition;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.DenormalizedTable;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.TypeDef;
+import org.hibernate.mapping.AuxiliaryDatabaseObject;
+import org.hibernate.mapping.Column;
+import org.hibernate.util.StringHelper;
+
+/**
+ * A collection of mappings from classes and collections to
+ * relational database tables. (Represents a single
+ * <tt><hibernate-mapping></tt> element.)
+ * @author Gavin King
+ */
+public class Mappings implements Serializable {
+
+ private static final Logger log = LoggerFactory.getLogger(Mappings.class);
+
+ protected final Map classes;
+ protected final Map collections;
+ protected final Map tables;
+ protected final Map queries;
+ protected final Map sqlqueries;
+ protected final Map resultSetMappings;
+ protected final Map typeDefs;
+ protected final List secondPasses;
+ protected final Map imports;
+ protected String schemaName;
+ protected String catalogName;
+ protected String defaultCascade;
+ protected String defaultPackage;
+ protected String defaultAccess;
+ protected boolean autoImport;
+ protected boolean defaultLazy;
+ protected final List propertyReferences;
+ protected final NamingStrategy namingStrategy;
+ protected final Map filterDefinitions;
+ protected final List auxiliaryDatabaseObjects;
+
+ protected final Map extendsQueue;
+// private final List extendsQueue;
+
+ /**
+ * binding table between the logical column name and the name out of the naming strategy
+ * for each table.
+ * According that when the column name is not set, the property name is considered as such
+ * This means that while theorically possible through the naming strategy contract, it is
+ * forbidden to have 2 real columns having the same logical name
+ * <Table, ColumnNames >
+ */
+ protected final Map columnNameBindingPerTable;
+ /**
+ * binding between logical table name and physical one (ie after the naming strategy has been applied)
+ * <String, TableDescription>
+ */
+ protected final Map tableNameBinding;
+
+
+ Mappings(
+ final Map classes,
+ final Map collections,
+ final Map tables,
+ final Map queries,
+ final Map sqlqueries,
+ final Map sqlResultSetMappings,
+ final Map imports,
+ final List secondPasses,
+ final List propertyReferences,
+ final NamingStrategy namingStrategy,
+ final Map typeDefs,
+ final Map filterDefinitions,
+// final List extendsQueue,
+ final Map extendsQueue,
+ final List auxiliaryDatabaseObjects,
+ final Map tableNamebinding,
+ final Map columnNameBindingPerTable
+ ) {
+ this.classes = classes;
+ this.collections = collections;
+ this.queries = queries;
+ this.sqlqueries = sqlqueries;
+ this.resultSetMappings = sqlResultSetMappings;
+ this.tables = tables;
+ this.imports = imports;
+ this.secondPasses = secondPasses;
+ this.propertyReferences = propertyReferences;
+ this.namingStrategy = namingStrategy;
+ this.typeDefs = typeDefs;
+ this.filterDefinitions = filterDefinitions;
+ this.extendsQueue = extendsQueue;
+ this.auxiliaryDatabaseObjects = auxiliaryDatabaseObjects;
+ this.tableNameBinding = tableNamebinding;
+ this.columnNameBindingPerTable = columnNameBindingPerTable;
+ }
+
+ public void addClass(PersistentClass persistentClass) throws MappingException {
+ Object old = classes.put( persistentClass.getEntityName(), persistentClass );
+ if ( old!=null ) {
+ throw new DuplicateMappingException( "class/entity", persistentClass.getEntityName() );
+ }
+ }
+ public void addCollection(Collection collection) throws MappingException {
+ Object old = collections.put( collection.getRole(), collection );
+ if ( old!=null ) {
+ throw new DuplicateMappingException( "collection role", collection.getRole() );
+ }
+ }
+ public PersistentClass getClass(String className) {
+ return (PersistentClass) classes.get(className);
+ }
+ public Collection getCollection(String role) {
+ return (Collection) collections.get(role);
+ }
+
+ public void addImport(String className, String rename) throws MappingException {
+ String existing = (String) imports.put(rename, className);
+ if ( existing!=null ) {
+ if ( existing.equals(className) ) {
+ log.info( "duplicate import: " + className + "->" + rename );
+ }
+ else {
+ throw new DuplicateMappingException(
+ "duplicate import: " + rename +
+ " refers to both " + className +
+ " and " + existing +
+ " (try using auto-import=\"false\")",
+ "import",
+ rename
+ );
+ }
+ }
+ }
+
+ public Table addTable(String schema,
+ String catalog,
+ String name,
+ String subselect,
+ boolean isAbstract
+ ) {
+ String key = subselect==null ?
+ Table.qualify(catalog, schema, name) :
+ subselect;
+ Table table = (Table) tables.get(key);
+
+ if (table == null) {
+ table = new Table();
+ table.setAbstract(isAbstract);
+ table.setName(name);
+ table.setSchema(schema);
+ table.setCatalog(catalog);
+ table.setSubselect(subselect);
+ tables.put(key, table);
+ }
+ else {
+ if (!isAbstract) table.setAbstract(false);
+ }
+
+ return table;
+ }
+
+ public Table addDenormalizedTable(
+ String schema,
+ String catalog,
+ String name,
+ boolean isAbstract,
+ String subselect,
+ Table includedTable)
+ throws MappingException {
+ String key = subselect==null ?
+ Table.qualify(catalog, schema, name) :
+ subselect;
+ if ( tables.containsKey(key) ) {
+ throw new DuplicateMappingException("table", name);
+ }
+
+ Table table = new DenormalizedTable(includedTable);
+ table.setAbstract(isAbstract);
+ table.setName(name);
+ table.setSchema(schema);
+ table.setCatalog(catalog);
+ table.setSubselect(subselect);
+ tables.put(key, table);
+ return table;
+ }
+
+ public Table getTable(String schema, String catalog, String name) {
+ String key = Table.qualify(catalog, schema, name);
+ return (Table) tables.get(key);
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public String getCatalogName() {
+ return catalogName;
+ }
+
+ public String getDefaultCascade() {
+ return defaultCascade;
+ }
+
+ /**
+ * Sets the schemaName.
+ * @param schemaName The schemaName to set
+ */
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+ /**
+ * Sets the catalogName.
+ * @param catalogName The catalogName to set
+ */
+ public void setCatalogName(String catalogName) {
+ this.catalogName = catalogName;
+ }
+
+ /**
+ * Sets the defaultCascade.
+ * @param defaultCascade The defaultCascade to set
+ */
+ public void setDefaultCascade(String defaultCascade) {
+ this.defaultCascade = defaultCascade;
+ }
+
+ /**
+ * sets the default access strategy
+ * @param defaultAccess the default access strategy.
+ */
+ public void setDefaultAccess(String defaultAccess) {
+ this.defaultAccess = defaultAccess;
+ }
+
+ public String getDefaultAccess() {
+ return defaultAccess;
+ }
+
+ public void addQuery(String name, NamedQueryDefinition query) throws MappingException {
+ checkQueryExist(name);
+ queries.put( name.intern(), query );
+ }
+
+ public void addSQLQuery(String name, NamedSQLQueryDefinition query) throws MappingException {
+ checkQueryExist(name);
+ sqlqueries.put( name.intern(), query );
+ }
+
+ private void checkQueryExist(String name) throws MappingException {
+ if ( sqlqueries.containsKey(name) || queries.containsKey(name) ) {
+ throw new DuplicateMappingException("query", name);
+ }
+ }
+
+ public void addResultSetMapping(ResultSetMappingDefinition sqlResultSetMapping) {
+ final String name = sqlResultSetMapping.getName();
+ if ( resultSetMappings.containsKey(name) ) {
+ throw new DuplicateMappingException("resultSet", name);
+ }
+ resultSetMappings.put(name, sqlResultSetMapping);
+ }
+
+ public ResultSetMappingDefinition getResultSetMapping(String name) {
+ return (ResultSetMappingDefinition) resultSetMappings.get(name);
+ }
+
+
+ public NamedQueryDefinition getQuery(String name) {
+ return (NamedQueryDefinition) queries.get(name);
+ }
+
+ public void addSecondPass(SecondPass sp) {
+ addSecondPass(sp, false);
+ }
+
+ public void addSecondPass(SecondPass sp, boolean onTopOfTheQueue) {
+ if (onTopOfTheQueue) {
+ secondPasses.add(0, sp);
+ }
+ else {
+ secondPasses.add(sp);
+ }
+ }
+
+ /**
+ * Returns the autoImport.
+ * @return boolean
+ */
+ public boolean isAutoImport() {
+ return autoImport;
+ }
+
+ /**
+ * Sets the autoImport.
+ * @param autoImport The autoImport to set
+ */
+ public void setAutoImport(boolean autoImport) {
+ this.autoImport = autoImport;
+ }
+
+ void addUniquePropertyReference(String referencedClass, String propertyName) {
+ PropertyReference upr = new PropertyReference();
+ upr.referencedClass = referencedClass;
+ upr.propertyName = propertyName;
+ upr.unique = true;
+ propertyReferences.add(upr);
+ }
+
+ void addPropertyReference(String referencedClass, String propertyName) {
+ PropertyReference upr = new PropertyReference();
+ upr.referencedClass = referencedClass;
+ upr.propertyName = propertyName;
+ propertyReferences.add(upr);
+ }
+
+ private String buildTableNameKey(String schema, String catalog, String finalName) {
+ StringBuffer keyBuilder = new StringBuffer();
+ if (schema != null) keyBuilder.append( schema );
+ keyBuilder.append( ".");
+ if (catalog != null) keyBuilder.append( catalog );
+ keyBuilder.append( ".");
+ keyBuilder.append( finalName );
+ return keyBuilder.toString();
+ }
+
+ static final class PropertyReference implements Serializable {
+ String referencedClass;
+ String propertyName;
+ boolean unique;
+ }
+
+ /**
+ * @return Returns the defaultPackage.
+ */
+ public String getDefaultPackage() {
+ return defaultPackage;
+ }
+
+ /**
+ * @param defaultPackage The defaultPackage to set.
+ */
+ public void setDefaultPackage(String defaultPackage) {
+ this.defaultPackage = defaultPackage;
+ }
+
+ public NamingStrategy getNamingStrategy() {
+ return namingStrategy;
+ }
+
+ public void addTypeDef(String typeName, String typeClass, Properties paramMap) {
+ TypeDef def = new TypeDef(typeClass, paramMap);
+ typeDefs.put(typeName, def);
+ log.debug("Added " + typeName + " with class " + typeClass);
+ }
+
+ public TypeDef getTypeDef(String typeName) {
+ return (TypeDef) typeDefs.get(typeName);
+ }
+
+ public Iterator iterateCollections() {
+ return collections.values().iterator();
+ }
+
+ public Iterator iterateTables() {
+ return tables.values().iterator();
+ }
+
+ public Map getFilterDefinitions() {
+ return filterDefinitions;
+ }
+
+ public void addFilterDefinition(FilterDefinition definition) {
+ filterDefinitions.put( definition.getFilterName(), definition );
+ }
+
+ public FilterDefinition getFilterDefinition(String name) {
+ return (FilterDefinition) filterDefinitions.get(name);
+ }
+
+ public boolean isDefaultLazy() {
+ return defaultLazy;
+ }
+ public void setDefaultLazy(boolean defaultLazy) {
+ this.defaultLazy = defaultLazy;
+ }
+
+ public void addToExtendsQueue(ExtendsQueueEntry entry) {
+ extendsQueue.put( entry, null );
+ }
+
+ public PersistentClass locatePersistentClassByEntityName(String entityName) {
+ PersistentClass persistentClass = ( PersistentClass ) classes.get( entityName );
+ if ( persistentClass == null ) {
+ String actualEntityName = ( String ) imports.get( entityName );
+ if ( StringHelper.isNotEmpty( actualEntityName ) ) {
+ persistentClass = ( PersistentClass ) classes.get( actualEntityName );
+ }
+ }
+ return persistentClass;
+ }
+
+ public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {
+ auxiliaryDatabaseObjects.add( auxiliaryDatabaseObject );
+ }
+
+ public void addTableBinding(
+ String schema, String catalog, String logicalName, String physicalName, Table denormalizedSuperTable
+ ) {
+ String key = buildTableNameKey( schema, catalog, physicalName );
+ TableDescription tableDescription = new TableDescription(
+ logicalName, denormalizedSuperTable
+ );
+ TableDescription oldDescriptor = (TableDescription) tableNameBinding.put( key, tableDescription );
+ if ( oldDescriptor != null && ! oldDescriptor.logicalName.equals( logicalName ) ) {
+ //TODO possibly relax that
+ throw new MappingException("Same physical table name reference several logical table names: "
+ + physicalName + " => " + "'" + oldDescriptor.logicalName + "' and '" + logicalName + "'");
+ }
+ }
+
+ public void addColumnBinding(String logicalName, Column finalColumn, Table table) {
+ ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(table);
+ if (binding == null) {
+ binding = new ColumnNames();
+ columnNameBindingPerTable.put(table, binding);
+ }
+ String oldFinalName = (String) binding.logicalToPhysical.put(
+ logicalName.toLowerCase(),
+ finalColumn.getQuotedName()
+ );
+ if ( oldFinalName != null &&
+ ! ( finalColumn.isQuoted() ?
+ oldFinalName.equals( finalColumn.getQuotedName() ) :
+ oldFinalName.equalsIgnoreCase( finalColumn.getQuotedName() ) ) ) {
+ //TODO possibly relax that
+ throw new MappingException("Same logical column name referenced by different physical ones: "
+ + table.getName() + "." + logicalName + " => '" + oldFinalName + "' and '" + finalColumn.getQuotedName() + "'" );
+ }
+ String oldLogicalName = (String) binding.physicalToLogical.put(
+ finalColumn.getQuotedName(),
+ logicalName
+ );
+ if ( oldLogicalName != null && ! oldLogicalName.equals( logicalName ) ) {
+ //TODO possibly relax that
+ throw new MappingException("Same physical column represented by different logical column names: "
+ + table.getName() + "." + finalColumn.getQuotedName() + " => '" + oldLogicalName + "' and '" + logicalName + "'");
+ }
+ }
+
+ private String getLogicalTableName(String schema, String catalog, String physicalName) {
+ String key = buildTableNameKey( schema, catalog, physicalName );
+ TableDescription descriptor = (TableDescription) tableNameBinding.get( key );
+ if (descriptor == null) {
+ throw new MappingException( "Unable to find physical table: " + physicalName);
+ }
+ return descriptor.logicalName;
+ }
+
+ public String getPhysicalColumnName(String logicalName, Table table) {
+ logicalName = logicalName.toLowerCase();
+ String finalName = null;
+ Table currentTable = table;
+ do {
+ ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
+ if (binding != null) {
+ finalName = (String) binding.logicalToPhysical.get( logicalName );
+ }
+ String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
+ TableDescription description = (TableDescription) tableNameBinding.get(key);
+ if (description != null) currentTable = description.denormalizedSupertable;
+ }
+ while (finalName == null && currentTable != null);
+ if (finalName == null) {
+ throw new MappingException( "Unable to find column with logical name "
+ + logicalName + " in table " + table.getName() );
+ }
+ return finalName;
+ }
+
+ public String getLogicalColumnName(String physicalName, Table table) {
+ String logical = null;
+ Table currentTable = table;
+ TableDescription description = null;
+ do {
+ ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
+ if (binding != null) {
+ logical = (String) binding.physicalToLogical.get( physicalName );
+ }
+ String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
+ description = (TableDescription) tableNameBinding.get(key);
+ if (description != null) currentTable = description.denormalizedSupertable;
+ }
+ while (logical == null && currentTable != null && description != null);
+ if (logical == null) {
+ throw new MappingException( "Unable to find logical column name from physical name "
+ + physicalName + " in table " + table.getName() );
+ }
+ return logical;
+ }
+
+ public String getLogicalTableName(Table table) {
+ return getLogicalTableName( table.getQuotedSchema(), table.getCatalog(), table.getQuotedName() );
+ }
+
+ static public class ColumnNames implements Serializable {
+ //<String, String>
+ public Map logicalToPhysical = new HashMap();
+ //<String, String>
+ public Map physicalToLogical = new HashMap();
+ public ColumnNames() {
+ }
+ }
+
+ static public class TableDescription implements Serializable {
+ public TableDescription(String logicalName, Table denormalizedSupertable) {
+ this.logicalName = logicalName;
+ this.denormalizedSupertable = denormalizedSupertable;
+ }
+
+ public String logicalName;
+ public Table denormalizedSupertable;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,99 +0,0 @@
-//$Id: NamedSQLQuerySecondPass.java 10196 2006-08-03 07:53:27Z max.andersen(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.util.Map;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.hibernate.MappingException;
-import org.hibernate.util.StringHelper;
-import org.hibernate.engine.NamedSQLQueryDefinition;
-import org.hibernate.engine.ResultSetMappingDefinition;
-import org.dom4j.Attribute;
-import org.dom4j.Element;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Emmanuel Bernard
- */
-public class NamedSQLQuerySecondPass extends ResultSetMappingBinder implements QuerySecondPass {
- private static Logger log = LoggerFactory.getLogger( NamedSQLQuerySecondPass.class);
- private Element queryElem;
- private String path;
- private Mappings mappings;
-
- public NamedSQLQuerySecondPass(Element queryElem, String path, Mappings mappings) {
- this.queryElem = queryElem;
- this.path = path;
- this.mappings = mappings;
- }
-
- public void doSecondPass(Map persistentClasses) throws MappingException {
- String queryName = queryElem.attribute( "name" ).getValue();
- if (path!=null) queryName = path + '.' + queryName;
-
- boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
- String region = queryElem.attributeValue( "cache-region" );
- Attribute tAtt = queryElem.attribute( "timeout" );
- Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
- Attribute fsAtt = queryElem.attribute( "fetch-size" );
- Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
- Attribute roAttr = queryElem.attribute( "read-only" );
- boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
- Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
- String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
- Attribute cmAtt = queryElem.attribute( "comment" );
- String comment = cmAtt == null ? null : cmAtt.getValue();
-
- java.util.List synchronizedTables = new ArrayList();
- Iterator tables = queryElem.elementIterator( "synchronize" );
- while ( tables.hasNext() ) {
- synchronizedTables.add( ( (Element) tables.next() ).attributeValue( "table" ) );
- }
- boolean callable = "true".equals( queryElem.attributeValue( "callable" ) );
-
- NamedSQLQueryDefinition namedQuery;
- Attribute ref = queryElem.attribute( "resultset-ref" );
- String resultSetRef = ref == null ? null : ref.getValue();
- if ( StringHelper.isNotEmpty( resultSetRef ) ) {
- namedQuery = new NamedSQLQueryDefinition(
- queryElem.getText(),
- resultSetRef,
- synchronizedTables,
- cacheable,
- region,
- timeout,
- fetchSize,
- HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ),
- HbmBinder.getCacheMode( cacheMode ),
- readOnly,
- comment,
- HbmBinder.getParameterTypes( queryElem ),
- callable
- );
- //TODO check there is no actual definition elemnents when a ref is defined
- }
- else {
- ResultSetMappingDefinition definition = buildResultSetMappingDefinition( queryElem, path, mappings );
- namedQuery = new NamedSQLQueryDefinition(
- queryElem.getText(),
- definition.getQueryReturns(),
- synchronizedTables,
- cacheable,
- region,
- timeout,
- fetchSize,
- HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ),
- HbmBinder.getCacheMode( cacheMode ),
- readOnly,
- comment,
- HbmBinder.getParameterTypes( queryElem ),
- callable
- );
- }
-
- log.debug( "Named SQL query: " + queryName + " -> " + namedQuery.getQueryString() );
- mappings.addSQLQuery( queryName, namedQuery );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamedSQLQuerySecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,122 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.MappingException;
+import org.hibernate.util.StringHelper;
+import org.hibernate.engine.NamedSQLQueryDefinition;
+import org.hibernate.engine.ResultSetMappingDefinition;
+import org.dom4j.Attribute;
+import org.dom4j.Element;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class NamedSQLQuerySecondPass extends ResultSetMappingBinder implements QuerySecondPass {
+ private static Logger log = LoggerFactory.getLogger( NamedSQLQuerySecondPass.class);
+ private Element queryElem;
+ private String path;
+ private Mappings mappings;
+
+ public NamedSQLQuerySecondPass(Element queryElem, String path, Mappings mappings) {
+ this.queryElem = queryElem;
+ this.path = path;
+ this.mappings = mappings;
+ }
+
+ public void doSecondPass(Map persistentClasses) throws MappingException {
+ String queryName = queryElem.attribute( "name" ).getValue();
+ if (path!=null) queryName = path + '.' + queryName;
+
+ boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
+ String region = queryElem.attributeValue( "cache-region" );
+ Attribute tAtt = queryElem.attribute( "timeout" );
+ Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
+ Attribute fsAtt = queryElem.attribute( "fetch-size" );
+ Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
+ Attribute roAttr = queryElem.attribute( "read-only" );
+ boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
+ Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
+ String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
+ Attribute cmAtt = queryElem.attribute( "comment" );
+ String comment = cmAtt == null ? null : cmAtt.getValue();
+
+ java.util.List synchronizedTables = new ArrayList();
+ Iterator tables = queryElem.elementIterator( "synchronize" );
+ while ( tables.hasNext() ) {
+ synchronizedTables.add( ( (Element) tables.next() ).attributeValue( "table" ) );
+ }
+ boolean callable = "true".equals( queryElem.attributeValue( "callable" ) );
+
+ NamedSQLQueryDefinition namedQuery;
+ Attribute ref = queryElem.attribute( "resultset-ref" );
+ String resultSetRef = ref == null ? null : ref.getValue();
+ if ( StringHelper.isNotEmpty( resultSetRef ) ) {
+ namedQuery = new NamedSQLQueryDefinition(
+ queryElem.getText(),
+ resultSetRef,
+ synchronizedTables,
+ cacheable,
+ region,
+ timeout,
+ fetchSize,
+ HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ),
+ HbmBinder.getCacheMode( cacheMode ),
+ readOnly,
+ comment,
+ HbmBinder.getParameterTypes( queryElem ),
+ callable
+ );
+ //TODO check there is no actual definition elemnents when a ref is defined
+ }
+ else {
+ ResultSetMappingDefinition definition = buildResultSetMappingDefinition( queryElem, path, mappings );
+ namedQuery = new NamedSQLQueryDefinition(
+ queryElem.getText(),
+ definition.getQueryReturns(),
+ synchronizedTables,
+ cacheable,
+ region,
+ timeout,
+ fetchSize,
+ HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ),
+ HbmBinder.getCacheMode( cacheMode ),
+ readOnly,
+ comment,
+ HbmBinder.getParameterTypes( queryElem ),
+ callable
+ );
+ }
+
+ log.debug( "Named SQL query: " + queryName + " -> " + namedQuery.getQueryString() );
+ mappings.addSQLQuery( queryName, namedQuery );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/NamingStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,101 +0,0 @@
-//$Id: NamingStrategy.java 9874 2006-05-04 15:10:22Z epbernard $
-package org.hibernate.cfg;
-
-/**
- * A set of rules for determining the physical column
- * and table names given the information in the mapping
- * document. May be used to implement project-scoped
- * naming standards for database objects.
- *
- * #propertyToTableName(String, String) should be replaced by
- * {@link #collectionTableName(String,String,String,String,String)}
- *
- * @see DefaultNamingStrategy
- * @see ImprovedNamingStrategy
- * @author Gavin King
- * @author Emmanuel Bernard
- */
-public interface NamingStrategy {
- /**
- * Return a table name for an entity class
- * @param className the fully-qualified class name
- * @return a table name
- */
- public String classToTableName(String className);
- /**
- * Return a column name for a property path expression
- * @param propertyName a property path
- * @return a column name
- */
- public String propertyToColumnName(String propertyName);
- /**
- * Alter the table name given in the mapping document
- * @param tableName a table name
- * @return a table name
- */
- public String tableName(String tableName);
- /**
- * Alter the column name given in the mapping document
- * @param columnName a column name
- * @return a column name
- */
- public String columnName(String columnName);
- /**
- * Return a collection table name ie an association having a join table
- *
- * @param ownerEntity
- * @param ownerEntityTable owner side table name
- * @param associatedEntity
- * @param associatedEntityTable reverse side table name if any
- * @param propertyName collection role
- */
- public String collectionTableName(
- String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
- String propertyName
- );
- /**
- * Return the join key column name ie a FK column used in a JOINED strategy or for a secondary table
- *
- * @param joinedColumn joined column name (logical one) used to join with
- * @param joinedTable joined table name (ie the referenced table) used to join with
- */
- public String joinKeyColumnName(String joinedColumn, String joinedTable);
- /**
- * Return the foreign key column name for the given parameters
- * @param propertyName the property name involved
- * @param propertyEntityName
- * @param propertyTableName the property table name involved (logical one)
- * @param referencedColumnName the referenced column name involved (logical one)
- */
- public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
- );
- /**
- * Return the logical column name used to refer to a column in the metadata
- * (like index, unique constraints etc)
- * A full bijection is required between logicalNames and physical ones
- * logicalName have to be case insersitively unique for a given table
- *
- * @param columnName given column name if any
- * @param propertyName property name of this column
- */
- public String logicalColumnName(String columnName, String propertyName);
- /**
- * Returns the logical collection table name used to refer to a table in the mapping metadata
- *
- * @param tableName the metadata explicit name
- * @param ownerEntityTable owner table entity table name (logical one)
- * @param associatedEntityTable reverse side table name if any (logical one)
- * @param propertyName collection role
- */
- public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName);
-
- /**
- * Returns the logical foreign key column name used to refer to this column in the mapping metadata
- *
- * @param columnName given column name in the metadata if any
- * @param propertyName property name
- * @param referencedColumn referenced column name (logical one) in the join
- */
- public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/NamingStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/NamingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,124 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+/**
+ * A set of rules for determining the physical column
+ * and table names given the information in the mapping
+ * document. May be used to implement project-scoped
+ * naming standards for database objects.
+ *
+ * #propertyToTableName(String, String) should be replaced by
+ * {@link #collectionTableName(String,String,String,String,String)}
+ *
+ * @see DefaultNamingStrategy
+ * @see ImprovedNamingStrategy
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ */
+public interface NamingStrategy {
+ /**
+ * Return a table name for an entity class
+ * @param className the fully-qualified class name
+ * @return a table name
+ */
+ public String classToTableName(String className);
+ /**
+ * Return a column name for a property path expression
+ * @param propertyName a property path
+ * @return a column name
+ */
+ public String propertyToColumnName(String propertyName);
+ /**
+ * Alter the table name given in the mapping document
+ * @param tableName a table name
+ * @return a table name
+ */
+ public String tableName(String tableName);
+ /**
+ * Alter the column name given in the mapping document
+ * @param columnName a column name
+ * @return a column name
+ */
+ public String columnName(String columnName);
+ /**
+ * Return a collection table name ie an association having a join table
+ *
+ * @param ownerEntity
+ * @param ownerEntityTable owner side table name
+ * @param associatedEntity
+ * @param associatedEntityTable reverse side table name if any
+ * @param propertyName collection role
+ */
+ public String collectionTableName(
+ String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
+ String propertyName
+ );
+ /**
+ * Return the join key column name ie a FK column used in a JOINED strategy or for a secondary table
+ *
+ * @param joinedColumn joined column name (logical one) used to join with
+ * @param joinedTable joined table name (ie the referenced table) used to join with
+ */
+ public String joinKeyColumnName(String joinedColumn, String joinedTable);
+ /**
+ * Return the foreign key column name for the given parameters
+ * @param propertyName the property name involved
+ * @param propertyEntityName
+ * @param propertyTableName the property table name involved (logical one)
+ * @param referencedColumnName the referenced column name involved (logical one)
+ */
+ public String foreignKeyColumnName(
+ String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
+ );
+ /**
+ * Return the logical column name used to refer to a column in the metadata
+ * (like index, unique constraints etc)
+ * A full bijection is required between logicalNames and physical ones
+ * logicalName have to be case insersitively unique for a given table
+ *
+ * @param columnName given column name if any
+ * @param propertyName property name of this column
+ */
+ public String logicalColumnName(String columnName, String propertyName);
+ /**
+ * Returns the logical collection table name used to refer to a table in the mapping metadata
+ *
+ * @param tableName the metadata explicit name
+ * @param ownerEntityTable owner table entity table name (logical one)
+ * @param associatedEntityTable reverse side table name if any (logical one)
+ * @param propertyName collection role
+ */
+ public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName);
+
+ /**
+ * Returns the logical foreign key column name used to refer to this column in the mapping metadata
+ *
+ * @param columnName given column name in the metadata if any
+ * @param propertyName property name
+ * @param referencedColumn referenced column name (logical one) in the join
+ */
+ public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,10 +0,0 @@
-//$Id: QuerySecondPass.java 9019 2006-01-11 18:50:33Z epbernard $
-package org.hibernate.cfg;
-
-/**
- * Bind query
- *
- * @author Emmanuel Bernard
- */
-public interface QuerySecondPass extends SecondPass {
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/QuerySecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,33 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+/**
+ * Bind query
+ *
+ * @author Emmanuel Bernard
+ */
+public interface QuerySecondPass extends SecondPass {
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,366 +0,0 @@
-//$Id: ResultSetMappingBinder.java 10180 2006-07-28 20:17:01Z epbernard $
-package org.hibernate.cfg;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.dom4j.Element;
-import org.hibernate.LockMode;
-import org.hibernate.MappingException;
-import org.hibernate.engine.query.sql.NativeSQLQueryCollectionReturn;
-import org.hibernate.engine.ResultSetMappingDefinition;
-import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
-import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
-import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
-import org.hibernate.mapping.Component;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Value;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.ToOne;
-import org.hibernate.type.Type;
-import org.hibernate.type.TypeFactory;
-import org.hibernate.util.ArrayHelper;
-import org.hibernate.util.CollectionHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-public abstract class ResultSetMappingBinder {
- /**
- * Build a ResultSetMappingDefinition given a containing element for the "return-XXX" elements
- *
- * @param resultSetElem The element containing the return definitions.
- * @param path No clue...
- * @param mappings The current processing state.
- * @return The description of the mappings...
- */
- protected static ResultSetMappingDefinition buildResultSetMappingDefinition(Element resultSetElem, String path, Mappings mappings) {
- String resultSetName = resultSetElem.attribute( "name" ).getValue();
- if ( path != null ) {
- resultSetName = path + '.' + resultSetName;
- }
- ResultSetMappingDefinition definition = new ResultSetMappingDefinition( resultSetName );
-
- int cnt = 0;
- Iterator returns = resultSetElem.elementIterator();
- while ( returns.hasNext() ) {
- cnt++;
- Element returnElem = (Element) returns.next();
- String name = returnElem.getName();
- if ( "return-scalar".equals( name ) ) {
- String column = returnElem.attributeValue( "column" );
- String typeFromXML = HbmBinder.getTypeFromXML( returnElem );
- Type type = null;
- if(typeFromXML!=null) {
- type = TypeFactory.heuristicType( typeFromXML );
- if ( type == null ) {
- throw new MappingException( "could not determine type " + type );
- }
- }
- definition.addQueryReturn( new NativeSQLQueryScalarReturn( column, type ) );
- }
- else if ( "return".equals( name ) ) {
- definition.addQueryReturn( bindReturn( returnElem, mappings, cnt ) );
- }
- else if ( "return-join".equals( name ) ) {
- definition.addQueryReturn( bindReturnJoin( returnElem, mappings ) );
- }
- else if ( "load-collection".equals( name ) ) {
- definition.addQueryReturn( bindLoadCollection( returnElem, mappings ) );
- }
- }
- return definition;
- }
-
- private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
- String alias = returnElem.attributeValue( "alias" );
- if( StringHelper.isEmpty(alias)) {
- alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
- }
-
- String entityName = HbmBinder.getEntityName(returnElem, mappings);
- if(entityName==null) {
- throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
- }
- LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
-
- PersistentClass pc = mappings.getClass( entityName );
- java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
-
- return new NativeSQLQueryRootReturn(
- alias,
- entityName,
- propertyResults,
- lockMode
- );
- }
-
- private static NativeSQLQueryJoinReturn bindReturnJoin(Element returnElem, Mappings mappings) {
- String alias = returnElem.attributeValue( "alias" );
- String roleAttribute = returnElem.attributeValue( "property" );
- LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
- int dot = roleAttribute.lastIndexOf( '.' );
- if ( dot == -1 ) {
- throw new MappingException(
- "Role attribute for sql query return [alias=" + alias +
- "] not formatted correctly {owningAlias.propertyName}"
- );
- }
- String roleOwnerAlias = roleAttribute.substring( 0, dot );
- String roleProperty = roleAttribute.substring( dot + 1 );
-
- //FIXME: get the PersistentClass
- java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );
-
- return new NativeSQLQueryJoinReturn(
- alias,
- roleOwnerAlias,
- roleProperty,
- propertyResults, // TODO: bindpropertyresults(alias, returnElem)
- lockMode
- );
- }
-
- private static NativeSQLQueryCollectionReturn bindLoadCollection(Element returnElem, Mappings mappings) {
- String alias = returnElem.attributeValue( "alias" );
- String collectionAttribute = returnElem.attributeValue( "role" );
- LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
- int dot = collectionAttribute.lastIndexOf( '.' );
- if ( dot == -1 ) {
- throw new MappingException(
- "Collection attribute for sql query return [alias=" + alias +
- "] not formatted correctly {OwnerClassName.propertyName}"
- );
- }
- String ownerClassName = HbmBinder.getClassName( collectionAttribute.substring( 0, dot ), mappings );
- String ownerPropertyName = collectionAttribute.substring( dot + 1 );
-
- //FIXME: get the PersistentClass
- java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );
-
- return new NativeSQLQueryCollectionReturn(
- alias,
- ownerClassName,
- ownerPropertyName,
- propertyResults,
- lockMode
- );
- }
-
- private static java.util.Map bindPropertyResults(
- String alias, Element returnElement, PersistentClass pc, Mappings mappings
- ) {
-
- HashMap propertyresults = new HashMap(); // maybe a concrete SQLpropertyresult type, but Map is exactly what is required at the moment
-
- Element discriminatorResult = returnElement.element("return-discriminator");
- if(discriminatorResult!=null) {
- ArrayList resultColumns = getResultColumns(discriminatorResult);
- propertyresults.put("class", ArrayHelper.toStringArray(resultColumns) );
- }
- Iterator iterator = returnElement.elementIterator("return-property");
- List properties = new ArrayList();
- List propertyNames = new ArrayList();
- while ( iterator.hasNext() ) {
- Element propertyresult = (Element) iterator.next();
- String name = propertyresult.attributeValue("name");
- if ( pc == null || name.indexOf( '.') == -1) { //if dotted and not load-collection nor return-join
- //regular property
- properties.add(propertyresult);
- propertyNames.add(name);
- }
- else {
- /**
- * Reorder properties
- * 1. get the parent property
- * 2. list all the properties following the expected one in the parent property
- * 3. calculate the lowest index and insert the property
- */
- if (pc == null)
- throw new MappingException("dotted notation in <return-join> or <load_collection> not yet supported");
- int dotIndex = name.lastIndexOf( '.' );
- String reducedName = name.substring( 0, dotIndex );
- Value value = pc.getRecursiveProperty( reducedName ).getValue();
- Iterator parentPropIter;
- if ( value instanceof Component ) {
- Component comp = (Component) value;
- parentPropIter = comp.getPropertyIterator();
- }
- else if ( value instanceof ToOne ) {
- ToOne toOne = (ToOne) value;
- PersistentClass referencedPc = mappings.getClass( toOne.getReferencedEntityName() );
- if ( toOne.getReferencedPropertyName() != null ) {
- try {
- parentPropIter = ( (Component) referencedPc.getRecursiveProperty( toOne.getReferencedPropertyName() ).getValue() ).getPropertyIterator();
- } catch (ClassCastException e) {
- throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
- }
- }
- else {
- try {
- if ( referencedPc.getIdentifierMapper() == null ) {
- parentPropIter = ( (Component) referencedPc.getIdentifierProperty().getValue() ).getPropertyIterator();
- }
- else {
- parentPropIter = referencedPc.getIdentifierMapper().getPropertyIterator();
- }
- }
- catch (ClassCastException e) {
- throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
- }
- }
- }
- else {
- throw new MappingException("dotted notation reference neither a component nor a many/one to one");
- }
- boolean hasFollowers = false;
- List followers = new ArrayList();
- while ( parentPropIter.hasNext() ) {
- String currentPropertyName = ( (Property) parentPropIter.next() ).getName();
- String currentName = reducedName + '.' + currentPropertyName;
- if (hasFollowers) {
- followers.add( currentName );
- }
- if ( name.equals( currentName ) ) hasFollowers = true;
- }
-
- int index = propertyNames.size();
- int followersSize = followers.size();
- for (int loop = 0 ; loop < followersSize ; loop++) {
- String follower = (String) followers.get(loop);
- int currentIndex = getIndexOfFirstMatchingProperty(propertyNames, follower);
- index = currentIndex != -1 && currentIndex < index ? currentIndex : index;
- }
- propertyNames.add(index, name);
- properties.add(index, propertyresult);
- }
- }
-
- Set uniqueReturnProperty = new HashSet();
- iterator = properties.iterator();
- while ( iterator.hasNext() ) {
- Element propertyresult = (Element) iterator.next();
- String name = propertyresult.attributeValue("name");
- if ( "class".equals(name) ) {
- throw new MappingException(
- "class is not a valid property name to use in a <return-property>, use <return-discriminator> instead"
- );
- }
- //TODO: validate existing of property with the chosen name. (secondpass )
- ArrayList allResultColumns = getResultColumns(propertyresult);
-
- if ( allResultColumns.isEmpty() ) {
- throw new MappingException(
- "return-property for alias " + alias +
- " must specify at least one column or return-column name"
- );
- }
- if ( uniqueReturnProperty.contains( name ) ) {
- throw new MappingException(
- "duplicate return-property for property " + name +
- " on alias " + alias
- );
- }
- uniqueReturnProperty.add(name);
-
- // the issue here is that for <return-join/> representing an entity collection,
- // the collection element values (the property values of the associated entity)
- // are represented as 'element.{propertyname}'. Thus the StringHelper.root()
- // here puts everything under 'element' (which additionally has significant
- // meaning). Probably what we need to do is to something like this instead:
- // String root = StringHelper.root( name );
- // String key = root; // by default
- // if ( !root.equals( name ) ) {
- // // we had a dot
- // if ( !root.equals( alias ) {
- // // the root does not apply to the specific alias
- // if ( "elements".equals( root ) {
- // // we specifically have a <return-join/> representing an entity collection
- // // and this <return-property/> is one of that entity's properties
- // key = name;
- // }
- // }
- // }
- // but I am not clear enough on the intended purpose of this code block, especially
- // in relation to the "Reorder properties" code block above...
-// String key = StringHelper.root( name );
- String key = name;
- ArrayList intermediateResults = (ArrayList) propertyresults.get( key );
- if (intermediateResults == null) {
- propertyresults.put( key, allResultColumns );
- }
- else {
- intermediateResults.addAll( allResultColumns );
- }
- }
-
- Iterator entries = propertyresults.entrySet().iterator();
- while ( entries.hasNext() ) {
- Map.Entry entry = (Map.Entry) entries.next();
- if (entry.getValue() instanceof ArrayList) {
- ArrayList list = (ArrayList) entry.getValue();
- entry.setValue( list.toArray( new String[ list.size() ] ) );
- }
- }
- return propertyresults.isEmpty() ? CollectionHelper.EMPTY_MAP : propertyresults;
- }
-
- private static int getIndexOfFirstMatchingProperty(List propertyNames, String follower) {
- int propertySize = propertyNames.size();
- for (int propIndex = 0 ; propIndex < propertySize ; propIndex++) {
- if ( ( (String) propertyNames.get(propIndex) ).startsWith( follower ) ) {
- return propIndex;
- }
- }
- return -1;
- }
-
- private static ArrayList getResultColumns(Element propertyresult) {
- String column = unquote(propertyresult.attributeValue("column"));
- ArrayList allResultColumns = new ArrayList();
- if(column!=null) allResultColumns.add(column);
- Iterator resultColumns = propertyresult.elementIterator("return-column");
- while ( resultColumns.hasNext() ) {
- Element element = (Element) resultColumns.next();
- allResultColumns.add( unquote(element.attributeValue("name")) );
- }
- return allResultColumns;
- }
-
- private static String unquote(String name) {
- if (name!=null && name.charAt(0)=='`') {
- name=name.substring( 1, name.length()-1 );
- }
- return name;
- }
-
- private static LockMode getLockMode(String lockMode) {
- if ( lockMode == null || "read".equals( lockMode ) ) {
- return LockMode.READ;
- }
- else if ( "none".equals( lockMode ) ) {
- return LockMode.NONE;
- }
- else if ( "upgrade".equals( lockMode ) ) {
- return LockMode.UPGRADE;
- }
- else if ( "upgrade-nowait".equals( lockMode ) ) {
- return LockMode.UPGRADE_NOWAIT;
- }
- else if ( "write".equals( lockMode ) ) {
- return LockMode.WRITE;
- }
- else if ( "force".equals( lockMode ) ) {
- return LockMode.FORCE;
- }
- else {
- throw new MappingException( "unknown lockmode" );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingBinder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,389 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.dom4j.Element;
+import org.hibernate.LockMode;
+import org.hibernate.MappingException;
+import org.hibernate.engine.query.sql.NativeSQLQueryCollectionReturn;
+import org.hibernate.engine.ResultSetMappingDefinition;
+import org.hibernate.engine.query.sql.NativeSQLQueryJoinReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn;
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Value;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.ToOne;
+import org.hibernate.type.Type;
+import org.hibernate.type.TypeFactory;
+import org.hibernate.util.ArrayHelper;
+import org.hibernate.util.CollectionHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public abstract class ResultSetMappingBinder {
+ /**
+ * Build a ResultSetMappingDefinition given a containing element for the "return-XXX" elements
+ *
+ * @param resultSetElem The element containing the return definitions.
+ * @param path No clue...
+ * @param mappings The current processing state.
+ * @return The description of the mappings...
+ */
+ protected static ResultSetMappingDefinition buildResultSetMappingDefinition(Element resultSetElem, String path, Mappings mappings) {
+ String resultSetName = resultSetElem.attribute( "name" ).getValue();
+ if ( path != null ) {
+ resultSetName = path + '.' + resultSetName;
+ }
+ ResultSetMappingDefinition definition = new ResultSetMappingDefinition( resultSetName );
+
+ int cnt = 0;
+ Iterator returns = resultSetElem.elementIterator();
+ while ( returns.hasNext() ) {
+ cnt++;
+ Element returnElem = (Element) returns.next();
+ String name = returnElem.getName();
+ if ( "return-scalar".equals( name ) ) {
+ String column = returnElem.attributeValue( "column" );
+ String typeFromXML = HbmBinder.getTypeFromXML( returnElem );
+ Type type = null;
+ if(typeFromXML!=null) {
+ type = TypeFactory.heuristicType( typeFromXML );
+ if ( type == null ) {
+ throw new MappingException( "could not determine type " + type );
+ }
+ }
+ definition.addQueryReturn( new NativeSQLQueryScalarReturn( column, type ) );
+ }
+ else if ( "return".equals( name ) ) {
+ definition.addQueryReturn( bindReturn( returnElem, mappings, cnt ) );
+ }
+ else if ( "return-join".equals( name ) ) {
+ definition.addQueryReturn( bindReturnJoin( returnElem, mappings ) );
+ }
+ else if ( "load-collection".equals( name ) ) {
+ definition.addQueryReturn( bindLoadCollection( returnElem, mappings ) );
+ }
+ }
+ return definition;
+ }
+
+ private static NativeSQLQueryRootReturn bindReturn(Element returnElem, Mappings mappings, int elementCount) {
+ String alias = returnElem.attributeValue( "alias" );
+ if( StringHelper.isEmpty(alias)) {
+ alias = "alias_" + elementCount; // hack/workaround as sqlquery impl depend on having a key.
+ }
+
+ String entityName = HbmBinder.getEntityName(returnElem, mappings);
+ if(entityName==null) {
+ throw new MappingException( "<return alias='" + alias + "'> must specify either a class or entity-name");
+ }
+ LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
+
+ PersistentClass pc = mappings.getClass( entityName );
+ java.util.Map propertyResults = bindPropertyResults(alias, returnElem, pc, mappings );
+
+ return new NativeSQLQueryRootReturn(
+ alias,
+ entityName,
+ propertyResults,
+ lockMode
+ );
+ }
+
+ private static NativeSQLQueryJoinReturn bindReturnJoin(Element returnElem, Mappings mappings) {
+ String alias = returnElem.attributeValue( "alias" );
+ String roleAttribute = returnElem.attributeValue( "property" );
+ LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
+ int dot = roleAttribute.lastIndexOf( '.' );
+ if ( dot == -1 ) {
+ throw new MappingException(
+ "Role attribute for sql query return [alias=" + alias +
+ "] not formatted correctly {owningAlias.propertyName}"
+ );
+ }
+ String roleOwnerAlias = roleAttribute.substring( 0, dot );
+ String roleProperty = roleAttribute.substring( dot + 1 );
+
+ //FIXME: get the PersistentClass
+ java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );
+
+ return new NativeSQLQueryJoinReturn(
+ alias,
+ roleOwnerAlias,
+ roleProperty,
+ propertyResults, // TODO: bindpropertyresults(alias, returnElem)
+ lockMode
+ );
+ }
+
+ private static NativeSQLQueryCollectionReturn bindLoadCollection(Element returnElem, Mappings mappings) {
+ String alias = returnElem.attributeValue( "alias" );
+ String collectionAttribute = returnElem.attributeValue( "role" );
+ LockMode lockMode = getLockMode( returnElem.attributeValue( "lock-mode" ) );
+ int dot = collectionAttribute.lastIndexOf( '.' );
+ if ( dot == -1 ) {
+ throw new MappingException(
+ "Collection attribute for sql query return [alias=" + alias +
+ "] not formatted correctly {OwnerClassName.propertyName}"
+ );
+ }
+ String ownerClassName = HbmBinder.getClassName( collectionAttribute.substring( 0, dot ), mappings );
+ String ownerPropertyName = collectionAttribute.substring( dot + 1 );
+
+ //FIXME: get the PersistentClass
+ java.util.Map propertyResults = bindPropertyResults(alias, returnElem, null, mappings );
+
+ return new NativeSQLQueryCollectionReturn(
+ alias,
+ ownerClassName,
+ ownerPropertyName,
+ propertyResults,
+ lockMode
+ );
+ }
+
+ private static java.util.Map bindPropertyResults(
+ String alias, Element returnElement, PersistentClass pc, Mappings mappings
+ ) {
+
+ HashMap propertyresults = new HashMap(); // maybe a concrete SQLpropertyresult type, but Map is exactly what is required at the moment
+
+ Element discriminatorResult = returnElement.element("return-discriminator");
+ if(discriminatorResult!=null) {
+ ArrayList resultColumns = getResultColumns(discriminatorResult);
+ propertyresults.put("class", ArrayHelper.toStringArray(resultColumns) );
+ }
+ Iterator iterator = returnElement.elementIterator("return-property");
+ List properties = new ArrayList();
+ List propertyNames = new ArrayList();
+ while ( iterator.hasNext() ) {
+ Element propertyresult = (Element) iterator.next();
+ String name = propertyresult.attributeValue("name");
+ if ( pc == null || name.indexOf( '.') == -1) { //if dotted and not load-collection nor return-join
+ //regular property
+ properties.add(propertyresult);
+ propertyNames.add(name);
+ }
+ else {
+ /**
+ * Reorder properties
+ * 1. get the parent property
+ * 2. list all the properties following the expected one in the parent property
+ * 3. calculate the lowest index and insert the property
+ */
+ if (pc == null)
+ throw new MappingException("dotted notation in <return-join> or <load_collection> not yet supported");
+ int dotIndex = name.lastIndexOf( '.' );
+ String reducedName = name.substring( 0, dotIndex );
+ Value value = pc.getRecursiveProperty( reducedName ).getValue();
+ Iterator parentPropIter;
+ if ( value instanceof Component ) {
+ Component comp = (Component) value;
+ parentPropIter = comp.getPropertyIterator();
+ }
+ else if ( value instanceof ToOne ) {
+ ToOne toOne = (ToOne) value;
+ PersistentClass referencedPc = mappings.getClass( toOne.getReferencedEntityName() );
+ if ( toOne.getReferencedPropertyName() != null ) {
+ try {
+ parentPropIter = ( (Component) referencedPc.getRecursiveProperty( toOne.getReferencedPropertyName() ).getValue() ).getPropertyIterator();
+ } catch (ClassCastException e) {
+ throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
+ }
+ }
+ else {
+ try {
+ if ( referencedPc.getIdentifierMapper() == null ) {
+ parentPropIter = ( (Component) referencedPc.getIdentifierProperty().getValue() ).getPropertyIterator();
+ }
+ else {
+ parentPropIter = referencedPc.getIdentifierMapper().getPropertyIterator();
+ }
+ }
+ catch (ClassCastException e) {
+ throw new MappingException("dotted notation reference neither a component nor a many/one to one", e);
+ }
+ }
+ }
+ else {
+ throw new MappingException("dotted notation reference neither a component nor a many/one to one");
+ }
+ boolean hasFollowers = false;
+ List followers = new ArrayList();
+ while ( parentPropIter.hasNext() ) {
+ String currentPropertyName = ( (Property) parentPropIter.next() ).getName();
+ String currentName = reducedName + '.' + currentPropertyName;
+ if (hasFollowers) {
+ followers.add( currentName );
+ }
+ if ( name.equals( currentName ) ) hasFollowers = true;
+ }
+
+ int index = propertyNames.size();
+ int followersSize = followers.size();
+ for (int loop = 0 ; loop < followersSize ; loop++) {
+ String follower = (String) followers.get(loop);
+ int currentIndex = getIndexOfFirstMatchingProperty(propertyNames, follower);
+ index = currentIndex != -1 && currentIndex < index ? currentIndex : index;
+ }
+ propertyNames.add(index, name);
+ properties.add(index, propertyresult);
+ }
+ }
+
+ Set uniqueReturnProperty = new HashSet();
+ iterator = properties.iterator();
+ while ( iterator.hasNext() ) {
+ Element propertyresult = (Element) iterator.next();
+ String name = propertyresult.attributeValue("name");
+ if ( "class".equals(name) ) {
+ throw new MappingException(
+ "class is not a valid property name to use in a <return-property>, use <return-discriminator> instead"
+ );
+ }
+ //TODO: validate existing of property with the chosen name. (secondpass )
+ ArrayList allResultColumns = getResultColumns(propertyresult);
+
+ if ( allResultColumns.isEmpty() ) {
+ throw new MappingException(
+ "return-property for alias " + alias +
+ " must specify at least one column or return-column name"
+ );
+ }
+ if ( uniqueReturnProperty.contains( name ) ) {
+ throw new MappingException(
+ "duplicate return-property for property " + name +
+ " on alias " + alias
+ );
+ }
+ uniqueReturnProperty.add(name);
+
+ // the issue here is that for <return-join/> representing an entity collection,
+ // the collection element values (the property values of the associated entity)
+ // are represented as 'element.{propertyname}'. Thus the StringHelper.root()
+ // here puts everything under 'element' (which additionally has significant
+ // meaning). Probably what we need to do is to something like this instead:
+ // String root = StringHelper.root( name );
+ // String key = root; // by default
+ // if ( !root.equals( name ) ) {
+ // // we had a dot
+ // if ( !root.equals( alias ) {
+ // // the root does not apply to the specific alias
+ // if ( "elements".equals( root ) {
+ // // we specifically have a <return-join/> representing an entity collection
+ // // and this <return-property/> is one of that entity's properties
+ // key = name;
+ // }
+ // }
+ // }
+ // but I am not clear enough on the intended purpose of this code block, especially
+ // in relation to the "Reorder properties" code block above...
+// String key = StringHelper.root( name );
+ String key = name;
+ ArrayList intermediateResults = (ArrayList) propertyresults.get( key );
+ if (intermediateResults == null) {
+ propertyresults.put( key, allResultColumns );
+ }
+ else {
+ intermediateResults.addAll( allResultColumns );
+ }
+ }
+
+ Iterator entries = propertyresults.entrySet().iterator();
+ while ( entries.hasNext() ) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ if (entry.getValue() instanceof ArrayList) {
+ ArrayList list = (ArrayList) entry.getValue();
+ entry.setValue( list.toArray( new String[ list.size() ] ) );
+ }
+ }
+ return propertyresults.isEmpty() ? CollectionHelper.EMPTY_MAP : propertyresults;
+ }
+
+ private static int getIndexOfFirstMatchingProperty(List propertyNames, String follower) {
+ int propertySize = propertyNames.size();
+ for (int propIndex = 0 ; propIndex < propertySize ; propIndex++) {
+ if ( ( (String) propertyNames.get(propIndex) ).startsWith( follower ) ) {
+ return propIndex;
+ }
+ }
+ return -1;
+ }
+
+ private static ArrayList getResultColumns(Element propertyresult) {
+ String column = unquote(propertyresult.attributeValue("column"));
+ ArrayList allResultColumns = new ArrayList();
+ if(column!=null) allResultColumns.add(column);
+ Iterator resultColumns = propertyresult.elementIterator("return-column");
+ while ( resultColumns.hasNext() ) {
+ Element element = (Element) resultColumns.next();
+ allResultColumns.add( unquote(element.attributeValue("name")) );
+ }
+ return allResultColumns;
+ }
+
+ private static String unquote(String name) {
+ if (name!=null && name.charAt(0)=='`') {
+ name=name.substring( 1, name.length()-1 );
+ }
+ return name;
+ }
+
+ private static LockMode getLockMode(String lockMode) {
+ if ( lockMode == null || "read".equals( lockMode ) ) {
+ return LockMode.READ;
+ }
+ else if ( "none".equals( lockMode ) ) {
+ return LockMode.NONE;
+ }
+ else if ( "upgrade".equals( lockMode ) ) {
+ return LockMode.UPGRADE;
+ }
+ else if ( "upgrade-nowait".equals( lockMode ) ) {
+ return LockMode.UPGRADE_NOWAIT;
+ }
+ else if ( "write".equals( lockMode ) ) {
+ return LockMode.WRITE;
+ }
+ else if ( "force".equals( lockMode ) ) {
+ return LockMode.FORCE;
+ }
+ else {
+ throw new MappingException( "unknown lockmode" );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,28 +0,0 @@
-//$Id: ResultSetMappingSecondPass.java 10196 2006-08-03 07:53:27Z max.andersen(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.util.Map;
-
-import org.dom4j.Element;
-import org.hibernate.MappingException;
-import org.hibernate.engine.ResultSetMappingDefinition;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ResultSetMappingSecondPass extends ResultSetMappingBinder implements QuerySecondPass {
- private Element element;
- private String path;
- private Mappings mappings;
-
- public ResultSetMappingSecondPass(Element element, String path, Mappings mappings) {
- this.element = element;
- this.path = path;
- this.mappings = mappings;
- }
-
- public void doSecondPass(Map persistentClasses) throws MappingException {
- ResultSetMappingDefinition definition = buildResultSetMappingDefinition( element, path, mappings);
- mappings.addResultSetMapping( definition );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/ResultSetMappingSecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.util.Map;
+
+import org.dom4j.Element;
+import org.hibernate.MappingException;
+import org.hibernate.engine.ResultSetMappingDefinition;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ResultSetMappingSecondPass extends ResultSetMappingBinder implements QuerySecondPass {
+ private Element element;
+ private String path;
+ private Mappings mappings;
+
+ public ResultSetMappingSecondPass(Element element, String path, Mappings mappings) {
+ this.element = element;
+ this.path = path;
+ this.mappings = mappings;
+ }
+
+ public void doSecondPass(Map persistentClasses) throws MappingException {
+ ResultSetMappingDefinition definition = buildResultSetMappingDefinition( element, path, mappings);
+ mappings.addResultSetMapping( definition );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/SecondPass.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,18 +0,0 @@
-//$Id: SecondPass.java 10196 2006-08-03 07:53:27Z max.andersen(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.io.Serializable;
-
-import org.hibernate.MappingException;
-
-/**
- * Second pass operation
- *
- * @author Emmanuel Bernard
- */
-public interface SecondPass extends Serializable {
-
- void doSecondPass(java.util.Map persistentClasses)
- throws MappingException;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/SecondPass.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SecondPass.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.Serializable;
+
+import org.hibernate.MappingException;
+
+/**
+ * Second pass operation
+ *
+ * @author Emmanuel Bernard
+ */
+public interface SecondPass extends Serializable {
+
+ void doSecondPass(java.util.Map persistentClasses)
+ throws MappingException;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,461 +0,0 @@
-//$Id: Settings.java 11402 2007-04-11 14:24:35Z steve.ebersole(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.util.Map;
-
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.EntityMode;
-import org.hibernate.cache.QueryCacheFactory;
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.exception.SQLExceptionConverter;
-import org.hibernate.hql.QueryTranslatorFactory;
-import org.hibernate.jdbc.BatcherFactory;
-import org.hibernate.jdbc.util.SQLStatementLogger;
-import org.hibernate.transaction.TransactionFactory;
-import org.hibernate.transaction.TransactionManagerLookup;
-
-/**
- * Settings that affect the behaviour of Hibernate at runtime.
- *
- * @author Gavin King
- */
-public final class Settings {
-
-// private boolean showSql;
-// private boolean formatSql;
- private SQLStatementLogger sqlStatementLogger;
- private Integer maximumFetchDepth;
- private Map querySubstitutions;
- private Dialect dialect;
- private int jdbcBatchSize;
- private int defaultBatchFetchSize;
- private boolean scrollableResultSetsEnabled;
- private boolean getGeneratedKeysEnabled;
- private String defaultSchemaName;
- private String defaultCatalogName;
- private Integer jdbcFetchSize;
- private String sessionFactoryName;
- private boolean autoCreateSchema;
- private boolean autoDropSchema;
- private boolean autoUpdateSchema;
- private boolean autoValidateSchema;
- private boolean queryCacheEnabled;
- private boolean structuredCacheEntriesEnabled;
- private boolean secondLevelCacheEnabled;
- private String cacheRegionPrefix;
- private boolean minimalPutsEnabled;
- private boolean commentsEnabled;
- private boolean statisticsEnabled;
- private boolean jdbcBatchVersionedData;
- private boolean identifierRollbackEnabled;
- private boolean flushBeforeCompletionEnabled;
- private boolean autoCloseSessionEnabled;
- private ConnectionReleaseMode connectionReleaseMode;
- private RegionFactory regionFactory;
- private QueryCacheFactory queryCacheFactory;
- private ConnectionProvider connectionProvider;
- private TransactionFactory transactionFactory;
- private TransactionManagerLookup transactionManagerLookup;
- private BatcherFactory batcherFactory;
- private QueryTranslatorFactory queryTranslatorFactory;
- private SQLExceptionConverter sqlExceptionConverter;
- private boolean wrapResultSetsEnabled;
- private boolean orderUpdatesEnabled;
- private boolean orderInsertsEnabled;
- private EntityMode defaultEntityMode;
- private boolean dataDefinitionImplicitCommit;
- private boolean dataDefinitionInTransactionSupported;
- private boolean strictJPAQLCompliance;
- private boolean namedQueryStartupCheckingEnabled;
-// private BytecodeProvider bytecodeProvider;
-
- /**
- * Package protected constructor
- */
- Settings() {
- }
-
- // public getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-// public boolean isShowSqlEnabled() {
-// return showSql;
-// }
-//
-// public boolean isFormatSqlEnabled() {
-// return formatSql;
-// }
-
- public SQLStatementLogger getSqlStatementLogger() {
- return sqlStatementLogger;
- }
-
- public String getDefaultSchemaName() {
- return defaultSchemaName;
- }
-
- public String getDefaultCatalogName() {
- return defaultCatalogName;
- }
-
- public Dialect getDialect() {
- return dialect;
- }
-
- public int getJdbcBatchSize() {
- return jdbcBatchSize;
- }
-
- public int getDefaultBatchFetchSize() {
- return defaultBatchFetchSize;
- }
-
- public Map getQuerySubstitutions() {
- return querySubstitutions;
- }
-
- public boolean isIdentifierRollbackEnabled() {
- return identifierRollbackEnabled;
- }
-
- public boolean isScrollableResultSetsEnabled() {
- return scrollableResultSetsEnabled;
- }
-
- public boolean isGetGeneratedKeysEnabled() {
- return getGeneratedKeysEnabled;
- }
-
- public boolean isMinimalPutsEnabled() {
- return minimalPutsEnabled;
- }
-
- public Integer getJdbcFetchSize() {
- return jdbcFetchSize;
- }
-
- public ConnectionProvider getConnectionProvider() {
- return connectionProvider;
- }
-
- public TransactionFactory getTransactionFactory() {
- return transactionFactory;
- }
-
- public String getSessionFactoryName() {
- return sessionFactoryName;
- }
-
- public boolean isAutoCreateSchema() {
- return autoCreateSchema;
- }
-
- public boolean isAutoDropSchema() {
- return autoDropSchema;
- }
-
- public boolean isAutoUpdateSchema() {
- return autoUpdateSchema;
- }
-
- public Integer getMaximumFetchDepth() {
- return maximumFetchDepth;
- }
-
- public RegionFactory getRegionFactory() {
- return regionFactory;
- }
-
- public TransactionManagerLookup getTransactionManagerLookup() {
- return transactionManagerLookup;
- }
-
- public boolean isQueryCacheEnabled() {
- return queryCacheEnabled;
- }
-
- public boolean isCommentsEnabled() {
- return commentsEnabled;
- }
-
- public boolean isSecondLevelCacheEnabled() {
- return secondLevelCacheEnabled;
- }
-
- public String getCacheRegionPrefix() {
- return cacheRegionPrefix;
- }
-
- public QueryCacheFactory getQueryCacheFactory() {
- return queryCacheFactory;
- }
-
- public boolean isStatisticsEnabled() {
- return statisticsEnabled;
- }
-
- public boolean isJdbcBatchVersionedData() {
- return jdbcBatchVersionedData;
- }
-
- public boolean isFlushBeforeCompletionEnabled() {
- return flushBeforeCompletionEnabled;
- }
-
- public BatcherFactory getBatcherFactory() {
- return batcherFactory;
- }
-
- public boolean isAutoCloseSessionEnabled() {
- return autoCloseSessionEnabled;
- }
-
- public ConnectionReleaseMode getConnectionReleaseMode() {
- return connectionReleaseMode;
- }
-
- public QueryTranslatorFactory getQueryTranslatorFactory() {
- return queryTranslatorFactory;
- }
-
- public SQLExceptionConverter getSQLExceptionConverter() {
- return sqlExceptionConverter;
- }
-
- public boolean isWrapResultSetsEnabled() {
- return wrapResultSetsEnabled;
- }
-
- public boolean isOrderUpdatesEnabled() {
- return orderUpdatesEnabled;
- }
-
- public boolean isOrderInsertsEnabled() {
- return orderInsertsEnabled;
- }
-
- public boolean isStructuredCacheEntriesEnabled() {
- return structuredCacheEntriesEnabled;
- }
-
- public EntityMode getDefaultEntityMode() {
- return defaultEntityMode;
- }
-
- public boolean isAutoValidateSchema() {
- return autoValidateSchema;
- }
-
- public boolean isDataDefinitionImplicitCommit() {
- return dataDefinitionImplicitCommit;
- }
-
- public boolean isDataDefinitionInTransactionSupported() {
- return dataDefinitionInTransactionSupported;
- }
-
- public boolean isStrictJPAQLCompliance() {
- return strictJPAQLCompliance;
- }
-
- public boolean isNamedQueryStartupCheckingEnabled() {
- return namedQueryStartupCheckingEnabled;
- }
-
-
- // package protected setters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-// void setShowSqlEnabled(boolean b) {
-// showSql = b;
-// }
-//
-// void setFormatSqlEnabled(boolean b) {
-// formatSql = b;
-// }
-
- void setSqlStatementLogger(SQLStatementLogger sqlStatementLogger) {
- this.sqlStatementLogger = sqlStatementLogger;
- }
-
- void setDefaultSchemaName(String string) {
- defaultSchemaName = string;
- }
-
- void setDefaultCatalogName(String string) {
- defaultCatalogName = string;
- }
-
- void setDialect(Dialect dialect) {
- this.dialect = dialect;
- }
-
- void setJdbcBatchSize(int i) {
- jdbcBatchSize = i;
- }
-
- void setDefaultBatchFetchSize(int i) {
- defaultBatchFetchSize = i;
- }
-
- void setQuerySubstitutions(Map map) {
- querySubstitutions = map;
- }
-
- void setIdentifierRollbackEnabled(boolean b) {
- identifierRollbackEnabled = b;
- }
-
- void setMinimalPutsEnabled(boolean b) {
- minimalPutsEnabled = b;
- }
-
- void setScrollableResultSetsEnabled(boolean b) {
- scrollableResultSetsEnabled = b;
- }
-
- void setGetGeneratedKeysEnabled(boolean b) {
- getGeneratedKeysEnabled = b;
- }
-
- void setJdbcFetchSize(Integer integer) {
- jdbcFetchSize = integer;
- }
-
- void setConnectionProvider(ConnectionProvider provider) {
- connectionProvider = provider;
- }
-
- void setTransactionFactory(TransactionFactory factory) {
- transactionFactory = factory;
- }
-
- void setSessionFactoryName(String string) {
- sessionFactoryName = string;
- }
-
- void setAutoCreateSchema(boolean b) {
- autoCreateSchema = b;
- }
-
- void setAutoDropSchema(boolean b) {
- autoDropSchema = b;
- }
-
- void setAutoUpdateSchema(boolean b) {
- autoUpdateSchema = b;
- }
-
- void setMaximumFetchDepth(Integer i) {
- maximumFetchDepth = i;
- }
-
- void setRegionFactory(RegionFactory regionFactory) {
- this.regionFactory = regionFactory;
- }
-
- void setTransactionManagerLookup(TransactionManagerLookup lookup) {
- transactionManagerLookup = lookup;
- }
-
- void setQueryCacheEnabled(boolean b) {
- queryCacheEnabled = b;
- }
-
- void setCommentsEnabled(boolean commentsEnabled) {
- this.commentsEnabled = commentsEnabled;
- }
-
- void setSecondLevelCacheEnabled(boolean secondLevelCacheEnabled) {
- this.secondLevelCacheEnabled = secondLevelCacheEnabled;
- }
-
- void setCacheRegionPrefix(String cacheRegionPrefix) {
- this.cacheRegionPrefix = cacheRegionPrefix;
- }
-
- void setQueryCacheFactory(QueryCacheFactory queryCacheFactory) {
- this.queryCacheFactory = queryCacheFactory;
- }
-
- void setStatisticsEnabled(boolean statisticsEnabled) {
- this.statisticsEnabled = statisticsEnabled;
- }
-
- void setJdbcBatchVersionedData(boolean jdbcBatchVersionedData) {
- this.jdbcBatchVersionedData = jdbcBatchVersionedData;
- }
-
- void setFlushBeforeCompletionEnabled(boolean flushBeforeCompletionEnabled) {
- this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
- }
-
- void setBatcherFactory(BatcherFactory batcher) {
- this.batcherFactory = batcher;
- }
-
- void setAutoCloseSessionEnabled(boolean autoCloseSessionEnabled) {
- this.autoCloseSessionEnabled = autoCloseSessionEnabled;
- }
-
- void setConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
- this.connectionReleaseMode = connectionReleaseMode;
- }
-
- void setQueryTranslatorFactory(QueryTranslatorFactory queryTranslatorFactory) {
- this.queryTranslatorFactory = queryTranslatorFactory;
- }
-
- void setSQLExceptionConverter(SQLExceptionConverter sqlExceptionConverter) {
- this.sqlExceptionConverter = sqlExceptionConverter;
- }
-
- void setWrapResultSetsEnabled(boolean wrapResultSetsEnabled) {
- this.wrapResultSetsEnabled = wrapResultSetsEnabled;
- }
-
- void setOrderUpdatesEnabled(boolean orderUpdatesEnabled) {
- this.orderUpdatesEnabled = orderUpdatesEnabled;
- }
-
- void setOrderInsertsEnabled(boolean orderInsertsEnabled) {
- this.orderInsertsEnabled = orderInsertsEnabled;
- }
-
- void setStructuredCacheEntriesEnabled(boolean structuredCacheEntriesEnabled) {
- this.structuredCacheEntriesEnabled = structuredCacheEntriesEnabled;
- }
-
- void setDefaultEntityMode(EntityMode defaultEntityMode) {
- this.defaultEntityMode = defaultEntityMode;
- }
-
- void setAutoValidateSchema(boolean autoValidateSchema) {
- this.autoValidateSchema = autoValidateSchema;
- }
-
- void setDataDefinitionImplicitCommit(boolean dataDefinitionImplicitCommit) {
- this.dataDefinitionImplicitCommit = dataDefinitionImplicitCommit;
- }
-
- void setDataDefinitionInTransactionSupported(boolean dataDefinitionInTransactionSupported) {
- this.dataDefinitionInTransactionSupported = dataDefinitionInTransactionSupported;
- }
-
- void setStrictJPAQLCompliance(boolean strictJPAQLCompliance) {
- this.strictJPAQLCompliance = strictJPAQLCompliance;
- }
-
- void setNamedQueryStartupCheckingEnabled(boolean namedQueryStartupCheckingEnabled) {
- this.namedQueryStartupCheckingEnabled = namedQueryStartupCheckingEnabled;
- }
-
-
-// public BytecodeProvider getBytecodeProvider() {
-// return bytecodeProvider;
-// }
-//
-// void setBytecodeProvider(BytecodeProvider bytecodeProvider) {
-// this.bytecodeProvider = bytecodeProvider;
-// }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/Settings.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/Settings.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,484 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.util.Map;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.EntityMode;
+import org.hibernate.cache.QueryCacheFactory;
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.hql.QueryTranslatorFactory;
+import org.hibernate.jdbc.BatcherFactory;
+import org.hibernate.jdbc.util.SQLStatementLogger;
+import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.transaction.TransactionManagerLookup;
+
+/**
+ * Settings that affect the behaviour of Hibernate at runtime.
+ *
+ * @author Gavin King
+ */
+public final class Settings {
+
+// private boolean showSql;
+// private boolean formatSql;
+ private SQLStatementLogger sqlStatementLogger;
+ private Integer maximumFetchDepth;
+ private Map querySubstitutions;
+ private Dialect dialect;
+ private int jdbcBatchSize;
+ private int defaultBatchFetchSize;
+ private boolean scrollableResultSetsEnabled;
+ private boolean getGeneratedKeysEnabled;
+ private String defaultSchemaName;
+ private String defaultCatalogName;
+ private Integer jdbcFetchSize;
+ private String sessionFactoryName;
+ private boolean autoCreateSchema;
+ private boolean autoDropSchema;
+ private boolean autoUpdateSchema;
+ private boolean autoValidateSchema;
+ private boolean queryCacheEnabled;
+ private boolean structuredCacheEntriesEnabled;
+ private boolean secondLevelCacheEnabled;
+ private String cacheRegionPrefix;
+ private boolean minimalPutsEnabled;
+ private boolean commentsEnabled;
+ private boolean statisticsEnabled;
+ private boolean jdbcBatchVersionedData;
+ private boolean identifierRollbackEnabled;
+ private boolean flushBeforeCompletionEnabled;
+ private boolean autoCloseSessionEnabled;
+ private ConnectionReleaseMode connectionReleaseMode;
+ private RegionFactory regionFactory;
+ private QueryCacheFactory queryCacheFactory;
+ private ConnectionProvider connectionProvider;
+ private TransactionFactory transactionFactory;
+ private TransactionManagerLookup transactionManagerLookup;
+ private BatcherFactory batcherFactory;
+ private QueryTranslatorFactory queryTranslatorFactory;
+ private SQLExceptionConverter sqlExceptionConverter;
+ private boolean wrapResultSetsEnabled;
+ private boolean orderUpdatesEnabled;
+ private boolean orderInsertsEnabled;
+ private EntityMode defaultEntityMode;
+ private boolean dataDefinitionImplicitCommit;
+ private boolean dataDefinitionInTransactionSupported;
+ private boolean strictJPAQLCompliance;
+ private boolean namedQueryStartupCheckingEnabled;
+// private BytecodeProvider bytecodeProvider;
+
+ /**
+ * Package protected constructor
+ */
+ Settings() {
+ }
+
+ // public getters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+// public boolean isShowSqlEnabled() {
+// return showSql;
+// }
+//
+// public boolean isFormatSqlEnabled() {
+// return formatSql;
+// }
+
+ public SQLStatementLogger getSqlStatementLogger() {
+ return sqlStatementLogger;
+ }
+
+ public String getDefaultSchemaName() {
+ return defaultSchemaName;
+ }
+
+ public String getDefaultCatalogName() {
+ return defaultCatalogName;
+ }
+
+ public Dialect getDialect() {
+ return dialect;
+ }
+
+ public int getJdbcBatchSize() {
+ return jdbcBatchSize;
+ }
+
+ public int getDefaultBatchFetchSize() {
+ return defaultBatchFetchSize;
+ }
+
+ public Map getQuerySubstitutions() {
+ return querySubstitutions;
+ }
+
+ public boolean isIdentifierRollbackEnabled() {
+ return identifierRollbackEnabled;
+ }
+
+ public boolean isScrollableResultSetsEnabled() {
+ return scrollableResultSetsEnabled;
+ }
+
+ public boolean isGetGeneratedKeysEnabled() {
+ return getGeneratedKeysEnabled;
+ }
+
+ public boolean isMinimalPutsEnabled() {
+ return minimalPutsEnabled;
+ }
+
+ public Integer getJdbcFetchSize() {
+ return jdbcFetchSize;
+ }
+
+ public ConnectionProvider getConnectionProvider() {
+ return connectionProvider;
+ }
+
+ public TransactionFactory getTransactionFactory() {
+ return transactionFactory;
+ }
+
+ public String getSessionFactoryName() {
+ return sessionFactoryName;
+ }
+
+ public boolean isAutoCreateSchema() {
+ return autoCreateSchema;
+ }
+
+ public boolean isAutoDropSchema() {
+ return autoDropSchema;
+ }
+
+ public boolean isAutoUpdateSchema() {
+ return autoUpdateSchema;
+ }
+
+ public Integer getMaximumFetchDepth() {
+ return maximumFetchDepth;
+ }
+
+ public RegionFactory getRegionFactory() {
+ return regionFactory;
+ }
+
+ public TransactionManagerLookup getTransactionManagerLookup() {
+ return transactionManagerLookup;
+ }
+
+ public boolean isQueryCacheEnabled() {
+ return queryCacheEnabled;
+ }
+
+ public boolean isCommentsEnabled() {
+ return commentsEnabled;
+ }
+
+ public boolean isSecondLevelCacheEnabled() {
+ return secondLevelCacheEnabled;
+ }
+
+ public String getCacheRegionPrefix() {
+ return cacheRegionPrefix;
+ }
+
+ public QueryCacheFactory getQueryCacheFactory() {
+ return queryCacheFactory;
+ }
+
+ public boolean isStatisticsEnabled() {
+ return statisticsEnabled;
+ }
+
+ public boolean isJdbcBatchVersionedData() {
+ return jdbcBatchVersionedData;
+ }
+
+ public boolean isFlushBeforeCompletionEnabled() {
+ return flushBeforeCompletionEnabled;
+ }
+
+ public BatcherFactory getBatcherFactory() {
+ return batcherFactory;
+ }
+
+ public boolean isAutoCloseSessionEnabled() {
+ return autoCloseSessionEnabled;
+ }
+
+ public ConnectionReleaseMode getConnectionReleaseMode() {
+ return connectionReleaseMode;
+ }
+
+ public QueryTranslatorFactory getQueryTranslatorFactory() {
+ return queryTranslatorFactory;
+ }
+
+ public SQLExceptionConverter getSQLExceptionConverter() {
+ return sqlExceptionConverter;
+ }
+
+ public boolean isWrapResultSetsEnabled() {
+ return wrapResultSetsEnabled;
+ }
+
+ public boolean isOrderUpdatesEnabled() {
+ return orderUpdatesEnabled;
+ }
+
+ public boolean isOrderInsertsEnabled() {
+ return orderInsertsEnabled;
+ }
+
+ public boolean isStructuredCacheEntriesEnabled() {
+ return structuredCacheEntriesEnabled;
+ }
+
+ public EntityMode getDefaultEntityMode() {
+ return defaultEntityMode;
+ }
+
+ public boolean isAutoValidateSchema() {
+ return autoValidateSchema;
+ }
+
+ public boolean isDataDefinitionImplicitCommit() {
+ return dataDefinitionImplicitCommit;
+ }
+
+ public boolean isDataDefinitionInTransactionSupported() {
+ return dataDefinitionInTransactionSupported;
+ }
+
+ public boolean isStrictJPAQLCompliance() {
+ return strictJPAQLCompliance;
+ }
+
+ public boolean isNamedQueryStartupCheckingEnabled() {
+ return namedQueryStartupCheckingEnabled;
+ }
+
+
+ // package protected setters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+// void setShowSqlEnabled(boolean b) {
+// showSql = b;
+// }
+//
+// void setFormatSqlEnabled(boolean b) {
+// formatSql = b;
+// }
+
+ void setSqlStatementLogger(SQLStatementLogger sqlStatementLogger) {
+ this.sqlStatementLogger = sqlStatementLogger;
+ }
+
+ void setDefaultSchemaName(String string) {
+ defaultSchemaName = string;
+ }
+
+ void setDefaultCatalogName(String string) {
+ defaultCatalogName = string;
+ }
+
+ void setDialect(Dialect dialect) {
+ this.dialect = dialect;
+ }
+
+ void setJdbcBatchSize(int i) {
+ jdbcBatchSize = i;
+ }
+
+ void setDefaultBatchFetchSize(int i) {
+ defaultBatchFetchSize = i;
+ }
+
+ void setQuerySubstitutions(Map map) {
+ querySubstitutions = map;
+ }
+
+ void setIdentifierRollbackEnabled(boolean b) {
+ identifierRollbackEnabled = b;
+ }
+
+ void setMinimalPutsEnabled(boolean b) {
+ minimalPutsEnabled = b;
+ }
+
+ void setScrollableResultSetsEnabled(boolean b) {
+ scrollableResultSetsEnabled = b;
+ }
+
+ void setGetGeneratedKeysEnabled(boolean b) {
+ getGeneratedKeysEnabled = b;
+ }
+
+ void setJdbcFetchSize(Integer integer) {
+ jdbcFetchSize = integer;
+ }
+
+ void setConnectionProvider(ConnectionProvider provider) {
+ connectionProvider = provider;
+ }
+
+ void setTransactionFactory(TransactionFactory factory) {
+ transactionFactory = factory;
+ }
+
+ void setSessionFactoryName(String string) {
+ sessionFactoryName = string;
+ }
+
+ void setAutoCreateSchema(boolean b) {
+ autoCreateSchema = b;
+ }
+
+ void setAutoDropSchema(boolean b) {
+ autoDropSchema = b;
+ }
+
+ void setAutoUpdateSchema(boolean b) {
+ autoUpdateSchema = b;
+ }
+
+ void setMaximumFetchDepth(Integer i) {
+ maximumFetchDepth = i;
+ }
+
+ void setRegionFactory(RegionFactory regionFactory) {
+ this.regionFactory = regionFactory;
+ }
+
+ void setTransactionManagerLookup(TransactionManagerLookup lookup) {
+ transactionManagerLookup = lookup;
+ }
+
+ void setQueryCacheEnabled(boolean b) {
+ queryCacheEnabled = b;
+ }
+
+ void setCommentsEnabled(boolean commentsEnabled) {
+ this.commentsEnabled = commentsEnabled;
+ }
+
+ void setSecondLevelCacheEnabled(boolean secondLevelCacheEnabled) {
+ this.secondLevelCacheEnabled = secondLevelCacheEnabled;
+ }
+
+ void setCacheRegionPrefix(String cacheRegionPrefix) {
+ this.cacheRegionPrefix = cacheRegionPrefix;
+ }
+
+ void setQueryCacheFactory(QueryCacheFactory queryCacheFactory) {
+ this.queryCacheFactory = queryCacheFactory;
+ }
+
+ void setStatisticsEnabled(boolean statisticsEnabled) {
+ this.statisticsEnabled = statisticsEnabled;
+ }
+
+ void setJdbcBatchVersionedData(boolean jdbcBatchVersionedData) {
+ this.jdbcBatchVersionedData = jdbcBatchVersionedData;
+ }
+
+ void setFlushBeforeCompletionEnabled(boolean flushBeforeCompletionEnabled) {
+ this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
+ }
+
+ void setBatcherFactory(BatcherFactory batcher) {
+ this.batcherFactory = batcher;
+ }
+
+ void setAutoCloseSessionEnabled(boolean autoCloseSessionEnabled) {
+ this.autoCloseSessionEnabled = autoCloseSessionEnabled;
+ }
+
+ void setConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) {
+ this.connectionReleaseMode = connectionReleaseMode;
+ }
+
+ void setQueryTranslatorFactory(QueryTranslatorFactory queryTranslatorFactory) {
+ this.queryTranslatorFactory = queryTranslatorFactory;
+ }
+
+ void setSQLExceptionConverter(SQLExceptionConverter sqlExceptionConverter) {
+ this.sqlExceptionConverter = sqlExceptionConverter;
+ }
+
+ void setWrapResultSetsEnabled(boolean wrapResultSetsEnabled) {
+ this.wrapResultSetsEnabled = wrapResultSetsEnabled;
+ }
+
+ void setOrderUpdatesEnabled(boolean orderUpdatesEnabled) {
+ this.orderUpdatesEnabled = orderUpdatesEnabled;
+ }
+
+ void setOrderInsertsEnabled(boolean orderInsertsEnabled) {
+ this.orderInsertsEnabled = orderInsertsEnabled;
+ }
+
+ void setStructuredCacheEntriesEnabled(boolean structuredCacheEntriesEnabled) {
+ this.structuredCacheEntriesEnabled = structuredCacheEntriesEnabled;
+ }
+
+ void setDefaultEntityMode(EntityMode defaultEntityMode) {
+ this.defaultEntityMode = defaultEntityMode;
+ }
+
+ void setAutoValidateSchema(boolean autoValidateSchema) {
+ this.autoValidateSchema = autoValidateSchema;
+ }
+
+ void setDataDefinitionImplicitCommit(boolean dataDefinitionImplicitCommit) {
+ this.dataDefinitionImplicitCommit = dataDefinitionImplicitCommit;
+ }
+
+ void setDataDefinitionInTransactionSupported(boolean dataDefinitionInTransactionSupported) {
+ this.dataDefinitionInTransactionSupported = dataDefinitionInTransactionSupported;
+ }
+
+ void setStrictJPAQLCompliance(boolean strictJPAQLCompliance) {
+ this.strictJPAQLCompliance = strictJPAQLCompliance;
+ }
+
+ void setNamedQueryStartupCheckingEnabled(boolean namedQueryStartupCheckingEnabled) {
+ this.namedQueryStartupCheckingEnabled = namedQueryStartupCheckingEnabled;
+ }
+
+
+// public BytecodeProvider getBytecodeProvider() {
+// return bytecodeProvider;
+// }
+//
+// void setBytecodeProvider(BytecodeProvider bytecodeProvider) {
+// this.bytecodeProvider = bytecodeProvider;
+// }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,440 +0,0 @@
-//$Id: SettingsFactory.java 11402 2007-04-11 14:24:35Z steve.ebersole(a)jboss.com $
-package org.hibernate.cfg;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Map;
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.bytecode.BytecodeProvider;
-import org.hibernate.cache.QueryCacheFactory;
-import org.hibernate.cache.RegionFactory;
-import org.hibernate.cache.impl.NoCachingRegionFactory;
-import org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.DialectFactory;
-import org.hibernate.exception.SQLExceptionConverter;
-import org.hibernate.exception.SQLExceptionConverterFactory;
-import org.hibernate.hql.QueryTranslatorFactory;
-import org.hibernate.jdbc.BatcherFactory;
-import org.hibernate.jdbc.BatchingBatcherFactory;
-import org.hibernate.jdbc.NonBatchingBatcherFactory;
-import org.hibernate.jdbc.util.SQLStatementLogger;
-import org.hibernate.transaction.TransactionFactory;
-import org.hibernate.transaction.TransactionFactoryFactory;
-import org.hibernate.transaction.TransactionManagerLookup;
-import org.hibernate.transaction.TransactionManagerLookupFactory;
-import org.hibernate.util.PropertiesHelper;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * Reads configuration properties and configures a <tt>Settings</tt> instance.
- *
- * @author Gavin King
- */
-public class SettingsFactory implements Serializable {
-
- public static final String DEF_CACHE_REG_FACTORY = NoCachingRegionFactory.class.getName();
- private static final Logger log = LoggerFactory.getLogger(SettingsFactory.class);
-
- protected SettingsFactory() {
- }
-
- public Settings buildSettings(Properties props) {
- Settings settings = new Settings();
-
- //SessionFactory name:
-
- String sessionFactoryName = props.getProperty(Environment.SESSION_FACTORY_NAME);
- settings.setSessionFactoryName(sessionFactoryName);
-
- //JDBC and connection settings:
-
- ConnectionProvider connections = createConnectionProvider(props);
- settings.setConnectionProvider(connections);
-
- //Interrogate JDBC metadata
-
- String databaseName = null;
- int databaseMajorVersion = 0;
- boolean metaSupportsScrollable = false;
- boolean metaSupportsGetGeneratedKeys = false;
- boolean metaSupportsBatchUpdates = false;
- boolean metaReportsDDLCausesTxnCommit = false;
- boolean metaReportsDDLInTxnSupported = true;
-
- // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
- // The need for it is intended to be alleviated with 3.3 developement, thus it is
- // not defined as an Environment constant...
- // it is used to control whether we should consult the JDBC metadata to determine
- // certain Settings default values; it is useful to *not* do this when the database
- // may not be available (mainly in tools usage).
- boolean useJdbcMetadata = PropertiesHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", props, true );
- if ( useJdbcMetadata ) {
- try {
- Connection conn = connections.getConnection();
- try {
- DatabaseMetaData meta = conn.getMetaData();
- databaseName = meta.getDatabaseProductName();
- databaseMajorVersion = getDatabaseMajorVersion(meta);
- log.info("RDBMS: " + databaseName + ", version: " + meta.getDatabaseProductVersion() );
- log.info("JDBC driver: " + meta.getDriverName() + ", version: " + meta.getDriverVersion() );
-
- metaSupportsScrollable = meta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
- metaSupportsBatchUpdates = meta.supportsBatchUpdates();
- metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
- metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
-
- if ( Environment.jvmSupportsGetGeneratedKeys() ) {
- try {
- Boolean result = (Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null)
- .invoke(meta, null);
- metaSupportsGetGeneratedKeys = result.booleanValue();
- }
- catch (AbstractMethodError ame) {
- metaSupportsGetGeneratedKeys = false;
- }
- catch (Exception e) {
- metaSupportsGetGeneratedKeys = false;
- }
- }
-
- }
- finally {
- connections.closeConnection(conn);
- }
- }
- catch (SQLException sqle) {
- log.warn("Could not obtain connection metadata", sqle);
- }
- catch (UnsupportedOperationException uoe) {
- // user supplied JDBC connections
- }
- }
- settings.setDataDefinitionImplicitCommit( metaReportsDDLCausesTxnCommit );
- settings.setDataDefinitionInTransactionSupported( metaReportsDDLInTxnSupported );
-
-
- //SQL Dialect:
- Dialect dialect = determineDialect( props, databaseName, databaseMajorVersion );
- settings.setDialect(dialect);
-
- //use dialect default properties
- final Properties properties = new Properties();
- properties.putAll( dialect.getDefaultProperties() );
- properties.putAll(props);
-
- // Transaction settings:
-
- TransactionFactory transactionFactory = createTransactionFactory(properties);
- settings.setTransactionFactory(transactionFactory);
- settings.setTransactionManagerLookup( createTransactionManagerLookup(properties) );
-
- boolean flushBeforeCompletion = PropertiesHelper.getBoolean(Environment.FLUSH_BEFORE_COMPLETION, properties);
- log.info("Automatic flush during beforeCompletion(): " + enabledDisabled(flushBeforeCompletion) );
- settings.setFlushBeforeCompletionEnabled(flushBeforeCompletion);
-
- boolean autoCloseSession = PropertiesHelper.getBoolean(Environment.AUTO_CLOSE_SESSION, properties);
- log.info("Automatic session close at end of transaction: " + enabledDisabled(autoCloseSession) );
- settings.setAutoCloseSessionEnabled(autoCloseSession);
-
- //JDBC and connection settings:
-
- int batchSize = PropertiesHelper.getInt(Environment.STATEMENT_BATCH_SIZE, properties, 0);
- if ( !metaSupportsBatchUpdates ) batchSize = 0;
- if (batchSize>0) log.info("JDBC batch size: " + batchSize);
- settings.setJdbcBatchSize(batchSize);
- boolean jdbcBatchVersionedData = PropertiesHelper.getBoolean(Environment.BATCH_VERSIONED_DATA, properties, false);
- if (batchSize>0) log.info("JDBC batch updates for versioned data: " + enabledDisabled(jdbcBatchVersionedData) );
- settings.setJdbcBatchVersionedData(jdbcBatchVersionedData);
- settings.setBatcherFactory( createBatcherFactory(properties, batchSize) );
-
- boolean useScrollableResultSets = PropertiesHelper.getBoolean(Environment.USE_SCROLLABLE_RESULTSET, properties, metaSupportsScrollable);
- log.info("Scrollable result sets: " + enabledDisabled(useScrollableResultSets) );
- settings.setScrollableResultSetsEnabled(useScrollableResultSets);
-
- boolean wrapResultSets = PropertiesHelper.getBoolean(Environment.WRAP_RESULT_SETS, properties, false);
- log.debug( "Wrap result sets: " + enabledDisabled(wrapResultSets) );
- settings.setWrapResultSetsEnabled(wrapResultSets);
-
- boolean useGetGeneratedKeys = PropertiesHelper.getBoolean(Environment.USE_GET_GENERATED_KEYS, properties, metaSupportsGetGeneratedKeys);
- log.info("JDBC3 getGeneratedKeys(): " + enabledDisabled(useGetGeneratedKeys) );
- settings.setGetGeneratedKeysEnabled(useGetGeneratedKeys);
-
- Integer statementFetchSize = PropertiesHelper.getInteger(Environment.STATEMENT_FETCH_SIZE, properties);
- if (statementFetchSize!=null) log.info("JDBC result set fetch size: " + statementFetchSize);
- settings.setJdbcFetchSize(statementFetchSize);
-
- String releaseModeName = PropertiesHelper.getString( Environment.RELEASE_CONNECTIONS, properties, "auto" );
- log.info( "Connection release mode: " + releaseModeName );
- ConnectionReleaseMode releaseMode;
- if ( "auto".equals(releaseModeName) ) {
- releaseMode = transactionFactory.getDefaultReleaseMode();
- }
- else {
- releaseMode = ConnectionReleaseMode.parse( releaseModeName );
- if ( releaseMode == ConnectionReleaseMode.AFTER_STATEMENT && !connections.supportsAggressiveRelease() ) {
- log.warn( "Overriding release mode as connection provider does not support 'after_statement'" );
- releaseMode = ConnectionReleaseMode.AFTER_TRANSACTION;
- }
- }
- settings.setConnectionReleaseMode( releaseMode );
-
- //SQL Generation settings:
-
- String defaultSchema = properties.getProperty(Environment.DEFAULT_SCHEMA);
- String defaultCatalog = properties.getProperty(Environment.DEFAULT_CATALOG);
- if (defaultSchema!=null) log.info("Default schema: " + defaultSchema);
- if (defaultCatalog!=null) log.info("Default catalog: " + defaultCatalog);
- settings.setDefaultSchemaName(defaultSchema);
- settings.setDefaultCatalogName(defaultCatalog);
-
- Integer maxFetchDepth = PropertiesHelper.getInteger(Environment.MAX_FETCH_DEPTH, properties);
- if (maxFetchDepth!=null) log.info("Maximum outer join fetch depth: " + maxFetchDepth);
- settings.setMaximumFetchDepth(maxFetchDepth);
- int batchFetchSize = PropertiesHelper.getInt(Environment.DEFAULT_BATCH_FETCH_SIZE, properties, 1);
- log.info("Default batch fetch size: " + batchFetchSize);
- settings.setDefaultBatchFetchSize(batchFetchSize);
-
- boolean comments = PropertiesHelper.getBoolean(Environment.USE_SQL_COMMENTS, properties);
- log.info( "Generate SQL with comments: " + enabledDisabled(comments) );
- settings.setCommentsEnabled(comments);
-
- boolean orderUpdates = PropertiesHelper.getBoolean(Environment.ORDER_UPDATES, properties);
- log.info( "Order SQL updates by primary key: " + enabledDisabled(orderUpdates) );
- settings.setOrderUpdatesEnabled(orderUpdates);
-
- boolean orderInserts = PropertiesHelper.getBoolean(Environment.ORDER_INSERTS, properties);
- log.info( "Order SQL inserts for batching: " + enabledDisabled( orderInserts ) );
- settings.setOrderInsertsEnabled( orderInserts );
-
- //Query parser settings:
-
- settings.setQueryTranslatorFactory( createQueryTranslatorFactory(properties) );
-
- Map querySubstitutions = PropertiesHelper.toMap(Environment.QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", properties);
- log.info("Query language substitutions: " + querySubstitutions);
- settings.setQuerySubstitutions(querySubstitutions);
-
- boolean jpaqlCompliance = PropertiesHelper.getBoolean( Environment.JPAQL_STRICT_COMPLIANCE, properties, false );
- settings.setStrictJPAQLCompliance( jpaqlCompliance );
- log.info( "JPA-QL strict compliance: " + enabledDisabled( jpaqlCompliance ) );
-
- // Second-level / query cache:
-
- boolean useSecondLevelCache = PropertiesHelper.getBoolean(Environment.USE_SECOND_LEVEL_CACHE, properties, true);
- log.info( "Second-level cache: " + enabledDisabled(useSecondLevelCache) );
- settings.setSecondLevelCacheEnabled(useSecondLevelCache);
-
- boolean useQueryCache = PropertiesHelper.getBoolean(Environment.USE_QUERY_CACHE, properties);
- log.info( "Query cache: " + enabledDisabled(useQueryCache) );
- settings.setQueryCacheEnabled(useQueryCache);
-
- // The cache provider is needed when we either have second-level cache enabled
- // or query cache enabled. Note that useSecondLevelCache is enabled by default
- settings.setRegionFactory( createRegionFactory( properties, ( useSecondLevelCache || useQueryCache ) ) );
-
- boolean useMinimalPuts = PropertiesHelper.getBoolean(
- Environment.USE_MINIMAL_PUTS, properties, settings.getRegionFactory().isMinimalPutsEnabledByDefault()
- );
- log.info( "Optimize cache for minimal puts: " + enabledDisabled(useMinimalPuts) );
- settings.setMinimalPutsEnabled(useMinimalPuts);
-
- String prefix = properties.getProperty(Environment.CACHE_REGION_PREFIX);
- if ( StringHelper.isEmpty(prefix) ) prefix=null;
- if (prefix!=null) log.info("Cache region prefix: "+ prefix);
- settings.setCacheRegionPrefix(prefix);
-
- boolean useStructuredCacheEntries = PropertiesHelper.getBoolean(Environment.USE_STRUCTURED_CACHE, properties, false);
- log.info( "Structured second-level cache entries: " + enabledDisabled(useStructuredCacheEntries) );
- settings.setStructuredCacheEntriesEnabled(useStructuredCacheEntries);
-
- if (useQueryCache) settings.setQueryCacheFactory( createQueryCacheFactory(properties) );
-
- //SQL Exception converter:
-
- SQLExceptionConverter sqlExceptionConverter;
- try {
- sqlExceptionConverter = SQLExceptionConverterFactory.buildSQLExceptionConverter( dialect, properties );
- }
- catch(HibernateException e) {
- log.warn("Error building SQLExceptionConverter; using minimal converter");
- sqlExceptionConverter = SQLExceptionConverterFactory.buildMinimalSQLExceptionConverter();
- }
- settings.setSQLExceptionConverter(sqlExceptionConverter);
-
- //Statistics and logging:
-
- boolean showSql = PropertiesHelper.getBoolean(Environment.SHOW_SQL, properties);
- if (showSql) log.info("Echoing all SQL to stdout");
-// settings.setShowSqlEnabled(showSql);
-
- boolean formatSql = PropertiesHelper.getBoolean(Environment.FORMAT_SQL, properties);
-// settings.setFormatSqlEnabled(formatSql);
-
- settings.setSqlStatementLogger( new SQLStatementLogger( showSql, formatSql ) );
-
- boolean useStatistics = PropertiesHelper.getBoolean(Environment.GENERATE_STATISTICS, properties);
- log.info( "Statistics: " + enabledDisabled(useStatistics) );
- settings.setStatisticsEnabled(useStatistics);
-
- boolean useIdentifierRollback = PropertiesHelper.getBoolean(Environment.USE_IDENTIFIER_ROLLBACK, properties);
- log.info( "Deleted entity synthetic identifier rollback: " + enabledDisabled(useIdentifierRollback) );
- settings.setIdentifierRollbackEnabled(useIdentifierRollback);
-
- //Schema export:
-
- String autoSchemaExport = properties.getProperty(Environment.HBM2DDL_AUTO);
- if ( "validate".equals(autoSchemaExport) ) settings.setAutoValidateSchema(true);
- if ( "update".equals(autoSchemaExport) ) settings.setAutoUpdateSchema(true);
- if ( "create".equals(autoSchemaExport) ) settings.setAutoCreateSchema(true);
- if ( "create-drop".equals(autoSchemaExport) ) {
- settings.setAutoCreateSchema(true);
- settings.setAutoDropSchema(true);
- }
-
- EntityMode defaultEntityMode = EntityMode.parse( properties.getProperty( Environment.DEFAULT_ENTITY_MODE ) );
- log.info( "Default entity-mode: " + defaultEntityMode );
- settings.setDefaultEntityMode( defaultEntityMode );
-
- boolean namedQueryChecking = PropertiesHelper.getBoolean( Environment.QUERY_STARTUP_CHECKING, properties, true );
- log.info( "Named query checking : " + enabledDisabled( namedQueryChecking ) );
- settings.setNamedQueryStartupCheckingEnabled( namedQueryChecking );
-
-// String provider = properties.getProperty( Environment.BYTECODE_PROVIDER );
-// log.info( "Bytecode provider name : " + provider );
-// BytecodeProvider bytecodeProvider = buildBytecodeProvider( provider );
-// settings.setBytecodeProvider( bytecodeProvider );
-
- return settings;
-
- }
-
- protected BytecodeProvider buildBytecodeProvider(String providerName) {
- if ( "javassist".equals( providerName ) ) {
- return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
- }
- else if ( "cglib".equals( providerName ) ) {
- return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
- }
- else {
- log.debug( "using cglib as bytecode provider by default" );
- return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
- }
- }
-
- private int getDatabaseMajorVersion(DatabaseMetaData meta) {
- try {
- Method gdbmvMethod = DatabaseMetaData.class.getMethod("getDatabaseMajorVersion", null);
- return ( (Integer) gdbmvMethod.invoke(meta, null) ).intValue();
- }
- catch (NoSuchMethodException nsme) {
- return 0;
- }
- catch (Throwable t) {
- log.debug("could not get database version from JDBC metadata");
- return 0;
- }
- }
-
- private static String enabledDisabled(boolean value) {
- return value ? "enabled" : "disabled";
- }
-
- protected QueryCacheFactory createQueryCacheFactory(Properties properties) {
- String queryCacheFactoryClassName = PropertiesHelper.getString(
- Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory"
- );
- log.info("Query cache factory: " + queryCacheFactoryClassName);
- try {
- return (QueryCacheFactory) ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
- }
- catch (Exception cnfe) {
- throw new HibernateException("could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, cnfe);
- }
- }
-
- protected RegionFactory createRegionFactory(Properties properties, boolean cachingEnabled) {
- String regionFactoryClassName = PropertiesHelper.getString( Environment.CACHE_REGION_FACTORY, properties, null );
- if ( regionFactoryClassName == null && cachingEnabled ) {
- String providerClassName = PropertiesHelper.getString( Environment.CACHE_PROVIDER, properties, null );
- if ( providerClassName != null ) {
- // legacy behavior, apply the bridge...
- regionFactoryClassName = RegionFactoryCacheProviderBridge.class.getName();
- }
- }
- if ( regionFactoryClassName == null ) {
- regionFactoryClassName = DEF_CACHE_REG_FACTORY;
- }
- log.info( "Cache region factory : " + regionFactoryClassName );
- try {
- return ( RegionFactory ) ReflectHelper.classForName( regionFactoryClassName )
- .getConstructor( new Class[] { Properties.class } )
- .newInstance( new Object[] { properties } );
- }
- catch ( Exception e ) {
- throw new HibernateException( "could not instantiate RegionFactory [" + regionFactoryClassName + "]", e );
- }
- }
-
- protected QueryTranslatorFactory createQueryTranslatorFactory(Properties properties) {
- String className = PropertiesHelper.getString(
- Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory"
- );
- log.info("Query translator: " + className);
- try {
- return (QueryTranslatorFactory) ReflectHelper.classForName(className).newInstance();
- }
- catch (Exception cnfe) {
- throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe);
- }
- }
-
- protected BatcherFactory createBatcherFactory(Properties properties, int batchSize) {
- String batcherClass = properties.getProperty(Environment.BATCH_STRATEGY);
- if (batcherClass==null) {
- return batchSize==0 ?
- (BatcherFactory) new NonBatchingBatcherFactory() :
- (BatcherFactory) new BatchingBatcherFactory();
- }
- else {
- log.info("Batcher factory: " + batcherClass);
- try {
- return (BatcherFactory) ReflectHelper.classForName(batcherClass).newInstance();
- }
- catch (Exception cnfe) {
- throw new HibernateException("could not instantiate BatcherFactory: " + batcherClass, cnfe);
- }
- }
- }
-
- protected ConnectionProvider createConnectionProvider(Properties properties) {
- return ConnectionProviderFactory.newConnectionProvider(properties);
- }
-
- protected TransactionFactory createTransactionFactory(Properties properties) {
- return TransactionFactoryFactory.buildTransactionFactory(properties);
- }
-
- protected TransactionManagerLookup createTransactionManagerLookup(Properties properties) {
- return TransactionManagerLookupFactory.getTransactionManagerLookup(properties);
- }
-
- private Dialect determineDialect(Properties props, String databaseName, int databaseMajorVersion) {
- return DialectFactory.buildDialect( props, databaseName, databaseMajorVersion );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/SettingsFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/SettingsFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,463 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.cfg;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.bytecode.BytecodeProvider;
+import org.hibernate.cache.QueryCacheFactory;
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.impl.NoCachingRegionFactory;
+import org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.connection.ConnectionProviderFactory;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.DialectFactory;
+import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.exception.SQLExceptionConverterFactory;
+import org.hibernate.hql.QueryTranslatorFactory;
+import org.hibernate.jdbc.BatcherFactory;
+import org.hibernate.jdbc.BatchingBatcherFactory;
+import org.hibernate.jdbc.NonBatchingBatcherFactory;
+import org.hibernate.jdbc.util.SQLStatementLogger;
+import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.transaction.TransactionFactoryFactory;
+import org.hibernate.transaction.TransactionManagerLookup;
+import org.hibernate.transaction.TransactionManagerLookupFactory;
+import org.hibernate.util.PropertiesHelper;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Reads configuration properties and configures a <tt>Settings</tt> instance.
+ *
+ * @author Gavin King
+ */
+public class SettingsFactory implements Serializable {
+
+ public static final String DEF_CACHE_REG_FACTORY = NoCachingRegionFactory.class.getName();
+ private static final Logger log = LoggerFactory.getLogger(SettingsFactory.class);
+
+ protected SettingsFactory() {
+ }
+
+ public Settings buildSettings(Properties props) {
+ Settings settings = new Settings();
+
+ //SessionFactory name:
+
+ String sessionFactoryName = props.getProperty(Environment.SESSION_FACTORY_NAME);
+ settings.setSessionFactoryName(sessionFactoryName);
+
+ //JDBC and connection settings:
+
+ ConnectionProvider connections = createConnectionProvider(props);
+ settings.setConnectionProvider(connections);
+
+ //Interrogate JDBC metadata
+
+ String databaseName = null;
+ int databaseMajorVersion = 0;
+ boolean metaSupportsScrollable = false;
+ boolean metaSupportsGetGeneratedKeys = false;
+ boolean metaSupportsBatchUpdates = false;
+ boolean metaReportsDDLCausesTxnCommit = false;
+ boolean metaReportsDDLInTxnSupported = true;
+
+ // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
+ // The need for it is intended to be alleviated with 3.3 developement, thus it is
+ // not defined as an Environment constant...
+ // it is used to control whether we should consult the JDBC metadata to determine
+ // certain Settings default values; it is useful to *not* do this when the database
+ // may not be available (mainly in tools usage).
+ boolean useJdbcMetadata = PropertiesHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", props, true );
+ if ( useJdbcMetadata ) {
+ try {
+ Connection conn = connections.getConnection();
+ try {
+ DatabaseMetaData meta = conn.getMetaData();
+ databaseName = meta.getDatabaseProductName();
+ databaseMajorVersion = getDatabaseMajorVersion(meta);
+ log.info("RDBMS: " + databaseName + ", version: " + meta.getDatabaseProductVersion() );
+ log.info("JDBC driver: " + meta.getDriverName() + ", version: " + meta.getDriverVersion() );
+
+ metaSupportsScrollable = meta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
+ metaSupportsBatchUpdates = meta.supportsBatchUpdates();
+ metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
+ metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
+
+ if ( Environment.jvmSupportsGetGeneratedKeys() ) {
+ try {
+ Boolean result = (Boolean) DatabaseMetaData.class.getMethod("supportsGetGeneratedKeys", null)
+ .invoke(meta, null);
+ metaSupportsGetGeneratedKeys = result.booleanValue();
+ }
+ catch (AbstractMethodError ame) {
+ metaSupportsGetGeneratedKeys = false;
+ }
+ catch (Exception e) {
+ metaSupportsGetGeneratedKeys = false;
+ }
+ }
+
+ }
+ finally {
+ connections.closeConnection(conn);
+ }
+ }
+ catch (SQLException sqle) {
+ log.warn("Could not obtain connection metadata", sqle);
+ }
+ catch (UnsupportedOperationException uoe) {
+ // user supplied JDBC connections
+ }
+ }
+ settings.setDataDefinitionImplicitCommit( metaReportsDDLCausesTxnCommit );
+ settings.setDataDefinitionInTransactionSupported( metaReportsDDLInTxnSupported );
+
+
+ //SQL Dialect:
+ Dialect dialect = determineDialect( props, databaseName, databaseMajorVersion );
+ settings.setDialect(dialect);
+
+ //use dialect default properties
+ final Properties properties = new Properties();
+ properties.putAll( dialect.getDefaultProperties() );
+ properties.putAll(props);
+
+ // Transaction settings:
+
+ TransactionFactory transactionFactory = createTransactionFactory(properties);
+ settings.setTransactionFactory(transactionFactory);
+ settings.setTransactionManagerLookup( createTransactionManagerLookup(properties) );
+
+ boolean flushBeforeCompletion = PropertiesHelper.getBoolean(Environment.FLUSH_BEFORE_COMPLETION, properties);
+ log.info("Automatic flush during beforeCompletion(): " + enabledDisabled(flushBeforeCompletion) );
+ settings.setFlushBeforeCompletionEnabled(flushBeforeCompletion);
+
+ boolean autoCloseSession = PropertiesHelper.getBoolean(Environment.AUTO_CLOSE_SESSION, properties);
+ log.info("Automatic session close at end of transaction: " + enabledDisabled(autoCloseSession) );
+ settings.setAutoCloseSessionEnabled(autoCloseSession);
+
+ //JDBC and connection settings:
+
+ int batchSize = PropertiesHelper.getInt(Environment.STATEMENT_BATCH_SIZE, properties, 0);
+ if ( !metaSupportsBatchUpdates ) batchSize = 0;
+ if (batchSize>0) log.info("JDBC batch size: " + batchSize);
+ settings.setJdbcBatchSize(batchSize);
+ boolean jdbcBatchVersionedData = PropertiesHelper.getBoolean(Environment.BATCH_VERSIONED_DATA, properties, false);
+ if (batchSize>0) log.info("JDBC batch updates for versioned data: " + enabledDisabled(jdbcBatchVersionedData) );
+ settings.setJdbcBatchVersionedData(jdbcBatchVersionedData);
+ settings.setBatcherFactory( createBatcherFactory(properties, batchSize) );
+
+ boolean useScrollableResultSets = PropertiesHelper.getBoolean(Environment.USE_SCROLLABLE_RESULTSET, properties, metaSupportsScrollable);
+ log.info("Scrollable result sets: " + enabledDisabled(useScrollableResultSets) );
+ settings.setScrollableResultSetsEnabled(useScrollableResultSets);
+
+ boolean wrapResultSets = PropertiesHelper.getBoolean(Environment.WRAP_RESULT_SETS, properties, false);
+ log.debug( "Wrap result sets: " + enabledDisabled(wrapResultSets) );
+ settings.setWrapResultSetsEnabled(wrapResultSets);
+
+ boolean useGetGeneratedKeys = PropertiesHelper.getBoolean(Environment.USE_GET_GENERATED_KEYS, properties, metaSupportsGetGeneratedKeys);
+ log.info("JDBC3 getGeneratedKeys(): " + enabledDisabled(useGetGeneratedKeys) );
+ settings.setGetGeneratedKeysEnabled(useGetGeneratedKeys);
+
+ Integer statementFetchSize = PropertiesHelper.getInteger(Environment.STATEMENT_FETCH_SIZE, properties);
+ if (statementFetchSize!=null) log.info("JDBC result set fetch size: " + statementFetchSize);
+ settings.setJdbcFetchSize(statementFetchSize);
+
+ String releaseModeName = PropertiesHelper.getString( Environment.RELEASE_CONNECTIONS, properties, "auto" );
+ log.info( "Connection release mode: " + releaseModeName );
+ ConnectionReleaseMode releaseMode;
+ if ( "auto".equals(releaseModeName) ) {
+ releaseMode = transactionFactory.getDefaultReleaseMode();
+ }
+ else {
+ releaseMode = ConnectionReleaseMode.parse( releaseModeName );
+ if ( releaseMode == ConnectionReleaseMode.AFTER_STATEMENT && !connections.supportsAggressiveRelease() ) {
+ log.warn( "Overriding release mode as connection provider does not support 'after_statement'" );
+ releaseMode = ConnectionReleaseMode.AFTER_TRANSACTION;
+ }
+ }
+ settings.setConnectionReleaseMode( releaseMode );
+
+ //SQL Generation settings:
+
+ String defaultSchema = properties.getProperty(Environment.DEFAULT_SCHEMA);
+ String defaultCatalog = properties.getProperty(Environment.DEFAULT_CATALOG);
+ if (defaultSchema!=null) log.info("Default schema: " + defaultSchema);
+ if (defaultCatalog!=null) log.info("Default catalog: " + defaultCatalog);
+ settings.setDefaultSchemaName(defaultSchema);
+ settings.setDefaultCatalogName(defaultCatalog);
+
+ Integer maxFetchDepth = PropertiesHelper.getInteger(Environment.MAX_FETCH_DEPTH, properties);
+ if (maxFetchDepth!=null) log.info("Maximum outer join fetch depth: " + maxFetchDepth);
+ settings.setMaximumFetchDepth(maxFetchDepth);
+ int batchFetchSize = PropertiesHelper.getInt(Environment.DEFAULT_BATCH_FETCH_SIZE, properties, 1);
+ log.info("Default batch fetch size: " + batchFetchSize);
+ settings.setDefaultBatchFetchSize(batchFetchSize);
+
+ boolean comments = PropertiesHelper.getBoolean(Environment.USE_SQL_COMMENTS, properties);
+ log.info( "Generate SQL with comments: " + enabledDisabled(comments) );
+ settings.setCommentsEnabled(comments);
+
+ boolean orderUpdates = PropertiesHelper.getBoolean(Environment.ORDER_UPDATES, properties);
+ log.info( "Order SQL updates by primary key: " + enabledDisabled(orderUpdates) );
+ settings.setOrderUpdatesEnabled(orderUpdates);
+
+ boolean orderInserts = PropertiesHelper.getBoolean(Environment.ORDER_INSERTS, properties);
+ log.info( "Order SQL inserts for batching: " + enabledDisabled( orderInserts ) );
+ settings.setOrderInsertsEnabled( orderInserts );
+
+ //Query parser settings:
+
+ settings.setQueryTranslatorFactory( createQueryTranslatorFactory(properties) );
+
+ Map querySubstitutions = PropertiesHelper.toMap(Environment.QUERY_SUBSTITUTIONS, " ,=;:\n\t\r\f", properties);
+ log.info("Query language substitutions: " + querySubstitutions);
+ settings.setQuerySubstitutions(querySubstitutions);
+
+ boolean jpaqlCompliance = PropertiesHelper.getBoolean( Environment.JPAQL_STRICT_COMPLIANCE, properties, false );
+ settings.setStrictJPAQLCompliance( jpaqlCompliance );
+ log.info( "JPA-QL strict compliance: " + enabledDisabled( jpaqlCompliance ) );
+
+ // Second-level / query cache:
+
+ boolean useSecondLevelCache = PropertiesHelper.getBoolean(Environment.USE_SECOND_LEVEL_CACHE, properties, true);
+ log.info( "Second-level cache: " + enabledDisabled(useSecondLevelCache) );
+ settings.setSecondLevelCacheEnabled(useSecondLevelCache);
+
+ boolean useQueryCache = PropertiesHelper.getBoolean(Environment.USE_QUERY_CACHE, properties);
+ log.info( "Query cache: " + enabledDisabled(useQueryCache) );
+ settings.setQueryCacheEnabled(useQueryCache);
+
+ // The cache provider is needed when we either have second-level cache enabled
+ // or query cache enabled. Note that useSecondLevelCache is enabled by default
+ settings.setRegionFactory( createRegionFactory( properties, ( useSecondLevelCache || useQueryCache ) ) );
+
+ boolean useMinimalPuts = PropertiesHelper.getBoolean(
+ Environment.USE_MINIMAL_PUTS, properties, settings.getRegionFactory().isMinimalPutsEnabledByDefault()
+ );
+ log.info( "Optimize cache for minimal puts: " + enabledDisabled(useMinimalPuts) );
+ settings.setMinimalPutsEnabled(useMinimalPuts);
+
+ String prefix = properties.getProperty(Environment.CACHE_REGION_PREFIX);
+ if ( StringHelper.isEmpty(prefix) ) prefix=null;
+ if (prefix!=null) log.info("Cache region prefix: "+ prefix);
+ settings.setCacheRegionPrefix(prefix);
+
+ boolean useStructuredCacheEntries = PropertiesHelper.getBoolean(Environment.USE_STRUCTURED_CACHE, properties, false);
+ log.info( "Structured second-level cache entries: " + enabledDisabled(useStructuredCacheEntries) );
+ settings.setStructuredCacheEntriesEnabled(useStructuredCacheEntries);
+
+ if (useQueryCache) settings.setQueryCacheFactory( createQueryCacheFactory(properties) );
+
+ //SQL Exception converter:
+
+ SQLExceptionConverter sqlExceptionConverter;
+ try {
+ sqlExceptionConverter = SQLExceptionConverterFactory.buildSQLExceptionConverter( dialect, properties );
+ }
+ catch(HibernateException e) {
+ log.warn("Error building SQLExceptionConverter; using minimal converter");
+ sqlExceptionConverter = SQLExceptionConverterFactory.buildMinimalSQLExceptionConverter();
+ }
+ settings.setSQLExceptionConverter(sqlExceptionConverter);
+
+ //Statistics and logging:
+
+ boolean showSql = PropertiesHelper.getBoolean(Environment.SHOW_SQL, properties);
+ if (showSql) log.info("Echoing all SQL to stdout");
+// settings.setShowSqlEnabled(showSql);
+
+ boolean formatSql = PropertiesHelper.getBoolean(Environment.FORMAT_SQL, properties);
+// settings.setFormatSqlEnabled(formatSql);
+
+ settings.setSqlStatementLogger( new SQLStatementLogger( showSql, formatSql ) );
+
+ boolean useStatistics = PropertiesHelper.getBoolean(Environment.GENERATE_STATISTICS, properties);
+ log.info( "Statistics: " + enabledDisabled(useStatistics) );
+ settings.setStatisticsEnabled(useStatistics);
+
+ boolean useIdentifierRollback = PropertiesHelper.getBoolean(Environment.USE_IDENTIFIER_ROLLBACK, properties);
+ log.info( "Deleted entity synthetic identifier rollback: " + enabledDisabled(useIdentifierRollback) );
+ settings.setIdentifierRollbackEnabled(useIdentifierRollback);
+
+ //Schema export:
+
+ String autoSchemaExport = properties.getProperty(Environment.HBM2DDL_AUTO);
+ if ( "validate".equals(autoSchemaExport) ) settings.setAutoValidateSchema(true);
+ if ( "update".equals(autoSchemaExport) ) settings.setAutoUpdateSchema(true);
+ if ( "create".equals(autoSchemaExport) ) settings.setAutoCreateSchema(true);
+ if ( "create-drop".equals(autoSchemaExport) ) {
+ settings.setAutoCreateSchema(true);
+ settings.setAutoDropSchema(true);
+ }
+
+ EntityMode defaultEntityMode = EntityMode.parse( properties.getProperty( Environment.DEFAULT_ENTITY_MODE ) );
+ log.info( "Default entity-mode: " + defaultEntityMode );
+ settings.setDefaultEntityMode( defaultEntityMode );
+
+ boolean namedQueryChecking = PropertiesHelper.getBoolean( Environment.QUERY_STARTUP_CHECKING, properties, true );
+ log.info( "Named query checking : " + enabledDisabled( namedQueryChecking ) );
+ settings.setNamedQueryStartupCheckingEnabled( namedQueryChecking );
+
+// String provider = properties.getProperty( Environment.BYTECODE_PROVIDER );
+// log.info( "Bytecode provider name : " + provider );
+// BytecodeProvider bytecodeProvider = buildBytecodeProvider( provider );
+// settings.setBytecodeProvider( bytecodeProvider );
+
+ return settings;
+
+ }
+
+ protected BytecodeProvider buildBytecodeProvider(String providerName) {
+ if ( "javassist".equals( providerName ) ) {
+ return new org.hibernate.bytecode.javassist.BytecodeProviderImpl();
+ }
+ else if ( "cglib".equals( providerName ) ) {
+ return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
+ }
+ else {
+ log.debug( "using cglib as bytecode provider by default" );
+ return new org.hibernate.bytecode.cglib.BytecodeProviderImpl();
+ }
+ }
+
+ private int getDatabaseMajorVersion(DatabaseMetaData meta) {
+ try {
+ Method gdbmvMethod = DatabaseMetaData.class.getMethod("getDatabaseMajorVersion", null);
+ return ( (Integer) gdbmvMethod.invoke(meta, null) ).intValue();
+ }
+ catch (NoSuchMethodException nsme) {
+ return 0;
+ }
+ catch (Throwable t) {
+ log.debug("could not get database version from JDBC metadata");
+ return 0;
+ }
+ }
+
+ private static String enabledDisabled(boolean value) {
+ return value ? "enabled" : "disabled";
+ }
+
+ protected QueryCacheFactory createQueryCacheFactory(Properties properties) {
+ String queryCacheFactoryClassName = PropertiesHelper.getString(
+ Environment.QUERY_CACHE_FACTORY, properties, "org.hibernate.cache.StandardQueryCacheFactory"
+ );
+ log.info("Query cache factory: " + queryCacheFactoryClassName);
+ try {
+ return (QueryCacheFactory) ReflectHelper.classForName(queryCacheFactoryClassName).newInstance();
+ }
+ catch (Exception cnfe) {
+ throw new HibernateException("could not instantiate QueryCacheFactory: " + queryCacheFactoryClassName, cnfe);
+ }
+ }
+
+ protected RegionFactory createRegionFactory(Properties properties, boolean cachingEnabled) {
+ String regionFactoryClassName = PropertiesHelper.getString( Environment.CACHE_REGION_FACTORY, properties, null );
+ if ( regionFactoryClassName == null && cachingEnabled ) {
+ String providerClassName = PropertiesHelper.getString( Environment.CACHE_PROVIDER, properties, null );
+ if ( providerClassName != null ) {
+ // legacy behavior, apply the bridge...
+ regionFactoryClassName = RegionFactoryCacheProviderBridge.class.getName();
+ }
+ }
+ if ( regionFactoryClassName == null ) {
+ regionFactoryClassName = DEF_CACHE_REG_FACTORY;
+ }
+ log.info( "Cache region factory : " + regionFactoryClassName );
+ try {
+ return ( RegionFactory ) ReflectHelper.classForName( regionFactoryClassName )
+ .getConstructor( new Class[] { Properties.class } )
+ .newInstance( new Object[] { properties } );
+ }
+ catch ( Exception e ) {
+ throw new HibernateException( "could not instantiate RegionFactory [" + regionFactoryClassName + "]", e );
+ }
+ }
+
+ protected QueryTranslatorFactory createQueryTranslatorFactory(Properties properties) {
+ String className = PropertiesHelper.getString(
+ Environment.QUERY_TRANSLATOR, properties, "org.hibernate.hql.ast.ASTQueryTranslatorFactory"
+ );
+ log.info("Query translator: " + className);
+ try {
+ return (QueryTranslatorFactory) ReflectHelper.classForName(className).newInstance();
+ }
+ catch (Exception cnfe) {
+ throw new HibernateException("could not instantiate QueryTranslatorFactory: " + className, cnfe);
+ }
+ }
+
+ protected BatcherFactory createBatcherFactory(Properties properties, int batchSize) {
+ String batcherClass = properties.getProperty(Environment.BATCH_STRATEGY);
+ if (batcherClass==null) {
+ return batchSize==0 ?
+ (BatcherFactory) new NonBatchingBatcherFactory() :
+ (BatcherFactory) new BatchingBatcherFactory();
+ }
+ else {
+ log.info("Batcher factory: " + batcherClass);
+ try {
+ return (BatcherFactory) ReflectHelper.classForName(batcherClass).newInstance();
+ }
+ catch (Exception cnfe) {
+ throw new HibernateException("could not instantiate BatcherFactory: " + batcherClass, cnfe);
+ }
+ }
+ }
+
+ protected ConnectionProvider createConnectionProvider(Properties properties) {
+ return ConnectionProviderFactory.newConnectionProvider(properties);
+ }
+
+ protected TransactionFactory createTransactionFactory(Properties properties) {
+ return TransactionFactoryFactory.buildTransactionFactory(properties);
+ }
+
+ protected TransactionManagerLookup createTransactionManagerLookup(Properties properties) {
+ return TransactionManagerLookupFactory.getTransactionManagerLookup(properties);
+ }
+
+ private Dialect determineDialect(Properties props, String databaseName, int databaseMajorVersion) {
+ return DialectFactory.buildDialect( props, databaseName, databaseMajorVersion );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,9 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- This package defines APIs for configuring Hibernate, and classes
- for building the Hibernate configuration-time metamodel.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/cfg/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/cfg/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ This package defines APIs for configuring Hibernate, and classes
+ for building the Hibernate configuration-time metamodel.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/classic/Lifecycle.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,94 +0,0 @@
-//$Id: Lifecycle.java 7566 2005-07-20 07:16:33Z oneovthafew $
-package org.hibernate.classic;
-
-import java.io.Serializable;
-
-import org.hibernate.CallbackException;
-import org.hibernate.Session;
-
-/**
- * Provides callbacks from the <tt>Session</tt> to the persistent object.
- * Persistent classes <b>may</b> implement this interface but they are not
- * required to.<br>
- * <br>
- * <b>onSave:</b> called just before the object is saved<br>
- * <b>onUpdate:</b> called just before an object is updated,
- * ie. when <tt>Session.update()</tt> is called<br>
- * <b>onDelete:</b> called just before an object is deleted<br>
- * <b>onLoad:</b> called just after an object is loaded<br>
- * <br>
- * <tt>onLoad()</tt> may be used to initialize transient properties of the
- * object from its persistent state. It may <b>not</b> be used to load
- * dependent objects since the <tt>Session</tt> interface may not be
- * invoked from inside this method.<br>
- * <br>
- * A further intended usage of <tt>onLoad()</tt>, <tt>onSave()</tt> and
- * <tt>onUpdate()</tt> is to store a reference to the <tt>Session</tt>
- * for later use.<br>
- * <br>
- * If <tt>onSave()</tt>, <tt>onUpdate()</tt> or <tt>onDelete()</tt> return
- * <tt>VETO</tt>, the operation is silently vetoed. If a
- * <tt>CallbackException</tt> is thrown, the operation is vetoed and the
- * exception is passed back to the application.<br>
- * <br>
- * Note that <tt>onSave()</tt> is called after an identifier is assigned
- * to the object, except when identity column key generation is used.
- *
- * @see CallbackException
- * @author Gavin King
- */
-public interface Lifecycle {
-
- /**
- * Return value to veto the action (true)
- */
- public static final boolean VETO = true;
-
- /**
- * Return value to accept the action (false)
- */
- public static final boolean NO_VETO = false;
-
- /**
- * Called when an entity is saved.
- * @param s the session
- * @return true to veto save
- * @throws CallbackException
- */
- public boolean onSave(Session s) throws CallbackException;
-
- /**
- * Called when an entity is passed to <tt>Session.update()</tt>.
- * This method is <em>not</em> called every time the object's
- * state is persisted during a flush.
- * @param s the session
- * @return true to veto update
- * @throws CallbackException
- */
- public boolean onUpdate(Session s) throws CallbackException;
-
- /**
- * Called when an entity is deleted.
- * @param s the session
- * @return true to veto delete
- * @throws CallbackException
- */
- public boolean onDelete(Session s) throws CallbackException;
-
- /**
- * Called after an entity is loaded. <em>It is illegal to
- * access the <tt>Session</tt> from inside this method.</em>
- * However, the object may keep a reference to the session
- * for later use.
- *
- * @param s the session
- * @param id the identifier
- */
- public void onLoad(Session s, Serializable id);
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/classic/Lifecycle.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Lifecycle.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,117 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.classic;
+
+import java.io.Serializable;
+
+import org.hibernate.CallbackException;
+import org.hibernate.Session;
+
+/**
+ * Provides callbacks from the <tt>Session</tt> to the persistent object.
+ * Persistent classes <b>may</b> implement this interface but they are not
+ * required to.<br>
+ * <br>
+ * <b>onSave:</b> called just before the object is saved<br>
+ * <b>onUpdate:</b> called just before an object is updated,
+ * ie. when <tt>Session.update()</tt> is called<br>
+ * <b>onDelete:</b> called just before an object is deleted<br>
+ * <b>onLoad:</b> called just after an object is loaded<br>
+ * <br>
+ * <tt>onLoad()</tt> may be used to initialize transient properties of the
+ * object from its persistent state. It may <b>not</b> be used to load
+ * dependent objects since the <tt>Session</tt> interface may not be
+ * invoked from inside this method.<br>
+ * <br>
+ * A further intended usage of <tt>onLoad()</tt>, <tt>onSave()</tt> and
+ * <tt>onUpdate()</tt> is to store a reference to the <tt>Session</tt>
+ * for later use.<br>
+ * <br>
+ * If <tt>onSave()</tt>, <tt>onUpdate()</tt> or <tt>onDelete()</tt> return
+ * <tt>VETO</tt>, the operation is silently vetoed. If a
+ * <tt>CallbackException</tt> is thrown, the operation is vetoed and the
+ * exception is passed back to the application.<br>
+ * <br>
+ * Note that <tt>onSave()</tt> is called after an identifier is assigned
+ * to the object, except when identity column key generation is used.
+ *
+ * @see CallbackException
+ * @author Gavin King
+ */
+public interface Lifecycle {
+
+ /**
+ * Return value to veto the action (true)
+ */
+ public static final boolean VETO = true;
+
+ /**
+ * Return value to accept the action (false)
+ */
+ public static final boolean NO_VETO = false;
+
+ /**
+ * Called when an entity is saved.
+ * @param s the session
+ * @return true to veto save
+ * @throws CallbackException
+ */
+ public boolean onSave(Session s) throws CallbackException;
+
+ /**
+ * Called when an entity is passed to <tt>Session.update()</tt>.
+ * This method is <em>not</em> called every time the object's
+ * state is persisted during a flush.
+ * @param s the session
+ * @return true to veto update
+ * @throws CallbackException
+ */
+ public boolean onUpdate(Session s) throws CallbackException;
+
+ /**
+ * Called when an entity is deleted.
+ * @param s the session
+ * @return true to veto delete
+ * @throws CallbackException
+ */
+ public boolean onDelete(Session s) throws CallbackException;
+
+ /**
+ * Called after an entity is loaded. <em>It is illegal to
+ * access the <tt>Session</tt> from inside this method.</em>
+ * However, the object may keep a reference to the session
+ * for later use.
+ *
+ * @param s the session
+ * @param id the identifier
+ */
+ public void onLoad(Session s, Serializable id);
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/classic/Session.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,352 +0,0 @@
-//$Id: Session.java 9652 2006-03-17 18:59:03Z steve.ebersole(a)jboss.com $
-package org.hibernate.classic;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.type.Type;
-
-/**
- * An extension of the <tt>Session</tt> API, including all
- * deprecated methods from Hibernate2. This interface is
- * provided to allow easier migration of existing applications.
- * New code should use <tt>org.hibernate.Session</tt>.
- * @author Gavin King
- */
-public interface Session extends org.hibernate.Session {
-
- /**
- * Copy the state of the given object onto the persistent object with the same
- * identifier. If there is no persistent instance currently associated with
- * the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved or does not exist in the database, save it and
- * return it as a newly persistent instance. Otherwise, the given instance
- * does not become associated with the session.
- *
- * @deprecated use {@link org.hibernate.Session#merge(Object)}
- *
- * @param object a transient instance with state to be copied
- * @return an updated persistent instance
- */
- public Object saveOrUpdateCopy(Object object) throws HibernateException;
-
- /**
- * Copy the state of the given object onto the persistent object with the
- * given identifier. If there is no persistent instance currently associated
- * with the session, it will be loaded. Return the persistent instance. If
- * there is no database row with the given identifier, save the given instance
- * and return it as a newly persistent instance. Otherwise, the given instance
- * does not become associated with the session.
- *
- * @deprecated with no replacement
- *
- * @param object a persistent or transient instance with state to be copied
- * @param id the identifier of the instance to copy to
- * @return an updated persistent instance
- */
- public Object saveOrUpdateCopy(Object object, Serializable id) throws HibernateException;
-
- /**
- * Copy the state of the given object onto the persistent object with the same
- * identifier. If there is no persistent instance currently associated with
- * the session, it will be loaded. Return the persistent instance. If the
- * given instance is unsaved or does not exist in the database, save it and
- * return it as a newly persistent instance. Otherwise, the given instance
- * does not become associated with the session.
- *
- * @deprecated use {@link org.hibernate.Session#merge(String, Object)}
- *
- * @param object a transient instance with state to be copied
- * @return an updated persistent instance
- */
- public Object saveOrUpdateCopy(String entityName, Object object) throws HibernateException;
-
- /**
- * Copy the state of the given object onto the persistent object with the
- * given identifier. If there is no persistent instance currently associated
- * with the session, it will be loaded. Return the persistent instance. If
- * there is no database row with the given identifier, save the given instance
- * and return it as a newly persistent instance. Otherwise, the given instance
- * does not become associated with the session.
- *
- * @deprecated with no replacement
- *
- * @param object a persistent or transient instance with state to be copied
- * @param id the identifier of the instance to copy to
- * @return an updated persistent instance
- */
- public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException;
-
- /**
- * Execute a query.
- *
- * @deprecated use {@link #createQuery}.{@link Query#list()}
- *
- * @param query a query expressed in Hibernate's query language
- * @return a distinct list of instances (or arrays of instances)
- * @throws HibernateException
- */
- public List find(String query) throws HibernateException;
-
- /**
- * Execute a query with bind parameters, binding a value to a "?" parameter
- * in the query string.
- *
- * @deprecated use {@link #createQuery}.setXYZ.{@link Query#list()}
- *
- * @param query the query string
- * @param value a value to be bound to a "?" placeholder (JDBC IN parameter).
- * @param type the Hibernate type of the value
- * @see org.hibernate.Hibernate for access to <tt>Type</tt> instances
- * @return a distinct list of instances (or arrays of instances)
- * @throws HibernateException
- */
- public List find(String query, Object value, Type type) throws HibernateException;
-
- /**
- * Execute a query with bind parameters, binding an array of values to "?"
- * parameters in the query string.
- *
- * @deprecated use {@link #createQuery}.setXYZ.{@link Query#list()}
- *
- * @param query the query string
- * @param values an array of values to be bound to the "?" placeholders (JDBC IN parameters).
- * @param types an array of Hibernate types of the values
- * @see org.hibernate.Hibernate for access to <tt>Type</tt> instances
- * @return a distinct list of instances
- * @throws HibernateException
- */
- public List find(String query, Object[] values, Type[] types) throws HibernateException;
-
- /**
- * Execute a query and return the results in an iterator. If the query has multiple
- * return values, values will be returned in an array of type <tt>Object[].</tt><br>
- * <br>
- * Entities returned as results are initialized on demand. The first SQL query returns
- * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
- * objects than <tt>find()</tt>.
- *
- * @deprecated use {@link #createQuery}.{@link Query#iterate}
- *
- * @param query the query string
- * @return an iterator
- * @throws HibernateException
- */
- public Iterator iterate(String query) throws HibernateException;
-
- /**
- * Execute a query and return the results in an iterator. Write the given value to "?"
- * in the query string. If the query has multiple return values, values will be returned
- * in an array of type <tt>Object[]</tt>.<br>
- * <br>
- * Entities returned as results are initialized on demand. The first SQL query returns
- * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
- * objects than <tt>find()</tt>.
- *
- * @deprecated use {@link #createQuery}.setXYZ.{@link Query#iterate}
- *
- * @param query the query string
- * @param value a value to be witten to a "?" placeholder in the query string
- * @param type the hibernate type of value
- * @return an iterator
- * @throws HibernateException
- */
- public Iterator iterate(String query, Object value, Type type) throws HibernateException;
-
- /**
- * Execute a query and return the results in an iterator. Write the given values to "?"
- * in the query string. If the query has multiple return values, values will be returned
- * in an array of type <tt>Object[]</tt>.<br>
- * <br>
- * Entities returned as results are initialized on demand. The first SQL query returns
- * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
- * objects than <tt>find()</tt>.
- *
- * @deprecated use {@link #createQuery}.setXYZ.{@link Query#iterate}
- *
- * @param query the query string
- * @param values a list of values to be written to "?" placeholders in the query
- * @param types a list of Hibernate types of the values
- * @return an iterator
- * @throws HibernateException
- */
- public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException;
-
- /**
- * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to
- * <tt>this</tt>, the collection element. Filters allow efficient access to very large lazy
- * collections. (Executing the filter does not initialize the collection.)
- *
- * @deprecated use {@link #createFilter(Object, String)}.{@link Query#list}
- *
- * @param collection a persistent collection to filter
- * @param filter a filter query string
- * @return Collection the resulting collection
- * @throws HibernateException
- */
- public Collection filter(Object collection, String filter) throws HibernateException;
-
- /**
- * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to
- * <tt>this</tt>, the collection element.
- *
- * @deprecated use {@link #createFilter(Object, String)}.setXYZ.{@link Query#list}
- *
- * @param collection a persistent collection to filter
- * @param filter a filter query string
- * @param value a value to be witten to a "?" placeholder in the query string
- * @param type the hibernate type of value
- * @return Collection
- * @throws HibernateException
- */
- public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException;
-
- /**
- * Apply a filter to a persistent collection.
- *
- * Bind the given parameters to "?" placeholders. A filter is a Hibernate query that
- * may refer to <tt>this</tt>, the collection element.
- *
- * @deprecated use {@link #createFilter(Object, String)}.setXYZ.{@link Query#list}
- *
- * @param collection a persistent collection to filter
- * @param filter a filter query string
- * @param values a list of values to be written to "?" placeholders in the query
- * @param types a list of Hibernate types of the values
- * @return Collection
- * @throws HibernateException
- */
- public Collection filter(Object collection, String filter, Object[] values, Type[] types) throws HibernateException;
-
- /**
- * Delete all objects returned by the query. Return the number of objects deleted.
- * <p/>
- * Note that this is very different from the delete-statement support added in HQL
- * since 3.1. The functionality here is to actually peform the query and then iterate
- * the results calling {@link #delete(Object)} individually.
- *
- * @deprecated consider using HQL delete statements
- *
- * @param query the query string
- * @return the number of instances deleted
- * @throws HibernateException
- */
- public int delete(String query) throws HibernateException;
-
- /**
- * Delete all objects returned by the query. Return the number of objects deleted.
- * <p/>
- * Note that this is very different from the delete-statement support added in HQL
- * since 3.1. The functionality here is to actually peform the query and then iterate
- * the results calling {@link #delete(Object)} individually.
- *
- * @deprecated consider using HQL delete statements
- *
- * @param query the query string
- * @param value a value to be witten to a "?" placeholder in the query string.
- * @param type the hibernate type of value.
- * @return the number of instances deleted
- * @throws HibernateException
- */
- public int delete(String query, Object value, Type type) throws HibernateException;
-
- /**
- * Delete all objects returned by the query. Return the number of objects deleted.
- * <p/>
- * Note that this is very different from the delete-statement support added in HQL
- * since 3.1. The functionality here is to actually peform the query and then iterate
- * the results calling {@link #delete(Object)} individually.
- *
- * @deprecated consider using HQL delete statements
- *
- * @param query the query string
- * @param values a list of values to be written to "?" placeholders in the query.
- * @param types a list of Hibernate types of the values
- * @return the number of instances deleted
- * @throws HibernateException
- */
- public int delete(String query, Object[] values, Type[] types) throws HibernateException;
-
-
- /**
- * Create a new instance of <tt>Query</tt> for the given SQL string.
- *
- * @deprecated will be replaced with a more Query like interface in later release
- *
- * @param sql a query expressed in SQL
- * @param returnAlias a table alias that appears inside <tt>{}</tt> in the SQL string
- * @param returnClass the returned persistent class
- */
- public Query createSQLQuery(String sql, String returnAlias, Class returnClass);
-
- /**
- * Create a new instance of <tt>Query</tt> for the given SQL string.
- *
- * @deprecated will be replaced with a more Query like interface in later release
- *
- * @param sql a query expressed in SQL
- * @param returnAliases an array of table aliases that appear inside <tt>{}</tt> in the SQL string
- * @param returnClasses the returned persistent classes
- */
- public Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses);
-
-
- /**
- * Persist the given transient instance, using the given identifier. This operation
- * cascades to associated instances if the association is mapped with
- * <tt>cascade="save-update"</tt>.
- *
- * @deprecated declare identifier properties for all classes
- *
- * @param object a transient instance of a persistent class
- * @param id an unused valid identifier
- * @throws HibernateException
- */
- public void save(Object object, Serializable id) throws HibernateException;
-
- /**
- * Persist the given transient instance, using the given identifier. This operation
- * cascades to associated instances if the association is mapped with
- * <tt>cascade="save-update"</tt>.
- *
- * @deprecated declare identifier properties for all classes
- *
- * @param object a transient instance of a persistent class
- * @param id an unused valid identifier
- * @throws HibernateException
- */
- public void save(String entityName, Object object, Serializable id) throws HibernateException;
-
- /**
- * Update the persistent state associated with the given identifier. An exception
- * is thrown if there is a persistent instance with the same identifier in the
- * current session. This operation cascades to associated instances
- * if the association is mapped with <tt>cascade="save-update"</tt>.
- *
- * @deprecated declare identifier properties for all classes
- *
- * @param object a detached instance containing updated state
- * @param id identifier of persistent instance
- * @throws HibernateException
- */
- public void update(Object object, Serializable id) throws HibernateException;
-
- /**
- * Update the persistent state associated with the given identifier. An exception
- * is thrown if there is a persistent instance with the same identifier in the
- * current session. This operation cascades to associated instances
- * if the association is mapped with <tt>cascade="save-update"</tt>.
- *
- * @deprecated declare identifier properties for all classes
- *
- * @param object a detached instance containing updated state
- * @param id identifier of persistent instance
- * @throws HibernateException
- */
- public void update(String entityName, Object object, Serializable id) throws HibernateException;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/classic/Session.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Session.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,375 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.classic;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Query;
+import org.hibernate.type.Type;
+
+/**
+ * An extension of the <tt>Session</tt> API, including all
+ * deprecated methods from Hibernate2. This interface is
+ * provided to allow easier migration of existing applications.
+ * New code should use <tt>org.hibernate.Session</tt>.
+ * @author Gavin King
+ */
+public interface Session extends org.hibernate.Session {
+
+ /**
+ * Copy the state of the given object onto the persistent object with the same
+ * identifier. If there is no persistent instance currently associated with
+ * the session, it will be loaded. Return the persistent instance. If the
+ * given instance is unsaved or does not exist in the database, save it and
+ * return it as a newly persistent instance. Otherwise, the given instance
+ * does not become associated with the session.
+ *
+ * @deprecated use {@link org.hibernate.Session#merge(Object)}
+ *
+ * @param object a transient instance with state to be copied
+ * @return an updated persistent instance
+ */
+ public Object saveOrUpdateCopy(Object object) throws HibernateException;
+
+ /**
+ * Copy the state of the given object onto the persistent object with the
+ * given identifier. If there is no persistent instance currently associated
+ * with the session, it will be loaded. Return the persistent instance. If
+ * there is no database row with the given identifier, save the given instance
+ * and return it as a newly persistent instance. Otherwise, the given instance
+ * does not become associated with the session.
+ *
+ * @deprecated with no replacement
+ *
+ * @param object a persistent or transient instance with state to be copied
+ * @param id the identifier of the instance to copy to
+ * @return an updated persistent instance
+ */
+ public Object saveOrUpdateCopy(Object object, Serializable id) throws HibernateException;
+
+ /**
+ * Copy the state of the given object onto the persistent object with the same
+ * identifier. If there is no persistent instance currently associated with
+ * the session, it will be loaded. Return the persistent instance. If the
+ * given instance is unsaved or does not exist in the database, save it and
+ * return it as a newly persistent instance. Otherwise, the given instance
+ * does not become associated with the session.
+ *
+ * @deprecated use {@link org.hibernate.Session#merge(String, Object)}
+ *
+ * @param object a transient instance with state to be copied
+ * @return an updated persistent instance
+ */
+ public Object saveOrUpdateCopy(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Copy the state of the given object onto the persistent object with the
+ * given identifier. If there is no persistent instance currently associated
+ * with the session, it will be loaded. Return the persistent instance. If
+ * there is no database row with the given identifier, save the given instance
+ * and return it as a newly persistent instance. Otherwise, the given instance
+ * does not become associated with the session.
+ *
+ * @deprecated with no replacement
+ *
+ * @param object a persistent or transient instance with state to be copied
+ * @param id the identifier of the instance to copy to
+ * @return an updated persistent instance
+ */
+ public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException;
+
+ /**
+ * Execute a query.
+ *
+ * @deprecated use {@link #createQuery}.{@link Query#list()}
+ *
+ * @param query a query expressed in Hibernate's query language
+ * @return a distinct list of instances (or arrays of instances)
+ * @throws HibernateException
+ */
+ public List find(String query) throws HibernateException;
+
+ /**
+ * Execute a query with bind parameters, binding a value to a "?" parameter
+ * in the query string.
+ *
+ * @deprecated use {@link #createQuery}.setXYZ.{@link Query#list()}
+ *
+ * @param query the query string
+ * @param value a value to be bound to a "?" placeholder (JDBC IN parameter).
+ * @param type the Hibernate type of the value
+ * @see org.hibernate.Hibernate for access to <tt>Type</tt> instances
+ * @return a distinct list of instances (or arrays of instances)
+ * @throws HibernateException
+ */
+ public List find(String query, Object value, Type type) throws HibernateException;
+
+ /**
+ * Execute a query with bind parameters, binding an array of values to "?"
+ * parameters in the query string.
+ *
+ * @deprecated use {@link #createQuery}.setXYZ.{@link Query#list()}
+ *
+ * @param query the query string
+ * @param values an array of values to be bound to the "?" placeholders (JDBC IN parameters).
+ * @param types an array of Hibernate types of the values
+ * @see org.hibernate.Hibernate for access to <tt>Type</tt> instances
+ * @return a distinct list of instances
+ * @throws HibernateException
+ */
+ public List find(String query, Object[] values, Type[] types) throws HibernateException;
+
+ /**
+ * Execute a query and return the results in an iterator. If the query has multiple
+ * return values, values will be returned in an array of type <tt>Object[].</tt><br>
+ * <br>
+ * Entities returned as results are initialized on demand. The first SQL query returns
+ * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
+ * objects than <tt>find()</tt>.
+ *
+ * @deprecated use {@link #createQuery}.{@link Query#iterate}
+ *
+ * @param query the query string
+ * @return an iterator
+ * @throws HibernateException
+ */
+ public Iterator iterate(String query) throws HibernateException;
+
+ /**
+ * Execute a query and return the results in an iterator. Write the given value to "?"
+ * in the query string. If the query has multiple return values, values will be returned
+ * in an array of type <tt>Object[]</tt>.<br>
+ * <br>
+ * Entities returned as results are initialized on demand. The first SQL query returns
+ * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
+ * objects than <tt>find()</tt>.
+ *
+ * @deprecated use {@link #createQuery}.setXYZ.{@link Query#iterate}
+ *
+ * @param query the query string
+ * @param value a value to be witten to a "?" placeholder in the query string
+ * @param type the hibernate type of value
+ * @return an iterator
+ * @throws HibernateException
+ */
+ public Iterator iterate(String query, Object value, Type type) throws HibernateException;
+
+ /**
+ * Execute a query and return the results in an iterator. Write the given values to "?"
+ * in the query string. If the query has multiple return values, values will be returned
+ * in an array of type <tt>Object[]</tt>.<br>
+ * <br>
+ * Entities returned as results are initialized on demand. The first SQL query returns
+ * identifiers only. So <tt>iterate()</tt> is usually a less efficient way to retrieve
+ * objects than <tt>find()</tt>.
+ *
+ * @deprecated use {@link #createQuery}.setXYZ.{@link Query#iterate}
+ *
+ * @param query the query string
+ * @param values a list of values to be written to "?" placeholders in the query
+ * @param types a list of Hibernate types of the values
+ * @return an iterator
+ * @throws HibernateException
+ */
+ public Iterator iterate(String query, Object[] values, Type[] types) throws HibernateException;
+
+ /**
+ * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to
+ * <tt>this</tt>, the collection element. Filters allow efficient access to very large lazy
+ * collections. (Executing the filter does not initialize the collection.)
+ *
+ * @deprecated use {@link #createFilter(Object, String)}.{@link Query#list}
+ *
+ * @param collection a persistent collection to filter
+ * @param filter a filter query string
+ * @return Collection the resulting collection
+ * @throws HibernateException
+ */
+ public Collection filter(Object collection, String filter) throws HibernateException;
+
+ /**
+ * Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to
+ * <tt>this</tt>, the collection element.
+ *
+ * @deprecated use {@link #createFilter(Object, String)}.setXYZ.{@link Query#list}
+ *
+ * @param collection a persistent collection to filter
+ * @param filter a filter query string
+ * @param value a value to be witten to a "?" placeholder in the query string
+ * @param type the hibernate type of value
+ * @return Collection
+ * @throws HibernateException
+ */
+ public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException;
+
+ /**
+ * Apply a filter to a persistent collection.
+ *
+ * Bind the given parameters to "?" placeholders. A filter is a Hibernate query that
+ * may refer to <tt>this</tt>, the collection element.
+ *
+ * @deprecated use {@link #createFilter(Object, String)}.setXYZ.{@link Query#list}
+ *
+ * @param collection a persistent collection to filter
+ * @param filter a filter query string
+ * @param values a list of values to be written to "?" placeholders in the query
+ * @param types a list of Hibernate types of the values
+ * @return Collection
+ * @throws HibernateException
+ */
+ public Collection filter(Object collection, String filter, Object[] values, Type[] types) throws HibernateException;
+
+ /**
+ * Delete all objects returned by the query. Return the number of objects deleted.
+ * <p/>
+ * Note that this is very different from the delete-statement support added in HQL
+ * since 3.1. The functionality here is to actually peform the query and then iterate
+ * the results calling {@link #delete(Object)} individually.
+ *
+ * @deprecated consider using HQL delete statements
+ *
+ * @param query the query string
+ * @return the number of instances deleted
+ * @throws HibernateException
+ */
+ public int delete(String query) throws HibernateException;
+
+ /**
+ * Delete all objects returned by the query. Return the number of objects deleted.
+ * <p/>
+ * Note that this is very different from the delete-statement support added in HQL
+ * since 3.1. The functionality here is to actually peform the query and then iterate
+ * the results calling {@link #delete(Object)} individually.
+ *
+ * @deprecated consider using HQL delete statements
+ *
+ * @param query the query string
+ * @param value a value to be witten to a "?" placeholder in the query string.
+ * @param type the hibernate type of value.
+ * @return the number of instances deleted
+ * @throws HibernateException
+ */
+ public int delete(String query, Object value, Type type) throws HibernateException;
+
+ /**
+ * Delete all objects returned by the query. Return the number of objects deleted.
+ * <p/>
+ * Note that this is very different from the delete-statement support added in HQL
+ * since 3.1. The functionality here is to actually peform the query and then iterate
+ * the results calling {@link #delete(Object)} individually.
+ *
+ * @deprecated consider using HQL delete statements
+ *
+ * @param query the query string
+ * @param values a list of values to be written to "?" placeholders in the query.
+ * @param types a list of Hibernate types of the values
+ * @return the number of instances deleted
+ * @throws HibernateException
+ */
+ public int delete(String query, Object[] values, Type[] types) throws HibernateException;
+
+
+ /**
+ * Create a new instance of <tt>Query</tt> for the given SQL string.
+ *
+ * @deprecated will be replaced with a more Query like interface in later release
+ *
+ * @param sql a query expressed in SQL
+ * @param returnAlias a table alias that appears inside <tt>{}</tt> in the SQL string
+ * @param returnClass the returned persistent class
+ */
+ public Query createSQLQuery(String sql, String returnAlias, Class returnClass);
+
+ /**
+ * Create a new instance of <tt>Query</tt> for the given SQL string.
+ *
+ * @deprecated will be replaced with a more Query like interface in later release
+ *
+ * @param sql a query expressed in SQL
+ * @param returnAliases an array of table aliases that appear inside <tt>{}</tt> in the SQL string
+ * @param returnClasses the returned persistent classes
+ */
+ public Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses);
+
+
+ /**
+ * Persist the given transient instance, using the given identifier. This operation
+ * cascades to associated instances if the association is mapped with
+ * <tt>cascade="save-update"</tt>.
+ *
+ * @deprecated declare identifier properties for all classes
+ *
+ * @param object a transient instance of a persistent class
+ * @param id an unused valid identifier
+ * @throws HibernateException
+ */
+ public void save(Object object, Serializable id) throws HibernateException;
+
+ /**
+ * Persist the given transient instance, using the given identifier. This operation
+ * cascades to associated instances if the association is mapped with
+ * <tt>cascade="save-update"</tt>.
+ *
+ * @deprecated declare identifier properties for all classes
+ *
+ * @param object a transient instance of a persistent class
+ * @param id an unused valid identifier
+ * @throws HibernateException
+ */
+ public void save(String entityName, Object object, Serializable id) throws HibernateException;
+
+ /**
+ * Update the persistent state associated with the given identifier. An exception
+ * is thrown if there is a persistent instance with the same identifier in the
+ * current session. This operation cascades to associated instances
+ * if the association is mapped with <tt>cascade="save-update"</tt>.
+ *
+ * @deprecated declare identifier properties for all classes
+ *
+ * @param object a detached instance containing updated state
+ * @param id identifier of persistent instance
+ * @throws HibernateException
+ */
+ public void update(Object object, Serializable id) throws HibernateException;
+
+ /**
+ * Update the persistent state associated with the given identifier. An exception
+ * is thrown if there is a persistent instance with the same identifier in the
+ * current session. This operation cascades to associated instances
+ * if the association is mapped with <tt>cascade="save-update"</tt>.
+ *
+ * @deprecated declare identifier properties for all classes
+ *
+ * @param object a detached instance containing updated state
+ * @param id identifier of persistent instance
+ * @throws HibernateException
+ */
+ public void update(String entityName, Object object, Serializable id) throws HibernateException;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/classic/Validatable.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,26 +0,0 @@
-//$Id: Validatable.java 4112 2004-07-28 03:33:35Z oneovthafew $
-package org.hibernate.classic;
-
-
-/**
- * Implemented by persistent classes with invariants that must
- * be checked before inserting into or updating the database.
- *
- * @author Gavin King
- */
-public interface Validatable {
- /**
- * Validate the state of the object before persisting it.
- * If a violation occurs, throw a <tt>ValidationFailure</tt>.
- * This method must not change the state of the object by
- * side-effect.
- * @throws ValidationFailure if an invariant is violated
- */
- public void validate() throws ValidationFailure;
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/classic/Validatable.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/Validatable.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,42 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.classic;
+
+/**
+ * Implemented by persistent classes with invariants that must
+ * be checked before inserting into or updating the database.
+ *
+ * @author Gavin King
+ */
+public interface Validatable {
+ /**
+ * Validate the state of the object before persisting it.
+ * If a violation occurs, throw a <tt>ValidationFailure</tt>.
+ * This method must not change the state of the object by
+ * side-effect.
+ * @throws ValidationFailure if an invariant is violated
+ */
+ public void validate() throws ValidationFailure;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/classic/ValidationFailure.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,33 +0,0 @@
-//$Id: ValidationFailure.java 4112 2004-07-28 03:33:35Z oneovthafew $
-package org.hibernate.classic;
-
-import org.hibernate.HibernateException;
-
-/**
- * Thrown from <tt>Validatable.validate()</tt> when an invariant
- * was violated. Some applications might subclass this exception
- * in order to provide more information about the violation.
- *
- * @author Gavin King
- */
-public class ValidationFailure extends HibernateException {
-
- public ValidationFailure(String message) {
- super(message);
- }
-
- public ValidationFailure(String message, Exception e) {
- super(message, e);
- }
-
- public ValidationFailure(Exception e) {
- super("A validation failure occurred", e);
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/classic/ValidationFailure.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/ValidationFailure.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.classic;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Thrown from <tt>Validatable.validate()</tt> when an invariant
+ * was violated. Some applications might subclass this exception
+ * in order to provide more information about the violation.
+ *
+ * @author Gavin King
+ */
+public class ValidationFailure extends HibernateException {
+
+ public ValidationFailure(String message) {
+ super(message);
+ }
+
+ public ValidationFailure(String message, Exception e) {
+ super(message, e);
+ }
+
+ public ValidationFailure(Exception e) {
+ super("A validation failure occurred", e);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/classic/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,9 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- This package implements backward-compatibility with Hibernate 2.1
- APIs now deprecated in Hibernate3.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/classic/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/classic/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ This package implements backward-compatibility with Hibernate 2.1
+ APIs now deprecated in Hibernate3.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,943 +0,0 @@
-//$Id: AbstractPersistentCollection.java 11302 2007-03-19 20:44:11Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.LazyInitializationException;
-import org.hibernate.engine.CollectionEntry;
-import org.hibernate.engine.ForeignKeys;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.type.Type;
-import org.hibernate.util.CollectionHelper;
-import org.hibernate.util.EmptyIterator;
-import org.hibernate.util.MarkerObject;
-
-/**
- * Base class implementing <tt>PersistentCollection</tt>
- * @see PersistentCollection
- * @author Gavin King
- */
-public abstract class AbstractPersistentCollection
- implements Serializable, PersistentCollection {
-
- private transient SessionImplementor session;
- private boolean initialized;
- private transient List operationQueue;
- private transient boolean directlyAccessible;
- private transient boolean initializing;
- private Object owner;
- private int cachedSize = -1;
-
- private String role;
- private Serializable key;
- // collections detect changes made via their public interface and mark
- // themselves as dirty as a performance optimization
- private boolean dirty;
- private Serializable storedSnapshot;
-
- public final String getRole() {
- return role;
- }
-
- public final Serializable getKey() {
- return key;
- }
-
- public final boolean isUnreferenced() {
- return role==null;
- }
-
- public final boolean isDirty() {
- return dirty;
- }
-
- public final void clearDirty() {
- dirty = false;
- }
-
- public final void dirty() {
- dirty = true;
- }
-
- public final Serializable getStoredSnapshot() {
- return storedSnapshot;
- }
-
- //Careful: these methods do not initialize the collection.
- /**
- * Is the initialized collection empty?
- */
- public abstract boolean empty();
- /**
- * Called by any read-only method of the collection interface
- */
- protected final void read() {
- initialize(false);
- }
- /**
- * Called by the <tt>size()</tt> method
- */
- protected boolean readSize() {
- if (!initialized) {
- if ( cachedSize!=-1 && !hasQueuedOperations() ) {
- return true;
- }
- else {
- throwLazyInitializationExceptionIfNotConnected();
- CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
- CollectionPersister persister = entry.getLoadedPersister();
- if ( persister.isExtraLazy() ) {
- if ( hasQueuedOperations() ) {
- session.flush();
- }
- cachedSize = persister.getSize( entry.getLoadedKey(), session );
- return true;
- }
- }
- }
- read();
- return false;
- }
-
- protected Boolean readIndexExistence(Object index) {
- if (!initialized) {
- throwLazyInitializationExceptionIfNotConnected();
- CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
- CollectionPersister persister = entry.getLoadedPersister();
- if ( persister.isExtraLazy() ) {
- if ( hasQueuedOperations() ) {
- session.flush();
- }
- return new Boolean( persister.indexExists( entry.getLoadedKey(), index, session ) );
- }
- }
- read();
- return null;
-
- }
-
- protected Boolean readElementExistence(Object element) {
- if (!initialized) {
- throwLazyInitializationExceptionIfNotConnected();
- CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
- CollectionPersister persister = entry.getLoadedPersister();
- if ( persister.isExtraLazy() ) {
- if ( hasQueuedOperations() ) {
- session.flush();
- }
- return new Boolean( persister.elementExists( entry.getLoadedKey(), element, session ) );
- }
- }
- read();
- return null;
-
- }
-
- protected static final Object UNKNOWN = new MarkerObject("UNKNOWN");
-
- protected Object readElementByIndex(Object index) {
- if (!initialized) {
- throwLazyInitializationExceptionIfNotConnected();
- CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
- CollectionPersister persister = entry.getLoadedPersister();
- if ( persister.isExtraLazy() ) {
- if ( hasQueuedOperations() ) {
- session.flush();
- }
- return persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
- }
- }
- read();
- return UNKNOWN;
-
- }
-
- protected int getCachedSize() {
- return cachedSize;
- }
-
- /**
- * Is the collection currently connected to an open session?
- */
- private final boolean isConnectedToSession() {
- return session!=null &&
- session.isOpen() &&
- session.getPersistenceContext().containsCollection(this);
- }
-
- /**
- * Called by any writer method of the collection interface
- */
- protected final void write() {
- initialize(true);
- dirty();
- }
- /**
- * Is this collection in a state that would allow us to
- * "queue" operations?
- */
- protected boolean isOperationQueueEnabled() {
- return !initialized &&
- isConnectedToSession() &&
- isInverseCollection();
- }
- /**
- * Is this collection in a state that would allow us to
- * "queue" puts? This is a special case, because of orphan
- * delete.
- */
- protected boolean isPutQueueEnabled() {
- return !initialized &&
- isConnectedToSession() &&
- isInverseOneToManyOrNoOrphanDelete();
- }
- /**
- * Is this collection in a state that would allow us to
- * "queue" clear? This is a special case, because of orphan
- * delete.
- */
- protected boolean isClearQueueEnabled() {
- return !initialized &&
- isConnectedToSession() &&
- isInverseCollectionNoOrphanDelete();
- }
-
- /**
- * Is this the "inverse" end of a bidirectional association?
- */
- private boolean isInverseCollection() {
- CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
- return ce != null && ce.getLoadedPersister().isInverse();
- }
-
- /**
- * Is this the "inverse" end of a bidirectional association with
- * no orphan delete enabled?
- */
- private boolean isInverseCollectionNoOrphanDelete() {
- CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
- return ce != null &&
- ce.getLoadedPersister().isInverse() &&
- !ce.getLoadedPersister().hasOrphanDelete();
- }
-
- /**
- * Is this the "inverse" end of a bidirectional one-to-many, or
- * of a collection with no orphan delete?
- */
- private boolean isInverseOneToManyOrNoOrphanDelete() {
- CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
- return ce != null && ce.getLoadedPersister().isInverse() && (
- ce.getLoadedPersister().isOneToMany() ||
- !ce.getLoadedPersister().hasOrphanDelete()
- );
- }
-
- /**
- * Queue an addition
- */
- protected final void queueOperation(Object element) {
- if (operationQueue==null) operationQueue = new ArrayList(10);
- operationQueue.add(element);
- dirty = true; //needed so that we remove this collection from the second-level cache
- }
-
- /**
- * After reading all existing elements from the database,
- * add the queued elements to the underlying collection.
- */
- protected final void performQueuedOperations() {
- for ( int i=0; i<operationQueue.size(); i++ ) {
- ( (DelayedOperation) operationQueue.get(i) ).operate();
- }
- }
-
- /**
- * After flushing, re-init snapshot state.
- */
- public void setSnapshot(Serializable key, String role, Serializable snapshot) {
- this.key = key;
- this.role = role;
- this.storedSnapshot = snapshot;
- }
-
- /**
- * After flushing, clear any "queued" additions, since the
- * database state is now synchronized with the memory state.
- */
- public void postAction() {
- operationQueue=null;
- cachedSize = -1;
- clearDirty();
- }
-
- /**
- * Not called by Hibernate, but used by non-JDK serialization,
- * eg. SOAP libraries.
- */
- public AbstractPersistentCollection() {}
-
- protected AbstractPersistentCollection(SessionImplementor session) {
- this.session = session;
- }
-
- /**
- * return the user-visible collection (or array) instance
- */
- public Object getValue() {
- return this;
- }
-
- /**
- * Called just before reading any rows from the JDBC result set
- */
- public void beginRead() {
- // override on some subclasses
- initializing = true;
- }
-
- /**
- * Called after reading all rows from the JDBC result set
- */
- public boolean endRead() {
- //override on some subclasses
- return afterInitialize();
- }
-
- public boolean afterInitialize() {
- setInitialized();
- //do this bit after setting initialized to true or it will recurse
- if (operationQueue!=null) {
- performQueuedOperations();
- operationQueue=null;
- cachedSize = -1;
- return false;
- }
- else {
- return true;
- }
- }
-
- /**
- * Initialize the collection, if possible, wrapping any exceptions
- * in a runtime exception
- * @param writing currently obsolete
- * @throws LazyInitializationException if we cannot initialize
- */
- protected final void initialize(boolean writing) {
- if (!initialized) {
- if (initializing) {
- throw new LazyInitializationException("illegal access to loading collection");
- }
- throwLazyInitializationExceptionIfNotConnected();
- session.initializeCollection(this, writing);
- }
- }
-
- private void throwLazyInitializationExceptionIfNotConnected() {
- if ( !isConnectedToSession() ) {
- throwLazyInitializationException("no session or session was closed");
- }
- if ( !session.isConnected() ) {
- throwLazyInitializationException("session is disconnected");
- }
- }
-
- private void throwLazyInitializationException(String message) {
- throw new LazyInitializationException(
- "failed to lazily initialize a collection" +
- ( role==null ? "" : " of role: " + role ) +
- ", " + message
- );
- }
-
- protected final void setInitialized() {
- this.initializing = false;
- this.initialized = true;
- }
-
- protected final void setDirectlyAccessible(boolean directlyAccessible) {
- this.directlyAccessible = directlyAccessible;
- }
-
- /**
- * Could the application possibly have a direct reference to
- * the underlying collection implementation?
- */
- public boolean isDirectlyAccessible() {
- return directlyAccessible;
- }
-
- /**
- * Disassociate this collection from the given session.
- * @return true if this was currently associated with the given session
- */
- public final boolean unsetSession(SessionImplementor currentSession) {
- if (currentSession==this.session) {
- this.session=null;
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * Associate the collection with the given session.
- * @return false if the collection was already associated with the session
- * @throws HibernateException if the collection was already associated
- * with another open session
- */
- public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
- if (session==this.session) {
- return false;
- }
- else {
- if ( isConnectedToSession() ) {
- CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
- if (ce==null) {
- throw new HibernateException(
- "Illegal attempt to associate a collection with two open sessions"
- );
- }
- else {
- throw new HibernateException(
- "Illegal attempt to associate a collection with two open sessions: " +
- MessageHelper.collectionInfoString(
- ce.getLoadedPersister(),
- ce.getLoadedKey(),
- session.getFactory()
- )
- );
- }
- }
- else {
- this.session = session;
- return true;
- }
- }
- }
-
- /**
- * Do we need to completely recreate this collection when it changes?
- */
- public boolean needsRecreate(CollectionPersister persister) {
- return false;
- }
-
- /**
- * To be called internally by the session, forcing
- * immediate initialization.
- */
- public final void forceInitialization() throws HibernateException {
- if (!initialized) {
- if (initializing) {
- throw new AssertionFailure("force initialize loading collection");
- }
- if (session==null) {
- throw new HibernateException("collection is not associated with any session");
- }
- if ( !session.isConnected() ) {
- throw new HibernateException("disconnected session");
- }
- session.initializeCollection(this, false);
- }
- }
-
-
- /**
- * Get the current snapshot from the session
- */
- protected final Serializable getSnapshot() {
- return session.getPersistenceContext().getSnapshot(this);
- }
-
- /**
- * Is this instance initialized?
- */
- public final boolean wasInitialized() {
- return initialized;
- }
-
- public boolean isRowUpdatePossible() {
- return true;
- }
-
- /**
- * Does this instance have any "queued" additions?
- */
- public final boolean hasQueuedOperations() {
- return operationQueue!=null;
- }
- /**
- * Iterate the "queued" additions
- */
- public final Iterator queuedAdditionIterator() {
- if ( hasQueuedOperations() ) {
- return new Iterator() {
- int i = 0;
- public Object next() {
- return ( (DelayedOperation) operationQueue.get(i++) ).getAddedInstance();
- }
- public boolean hasNext() {
- return i<operationQueue.size();
- }
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
- else {
- return EmptyIterator.INSTANCE;
- }
- }
- /**
- * Iterate the "queued" additions
- */
- public final Collection getQueuedOrphans(String entityName) {
- if ( hasQueuedOperations() ) {
- Collection additions = new ArrayList( operationQueue.size() );
- Collection removals = new ArrayList( operationQueue.size() );
- for ( int i = 0; i < operationQueue.size(); i++ ) {
- DelayedOperation op = (DelayedOperation) operationQueue.get(i);
- additions.add( op.getAddedInstance() );
- removals.add( op.getOrphan() );
- }
- return getOrphans(removals, additions, entityName, session);
- }
- else {
- return CollectionHelper.EMPTY_COLLECTION;
- }
- }
-
- /**
- * Called before inserting rows, to ensure that any surrogate keys
- * are fully generated
- */
- public void preInsert(CollectionPersister persister) throws HibernateException {}
- /**
- * Called after inserting a row, to fetch the natively generated id
- */
- public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException {}
- /**
- * get all "orphaned" elements
- */
- public abstract Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException;
-
- /**
- * Get the current session
- */
- public final SessionImplementor getSession() {
- return session;
- }
-
- final class IteratorProxy implements Iterator {
- private final Iterator iter;
- IteratorProxy(Iterator iter) {
- this.iter=iter;
- }
- public boolean hasNext() {
- return iter.hasNext();
- }
-
- public Object next() {
- return iter.next();
- }
-
- public void remove() {
- write();
- iter.remove();
- }
-
- }
-
- final class ListIteratorProxy implements ListIterator {
- private final ListIterator iter;
- ListIteratorProxy(ListIterator iter) {
- this.iter = iter;
- }
- public void add(Object o) {
- write();
- iter.add(o);
- }
-
- public boolean hasNext() {
- return iter.hasNext();
- }
-
- public boolean hasPrevious() {
- return iter.hasPrevious();
- }
-
- public Object next() {
- return iter.next();
- }
-
- public int nextIndex() {
- return iter.nextIndex();
- }
-
- public Object previous() {
- return iter.previous();
- }
-
- public int previousIndex() {
- return iter.previousIndex();
- }
-
- public void remove() {
- write();
- iter.remove();
- }
-
- public void set(Object o) {
- write();
- iter.set(o);
- }
-
- }
-
- class SetProxy implements java.util.Set {
-
- final Collection set;
-
- SetProxy(Collection set) {
- this.set=set;
- }
- public boolean add(Object o) {
- write();
- return set.add(o);
- }
-
- public boolean addAll(Collection c) {
- write();
- return set.addAll(c);
- }
-
- public void clear() {
- write();
- set.clear();
- }
-
- public boolean contains(Object o) {
- return set.contains(o);
- }
-
- public boolean containsAll(Collection c) {
- return set.containsAll(c);
- }
-
- public boolean isEmpty() {
- return set.isEmpty();
- }
-
- public Iterator iterator() {
- return new IteratorProxy( set.iterator() );
- }
-
- public boolean remove(Object o) {
- write();
- return set.remove(o);
- }
-
- public boolean removeAll(Collection c) {
- write();
- return set.removeAll(c);
- }
-
- public boolean retainAll(Collection c) {
- write();
- return set.retainAll(c);
- }
-
- public int size() {
- return set.size();
- }
-
- public Object[] toArray() {
- return set.toArray();
- }
-
- public Object[] toArray(Object[] array) {
- return set.toArray(array);
- }
-
- }
-
- final class ListProxy implements java.util.List {
-
- private final java.util.List list;
-
- ListProxy(java.util.List list) {
- this.list = list;
- }
-
- public void add(int index, Object value) {
- write();
- list.add(index, value);
- }
-
- /**
- * @see java.util.Collection#add(Object)
- */
- public boolean add(Object o) {
- write();
- return list.add(o);
- }
-
- /**
- * @see java.util.Collection#addAll(Collection)
- */
- public boolean addAll(Collection c) {
- write();
- return list.addAll(c);
- }
-
- /**
- * @see java.util.List#addAll(int, Collection)
- */
- public boolean addAll(int i, Collection c) {
- write();
- return list.addAll(i, c);
- }
-
- /**
- * @see java.util.Collection#clear()
- */
- public void clear() {
- write();
- list.clear();
- }
-
- /**
- * @see java.util.Collection#contains(Object)
- */
- public boolean contains(Object o) {
- return list.contains(o);
- }
-
- /**
- * @see java.util.Collection#containsAll(Collection)
- */
- public boolean containsAll(Collection c) {
- return list.containsAll(c);
- }
-
- /**
- * @see java.util.List#get(int)
- */
- public Object get(int i) {
- return list.get(i);
- }
-
- /**
- * @see java.util.List#indexOf(Object)
- */
- public int indexOf(Object o) {
- return list.indexOf(o);
- }
-
- /**
- * @see java.util.Collection#isEmpty()
- */
- public boolean isEmpty() {
- return list.isEmpty();
- }
-
- /**
- * @see java.util.Collection#iterator()
- */
- public Iterator iterator() {
- return new IteratorProxy( list.iterator() );
- }
-
- /**
- * @see java.util.List#lastIndexOf(Object)
- */
- public int lastIndexOf(Object o) {
- return list.lastIndexOf(o);
- }
-
- /**
- * @see java.util.List#listIterator()
- */
- public ListIterator listIterator() {
- return new ListIteratorProxy( list.listIterator() );
- }
-
- /**
- * @see java.util.List#listIterator(int)
- */
- public ListIterator listIterator(int i) {
- return new ListIteratorProxy( list.listIterator(i) );
- }
-
- /**
- * @see java.util.List#remove(int)
- */
- public Object remove(int i) {
- write();
- return list.remove(i);
- }
-
- /**
- * @see java.util.Collection#remove(Object)
- */
- public boolean remove(Object o) {
- write();
- return list.remove(o);
- }
-
- /**
- * @see java.util.Collection#removeAll(Collection)
- */
- public boolean removeAll(Collection c) {
- write();
- return list.removeAll(c);
- }
-
- /**
- * @see java.util.Collection#retainAll(Collection)
- */
- public boolean retainAll(Collection c) {
- write();
- return list.retainAll(c);
- }
-
- /**
- * @see java.util.List#set(int, Object)
- */
- public Object set(int i, Object o) {
- write();
- return list.set(i, o);
- }
-
- /**
- * @see java.util.Collection#size()
- */
- public int size() {
- return list.size();
- }
-
- /**
- * @see java.util.List#subList(int, int)
- */
- public List subList(int i, int j) {
- return list.subList(i, j);
- }
-
- /**
- * @see java.util.Collection#toArray()
- */
- public Object[] toArray() {
- return list.toArray();
- }
-
- /**
- * @see java.util.Collection#toArray(Object[])
- */
- public Object[] toArray(Object[] array) {
- return list.toArray(array);
- }
-
- }
-
-
- protected interface DelayedOperation {
- public void operate();
- public Object getAddedInstance();
- public Object getOrphan();
- }
-
- /**
- * Given a collection of entity instances that used to
- * belong to the collection, and a collection of instances
- * that currently belong, return a collection of orphans
- */
- protected static Collection getOrphans(
- Collection oldElements,
- Collection currentElements,
- String entityName,
- SessionImplementor session)
- throws HibernateException {
-
- // short-circuit(s)
- if ( currentElements.size()==0 ) return oldElements; // no new elements, the old list contains only Orphans
- if ( oldElements.size()==0) return oldElements; // no old elements, so no Orphans neither
-
- Type idType = session.getFactory().getEntityPersister(entityName).getIdentifierType();
-
- // create the collection holding the Orphans
- Collection res = new ArrayList();
-
- // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
- java.util.Set currentIds = new HashSet();
- for ( Iterator it=currentElements.iterator(); it.hasNext(); ) {
- Object current = it.next();
- if ( current!=null && ForeignKeys.isNotTransient(entityName, current, null, session) ) {
- Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, current, session);
- currentIds.add( new TypedValue( idType, currentId, session.getEntityMode() ) );
- }
- }
-
- // iterate over the *old* list
- for ( Iterator it=oldElements.iterator(); it.hasNext(); ) {
- Object old = it.next();
- Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, old, session);
- if ( !currentIds.contains( new TypedValue( idType, oldId, session.getEntityMode() ) ) ) {
- res.add(old);
- }
- }
-
- return res;
- }
-
- static void identityRemove(
- Collection list,
- Object object,
- String entityName,
- SessionImplementor session)
- throws HibernateException {
-
- if ( object!=null && ForeignKeys.isNotTransient(entityName, object, null, session) ) {
-
- Type idType = session.getFactory().getEntityPersister(entityName).getIdentifierType();
-
- Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, session);
- Iterator iter = list.iterator();
- while ( iter.hasNext() ) {
- Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, iter.next(), session);
- if ( idType.isEqual( idOfCurrent, idOfOld, session.getEntityMode(), session.getFactory() ) ) {
- iter.remove();
- break;
- }
- }
-
- }
- }
-
- public Object getIdentifier(Object entry, int i) {
- throw new UnsupportedOperationException();
- }
-
- public Object getOwner() {
- return owner;
- }
-
- public void setOwner(Object owner) {
- this.owner = owner;
- }
-
-}
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/AbstractPersistentCollection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,965 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.LazyInitializationException;
+import org.hibernate.engine.CollectionEntry;
+import org.hibernate.engine.ForeignKeys;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.type.Type;
+import org.hibernate.util.CollectionHelper;
+import org.hibernate.util.EmptyIterator;
+import org.hibernate.util.MarkerObject;
+
+/**
+ * Base class implementing {@link PersistentCollection}
+ *
+ * @author Gavin King
+ */
+public abstract class AbstractPersistentCollection implements Serializable, PersistentCollection {
+
+ private transient SessionImplementor session;
+ private boolean initialized;
+ private transient List operationQueue;
+ private transient boolean directlyAccessible;
+ private transient boolean initializing;
+ private Object owner;
+ private int cachedSize = -1;
+
+ private String role;
+ private Serializable key;
+ // collections detect changes made via their public interface and mark
+ // themselves as dirty as a performance optimization
+ private boolean dirty;
+ private Serializable storedSnapshot;
+
+ public final String getRole() {
+ return role;
+ }
+
+ public final Serializable getKey() {
+ return key;
+ }
+
+ public final boolean isUnreferenced() {
+ return role==null;
+ }
+
+ public final boolean isDirty() {
+ return dirty;
+ }
+
+ public final void clearDirty() {
+ dirty = false;
+ }
+
+ public final void dirty() {
+ dirty = true;
+ }
+
+ public final Serializable getStoredSnapshot() {
+ return storedSnapshot;
+ }
+
+ //Careful: these methods do not initialize the collection.
+ /**
+ * Is the initialized collection empty?
+ */
+ public abstract boolean empty();
+ /**
+ * Called by any read-only method of the collection interface
+ */
+ protected final void read() {
+ initialize(false);
+ }
+ /**
+ * Called by the <tt>size()</tt> method
+ */
+ protected boolean readSize() {
+ if (!initialized) {
+ if ( cachedSize!=-1 && !hasQueuedOperations() ) {
+ return true;
+ }
+ else {
+ throwLazyInitializationExceptionIfNotConnected();
+ CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
+ CollectionPersister persister = entry.getLoadedPersister();
+ if ( persister.isExtraLazy() ) {
+ if ( hasQueuedOperations() ) {
+ session.flush();
+ }
+ cachedSize = persister.getSize( entry.getLoadedKey(), session );
+ return true;
+ }
+ }
+ }
+ read();
+ return false;
+ }
+
+ protected Boolean readIndexExistence(Object index) {
+ if (!initialized) {
+ throwLazyInitializationExceptionIfNotConnected();
+ CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
+ CollectionPersister persister = entry.getLoadedPersister();
+ if ( persister.isExtraLazy() ) {
+ if ( hasQueuedOperations() ) {
+ session.flush();
+ }
+ return new Boolean( persister.indexExists( entry.getLoadedKey(), index, session ) );
+ }
+ }
+ read();
+ return null;
+
+ }
+
+ protected Boolean readElementExistence(Object element) {
+ if (!initialized) {
+ throwLazyInitializationExceptionIfNotConnected();
+ CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
+ CollectionPersister persister = entry.getLoadedPersister();
+ if ( persister.isExtraLazy() ) {
+ if ( hasQueuedOperations() ) {
+ session.flush();
+ }
+ return new Boolean( persister.elementExists( entry.getLoadedKey(), element, session ) );
+ }
+ }
+ read();
+ return null;
+
+ }
+
+ protected static final Object UNKNOWN = new MarkerObject("UNKNOWN");
+
+ protected Object readElementByIndex(Object index) {
+ if (!initialized) {
+ throwLazyInitializationExceptionIfNotConnected();
+ CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
+ CollectionPersister persister = entry.getLoadedPersister();
+ if ( persister.isExtraLazy() ) {
+ if ( hasQueuedOperations() ) {
+ session.flush();
+ }
+ return persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
+ }
+ }
+ read();
+ return UNKNOWN;
+
+ }
+
+ protected int getCachedSize() {
+ return cachedSize;
+ }
+
+ /**
+ * Is the collection currently connected to an open session?
+ */
+ private final boolean isConnectedToSession() {
+ return session!=null &&
+ session.isOpen() &&
+ session.getPersistenceContext().containsCollection(this);
+ }
+
+ /**
+ * Called by any writer method of the collection interface
+ */
+ protected final void write() {
+ initialize(true);
+ dirty();
+ }
+ /**
+ * Is this collection in a state that would allow us to
+ * "queue" operations?
+ */
+ protected boolean isOperationQueueEnabled() {
+ return !initialized &&
+ isConnectedToSession() &&
+ isInverseCollection();
+ }
+ /**
+ * Is this collection in a state that would allow us to
+ * "queue" puts? This is a special case, because of orphan
+ * delete.
+ */
+ protected boolean isPutQueueEnabled() {
+ return !initialized &&
+ isConnectedToSession() &&
+ isInverseOneToManyOrNoOrphanDelete();
+ }
+ /**
+ * Is this collection in a state that would allow us to
+ * "queue" clear? This is a special case, because of orphan
+ * delete.
+ */
+ protected boolean isClearQueueEnabled() {
+ return !initialized &&
+ isConnectedToSession() &&
+ isInverseCollectionNoOrphanDelete();
+ }
+
+ /**
+ * Is this the "inverse" end of a bidirectional association?
+ */
+ private boolean isInverseCollection() {
+ CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
+ return ce != null && ce.getLoadedPersister().isInverse();
+ }
+
+ /**
+ * Is this the "inverse" end of a bidirectional association with
+ * no orphan delete enabled?
+ */
+ private boolean isInverseCollectionNoOrphanDelete() {
+ CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
+ return ce != null &&
+ ce.getLoadedPersister().isInverse() &&
+ !ce.getLoadedPersister().hasOrphanDelete();
+ }
+
+ /**
+ * Is this the "inverse" end of a bidirectional one-to-many, or
+ * of a collection with no orphan delete?
+ */
+ private boolean isInverseOneToManyOrNoOrphanDelete() {
+ CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
+ return ce != null && ce.getLoadedPersister().isInverse() && (
+ ce.getLoadedPersister().isOneToMany() ||
+ !ce.getLoadedPersister().hasOrphanDelete()
+ );
+ }
+
+ /**
+ * Queue an addition
+ */
+ protected final void queueOperation(Object element) {
+ if (operationQueue==null) operationQueue = new ArrayList(10);
+ operationQueue.add(element);
+ dirty = true; //needed so that we remove this collection from the second-level cache
+ }
+
+ /**
+ * After reading all existing elements from the database,
+ * add the queued elements to the underlying collection.
+ */
+ protected final void performQueuedOperations() {
+ for ( int i=0; i<operationQueue.size(); i++ ) {
+ ( (DelayedOperation) operationQueue.get(i) ).operate();
+ }
+ }
+
+ /**
+ * After flushing, re-init snapshot state.
+ */
+ public void setSnapshot(Serializable key, String role, Serializable snapshot) {
+ this.key = key;
+ this.role = role;
+ this.storedSnapshot = snapshot;
+ }
+
+ /**
+ * After flushing, clear any "queued" additions, since the
+ * database state is now synchronized with the memory state.
+ */
+ public void postAction() {
+ operationQueue=null;
+ cachedSize = -1;
+ clearDirty();
+ }
+
+ /**
+ * Not called by Hibernate, but used by non-JDK serialization,
+ * eg. SOAP libraries.
+ */
+ public AbstractPersistentCollection() {}
+
+ protected AbstractPersistentCollection(SessionImplementor session) {
+ this.session = session;
+ }
+
+ /**
+ * return the user-visible collection (or array) instance
+ */
+ public Object getValue() {
+ return this;
+ }
+
+ /**
+ * Called just before reading any rows from the JDBC result set
+ */
+ public void beginRead() {
+ // override on some subclasses
+ initializing = true;
+ }
+
+ /**
+ * Called after reading all rows from the JDBC result set
+ */
+ public boolean endRead() {
+ //override on some subclasses
+ return afterInitialize();
+ }
+
+ public boolean afterInitialize() {
+ setInitialized();
+ //do this bit after setting initialized to true or it will recurse
+ if (operationQueue!=null) {
+ performQueuedOperations();
+ operationQueue=null;
+ cachedSize = -1;
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
+ /**
+ * Initialize the collection, if possible, wrapping any exceptions
+ * in a runtime exception
+ * @param writing currently obsolete
+ * @throws LazyInitializationException if we cannot initialize
+ */
+ protected final void initialize(boolean writing) {
+ if (!initialized) {
+ if (initializing) {
+ throw new LazyInitializationException("illegal access to loading collection");
+ }
+ throwLazyInitializationExceptionIfNotConnected();
+ session.initializeCollection(this, writing);
+ }
+ }
+
+ private void throwLazyInitializationExceptionIfNotConnected() {
+ if ( !isConnectedToSession() ) {
+ throwLazyInitializationException("no session or session was closed");
+ }
+ if ( !session.isConnected() ) {
+ throwLazyInitializationException("session is disconnected");
+ }
+ }
+
+ private void throwLazyInitializationException(String message) {
+ throw new LazyInitializationException(
+ "failed to lazily initialize a collection" +
+ ( role==null ? "" : " of role: " + role ) +
+ ", " + message
+ );
+ }
+
+ protected final void setInitialized() {
+ this.initializing = false;
+ this.initialized = true;
+ }
+
+ protected final void setDirectlyAccessible(boolean directlyAccessible) {
+ this.directlyAccessible = directlyAccessible;
+ }
+
+ /**
+ * Could the application possibly have a direct reference to
+ * the underlying collection implementation?
+ */
+ public boolean isDirectlyAccessible() {
+ return directlyAccessible;
+ }
+
+ /**
+ * Disassociate this collection from the given session.
+ * @return true if this was currently associated with the given session
+ */
+ public final boolean unsetSession(SessionImplementor currentSession) {
+ if (currentSession==this.session) {
+ this.session=null;
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * Associate the collection with the given session.
+ * @return false if the collection was already associated with the session
+ * @throws HibernateException if the collection was already associated
+ * with another open session
+ */
+ public final boolean setCurrentSession(SessionImplementor session) throws HibernateException {
+ if (session==this.session) {
+ return false;
+ }
+ else {
+ if ( isConnectedToSession() ) {
+ CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
+ if (ce==null) {
+ throw new HibernateException(
+ "Illegal attempt to associate a collection with two open sessions"
+ );
+ }
+ else {
+ throw new HibernateException(
+ "Illegal attempt to associate a collection with two open sessions: " +
+ MessageHelper.collectionInfoString(
+ ce.getLoadedPersister(),
+ ce.getLoadedKey(),
+ session.getFactory()
+ )
+ );
+ }
+ }
+ else {
+ this.session = session;
+ return true;
+ }
+ }
+ }
+
+ /**
+ * Do we need to completely recreate this collection when it changes?
+ */
+ public boolean needsRecreate(CollectionPersister persister) {
+ return false;
+ }
+
+ /**
+ * To be called internally by the session, forcing
+ * immediate initialization.
+ */
+ public final void forceInitialization() throws HibernateException {
+ if (!initialized) {
+ if (initializing) {
+ throw new AssertionFailure("force initialize loading collection");
+ }
+ if (session==null) {
+ throw new HibernateException("collection is not associated with any session");
+ }
+ if ( !session.isConnected() ) {
+ throw new HibernateException("disconnected session");
+ }
+ session.initializeCollection(this, false);
+ }
+ }
+
+
+ /**
+ * Get the current snapshot from the session
+ */
+ protected final Serializable getSnapshot() {
+ return session.getPersistenceContext().getSnapshot(this);
+ }
+
+ /**
+ * Is this instance initialized?
+ */
+ public final boolean wasInitialized() {
+ return initialized;
+ }
+
+ public boolean isRowUpdatePossible() {
+ return true;
+ }
+
+ /**
+ * Does this instance have any "queued" additions?
+ */
+ public final boolean hasQueuedOperations() {
+ return operationQueue!=null;
+ }
+ /**
+ * Iterate the "queued" additions
+ */
+ public final Iterator queuedAdditionIterator() {
+ if ( hasQueuedOperations() ) {
+ return new Iterator() {
+ int i = 0;
+ public Object next() {
+ return ( (DelayedOperation) operationQueue.get(i++) ).getAddedInstance();
+ }
+ public boolean hasNext() {
+ return i<operationQueue.size();
+ }
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+ else {
+ return EmptyIterator.INSTANCE;
+ }
+ }
+ /**
+ * Iterate the "queued" additions
+ */
+ public final Collection getQueuedOrphans(String entityName) {
+ if ( hasQueuedOperations() ) {
+ Collection additions = new ArrayList( operationQueue.size() );
+ Collection removals = new ArrayList( operationQueue.size() );
+ for ( int i = 0; i < operationQueue.size(); i++ ) {
+ DelayedOperation op = (DelayedOperation) operationQueue.get(i);
+ additions.add( op.getAddedInstance() );
+ removals.add( op.getOrphan() );
+ }
+ return getOrphans(removals, additions, entityName, session);
+ }
+ else {
+ return CollectionHelper.EMPTY_COLLECTION;
+ }
+ }
+
+ /**
+ * Called before inserting rows, to ensure that any surrogate keys
+ * are fully generated
+ */
+ public void preInsert(CollectionPersister persister) throws HibernateException {}
+ /**
+ * Called after inserting a row, to fetch the natively generated id
+ */
+ public void afterRowInsert(CollectionPersister persister, Object entry, int i) throws HibernateException {}
+ /**
+ * get all "orphaned" elements
+ */
+ public abstract Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException;
+
+ /**
+ * Get the current session
+ */
+ public final SessionImplementor getSession() {
+ return session;
+ }
+
+ final class IteratorProxy implements Iterator {
+ private final Iterator iter;
+ IteratorProxy(Iterator iter) {
+ this.iter=iter;
+ }
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ public Object next() {
+ return iter.next();
+ }
+
+ public void remove() {
+ write();
+ iter.remove();
+ }
+
+ }
+
+ final class ListIteratorProxy implements ListIterator {
+ private final ListIterator iter;
+ ListIteratorProxy(ListIterator iter) {
+ this.iter = iter;
+ }
+ public void add(Object o) {
+ write();
+ iter.add(o);
+ }
+
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ public boolean hasPrevious() {
+ return iter.hasPrevious();
+ }
+
+ public Object next() {
+ return iter.next();
+ }
+
+ public int nextIndex() {
+ return iter.nextIndex();
+ }
+
+ public Object previous() {
+ return iter.previous();
+ }
+
+ public int previousIndex() {
+ return iter.previousIndex();
+ }
+
+ public void remove() {
+ write();
+ iter.remove();
+ }
+
+ public void set(Object o) {
+ write();
+ iter.set(o);
+ }
+
+ }
+
+ class SetProxy implements java.util.Set {
+
+ final Collection set;
+
+ SetProxy(Collection set) {
+ this.set=set;
+ }
+ public boolean add(Object o) {
+ write();
+ return set.add(o);
+ }
+
+ public boolean addAll(Collection c) {
+ write();
+ return set.addAll(c);
+ }
+
+ public void clear() {
+ write();
+ set.clear();
+ }
+
+ public boolean contains(Object o) {
+ return set.contains(o);
+ }
+
+ public boolean containsAll(Collection c) {
+ return set.containsAll(c);
+ }
+
+ public boolean isEmpty() {
+ return set.isEmpty();
+ }
+
+ public Iterator iterator() {
+ return new IteratorProxy( set.iterator() );
+ }
+
+ public boolean remove(Object o) {
+ write();
+ return set.remove(o);
+ }
+
+ public boolean removeAll(Collection c) {
+ write();
+ return set.removeAll(c);
+ }
+
+ public boolean retainAll(Collection c) {
+ write();
+ return set.retainAll(c);
+ }
+
+ public int size() {
+ return set.size();
+ }
+
+ public Object[] toArray() {
+ return set.toArray();
+ }
+
+ public Object[] toArray(Object[] array) {
+ return set.toArray(array);
+ }
+
+ }
+
+ final class ListProxy implements java.util.List {
+
+ private final java.util.List list;
+
+ ListProxy(java.util.List list) {
+ this.list = list;
+ }
+
+ public void add(int index, Object value) {
+ write();
+ list.add(index, value);
+ }
+
+ /**
+ * @see java.util.Collection#add(Object)
+ */
+ public boolean add(Object o) {
+ write();
+ return list.add(o);
+ }
+
+ /**
+ * @see java.util.Collection#addAll(Collection)
+ */
+ public boolean addAll(Collection c) {
+ write();
+ return list.addAll(c);
+ }
+
+ /**
+ * @see java.util.List#addAll(int, Collection)
+ */
+ public boolean addAll(int i, Collection c) {
+ write();
+ return list.addAll(i, c);
+ }
+
+ /**
+ * @see java.util.Collection#clear()
+ */
+ public void clear() {
+ write();
+ list.clear();
+ }
+
+ /**
+ * @see java.util.Collection#contains(Object)
+ */
+ public boolean contains(Object o) {
+ return list.contains(o);
+ }
+
+ /**
+ * @see java.util.Collection#containsAll(Collection)
+ */
+ public boolean containsAll(Collection c) {
+ return list.containsAll(c);
+ }
+
+ /**
+ * @see java.util.List#get(int)
+ */
+ public Object get(int i) {
+ return list.get(i);
+ }
+
+ /**
+ * @see java.util.List#indexOf(Object)
+ */
+ public int indexOf(Object o) {
+ return list.indexOf(o);
+ }
+
+ /**
+ * @see java.util.Collection#isEmpty()
+ */
+ public boolean isEmpty() {
+ return list.isEmpty();
+ }
+
+ /**
+ * @see java.util.Collection#iterator()
+ */
+ public Iterator iterator() {
+ return new IteratorProxy( list.iterator() );
+ }
+
+ /**
+ * @see java.util.List#lastIndexOf(Object)
+ */
+ public int lastIndexOf(Object o) {
+ return list.lastIndexOf(o);
+ }
+
+ /**
+ * @see java.util.List#listIterator()
+ */
+ public ListIterator listIterator() {
+ return new ListIteratorProxy( list.listIterator() );
+ }
+
+ /**
+ * @see java.util.List#listIterator(int)
+ */
+ public ListIterator listIterator(int i) {
+ return new ListIteratorProxy( list.listIterator(i) );
+ }
+
+ /**
+ * @see java.util.List#remove(int)
+ */
+ public Object remove(int i) {
+ write();
+ return list.remove(i);
+ }
+
+ /**
+ * @see java.util.Collection#remove(Object)
+ */
+ public boolean remove(Object o) {
+ write();
+ return list.remove(o);
+ }
+
+ /**
+ * @see java.util.Collection#removeAll(Collection)
+ */
+ public boolean removeAll(Collection c) {
+ write();
+ return list.removeAll(c);
+ }
+
+ /**
+ * @see java.util.Collection#retainAll(Collection)
+ */
+ public boolean retainAll(Collection c) {
+ write();
+ return list.retainAll(c);
+ }
+
+ /**
+ * @see java.util.List#set(int, Object)
+ */
+ public Object set(int i, Object o) {
+ write();
+ return list.set(i, o);
+ }
+
+ /**
+ * @see java.util.Collection#size()
+ */
+ public int size() {
+ return list.size();
+ }
+
+ /**
+ * @see java.util.List#subList(int, int)
+ */
+ public List subList(int i, int j) {
+ return list.subList(i, j);
+ }
+
+ /**
+ * @see java.util.Collection#toArray()
+ */
+ public Object[] toArray() {
+ return list.toArray();
+ }
+
+ /**
+ * @see java.util.Collection#toArray(Object[])
+ */
+ public Object[] toArray(Object[] array) {
+ return list.toArray(array);
+ }
+
+ }
+
+
+ protected interface DelayedOperation {
+ public void operate();
+ public Object getAddedInstance();
+ public Object getOrphan();
+ }
+
+ /**
+ * Given a collection of entity instances that used to
+ * belong to the collection, and a collection of instances
+ * that currently belong, return a collection of orphans
+ */
+ protected static Collection getOrphans(
+ Collection oldElements,
+ Collection currentElements,
+ String entityName,
+ SessionImplementor session)
+ throws HibernateException {
+
+ // short-circuit(s)
+ if ( currentElements.size()==0 ) return oldElements; // no new elements, the old list contains only Orphans
+ if ( oldElements.size()==0) return oldElements; // no old elements, so no Orphans neither
+
+ Type idType = session.getFactory().getEntityPersister(entityName).getIdentifierType();
+
+ // create the collection holding the Orphans
+ Collection res = new ArrayList();
+
+ // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
+ java.util.Set currentIds = new HashSet();
+ for ( Iterator it=currentElements.iterator(); it.hasNext(); ) {
+ Object current = it.next();
+ if ( current!=null && ForeignKeys.isNotTransient(entityName, current, null, session) ) {
+ Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, current, session);
+ currentIds.add( new TypedValue( idType, currentId, session.getEntityMode() ) );
+ }
+ }
+
+ // iterate over the *old* list
+ for ( Iterator it=oldElements.iterator(); it.hasNext(); ) {
+ Object old = it.next();
+ Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, old, session);
+ if ( !currentIds.contains( new TypedValue( idType, oldId, session.getEntityMode() ) ) ) {
+ res.add(old);
+ }
+ }
+
+ return res;
+ }
+
+ static void identityRemove(
+ Collection list,
+ Object object,
+ String entityName,
+ SessionImplementor session)
+ throws HibernateException {
+
+ if ( object!=null && ForeignKeys.isNotTransient(entityName, object, null, session) ) {
+
+ Type idType = session.getFactory().getEntityPersister(entityName).getIdentifierType();
+
+ Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, session);
+ Iterator iter = list.iterator();
+ while ( iter.hasNext() ) {
+ Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, iter.next(), session);
+ if ( idType.isEqual( idOfCurrent, idOfOld, session.getEntityMode(), session.getFactory() ) ) {
+ iter.remove();
+ break;
+ }
+ }
+
+ }
+ }
+
+ public Object getIdentifier(Object entry, int i) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getOwner() {
+ return owner;
+ }
+
+ public void setOwner(Object owner) {
+ this.owner = owner;
+ }
+
+}
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,229 +0,0 @@
-//$Id: PersistentArrayHolder.java 10086 2006-07-05 18:17:27Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-/**
- * A persistent wrapper for an array. Lazy initialization
- * is NOT supported. Use of Hibernate arrays is not really
- * recommended.
- *
- * @author Gavin King
- */
-public class PersistentArrayHolder extends AbstractPersistentCollection {
- protected Object array;
-
- private static final Logger log = LoggerFactory.getLogger(PersistentArrayHolder.class);
-
- //just to help out during the load (ugly, i know)
- private transient Class elementClass;
- private transient java.util.List tempList;
-
- public PersistentArrayHolder(SessionImplementor session, Object array) {
- super(session);
- this.array = array;
- setInitialized();
- }
-
- public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
- EntityMode entityMode = getSession().getEntityMode();
- int length = /*(array==null) ? tempList.size() :*/ Array.getLength(array);
- Serializable result = (Serializable) Array.newInstance( persister.getElementClass(), length );
- for ( int i=0; i<length; i++ ) {
- Object elt = /*(array==null) ? tempList.get(i) :*/ Array.get(array, i);
- try {
- Array.set( result, i, persister.getElementType().deepCopy(elt, entityMode, persister.getFactory()) );
- }
- catch (IllegalArgumentException iae) {
- log.error("Array element type error", iae);
- throw new HibernateException( "Array element type error", iae );
- }
- }
- return result;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return Array.getLength( snapshot ) == 0;
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
- Object[] sn = (Object[]) snapshot;
- Object[] arr = (Object[]) array;
- ArrayList result = new ArrayList();
- for (int i=0; i<sn.length; i++) result.add( sn[i] );
- for (int i=0; i<sn.length; i++) identityRemove( result, arr[i], entityName, getSession() );
- return result;
- }
-
- public PersistentArrayHolder(SessionImplementor session, CollectionPersister persister) throws HibernateException {
- super(session);
- elementClass = persister.getElementClass();
- }
-
- public Object getArray() {
- return array;
- }
-
- public boolean isWrapper(Object collection) {
- return array==collection;
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- Serializable snapshot = getSnapshot();
- int xlen = Array.getLength(snapshot);
- if ( xlen!= Array.getLength(array) ) return false;
- for ( int i=0; i<xlen; i++) {
- if ( elementType.isDirty( Array.get(snapshot, i), Array.get(array, i), getSession() ) ) return false;
- }
- return true;
- }
-
- public Iterator elements() {
- //if (array==null) return tempList.iterator();
- int length = Array.getLength(array);
- java.util.List list = new ArrayList(length);
- for (int i=0; i<length; i++) {
- list.add( Array.get(array, i) );
- }
- return list.iterator();
- }
- public boolean empty() {
- return false;
- }
-
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
-
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
- for ( int i = tempList.size(); i<=index; i++) {
- tempList.add(i, null);
- }
- tempList.set(index, element);
- return element;
- }
-
- public Iterator entries(CollectionPersister persister) {
- return elements();
- }
-
- public void beginRead() {
- super.beginRead();
- tempList = new ArrayList();
- }
- public boolean endRead() {
- setInitialized();
- array = Array.newInstance( elementClass, tempList.size() );
- for ( int i=0; i<tempList.size(); i++) {
- Array.set(array, i, tempList.get(i) );
- }
- tempList=null;
- return true;
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
- //if (tempList==null) throw new UnsupportedOperationException("Can't lazily initialize arrays");
- }
-
- public boolean isDirectlyAccessible() {
- return true;
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
- Serializable[] cached = (Serializable[]) disassembled;
-
- array = Array.newInstance( persister.getElementClass(), cached.length );
-
- for ( int i=0; i<cached.length; i++ ) {
- Array.set( array, i, persister.getElementType().assemble( cached[i], getSession(), owner ) );
- }
- }
-
- public Serializable disassemble(CollectionPersister persister) throws HibernateException {
- int length = Array.getLength(array);
- Serializable[] result = new Serializable[length];
- for ( int i=0; i<length; i++ ) {
- result[i] = persister.getElementType().disassemble( Array.get(array,i), getSession(), null );
- }
-
- /*int length = tempList.size();
- Serializable[] result = new Serializable[length];
- for ( int i=0; i<length; i++ ) {
- result[i] = persister.getElementType().disassemble( tempList.get(i), session );
- }*/
-
- return result;
-
- }
-
- public Object getValue() {
- return array;
- }
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
- java.util.List deletes = new ArrayList();
- Serializable sn = getSnapshot();
- int snSize = Array.getLength(sn);
- int arraySize = Array.getLength(array);
- int end;
- if ( snSize > arraySize ) {
- for ( int i=arraySize; i<snSize; i++ ) deletes.add( new Integer(i) );
- end = arraySize;
- }
- else {
- end = snSize;
- }
- for ( int i=0; i<end; i++ ) {
- if ( Array.get(array, i)==null && Array.get(sn, i)!=null ) deletes.add( new Integer(i) );
- }
- return deletes.iterator();
- }
-
- public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
- Serializable sn = getSnapshot();
- return Array.get(array, i)!=null && ( i >= Array.getLength(sn) || Array.get(sn, i)==null );
- }
-
- public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
- Serializable sn = getSnapshot();
- return i<Array.getLength(sn) &&
- Array.get(sn, i)!=null &&
- Array.get(array, i)!=null &&
- elemType.isDirty( Array.get(array, i), Array.get(sn, i), getSession() );
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- return new Integer(i);
- }
-
- public Object getElement(Object entry) {
- return entry;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- Serializable sn = getSnapshot();
- return Array.get(sn, i);
- }
-
- public boolean entryExists(Object entry, int i) {
- return entry!=null;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentArrayHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,252 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * A persistent wrapper for an array. Lazy initialization
+ * is NOT supported. Use of Hibernate arrays is not really
+ * recommended.
+ *
+ * @author Gavin King
+ */
+public class PersistentArrayHolder extends AbstractPersistentCollection {
+ protected Object array;
+
+ private static final Logger log = LoggerFactory.getLogger(PersistentArrayHolder.class);
+
+ //just to help out during the load (ugly, i know)
+ private transient Class elementClass;
+ private transient java.util.List tempList;
+
+ public PersistentArrayHolder(SessionImplementor session, Object array) {
+ super(session);
+ this.array = array;
+ setInitialized();
+ }
+
+ public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
+ EntityMode entityMode = getSession().getEntityMode();
+ int length = /*(array==null) ? tempList.size() :*/ Array.getLength(array);
+ Serializable result = (Serializable) Array.newInstance( persister.getElementClass(), length );
+ for ( int i=0; i<length; i++ ) {
+ Object elt = /*(array==null) ? tempList.get(i) :*/ Array.get(array, i);
+ try {
+ Array.set( result, i, persister.getElementType().deepCopy(elt, entityMode, persister.getFactory()) );
+ }
+ catch (IllegalArgumentException iae) {
+ log.error("Array element type error", iae);
+ throw new HibernateException( "Array element type error", iae );
+ }
+ }
+ return result;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return Array.getLength( snapshot ) == 0;
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
+ Object[] sn = (Object[]) snapshot;
+ Object[] arr = (Object[]) array;
+ ArrayList result = new ArrayList();
+ for (int i=0; i<sn.length; i++) result.add( sn[i] );
+ for (int i=0; i<sn.length; i++) identityRemove( result, arr[i], entityName, getSession() );
+ return result;
+ }
+
+ public PersistentArrayHolder(SessionImplementor session, CollectionPersister persister) throws HibernateException {
+ super(session);
+ elementClass = persister.getElementClass();
+ }
+
+ public Object getArray() {
+ return array;
+ }
+
+ public boolean isWrapper(Object collection) {
+ return array==collection;
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ Serializable snapshot = getSnapshot();
+ int xlen = Array.getLength(snapshot);
+ if ( xlen!= Array.getLength(array) ) return false;
+ for ( int i=0; i<xlen; i++) {
+ if ( elementType.isDirty( Array.get(snapshot, i), Array.get(array, i), getSession() ) ) return false;
+ }
+ return true;
+ }
+
+ public Iterator elements() {
+ //if (array==null) return tempList.iterator();
+ int length = Array.getLength(array);
+ java.util.List list = new ArrayList(length);
+ for (int i=0; i<length; i++) {
+ list.add( Array.get(array, i) );
+ }
+ return list.iterator();
+ }
+ public boolean empty() {
+ return false;
+ }
+
+ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException {
+
+ Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
+ for ( int i = tempList.size(); i<=index; i++) {
+ tempList.add(i, null);
+ }
+ tempList.set(index, element);
+ return element;
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+ return elements();
+ }
+
+ public void beginRead() {
+ super.beginRead();
+ tempList = new ArrayList();
+ }
+ public boolean endRead() {
+ setInitialized();
+ array = Array.newInstance( elementClass, tempList.size() );
+ for ( int i=0; i<tempList.size(); i++) {
+ Array.set(array, i, tempList.get(i) );
+ }
+ tempList=null;
+ return true;
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
+ //if (tempList==null) throw new UnsupportedOperationException("Can't lazily initialize arrays");
+ }
+
+ public boolean isDirectlyAccessible() {
+ return true;
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+ Serializable[] cached = (Serializable[]) disassembled;
+
+ array = Array.newInstance( persister.getElementClass(), cached.length );
+
+ for ( int i=0; i<cached.length; i++ ) {
+ Array.set( array, i, persister.getElementType().assemble( cached[i], getSession(), owner ) );
+ }
+ }
+
+ public Serializable disassemble(CollectionPersister persister) throws HibernateException {
+ int length = Array.getLength(array);
+ Serializable[] result = new Serializable[length];
+ for ( int i=0; i<length; i++ ) {
+ result[i] = persister.getElementType().disassemble( Array.get(array,i), getSession(), null );
+ }
+
+ /*int length = tempList.size();
+ Serializable[] result = new Serializable[length];
+ for ( int i=0; i<length; i++ ) {
+ result[i] = persister.getElementType().disassemble( tempList.get(i), session );
+ }*/
+
+ return result;
+
+ }
+
+ public Object getValue() {
+ return array;
+ }
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
+ java.util.List deletes = new ArrayList();
+ Serializable sn = getSnapshot();
+ int snSize = Array.getLength(sn);
+ int arraySize = Array.getLength(array);
+ int end;
+ if ( snSize > arraySize ) {
+ for ( int i=arraySize; i<snSize; i++ ) deletes.add( new Integer(i) );
+ end = arraySize;
+ }
+ else {
+ end = snSize;
+ }
+ for ( int i=0; i<end; i++ ) {
+ if ( Array.get(array, i)==null && Array.get(sn, i)!=null ) deletes.add( new Integer(i) );
+ }
+ return deletes.iterator();
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
+ Serializable sn = getSnapshot();
+ return Array.get(array, i)!=null && ( i >= Array.getLength(sn) || Array.get(sn, i)==null );
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
+ Serializable sn = getSnapshot();
+ return i<Array.getLength(sn) &&
+ Array.get(sn, i)!=null &&
+ Array.get(array, i)!=null &&
+ elemType.isDirty( Array.get(array, i), Array.get(sn, i), getSession() );
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ return new Integer(i);
+ }
+
+ public Object getElement(Object entry) {
+ return entry;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ Serializable sn = getSnapshot();
+ return Array.get(sn, i);
+ }
+
+ public boolean entryExists(Object entry, int i) {
+ return entry!=null;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentBag.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,548 +0,0 @@
-//$Id: PersistentBag.java 10738 2006-11-06 21:56:38Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-/**
- * An unordered, unkeyed collection that can contain the same element
- * multiple times. The Java collections API, curiously, has no <tt>Bag</tt>.
- * Most developers seem to use <tt>List</tt>s to represent bag semantics,
- * so Hibernate follows this practice.
- *
- * @author Gavin King
- */
-public class PersistentBag extends AbstractPersistentCollection implements List {
-
- protected List bag;
-
- public PersistentBag(SessionImplementor session) {
- super(session);
- }
-
- public PersistentBag(SessionImplementor session, Collection coll) {
- super(session);
- if (coll instanceof List) {
- bag = (List) coll;
- }
- else {
- bag = new ArrayList();
- Iterator iter = coll.iterator();
- while ( iter.hasNext() ) {
- bag.add( iter.next() );
- }
- }
- setInitialized();
- setDirectlyAccessible(true);
- }
-
- public PersistentBag() {} //needed for SOAP libraries, etc
-
- public boolean isWrapper(Object collection) {
- return bag==collection;
- }
- public boolean empty() {
- return bag.isEmpty();
- }
-
- public Iterator entries(CollectionPersister persister) {
- return bag.iterator();
- }
-
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
- // note that if we load this collection from a cartesian product
- // the multiplicity would be broken ... so use an idbag instead
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
- if (element!=null) bag.add(element);
- return element;
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
- this.bag = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- EntityMode entityMode = getSession().getEntityMode();
- List sn = (List) getSnapshot();
- if ( sn.size()!=bag.size() ) return false;
- Iterator iter = bag.iterator();
- while ( iter.hasNext() ) {
- Object elt = iter.next();
- final boolean unequal = countOccurrences(elt, bag, elementType, entityMode) !=
- countOccurrences(elt, sn, elementType, entityMode);
- if ( unequal ) return false;
- }
- return true;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (Collection) snapshot ).isEmpty();
- }
-
- private int countOccurrences(Object element, List list, Type elementType, EntityMode entityMode)
- throws HibernateException {
- Iterator iter = list.iterator();
- int result=0;
- while ( iter.hasNext() ) {
- if ( elementType.isSame( element, iter.next(), entityMode ) ) result++;
- }
- return result;
- }
-
- public Serializable getSnapshot(CollectionPersister persister)
- throws HibernateException {
- EntityMode entityMode = getSession().getEntityMode();
- ArrayList clonedList = new ArrayList( bag.size() );
- Iterator iter = bag.iterator();
- while ( iter.hasNext() ) {
- clonedList.add( persister.getElementType().deepCopy( iter.next(), entityMode, persister.getFactory() ) );
- }
- return clonedList;
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
- List sn = (List) snapshot;
- return getOrphans( sn, bag, entityName, getSession() );
- }
-
-
- public Serializable disassemble(CollectionPersister persister)
- throws HibernateException {
-
- int length = bag.size();
- Serializable[] result = new Serializable[length];
- for ( int i=0; i<length; i++ ) {
- result[i] = persister.getElementType().disassemble( bag.get(i), getSession(), null );
- }
- return result;
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
- Serializable[] array = (Serializable[]) disassembled;
- int size = array.length;
- beforeInitialize( persister, size );
- for ( int i = 0; i < size; i++ ) {
- Object element = persister.getElementType().assemble( array[i], getSession(), owner );
- if ( element!=null ) {
- bag.add( element );
- }
- }
- }
-
- public boolean needsRecreate(CollectionPersister persister) {
- return !persister.isOneToMany();
- }
-
-
- // For a one-to-many, a <bag> is not really a bag;
- // it is *really* a set, since it can't contain the
- // same element twice. It could be considered a bug
- // in the mapping dtd that <bag> allows <one-to-many>.
-
- // Anyway, here we implement <set> semantics for a
- // <one-to-many> <bag>!
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
- //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
- Type elementType = persister.getElementType();
- EntityMode entityMode = getSession().getEntityMode();
- ArrayList deletes = new ArrayList();
- List sn = (List) getSnapshot();
- Iterator olditer = sn.iterator();
- int i=0;
- while ( olditer.hasNext() ) {
- Object old = olditer.next();
- Iterator newiter = bag.iterator();
- boolean found = false;
- if ( bag.size()>i && elementType.isSame( old, bag.get(i++), entityMode ) ) {
- //a shortcut if its location didn't change!
- found = true;
- }
- else {
- //search for it
- //note that this code is incorrect for other than one-to-many
- while ( newiter.hasNext() ) {
- if ( elementType.isSame( old, newiter.next(), entityMode ) ) {
- found = true;
- break;
- }
- }
- }
- if (!found) deletes.add(old);
- }
- return deletes.iterator();
- }
-
- public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
- //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
- List sn = (List) getSnapshot();
- final EntityMode entityMode = getSession().getEntityMode();
- if ( sn.size()>i && elemType.isSame( sn.get(i), entry, entityMode ) ) {
- //a shortcut if its location didn't change!
- return false;
- }
- else {
- //search for it
- //note that this code is incorrect for other than one-to-many
- Iterator olditer = sn.iterator();
- while ( olditer.hasNext() ) {
- Object old = olditer.next();
- if ( elemType.isSame( old, entry, entityMode ) ) return false;
- }
- return true;
- }
- }
-
- public boolean isRowUpdatePossible() {
- return false;
- }
-
- public boolean needsUpdating(Object entry, int i, Type elemType) {
- //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
- return false;
- }
-
- /**
- * @see java.util.Collection#size()
- */
- public int size() {
- return readSize() ? getCachedSize() : bag.size();
- }
-
- /**
- * @see java.util.Collection#isEmpty()
- */
- public boolean isEmpty() {
- return readSize() ? getCachedSize()==0 : bag.isEmpty();
- }
-
- /**
- * @see java.util.Collection#contains(Object)
- */
- public boolean contains(Object object) {
- Boolean exists = readElementExistence(object);
- return exists==null ?
- bag.contains(object) :
- exists.booleanValue();
- }
-
- /**
- * @see java.util.Collection#iterator()
- */
- public Iterator iterator() {
- read();
- return new IteratorProxy( bag.iterator() );
- }
-
- /**
- * @see java.util.Collection#toArray()
- */
- public Object[] toArray() {
- read();
- return bag.toArray();
- }
-
- /**
- * @see java.util.Collection#toArray(Object[])
- */
- public Object[] toArray(Object[] a) {
- read();
- return bag.toArray(a);
- }
-
- /**
- * @see java.util.Collection#add(Object)
- */
- public boolean add(Object object) {
- if ( !isOperationQueueEnabled() ) {
- write();
- return bag.add(object);
- }
- else {
- queueOperation( new SimpleAdd(object) );
- return true;
- }
- }
-
- /**
- * @see java.util.Collection#remove(Object)
- */
- public boolean remove(Object o) {
- initialize( true );
- if ( bag.remove( o ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Collection#containsAll(Collection)
- */
- public boolean containsAll(Collection c) {
- read();
- return bag.containsAll(c);
- }
-
- /**
- * @see java.util.Collection#addAll(Collection)
- */
- public boolean addAll(Collection values) {
- if ( values.size()==0 ) return false;
- if ( !isOperationQueueEnabled() ) {
- write();
- return bag.addAll(values);
- }
- else {
- Iterator iter = values.iterator();
- while ( iter.hasNext() ) {
- queueOperation( new SimpleAdd( iter.next() ) );
- }
- return values.size()>0;
- }
- }
-
- /**
- * @see java.util.Collection#removeAll(Collection)
- */
- public boolean removeAll(Collection c) {
- if ( c.size()>0 ) {
- initialize( true );
- if ( bag.removeAll( c ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Collection#retainAll(Collection)
- */
- public boolean retainAll(Collection c) {
- initialize( true );
- if ( bag.retainAll( c ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Collection#clear()
- */
- public void clear() {
- if ( isClearQueueEnabled() ) {
- queueOperation( new Clear() );
- }
- else {
- initialize( true );
- if ( ! bag.isEmpty() ) {
- bag.clear();
- dirty();
- }
- }
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- throw new UnsupportedOperationException("Bags don't have indexes");
- }
-
- public Object getElement(Object entry) {
- return entry;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- List sn = (List) getSnapshot();
- return sn.get(i);
- }
-
- public int occurrences(Object o) {
- read();
- Iterator iter = bag.iterator();
- int result=0;
- while ( iter.hasNext() ) {
- if ( o.equals( iter.next() ) ) result++;
- }
- return result;
- }
-
- // List OPERATIONS:
-
- /**
- * @see java.util.List#add(int, Object)
- */
- public void add(int i, Object o) {
- write();
- bag.add(i, o);
- }
-
- /**
- * @see java.util.List#addAll(int, Collection)
- */
- public boolean addAll(int i, Collection c) {
- if ( c.size()>0 ) {
- write();
- return bag.addAll(i, c);
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.List#get(int)
- */
- public Object get(int i) {
- read();
- return bag.get(i);
- }
-
- /**
- * @see java.util.List#indexOf(Object)
- */
- public int indexOf(Object o) {
- read();
- return bag.indexOf(o);
- }
-
- /**
- * @see java.util.List#lastIndexOf(Object)
- */
- public int lastIndexOf(Object o) {
- read();
- return bag.lastIndexOf(o);
- }
-
- /**
- * @see java.util.List#listIterator()
- */
- public ListIterator listIterator() {
- read();
- return new ListIteratorProxy( bag.listIterator() );
- }
-
- /**
- * @see java.util.List#listIterator(int)
- */
- public ListIterator listIterator(int i) {
- read();
- return new ListIteratorProxy( bag.listIterator(i) );
- }
-
- /**
- * @see java.util.List#remove(int)
- */
- public Object remove(int i) {
- write();
- return bag.remove(i);
- }
-
- /**
- * @see java.util.List#set(int, Object)
- */
- public Object set(int i, Object o) {
- write();
- return bag.set(i, o);
- }
-
- /**
- * @see java.util.List#subList(int, int)
- */
- public List subList(int start, int end) {
- read();
- return new ListProxy( bag.subList(start, end) );
- }
-
- public String toString() {
- read();
- return bag.toString();
- }
-
- /*public boolean equals(Object other) {
- read();
- return bag.equals(other);
- }
-
- public int hashCode(Object other) {
- read();
- return bag.hashCode();
- }*/
-
- public boolean entryExists(Object entry, int i) {
- return entry!=null;
- }
-
- /**
- * Bag does not respect the collection API and do an
- * JVM instance comparison to do the equals.
- * The semantic is broken not to have to initialize a
- * collection for a simple equals() operation.
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return super.hashCode();
- }
-
- final class Clear implements DelayedOperation {
- public void operate() {
- bag.clear();
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
- }
- }
-
- final class SimpleAdd implements DelayedOperation {
- private Object value;
-
- public SimpleAdd(Object value) {
- this.value = value;
- }
- public void operate() {
- bag.add(value);
- }
- public Object getAddedInstance() {
- return value;
- }
- public Object getOrphan() {
- return null;
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentBag.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentBag.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,571 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * An unordered, unkeyed collection that can contain the same element
+ * multiple times. The Java collections API, curiously, has no <tt>Bag</tt>.
+ * Most developers seem to use <tt>List</tt>s to represent bag semantics,
+ * so Hibernate follows this practice.
+ *
+ * @author Gavin King
+ */
+public class PersistentBag extends AbstractPersistentCollection implements List {
+
+ protected List bag;
+
+ public PersistentBag(SessionImplementor session) {
+ super(session);
+ }
+
+ public PersistentBag(SessionImplementor session, Collection coll) {
+ super(session);
+ if (coll instanceof List) {
+ bag = (List) coll;
+ }
+ else {
+ bag = new ArrayList();
+ Iterator iter = coll.iterator();
+ while ( iter.hasNext() ) {
+ bag.add( iter.next() );
+ }
+ }
+ setInitialized();
+ setDirectlyAccessible(true);
+ }
+
+ public PersistentBag() {} //needed for SOAP libraries, etc
+
+ public boolean isWrapper(Object collection) {
+ return bag==collection;
+ }
+ public boolean empty() {
+ return bag.isEmpty();
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+ return bag.iterator();
+ }
+
+ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException {
+ // note that if we load this collection from a cartesian product
+ // the multiplicity would be broken ... so use an idbag instead
+ Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
+ if (element!=null) bag.add(element);
+ return element;
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
+ this.bag = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ EntityMode entityMode = getSession().getEntityMode();
+ List sn = (List) getSnapshot();
+ if ( sn.size()!=bag.size() ) return false;
+ Iterator iter = bag.iterator();
+ while ( iter.hasNext() ) {
+ Object elt = iter.next();
+ final boolean unequal = countOccurrences(elt, bag, elementType, entityMode) !=
+ countOccurrences(elt, sn, elementType, entityMode);
+ if ( unequal ) return false;
+ }
+ return true;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (Collection) snapshot ).isEmpty();
+ }
+
+ private int countOccurrences(Object element, List list, Type elementType, EntityMode entityMode)
+ throws HibernateException {
+ Iterator iter = list.iterator();
+ int result=0;
+ while ( iter.hasNext() ) {
+ if ( elementType.isSame( element, iter.next(), entityMode ) ) result++;
+ }
+ return result;
+ }
+
+ public Serializable getSnapshot(CollectionPersister persister)
+ throws HibernateException {
+ EntityMode entityMode = getSession().getEntityMode();
+ ArrayList clonedList = new ArrayList( bag.size() );
+ Iterator iter = bag.iterator();
+ while ( iter.hasNext() ) {
+ clonedList.add( persister.getElementType().deepCopy( iter.next(), entityMode, persister.getFactory() ) );
+ }
+ return clonedList;
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
+ List sn = (List) snapshot;
+ return getOrphans( sn, bag, entityName, getSession() );
+ }
+
+
+ public Serializable disassemble(CollectionPersister persister)
+ throws HibernateException {
+
+ int length = bag.size();
+ Serializable[] result = new Serializable[length];
+ for ( int i=0; i<length; i++ ) {
+ result[i] = persister.getElementType().disassemble( bag.get(i), getSession(), null );
+ }
+ return result;
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+ Serializable[] array = (Serializable[]) disassembled;
+ int size = array.length;
+ beforeInitialize( persister, size );
+ for ( int i = 0; i < size; i++ ) {
+ Object element = persister.getElementType().assemble( array[i], getSession(), owner );
+ if ( element!=null ) {
+ bag.add( element );
+ }
+ }
+ }
+
+ public boolean needsRecreate(CollectionPersister persister) {
+ return !persister.isOneToMany();
+ }
+
+
+ // For a one-to-many, a <bag> is not really a bag;
+ // it is *really* a set, since it can't contain the
+ // same element twice. It could be considered a bug
+ // in the mapping dtd that <bag> allows <one-to-many>.
+
+ // Anyway, here we implement <set> semantics for a
+ // <one-to-many> <bag>!
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
+ //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
+ Type elementType = persister.getElementType();
+ EntityMode entityMode = getSession().getEntityMode();
+ ArrayList deletes = new ArrayList();
+ List sn = (List) getSnapshot();
+ Iterator olditer = sn.iterator();
+ int i=0;
+ while ( olditer.hasNext() ) {
+ Object old = olditer.next();
+ Iterator newiter = bag.iterator();
+ boolean found = false;
+ if ( bag.size()>i && elementType.isSame( old, bag.get(i++), entityMode ) ) {
+ //a shortcut if its location didn't change!
+ found = true;
+ }
+ else {
+ //search for it
+ //note that this code is incorrect for other than one-to-many
+ while ( newiter.hasNext() ) {
+ if ( elementType.isSame( old, newiter.next(), entityMode ) ) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found) deletes.add(old);
+ }
+ return deletes.iterator();
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
+ //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
+ List sn = (List) getSnapshot();
+ final EntityMode entityMode = getSession().getEntityMode();
+ if ( sn.size()>i && elemType.isSame( sn.get(i), entry, entityMode ) ) {
+ //a shortcut if its location didn't change!
+ return false;
+ }
+ else {
+ //search for it
+ //note that this code is incorrect for other than one-to-many
+ Iterator olditer = sn.iterator();
+ while ( olditer.hasNext() ) {
+ Object old = olditer.next();
+ if ( elemType.isSame( old, entry, entityMode ) ) return false;
+ }
+ return true;
+ }
+ }
+
+ public boolean isRowUpdatePossible() {
+ return false;
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elemType) {
+ //if ( !persister.isOneToMany() ) throw new AssertionFailure("Not implemented for Bags");
+ return false;
+ }
+
+ /**
+ * @see java.util.Collection#size()
+ */
+ public int size() {
+ return readSize() ? getCachedSize() : bag.size();
+ }
+
+ /**
+ * @see java.util.Collection#isEmpty()
+ */
+ public boolean isEmpty() {
+ return readSize() ? getCachedSize()==0 : bag.isEmpty();
+ }
+
+ /**
+ * @see java.util.Collection#contains(Object)
+ */
+ public boolean contains(Object object) {
+ Boolean exists = readElementExistence(object);
+ return exists==null ?
+ bag.contains(object) :
+ exists.booleanValue();
+ }
+
+ /**
+ * @see java.util.Collection#iterator()
+ */
+ public Iterator iterator() {
+ read();
+ return new IteratorProxy( bag.iterator() );
+ }
+
+ /**
+ * @see java.util.Collection#toArray()
+ */
+ public Object[] toArray() {
+ read();
+ return bag.toArray();
+ }
+
+ /**
+ * @see java.util.Collection#toArray(Object[])
+ */
+ public Object[] toArray(Object[] a) {
+ read();
+ return bag.toArray(a);
+ }
+
+ /**
+ * @see java.util.Collection#add(Object)
+ */
+ public boolean add(Object object) {
+ if ( !isOperationQueueEnabled() ) {
+ write();
+ return bag.add(object);
+ }
+ else {
+ queueOperation( new SimpleAdd(object) );
+ return true;
+ }
+ }
+
+ /**
+ * @see java.util.Collection#remove(Object)
+ */
+ public boolean remove(Object o) {
+ initialize( true );
+ if ( bag.remove( o ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Collection#containsAll(Collection)
+ */
+ public boolean containsAll(Collection c) {
+ read();
+ return bag.containsAll(c);
+ }
+
+ /**
+ * @see java.util.Collection#addAll(Collection)
+ */
+ public boolean addAll(Collection values) {
+ if ( values.size()==0 ) return false;
+ if ( !isOperationQueueEnabled() ) {
+ write();
+ return bag.addAll(values);
+ }
+ else {
+ Iterator iter = values.iterator();
+ while ( iter.hasNext() ) {
+ queueOperation( new SimpleAdd( iter.next() ) );
+ }
+ return values.size()>0;
+ }
+ }
+
+ /**
+ * @see java.util.Collection#removeAll(Collection)
+ */
+ public boolean removeAll(Collection c) {
+ if ( c.size()>0 ) {
+ initialize( true );
+ if ( bag.removeAll( c ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Collection#retainAll(Collection)
+ */
+ public boolean retainAll(Collection c) {
+ initialize( true );
+ if ( bag.retainAll( c ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Collection#clear()
+ */
+ public void clear() {
+ if ( isClearQueueEnabled() ) {
+ queueOperation( new Clear() );
+ }
+ else {
+ initialize( true );
+ if ( ! bag.isEmpty() ) {
+ bag.clear();
+ dirty();
+ }
+ }
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ throw new UnsupportedOperationException("Bags don't have indexes");
+ }
+
+ public Object getElement(Object entry) {
+ return entry;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ List sn = (List) getSnapshot();
+ return sn.get(i);
+ }
+
+ public int occurrences(Object o) {
+ read();
+ Iterator iter = bag.iterator();
+ int result=0;
+ while ( iter.hasNext() ) {
+ if ( o.equals( iter.next() ) ) result++;
+ }
+ return result;
+ }
+
+ // List OPERATIONS:
+
+ /**
+ * @see java.util.List#add(int, Object)
+ */
+ public void add(int i, Object o) {
+ write();
+ bag.add(i, o);
+ }
+
+ /**
+ * @see java.util.List#addAll(int, Collection)
+ */
+ public boolean addAll(int i, Collection c) {
+ if ( c.size()>0 ) {
+ write();
+ return bag.addAll(i, c);
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.List#get(int)
+ */
+ public Object get(int i) {
+ read();
+ return bag.get(i);
+ }
+
+ /**
+ * @see java.util.List#indexOf(Object)
+ */
+ public int indexOf(Object o) {
+ read();
+ return bag.indexOf(o);
+ }
+
+ /**
+ * @see java.util.List#lastIndexOf(Object)
+ */
+ public int lastIndexOf(Object o) {
+ read();
+ return bag.lastIndexOf(o);
+ }
+
+ /**
+ * @see java.util.List#listIterator()
+ */
+ public ListIterator listIterator() {
+ read();
+ return new ListIteratorProxy( bag.listIterator() );
+ }
+
+ /**
+ * @see java.util.List#listIterator(int)
+ */
+ public ListIterator listIterator(int i) {
+ read();
+ return new ListIteratorProxy( bag.listIterator(i) );
+ }
+
+ /**
+ * @see java.util.List#remove(int)
+ */
+ public Object remove(int i) {
+ write();
+ return bag.remove(i);
+ }
+
+ /**
+ * @see java.util.List#set(int, Object)
+ */
+ public Object set(int i, Object o) {
+ write();
+ return bag.set(i, o);
+ }
+
+ /**
+ * @see java.util.List#subList(int, int)
+ */
+ public List subList(int start, int end) {
+ read();
+ return new ListProxy( bag.subList(start, end) );
+ }
+
+ public String toString() {
+ read();
+ return bag.toString();
+ }
+
+ /*public boolean equals(Object other) {
+ read();
+ return bag.equals(other);
+ }
+
+ public int hashCode(Object other) {
+ read();
+ return bag.hashCode();
+ }*/
+
+ public boolean entryExists(Object entry, int i) {
+ return entry!=null;
+ }
+
+ /**
+ * Bag does not respect the collection API and do an
+ * JVM instance comparison to do the equals.
+ * The semantic is broken not to have to initialize a
+ * collection for a simple equals() operation.
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ final class Clear implements DelayedOperation {
+ public void operate() {
+ bag.clear();
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
+ }
+ }
+
+ final class SimpleAdd implements DelayedOperation {
+ private Object value;
+
+ public SimpleAdd(Object value) {
+ this.value = value;
+ }
+ public void operate() {
+ bag.add(value);
+ }
+ public Object getAddedInstance() {
+ return value;
+ }
+ public Object getOrphan() {
+ return null;
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentCollection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,303 +0,0 @@
-//$Id: PersistentCollection.java 10086 2006-07-05 18:17:27Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-/**
- * Persistent collections are treated as value objects by Hibernate.
- * ie. they have no independent existence beyond the object holding
- * a reference to them. Unlike instances of entity classes, they are
- * automatically deleted when unreferenced and automatically become
- * persistent when held by a persistent object. Collections can be
- * passed between different objects (change "roles") and this might
- * cause their elements to move from one database table to another.<br>
- * <br>
- * Hibernate "wraps" a java collection in an instance of
- * PersistentCollection. This mechanism is designed to support
- * tracking of changes to the collection's persistent state and
- * lazy instantiation of collection elements. The downside is that
- * only certain abstract collection types are supported and any
- * extra semantics are lost<br>
- * <br>
- * Applications should <em>never</em> use classes in this package
- * directly, unless extending the "framework" here.<br>
- * <br>
- * Changes to <em>structure</em> of the collection are recorded by the
- * collection calling back to the session. Changes to mutable
- * elements (ie. composite elements) are discovered by cloning their
- * state when the collection is initialized and comparing at flush
- * time.
- *
- * @author Gavin King
- */
-public interface PersistentCollection {
-
- /**
- * Get the owning entity. Note that the owner is only
- * set during the flush cycle, and when a new collection
- * wrapper is created while loading an entity.
- */
- public Object getOwner();
- /**
- * Set the reference to the owning entity
- */
- public void setOwner(Object entity);
-
- /**
- * Is the collection empty? (don't try to initialize the collection)
- */
- public boolean empty();
-
- /**
- * After flushing, re-init snapshot state.
- */
- public void setSnapshot(Serializable key, String role, Serializable snapshot);
-
- /**
- * After flushing, clear any "queued" additions, since the
- * database state is now synchronized with the memory state.
- */
- public void postAction();
-
- /**
- * return the user-visible collection (or array) instance
- */
- public Object getValue();
-
- /**
- * Called just before reading any rows from the JDBC result set
- */
- public void beginRead();
-
- /**
- * Called after reading all rows from the JDBC result set
- */
- public boolean endRead();
-
- /**
- * Called after initializing from cache
- */
- public boolean afterInitialize();
-
- /**
- * Could the application possibly have a direct reference to
- * the underlying collection implementation?
- */
- public boolean isDirectlyAccessible();
-
- /**
- * Disassociate this collection from the given session.
- * @return true if this was currently associated with the given session
- */
- public boolean unsetSession(SessionImplementor currentSession);
-
- /**
- * Associate the collection with the given session.
- * @return false if the collection was already associated with the session
- * @throws HibernateException if the collection was already associated
- * with another open session
- */
- public boolean setCurrentSession(SessionImplementor session)
- throws HibernateException;
-
- /**
- * Read the state of the collection from a disassembled cached value
- */
- public void initializeFromCache(CollectionPersister persister,
- Serializable disassembled, Object owner) throws HibernateException;
-
- /**
- * Iterate all collection entries, during update of the database
- */
- public Iterator entries(CollectionPersister persister);
-
- /**
- * Read a row from the JDBC result set
- */
- public Object readFrom(ResultSet rs, CollectionPersister role, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException;
-
- /**
- * Get the index of the given collection entry
- */
- public Object getIdentifier(Object entry, int i);
-
- /**
- * Get the index of the given collection entry
- * @param persister it was more elegant before we added this...
- */
- public Object getIndex(Object entry, int i, CollectionPersister persister);
-
- /**
- * Get the value of the given collection entry
- */
- public Object getElement(Object entry);
-
- /**
- * Get the snapshot value of the given collection entry
- */
- public Object getSnapshotElement(Object entry, int i);
-
- /**
- * Called before any elements are read into the collection,
- * allowing appropriate initializations to occur.
- *
- * @param persister The underlying collection persister.
- * @param anticipatedSize The anticipated size of the collection after initilization is complete.
- */
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize);
-
- /**
- * Does the current state exactly match the snapshot?
- */
- public boolean equalsSnapshot(CollectionPersister persister)
- throws HibernateException;
-
- /**
- * Is the snapshot empty?
- */
- public boolean isSnapshotEmpty(Serializable snapshot);
-
- /**
- * Disassemble the collection, ready for the cache
- */
- public Serializable disassemble(CollectionPersister persister)
- throws HibernateException;
-
- /**
- * Do we need to completely recreate this collection when it changes?
- */
- public boolean needsRecreate(CollectionPersister persister);
-
- /**
- * Return a new snapshot of the current state of the collection
- */
- public Serializable getSnapshot(CollectionPersister persister)
- throws HibernateException;
-
- /**
- * To be called internally by the session, forcing
- * immediate initialization.
- */
- public void forceInitialization() throws HibernateException;
-
- /**
- * Does an element exist at this entry in the collection?
- */
- public boolean entryExists(Object entry, int i); //note that i parameter is now unused (delete it?)
-
- /**
- * Do we need to insert this element?
- */
- public boolean needsInserting(Object entry, int i, Type elemType)
- throws HibernateException;
-
- /**
- * Do we need to update this element?
- */
- public boolean needsUpdating(Object entry, int i, Type elemType)
- throws HibernateException;
-
- public boolean isRowUpdatePossible();
-
- /**
- * Get all the elements that need deleting
- */
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
- throws HibernateException;
-
- /**
- * Is this the wrapper for the given underlying collection instance?
- */
- public boolean isWrapper(Object collection);
-
- /**
- * Is this instance initialized?
- */
- public boolean wasInitialized();
-
- /**
- * Does this instance have any "queued" additions?
- */
- public boolean hasQueuedOperations();
-
- /**
- * Iterate the "queued" additions
- */
- public Iterator queuedAdditionIterator();
-
- /**
- * Get the "queued" orphans
- */
- public Collection getQueuedOrphans(String entityName);
-
- /**
- * Get the current collection key value
- */
- public Serializable getKey();
-
- /**
- * Get the current role name
- */
- public String getRole();
-
- /**
- * Is the collection unreferenced?
- */
- public boolean isUnreferenced();
-
- /**
- * Is the collection dirty? Note that this is only
- * reliable during the flush cycle, after the
- * collection elements are dirty checked against
- * the snapshot.
- */
- public boolean isDirty();
-
- /**
- * Clear the dirty flag, after flushing changes
- * to the database.
- */
- public void clearDirty();
-
- /**
- * Get the snapshot cached by the collection
- * instance
- */
- public Serializable getStoredSnapshot();
-
- /**
- * Mark the collection as dirty
- */
- public void dirty();
-
- /**
- * Called before inserting rows, to ensure that any surrogate keys
- * are fully generated
- */
- public void preInsert(CollectionPersister persister)
- throws HibernateException;
-
- /**
- * Called after inserting a row, to fetch the natively generated id
- */
- public void afterRowInsert(CollectionPersister persister, Object entry, int i)
- throws HibernateException;
-
- /**
- * get all "orphaned" elements
- */
- public Collection getOrphans(Serializable snapshot, String entityName)
- throws HibernateException;
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentCollection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentCollection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,326 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * Persistent collections are treated as value objects by Hibernate.
+ * ie. they have no independent existence beyond the object holding
+ * a reference to them. Unlike instances of entity classes, they are
+ * automatically deleted when unreferenced and automatically become
+ * persistent when held by a persistent object. Collections can be
+ * passed between different objects (change "roles") and this might
+ * cause their elements to move from one database table to another.<br>
+ * <br>
+ * Hibernate "wraps" a java collection in an instance of
+ * PersistentCollection. This mechanism is designed to support
+ * tracking of changes to the collection's persistent state and
+ * lazy instantiation of collection elements. The downside is that
+ * only certain abstract collection types are supported and any
+ * extra semantics are lost<br>
+ * <br>
+ * Applications should <em>never</em> use classes in this package
+ * directly, unless extending the "framework" here.<br>
+ * <br>
+ * Changes to <em>structure</em> of the collection are recorded by the
+ * collection calling back to the session. Changes to mutable
+ * elements (ie. composite elements) are discovered by cloning their
+ * state when the collection is initialized and comparing at flush
+ * time.
+ *
+ * @author Gavin King
+ */
+public interface PersistentCollection {
+
+ /**
+ * Get the owning entity. Note that the owner is only
+ * set during the flush cycle, and when a new collection
+ * wrapper is created while loading an entity.
+ */
+ public Object getOwner();
+ /**
+ * Set the reference to the owning entity
+ */
+ public void setOwner(Object entity);
+
+ /**
+ * Is the collection empty? (don't try to initialize the collection)
+ */
+ public boolean empty();
+
+ /**
+ * After flushing, re-init snapshot state.
+ */
+ public void setSnapshot(Serializable key, String role, Serializable snapshot);
+
+ /**
+ * After flushing, clear any "queued" additions, since the
+ * database state is now synchronized with the memory state.
+ */
+ public void postAction();
+
+ /**
+ * return the user-visible collection (or array) instance
+ */
+ public Object getValue();
+
+ /**
+ * Called just before reading any rows from the JDBC result set
+ */
+ public void beginRead();
+
+ /**
+ * Called after reading all rows from the JDBC result set
+ */
+ public boolean endRead();
+
+ /**
+ * Called after initializing from cache
+ */
+ public boolean afterInitialize();
+
+ /**
+ * Could the application possibly have a direct reference to
+ * the underlying collection implementation?
+ */
+ public boolean isDirectlyAccessible();
+
+ /**
+ * Disassociate this collection from the given session.
+ * @return true if this was currently associated with the given session
+ */
+ public boolean unsetSession(SessionImplementor currentSession);
+
+ /**
+ * Associate the collection with the given session.
+ * @return false if the collection was already associated with the session
+ * @throws HibernateException if the collection was already associated
+ * with another open session
+ */
+ public boolean setCurrentSession(SessionImplementor session)
+ throws HibernateException;
+
+ /**
+ * Read the state of the collection from a disassembled cached value
+ */
+ public void initializeFromCache(CollectionPersister persister,
+ Serializable disassembled, Object owner) throws HibernateException;
+
+ /**
+ * Iterate all collection entries, during update of the database
+ */
+ public Iterator entries(CollectionPersister persister);
+
+ /**
+ * Read a row from the JDBC result set
+ */
+ public Object readFrom(ResultSet rs, CollectionPersister role, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException;
+
+ /**
+ * Get the index of the given collection entry
+ */
+ public Object getIdentifier(Object entry, int i);
+
+ /**
+ * Get the index of the given collection entry
+ * @param persister it was more elegant before we added this...
+ */
+ public Object getIndex(Object entry, int i, CollectionPersister persister);
+
+ /**
+ * Get the value of the given collection entry
+ */
+ public Object getElement(Object entry);
+
+ /**
+ * Get the snapshot value of the given collection entry
+ */
+ public Object getSnapshotElement(Object entry, int i);
+
+ /**
+ * Called before any elements are read into the collection,
+ * allowing appropriate initializations to occur.
+ *
+ * @param persister The underlying collection persister.
+ * @param anticipatedSize The anticipated size of the collection after initilization is complete.
+ */
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize);
+
+ /**
+ * Does the current state exactly match the snapshot?
+ */
+ public boolean equalsSnapshot(CollectionPersister persister)
+ throws HibernateException;
+
+ /**
+ * Is the snapshot empty?
+ */
+ public boolean isSnapshotEmpty(Serializable snapshot);
+
+ /**
+ * Disassemble the collection, ready for the cache
+ */
+ public Serializable disassemble(CollectionPersister persister)
+ throws HibernateException;
+
+ /**
+ * Do we need to completely recreate this collection when it changes?
+ */
+ public boolean needsRecreate(CollectionPersister persister);
+
+ /**
+ * Return a new snapshot of the current state of the collection
+ */
+ public Serializable getSnapshot(CollectionPersister persister)
+ throws HibernateException;
+
+ /**
+ * To be called internally by the session, forcing
+ * immediate initialization.
+ */
+ public void forceInitialization() throws HibernateException;
+
+ /**
+ * Does an element exist at this entry in the collection?
+ */
+ public boolean entryExists(Object entry, int i); //note that i parameter is now unused (delete it?)
+
+ /**
+ * Do we need to insert this element?
+ */
+ public boolean needsInserting(Object entry, int i, Type elemType)
+ throws HibernateException;
+
+ /**
+ * Do we need to update this element?
+ */
+ public boolean needsUpdating(Object entry, int i, Type elemType)
+ throws HibernateException;
+
+ public boolean isRowUpdatePossible();
+
+ /**
+ * Get all the elements that need deleting
+ */
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
+ throws HibernateException;
+
+ /**
+ * Is this the wrapper for the given underlying collection instance?
+ */
+ public boolean isWrapper(Object collection);
+
+ /**
+ * Is this instance initialized?
+ */
+ public boolean wasInitialized();
+
+ /**
+ * Does this instance have any "queued" additions?
+ */
+ public boolean hasQueuedOperations();
+
+ /**
+ * Iterate the "queued" additions
+ */
+ public Iterator queuedAdditionIterator();
+
+ /**
+ * Get the "queued" orphans
+ */
+ public Collection getQueuedOrphans(String entityName);
+
+ /**
+ * Get the current collection key value
+ */
+ public Serializable getKey();
+
+ /**
+ * Get the current role name
+ */
+ public String getRole();
+
+ /**
+ * Is the collection unreferenced?
+ */
+ public boolean isUnreferenced();
+
+ /**
+ * Is the collection dirty? Note that this is only
+ * reliable during the flush cycle, after the
+ * collection elements are dirty checked against
+ * the snapshot.
+ */
+ public boolean isDirty();
+
+ /**
+ * Clear the dirty flag, after flushing changes
+ * to the database.
+ */
+ public void clearDirty();
+
+ /**
+ * Get the snapshot cached by the collection
+ * instance
+ */
+ public Serializable getStoredSnapshot();
+
+ /**
+ * Mark the collection as dirty
+ */
+ public void dirty();
+
+ /**
+ * Called before inserting rows, to ensure that any surrogate keys
+ * are fully generated
+ */
+ public void preInsert(CollectionPersister persister)
+ throws HibernateException;
+
+ /**
+ * Called after inserting a row, to fetch the natively generated id
+ */
+ public void afterRowInsert(CollectionPersister persister, Object entry, int i)
+ throws HibernateException;
+
+ /**
+ * get all "orphaned" elements
+ */
+ public Collection getOrphans(Serializable snapshot, String entityName)
+ throws HibernateException;
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,209 +0,0 @@
-//$Id: PersistentElementHolder.java 10086 2006-07-05 18:17:27Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.dom4j.Element;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-import org.hibernate.util.CollectionHelper;
-
-/**
- * A persistent wrapper for an XML element
- *
- * @author Gavin King
- */
-public class PersistentElementHolder extends AbstractPersistentCollection {
- protected Element element;
-
- public PersistentElementHolder(SessionImplementor session, Element element) {
- super(session);
- this.element = element;
- setInitialized();
- }
-
- public Serializable getSnapshot(CollectionPersister persister)
- throws HibernateException {
-
- final Type elementType = persister.getElementType();
- List elements = element.elements( persister.getElementNodeName() );
- ArrayList snapshot = new ArrayList( elements.size() );
- for ( int i=0; i<elements.size(); i++ ) {
- Element elem = (Element) elements.get(i);
- Object value = elementType.fromXMLNode( elem, persister.getFactory() );
- Object copy = elementType.deepCopy(value , getSession().getEntityMode(), persister.getFactory() );
- snapshot.add(copy);
- }
- return snapshot;
-
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName)
- throws HibernateException {
- //orphan delete not supported for EntityMode.DOM4J
- return CollectionHelper.EMPTY_COLLECTION;
- }
-
- public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key)
- throws HibernateException {
- super(session);
- Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister);
- if (owner==null) throw new AssertionFailure("null owner");
- //element = XMLHelper.generateDom4jElement( persister.getNodeName() );
- final String nodeName = persister.getNodeName();
- if ( ".".equals(nodeName) ) {
- element = owner;
- }
- else {
- element = owner.element( nodeName );
- if (element==null) element = owner.addElement( nodeName );
- }
- }
-
- public boolean isWrapper(Object collection) {
- return element==collection;
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
-
- ArrayList snapshot = (ArrayList) getSnapshot();
- List elements = element.elements( persister.getElementNodeName() );
- if ( snapshot.size()!= elements.size() ) return false;
- for ( int i=0; i<snapshot.size(); i++ ) {
- Object old = snapshot.get(i);
- Element elem = (Element) elements.get(i);
- Object current = elementType.fromXMLNode( elem, persister.getFactory() );
- if ( elementType.isDirty( old, current, getSession() ) ) return false;
- }
- return true;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (Collection) snapshot ).isEmpty();
- }
-
- public boolean empty() {
- return !element.elementIterator().hasNext();
- }
-
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
- Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- final Type elementType = persister.getElementType();
- Element subelement = element.addElement( persister.getElementNodeName() );
- elementType.setToXMLNode( subelement, object, persister.getFactory() );
- return object;
- }
-
- public Iterator entries(CollectionPersister persister) {
-
- final Type elementType = persister.getElementType();
- List elements = element.elements( persister.getElementNodeName() );
- int length = elements.size();
- List result = new ArrayList(length);
- for ( int i=0; i<length; i++ ) {
- Element elem = (Element) elements.get(i);
- Object object = elementType.fromXMLNode( elem, persister.getFactory() );
- result.add(object);
- }
- return result.iterator();
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {}
-
- public boolean isDirectlyAccessible() {
- return true;
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
-
- Type elementType = persister.getElementType();
- Serializable[] cached = (Serializable[]) disassembled;
- for ( int i=0; i<cached.length; i++ ) {
- Object object = elementType.assemble( cached[i], getSession(), owner );
- Element subelement = element.addElement( persister.getElementNodeName() );
- elementType.setToXMLNode( subelement, object, persister.getFactory() );
- }
-
- }
-
- public Serializable disassemble(CollectionPersister persister) throws HibernateException {
-
- Type elementType = persister.getElementType();
- List elements = element.elements( persister.getElementNodeName() );
- int length = elements.size();
- Serializable[] result = new Serializable[length];
- for ( int i=0; i<length; i++ ) {
- Element elem = (Element) elements.get(i);
- Object object = elementType.fromXMLNode( elem, persister.getFactory() );
- result[i] = elementType.disassemble( object, getSession(), null );
- }
- return result;
- }
-
- public Object getValue() {
- return element;
- }
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
- throws HibernateException {
-
- Type elementType = persister.getElementType();
- ArrayList snapshot = (ArrayList) getSnapshot();
- List elements = element.elements( persister.getElementNodeName() );
- ArrayList result = new ArrayList();
- for ( int i=0; i<snapshot.size(); i++ ) {
- Object old = snapshot.get(i);
- if ( i >= elements.size() ) {
- result.add(old);
- }
- else {
- Element elem = (Element) elements.get(i);
- Object object = elementType.fromXMLNode( elem, persister.getFactory() );
- if ( elementType.isDirty( old, object, getSession() ) ) result.add(old);
- }
- }
- return result.iterator();
-
- }
-
- public boolean needsInserting(Object entry, int i, Type elementType)
- throws HibernateException {
- ArrayList snapshot = (ArrayList) getSnapshot();
- return i>=snapshot.size() || elementType.isDirty( snapshot.get(i), entry, getSession() );
- }
-
- public boolean needsUpdating(Object entry, int i, Type elementType)
- throws HibernateException {
- return false;
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- throw new UnsupportedOperationException();
- }
-
- public Object getElement(Object entry) {
- return entry;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- throw new UnsupportedOperationException();
- }
-
- public boolean entryExists(Object entry, int i) {
- return entry!=null;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,232 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.Element;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+import org.hibernate.util.CollectionHelper;
+
+/**
+ * A persistent wrapper for an XML element
+ *
+ * @author Gavin King
+ */
+public class PersistentElementHolder extends AbstractPersistentCollection {
+ protected Element element;
+
+ public PersistentElementHolder(SessionImplementor session, Element element) {
+ super(session);
+ this.element = element;
+ setInitialized();
+ }
+
+ public Serializable getSnapshot(CollectionPersister persister)
+ throws HibernateException {
+
+ final Type elementType = persister.getElementType();
+ List elements = element.elements( persister.getElementNodeName() );
+ ArrayList snapshot = new ArrayList( elements.size() );
+ for ( int i=0; i<elements.size(); i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object value = elementType.fromXMLNode( elem, persister.getFactory() );
+ Object copy = elementType.deepCopy(value , getSession().getEntityMode(), persister.getFactory() );
+ snapshot.add(copy);
+ }
+ return snapshot;
+
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName)
+ throws HibernateException {
+ //orphan delete not supported for EntityMode.DOM4J
+ return CollectionHelper.EMPTY_COLLECTION;
+ }
+
+ public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key)
+ throws HibernateException {
+ super(session);
+ Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister);
+ if (owner==null) throw new AssertionFailure("null owner");
+ //element = XMLHelper.generateDom4jElement( persister.getNodeName() );
+ final String nodeName = persister.getNodeName();
+ if ( ".".equals(nodeName) ) {
+ element = owner;
+ }
+ else {
+ element = owner.element( nodeName );
+ if (element==null) element = owner.addElement( nodeName );
+ }
+ }
+
+ public boolean isWrapper(Object collection) {
+ return element==collection;
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+
+ ArrayList snapshot = (ArrayList) getSnapshot();
+ List elements = element.elements( persister.getElementNodeName() );
+ if ( snapshot.size()!= elements.size() ) return false;
+ for ( int i=0; i<snapshot.size(); i++ ) {
+ Object old = snapshot.get(i);
+ Element elem = (Element) elements.get(i);
+ Object current = elementType.fromXMLNode( elem, persister.getFactory() );
+ if ( elementType.isDirty( old, current, getSession() ) ) return false;
+ }
+ return true;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (Collection) snapshot ).isEmpty();
+ }
+
+ public boolean empty() {
+ return !element.elementIterator().hasNext();
+ }
+
+ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException {
+ Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ final Type elementType = persister.getElementType();
+ Element subelement = element.addElement( persister.getElementNodeName() );
+ elementType.setToXMLNode( subelement, object, persister.getFactory() );
+ return object;
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+
+ final Type elementType = persister.getElementType();
+ List elements = element.elements( persister.getElementNodeName() );
+ int length = elements.size();
+ List result = new ArrayList(length);
+ for ( int i=0; i<length; i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object object = elementType.fromXMLNode( elem, persister.getFactory() );
+ result.add(object);
+ }
+ return result.iterator();
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {}
+
+ public boolean isDirectlyAccessible() {
+ return true;
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ Serializable[] cached = (Serializable[]) disassembled;
+ for ( int i=0; i<cached.length; i++ ) {
+ Object object = elementType.assemble( cached[i], getSession(), owner );
+ Element subelement = element.addElement( persister.getElementNodeName() );
+ elementType.setToXMLNode( subelement, object, persister.getFactory() );
+ }
+
+ }
+
+ public Serializable disassemble(CollectionPersister persister) throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ List elements = element.elements( persister.getElementNodeName() );
+ int length = elements.size();
+ Serializable[] result = new Serializable[length];
+ for ( int i=0; i<length; i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object object = elementType.fromXMLNode( elem, persister.getFactory() );
+ result[i] = elementType.disassemble( object, getSession(), null );
+ }
+ return result;
+ }
+
+ public Object getValue() {
+ return element;
+ }
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
+ throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ ArrayList snapshot = (ArrayList) getSnapshot();
+ List elements = element.elements( persister.getElementNodeName() );
+ ArrayList result = new ArrayList();
+ for ( int i=0; i<snapshot.size(); i++ ) {
+ Object old = snapshot.get(i);
+ if ( i >= elements.size() ) {
+ result.add(old);
+ }
+ else {
+ Element elem = (Element) elements.get(i);
+ Object object = elementType.fromXMLNode( elem, persister.getFactory() );
+ if ( elementType.isDirty( old, object, getSession() ) ) result.add(old);
+ }
+ }
+ return result.iterator();
+
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elementType)
+ throws HibernateException {
+ ArrayList snapshot = (ArrayList) getSnapshot();
+ return i>=snapshot.size() || elementType.isDirty( snapshot.get(i), entry, getSession() );
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elementType)
+ throws HibernateException {
+ return false;
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getElement(Object entry) {
+ return entry;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean entryExists(Object entry, int i) {
+ return entry!=null;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,412 +0,0 @@
-//$Id: PersistentIdentifierBag.java 10738 2006-11-06 21:56:38Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-/**
- * An <tt>IdentifierBag</tt> implements "bag" semantics more efficiently than
- * a regular <tt>Bag</tt> by adding a synthetic identifier column to the
- * table. This identifier is unique for all rows in the table, allowing very
- * efficient updates and deletes. The value of the identifier is never exposed
- * to the application.<br>
- * <br>
- * <tt>IdentifierBag</tt>s may not be used for a many-to-one association.
- * Furthermore, there is no reason to use <tt>inverse="true"</tt>.
- *
- * @author Gavin King
- */
-public class PersistentIdentifierBag extends AbstractPersistentCollection implements List {
-
- protected List values; //element
- protected Map identifiers; //index -> id
-
- public PersistentIdentifierBag(SessionImplementor session) {
- super(session);
- }
-
- public PersistentIdentifierBag() {} //needed for SOAP libraries, etc
-
- public PersistentIdentifierBag(SessionImplementor session, Collection coll) {
- super(session);
- if (coll instanceof List) {
- values = (List) coll;
- }
- else {
- values = new ArrayList();
- Iterator iter = coll.iterator();
- while ( iter.hasNext() ) {
- values.add( iter.next() );
- }
- }
- setInitialized();
- setDirectlyAccessible(true);
- identifiers = new HashMap();
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
- Serializable[] array = (Serializable[]) disassembled;
- int size = array.length;
- beforeInitialize( persister, size );
- for ( int i = 0; i < size; i+=2 ) {
- identifiers.put(
- new Integer(i/2),
- persister.getIdentifierType().assemble( array[i], getSession(), owner )
- );
- values.add( persister.getElementType().assemble( array[i+1], getSession(), owner ) );
- }
- }
-
- public Object getIdentifier(Object entry, int i) {
- return identifiers.get( new Integer(i) );
- }
-
- public boolean isWrapper(Object collection) {
- return values==collection;
- }
-
- public boolean add(Object o) {
- write();
- values.add(o);
- return true;
- }
-
- public void clear() {
- initialize( true );
- if ( ! values.isEmpty() || ! identifiers.isEmpty() ) {
- values.clear();
- identifiers.clear();
- dirty();
- }
- }
-
- public boolean contains(Object o) {
- read();
- return values.contains(o);
- }
-
- public boolean containsAll(Collection c) {
- read();
- return values.containsAll(c);
- }
-
- public boolean isEmpty() {
- return readSize() ? getCachedSize()==0 : values.isEmpty();
- }
-
- public Iterator iterator() {
- read();
- return new IteratorProxy( values.iterator() );
- }
-
- public boolean remove(Object o) {
- initialize( true );
- int index = values.indexOf(o);
- if (index>=0) {
- beforeRemove(index);
- values.remove(index);
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
-
- public boolean removeAll(Collection c) {
- if ( c.size() > 0 ) {
- boolean result = false;
- Iterator iter = c.iterator();
- while ( iter.hasNext() ) {
- if ( remove( iter.next() ) ) result=true;
- }
- return result;
- }
- else {
- return false;
- }
- }
-
- public boolean retainAll(Collection c) {
- initialize( true );
- if ( values.retainAll( c ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
-
- public int size() {
- return readSize() ? getCachedSize() : values.size();
- }
-
- public Object[] toArray() {
- read();
- return values.toArray();
- }
-
- public Object[] toArray(Object[] a) {
- read();
- return values.toArray(a);
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
- identifiers = anticipatedSize <= 0 ? new HashMap() : new HashMap( anticipatedSize + 1 + (int)( anticipatedSize * .75f ), .75f );
- values = anticipatedSize <= 0 ? new ArrayList() : new ArrayList( anticipatedSize );
- }
-
- public Serializable disassemble(CollectionPersister persister)
- throws HibernateException {
- Serializable[] result = new Serializable[ values.size() * 2 ];
- int i=0;
- for (int j=0; j< values.size(); j++) {
- Object value = values.get(j);
- result[i++] = persister.getIdentifierType().disassemble( identifiers.get( new Integer(j) ), getSession(), null );
- result[i++] = persister.getElementType().disassemble( value, getSession(), null );
- }
- return result;
- }
-
- public boolean empty() {
- return values.isEmpty();
- }
-
- public Iterator entries(CollectionPersister persister) {
- return values.iterator();
- }
-
- public boolean entryExists(Object entry, int i) {
- return entry!=null;
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- Map snap = (Map) getSnapshot();
- if ( snap.size()!= values.size() ) return false;
- for ( int i=0; i<values.size(); i++ ) {
- Object value = values.get(i);
- Object id = identifiers.get( new Integer(i) );
- if (id==null) return false;
- Object old = snap.get(id);
- if ( elementType.isDirty( old, value, getSession() ) ) return false;
- }
- return true;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (Map) snapshot ).isEmpty();
- }
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
- Map snap = (Map) getSnapshot();
- List deletes = new ArrayList( snap.keySet() );
- for ( int i=0; i<values.size(); i++ ) {
- if ( values.get(i)!=null ) deletes.remove( identifiers.get( new Integer(i) ) );
- }
- return deletes.iterator();
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- throw new UnsupportedOperationException("Bags don't have indexes");
- }
-
- public Object getElement(Object entry) {
- return entry;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- Map snap = (Map) getSnapshot();
- Object id = identifiers.get( new Integer(i) );
- return snap.get(id);
- }
-
- public boolean needsInserting(Object entry, int i, Type elemType)
- throws HibernateException {
-
- Map snap = (Map) getSnapshot();
- Object id = identifiers.get( new Integer(i) );
- return entry!=null && ( id==null || snap.get(id)==null );
- }
-
- public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
-
- if (entry==null) return false;
- Map snap = (Map) getSnapshot();
- Object id = identifiers.get( new Integer(i) );
- if (id==null) return false;
- Object old = snap.get(id);
- return old!=null && elemType.isDirty( old, entry, getSession() );
- }
-
-
- public Object readFrom(
- ResultSet rs,
- CollectionPersister persister,
- CollectionAliases descriptor,
- Object owner)
- throws HibernateException, SQLException {
-
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- Object old = identifiers.put(
- new Integer( values.size() ),
- persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() )
- );
- if ( old==null ) values.add(element); //maintain correct duplication if loaded in a cartesian product
- return element;
- }
-
- public Serializable getSnapshot(CollectionPersister persister)
- throws HibernateException {
-
- EntityMode entityMode = getSession().getEntityMode();
-
- HashMap map = new HashMap( values.size() );
- Iterator iter = values.iterator();
- int i=0;
- while ( iter.hasNext() ) {
- Object value = iter.next();
- map.put(
- identifiers.get( new Integer(i++) ),
- persister.getElementType().deepCopy(value, entityMode, persister.getFactory())
- );
- }
- return map;
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
- Map sn = (Map) snapshot;
- return getOrphans( sn.values(), values, entityName, getSession() );
- }
-
- public void preInsert(CollectionPersister persister) throws HibernateException {
- Iterator iter = values.iterator();
- int i=0;
- while ( iter.hasNext() ) {
- Object entry = iter.next();
- Integer loc = new Integer(i++);
- if ( !identifiers.containsKey(loc) ) { //TODO: native ids
- Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry );
- identifiers.put(loc, id);
- }
- }
- }
-
- public void add(int index, Object element) {
- write();
- beforeAdd(index);
- values.add(index, element);
- }
-
- public boolean addAll(int index, Collection c) {
- if ( c.size() > 0 ) {
- Iterator iter = c.iterator();
- while ( iter.hasNext() ) {
- add( index++, iter.next() );
- }
- return true;
- }
- else {
- return false;
- }
- }
-
- public Object get(int index) {
- read();
- return values.get(index);
- }
-
- public int indexOf(Object o) {
- read();
- return values.indexOf(o);
- }
-
- public int lastIndexOf(Object o) {
- read();
- return values.lastIndexOf(o);
- }
-
- public ListIterator listIterator() {
- read();
- return new ListIteratorProxy( values.listIterator() );
- }
-
- public ListIterator listIterator(int index) {
- read();
- return new ListIteratorProxy( values.listIterator(index) );
- }
-
- private void beforeRemove(int index) {
- Object removedId = identifiers.get( new Integer(index) );
- int last = values.size()-1;
- for ( int i=index; i<last; i++ ) {
- Object id = identifiers.get( new Integer(i+1) );
- if ( id==null ) {
- identifiers.remove( new Integer(i) );
- }
- else {
- identifiers.put( new Integer(i), id );
- }
- }
- identifiers.put( new Integer(last), removedId );
- }
-
- private void beforeAdd(int index) {
- for ( int i=index; i<values.size(); i++ ) {
- identifiers.put( new Integer(i+1), identifiers.get( new Integer(i) ) );
- }
- identifiers.remove( new Integer(index) );
- }
-
- public Object remove(int index) {
- write();
- beforeRemove(index);
- return values.remove(index);
- }
-
- public Object set(int index, Object element) {
- write();
- return values.set(index, element);
- }
-
- public List subList(int fromIndex, int toIndex) {
- read();
- return new ListProxy( values.subList(fromIndex, toIndex) );
- }
-
- public boolean addAll(Collection c) {
- if ( c.size()> 0 ) {
- write();
- return values.addAll(c);
- }
- else {
- return false;
- }
- }
-
- public void afterRowInsert(
- CollectionPersister persister,
- Object entry,
- int i)
- throws HibernateException {
- //TODO: if we are using identity columns, fetch the identifier
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIdentifierBag.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,435 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * An <tt>IdentifierBag</tt> implements "bag" semantics more efficiently than
+ * a regular <tt>Bag</tt> by adding a synthetic identifier column to the
+ * table. This identifier is unique for all rows in the table, allowing very
+ * efficient updates and deletes. The value of the identifier is never exposed
+ * to the application.<br>
+ * <br>
+ * <tt>IdentifierBag</tt>s may not be used for a many-to-one association.
+ * Furthermore, there is no reason to use <tt>inverse="true"</tt>.
+ *
+ * @author Gavin King
+ */
+public class PersistentIdentifierBag extends AbstractPersistentCollection implements List {
+
+ protected List values; //element
+ protected Map identifiers; //index -> id
+
+ public PersistentIdentifierBag(SessionImplementor session) {
+ super(session);
+ }
+
+ public PersistentIdentifierBag() {} //needed for SOAP libraries, etc
+
+ public PersistentIdentifierBag(SessionImplementor session, Collection coll) {
+ super(session);
+ if (coll instanceof List) {
+ values = (List) coll;
+ }
+ else {
+ values = new ArrayList();
+ Iterator iter = coll.iterator();
+ while ( iter.hasNext() ) {
+ values.add( iter.next() );
+ }
+ }
+ setInitialized();
+ setDirectlyAccessible(true);
+ identifiers = new HashMap();
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+ Serializable[] array = (Serializable[]) disassembled;
+ int size = array.length;
+ beforeInitialize( persister, size );
+ for ( int i = 0; i < size; i+=2 ) {
+ identifiers.put(
+ new Integer(i/2),
+ persister.getIdentifierType().assemble( array[i], getSession(), owner )
+ );
+ values.add( persister.getElementType().assemble( array[i+1], getSession(), owner ) );
+ }
+ }
+
+ public Object getIdentifier(Object entry, int i) {
+ return identifiers.get( new Integer(i) );
+ }
+
+ public boolean isWrapper(Object collection) {
+ return values==collection;
+ }
+
+ public boolean add(Object o) {
+ write();
+ values.add(o);
+ return true;
+ }
+
+ public void clear() {
+ initialize( true );
+ if ( ! values.isEmpty() || ! identifiers.isEmpty() ) {
+ values.clear();
+ identifiers.clear();
+ dirty();
+ }
+ }
+
+ public boolean contains(Object o) {
+ read();
+ return values.contains(o);
+ }
+
+ public boolean containsAll(Collection c) {
+ read();
+ return values.containsAll(c);
+ }
+
+ public boolean isEmpty() {
+ return readSize() ? getCachedSize()==0 : values.isEmpty();
+ }
+
+ public Iterator iterator() {
+ read();
+ return new IteratorProxy( values.iterator() );
+ }
+
+ public boolean remove(Object o) {
+ initialize( true );
+ int index = values.indexOf(o);
+ if (index>=0) {
+ beforeRemove(index);
+ values.remove(index);
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public boolean removeAll(Collection c) {
+ if ( c.size() > 0 ) {
+ boolean result = false;
+ Iterator iter = c.iterator();
+ while ( iter.hasNext() ) {
+ if ( remove( iter.next() ) ) result=true;
+ }
+ return result;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public boolean retainAll(Collection c) {
+ initialize( true );
+ if ( values.retainAll( c ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public int size() {
+ return readSize() ? getCachedSize() : values.size();
+ }
+
+ public Object[] toArray() {
+ read();
+ return values.toArray();
+ }
+
+ public Object[] toArray(Object[] a) {
+ read();
+ return values.toArray(a);
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
+ identifiers = anticipatedSize <= 0 ? new HashMap() : new HashMap( anticipatedSize + 1 + (int)( anticipatedSize * .75f ), .75f );
+ values = anticipatedSize <= 0 ? new ArrayList() : new ArrayList( anticipatedSize );
+ }
+
+ public Serializable disassemble(CollectionPersister persister)
+ throws HibernateException {
+ Serializable[] result = new Serializable[ values.size() * 2 ];
+ int i=0;
+ for (int j=0; j< values.size(); j++) {
+ Object value = values.get(j);
+ result[i++] = persister.getIdentifierType().disassemble( identifiers.get( new Integer(j) ), getSession(), null );
+ result[i++] = persister.getElementType().disassemble( value, getSession(), null );
+ }
+ return result;
+ }
+
+ public boolean empty() {
+ return values.isEmpty();
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+ return values.iterator();
+ }
+
+ public boolean entryExists(Object entry, int i) {
+ return entry!=null;
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ Map snap = (Map) getSnapshot();
+ if ( snap.size()!= values.size() ) return false;
+ for ( int i=0; i<values.size(); i++ ) {
+ Object value = values.get(i);
+ Object id = identifiers.get( new Integer(i) );
+ if (id==null) return false;
+ Object old = snap.get(id);
+ if ( elementType.isDirty( old, value, getSession() ) ) return false;
+ }
+ return true;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (Map) snapshot ).isEmpty();
+ }
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
+ Map snap = (Map) getSnapshot();
+ List deletes = new ArrayList( snap.keySet() );
+ for ( int i=0; i<values.size(); i++ ) {
+ if ( values.get(i)!=null ) deletes.remove( identifiers.get( new Integer(i) ) );
+ }
+ return deletes.iterator();
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ throw new UnsupportedOperationException("Bags don't have indexes");
+ }
+
+ public Object getElement(Object entry) {
+ return entry;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ Map snap = (Map) getSnapshot();
+ Object id = identifiers.get( new Integer(i) );
+ return snap.get(id);
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elemType)
+ throws HibernateException {
+
+ Map snap = (Map) getSnapshot();
+ Object id = identifiers.get( new Integer(i) );
+ return entry!=null && ( id==null || snap.get(id)==null );
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
+
+ if (entry==null) return false;
+ Map snap = (Map) getSnapshot();
+ Object id = identifiers.get( new Integer(i) );
+ if (id==null) return false;
+ Object old = snap.get(id);
+ return old!=null && elemType.isDirty( old, entry, getSession() );
+ }
+
+
+ public Object readFrom(
+ ResultSet rs,
+ CollectionPersister persister,
+ CollectionAliases descriptor,
+ Object owner)
+ throws HibernateException, SQLException {
+
+ Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ Object old = identifiers.put(
+ new Integer( values.size() ),
+ persister.readIdentifier( rs, descriptor.getSuffixedIdentifierAlias(), getSession() )
+ );
+ if ( old==null ) values.add(element); //maintain correct duplication if loaded in a cartesian product
+ return element;
+ }
+
+ public Serializable getSnapshot(CollectionPersister persister)
+ throws HibernateException {
+
+ EntityMode entityMode = getSession().getEntityMode();
+
+ HashMap map = new HashMap( values.size() );
+ Iterator iter = values.iterator();
+ int i=0;
+ while ( iter.hasNext() ) {
+ Object value = iter.next();
+ map.put(
+ identifiers.get( new Integer(i++) ),
+ persister.getElementType().deepCopy(value, entityMode, persister.getFactory())
+ );
+ }
+ return map;
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
+ Map sn = (Map) snapshot;
+ return getOrphans( sn.values(), values, entityName, getSession() );
+ }
+
+ public void preInsert(CollectionPersister persister) throws HibernateException {
+ Iterator iter = values.iterator();
+ int i=0;
+ while ( iter.hasNext() ) {
+ Object entry = iter.next();
+ Integer loc = new Integer(i++);
+ if ( !identifiers.containsKey(loc) ) { //TODO: native ids
+ Serializable id = persister.getIdentifierGenerator().generate( getSession(), entry );
+ identifiers.put(loc, id);
+ }
+ }
+ }
+
+ public void add(int index, Object element) {
+ write();
+ beforeAdd(index);
+ values.add(index, element);
+ }
+
+ public boolean addAll(int index, Collection c) {
+ if ( c.size() > 0 ) {
+ Iterator iter = c.iterator();
+ while ( iter.hasNext() ) {
+ add( index++, iter.next() );
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public Object get(int index) {
+ read();
+ return values.get(index);
+ }
+
+ public int indexOf(Object o) {
+ read();
+ return values.indexOf(o);
+ }
+
+ public int lastIndexOf(Object o) {
+ read();
+ return values.lastIndexOf(o);
+ }
+
+ public ListIterator listIterator() {
+ read();
+ return new ListIteratorProxy( values.listIterator() );
+ }
+
+ public ListIterator listIterator(int index) {
+ read();
+ return new ListIteratorProxy( values.listIterator(index) );
+ }
+
+ private void beforeRemove(int index) {
+ Object removedId = identifiers.get( new Integer(index) );
+ int last = values.size()-1;
+ for ( int i=index; i<last; i++ ) {
+ Object id = identifiers.get( new Integer(i+1) );
+ if ( id==null ) {
+ identifiers.remove( new Integer(i) );
+ }
+ else {
+ identifiers.put( new Integer(i), id );
+ }
+ }
+ identifiers.put( new Integer(last), removedId );
+ }
+
+ private void beforeAdd(int index) {
+ for ( int i=index; i<values.size(); i++ ) {
+ identifiers.put( new Integer(i+1), identifiers.get( new Integer(i) ) );
+ }
+ identifiers.remove( new Integer(index) );
+ }
+
+ public Object remove(int index) {
+ write();
+ beforeRemove(index);
+ return values.remove(index);
+ }
+
+ public Object set(int index, Object element) {
+ write();
+ return values.set(index, element);
+ }
+
+ public List subList(int fromIndex, int toIndex) {
+ read();
+ return new ListProxy( values.subList(fromIndex, toIndex) );
+ }
+
+ public boolean addAll(Collection c) {
+ if ( c.size()> 0 ) {
+ write();
+ return values.addAll(c);
+ }
+ else {
+ return false;
+ }
+ }
+
+ public void afterRowInsert(
+ CollectionPersister persister,
+ Object entry,
+ int i)
+ throws HibernateException {
+ //TODO: if we are using identity columns, fetch the identifier
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,228 +0,0 @@
-//$Id: PersistentIndexedElementHolder.java 10086 2006-07-05 18:17:27Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.dom4j.Element;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.NullableType;
-import org.hibernate.type.Type;
-import org.hibernate.util.CollectionHelper;
-
-/**
- * A persistent wrapper for an XML element
- *
- * @author Gavin King
- */
-public abstract class PersistentIndexedElementHolder extends AbstractPersistentCollection {
- protected Element element;
-
- public PersistentIndexedElementHolder(SessionImplementor session, Element element) {
- super(session);
- this.element = element;
- setInitialized();
- }
-
- public static final class IndexedValue {
- String index;
- Object value;
- IndexedValue(String index, Object value) {
- this.index = index;
- this.value = value;
- }
- }
-
- protected static String getIndex(Element element, String indexNodeName, int i) {
- if (indexNodeName!=null) {
- return element.attributeValue(indexNodeName);
- }
- else {
- return Integer.toString(i);
- }
- }
-
- protected static void setIndex(Element element, String indexNodeName, String index) {
- if (indexNodeName!=null) element.addAttribute(indexNodeName, index);
- }
-
- protected static String getIndexAttributeName(CollectionPersister persister) {
- String node = persister.getIndexNodeName();
- return node==null ? null : node.substring(1);
- }
-
- public Serializable getSnapshot(CollectionPersister persister)
- throws HibernateException {
-
- final Type elementType = persister.getElementType();
- String indexNode = getIndexAttributeName(persister);
- List elements = element.elements( persister.getElementNodeName() );
- HashMap snapshot = new HashMap( elements.size() );
- for ( int i=0; i<elements.size(); i++ ) {
- Element elem = (Element) elements.get(i);
- Object value = elementType.fromXMLNode( elem, persister.getFactory() );
- Object copy = elementType.deepCopy( value, getSession().getEntityMode(), persister.getFactory() );
- snapshot.put( getIndex(elem, indexNode, i), copy );
- }
- return snapshot;
-
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName)
- throws HibernateException {
- //orphan delete not supported for EntityMode.DOM4J
- return CollectionHelper.EMPTY_COLLECTION;
- }
-
- public PersistentIndexedElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key)
- throws HibernateException {
- super(session);
- Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister);
- if (owner==null) throw new AssertionFailure("null owner");
- //element = XMLHelper.generateDom4jElement( persister.getNodeName() );
- final String nodeName = persister.getNodeName();
- if ( ".".equals(nodeName) ) {
- element = owner;
- }
- else {
- element = owner.element( nodeName );
- if (element==null) element = owner.addElement( nodeName );
- }
- }
-
- public boolean isWrapper(Object collection) {
- return element==collection;
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- String indexNode = getIndexAttributeName(persister);
- HashMap snapshot = (HashMap) getSnapshot();
- List elements = element.elements( persister.getElementNodeName() );
- if ( snapshot.size()!= elements.size() ) return false;
- for ( int i=0; i<snapshot.size(); i++ ) {
- Element elem = (Element) elements.get(i);
- Object old = snapshot.get( getIndex(elem, indexNode, i) );
- Object current = elementType.fromXMLNode( elem, persister.getFactory() );
- if ( elementType.isDirty( old, current, getSession() ) ) return false;
- }
- return true;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (HashMap) snapshot ).isEmpty();
- }
-
- public boolean empty() {
- return !element.elementIterator().hasNext();
- }
-
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
- Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- final Type elementType = persister.getElementType();
- final SessionFactoryImplementor factory = persister.getFactory();
- String indexNode = getIndexAttributeName(persister);
-
- Element elem = element.addElement( persister.getElementNodeName() );
- elementType.setToXMLNode( elem, object, factory );
-
- final Type indexType = persister.getIndexType();
- final Object indexValue = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
- final String index = ( (NullableType) indexType ).toXMLString( indexValue, factory );
- setIndex(elem, indexNode, index);
- return object;
- }
-
- public Iterator entries(CollectionPersister persister) {
-
- final Type elementType = persister.getElementType();
- String indexNode = getIndexAttributeName(persister);
- List elements = element.elements( persister.getElementNodeName() );
- int length = elements.size();
- List result = new ArrayList(length);
- for ( int i=0; i<length; i++ ) {
- Element elem = (Element) elements.get(i);
- Object object = elementType.fromXMLNode( elem, persister.getFactory() );
- result.add( new IndexedValue( getIndex(elem, indexNode, i), object ) );
- }
- return result.iterator();
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {}
-
- public boolean isDirectlyAccessible() {
- return true;
- }
-
- public Object getValue() {
- return element;
- }
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
- throws HibernateException {
-
- final Type indexType = persister.getIndexType();
- HashMap snapshot = (HashMap) getSnapshot();
- HashMap deletes = (HashMap) snapshot.clone();
- deletes.keySet().removeAll( ( (HashMap) getSnapshot(persister) ).keySet() );
- ArrayList deleteList = new ArrayList( deletes.size() );
- Iterator iter = deletes.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry me = (Map.Entry) iter.next();
- final Object object = indexIsFormula ?
- me.getValue() :
- ( (NullableType) indexType ).fromXMLString( (String) me.getKey(), persister.getFactory() );
- if (object!=null) deleteList.add(object);
- }
-
- return deleteList.iterator();
-
- }
-
- public boolean needsInserting(Object entry, int i, Type elementType)
- throws HibernateException {
- HashMap snapshot = (HashMap) getSnapshot();
- IndexedValue iv = (IndexedValue) entry;
- return iv.value!=null && snapshot.get( iv.index )==null;
- }
-
- public boolean needsUpdating(Object entry, int i, Type elementType)
- throws HibernateException {
- HashMap snapshot = (HashMap) getSnapshot();
- IndexedValue iv = (IndexedValue) entry;
- Object old = snapshot.get( iv.index );
- return old!=null && elementType.isDirty( old, iv.value, getSession() );
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- String index = ( (IndexedValue) entry ).index;
- final Type indexType = persister.getIndexType();
- return ( (NullableType) indexType ).fromXMLString( index, persister.getFactory() );
- }
-
- public Object getElement(Object entry) {
- return ( (IndexedValue) entry ).value;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- return ( (HashMap) getSnapshot() ).get( ( (IndexedValue) entry ).index );
- }
-
- public boolean entryExists(Object entry, int i) {
- return entry!=null;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentIndexedElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,251 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.dom4j.Element;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.NullableType;
+import org.hibernate.type.Type;
+import org.hibernate.util.CollectionHelper;
+
+/**
+ * A persistent wrapper for an XML element
+ *
+ * @author Gavin King
+ */
+public abstract class PersistentIndexedElementHolder extends AbstractPersistentCollection {
+ protected Element element;
+
+ public PersistentIndexedElementHolder(SessionImplementor session, Element element) {
+ super(session);
+ this.element = element;
+ setInitialized();
+ }
+
+ public static final class IndexedValue {
+ String index;
+ Object value;
+ IndexedValue(String index, Object value) {
+ this.index = index;
+ this.value = value;
+ }
+ }
+
+ protected static String getIndex(Element element, String indexNodeName, int i) {
+ if (indexNodeName!=null) {
+ return element.attributeValue(indexNodeName);
+ }
+ else {
+ return Integer.toString(i);
+ }
+ }
+
+ protected static void setIndex(Element element, String indexNodeName, String index) {
+ if (indexNodeName!=null) element.addAttribute(indexNodeName, index);
+ }
+
+ protected static String getIndexAttributeName(CollectionPersister persister) {
+ String node = persister.getIndexNodeName();
+ return node==null ? null : node.substring(1);
+ }
+
+ public Serializable getSnapshot(CollectionPersister persister)
+ throws HibernateException {
+
+ final Type elementType = persister.getElementType();
+ String indexNode = getIndexAttributeName(persister);
+ List elements = element.elements( persister.getElementNodeName() );
+ HashMap snapshot = new HashMap( elements.size() );
+ for ( int i=0; i<elements.size(); i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object value = elementType.fromXMLNode( elem, persister.getFactory() );
+ Object copy = elementType.deepCopy( value, getSession().getEntityMode(), persister.getFactory() );
+ snapshot.put( getIndex(elem, indexNode, i), copy );
+ }
+ return snapshot;
+
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName)
+ throws HibernateException {
+ //orphan delete not supported for EntityMode.DOM4J
+ return CollectionHelper.EMPTY_COLLECTION;
+ }
+
+ public PersistentIndexedElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key)
+ throws HibernateException {
+ super(session);
+ Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister);
+ if (owner==null) throw new AssertionFailure("null owner");
+ //element = XMLHelper.generateDom4jElement( persister.getNodeName() );
+ final String nodeName = persister.getNodeName();
+ if ( ".".equals(nodeName) ) {
+ element = owner;
+ }
+ else {
+ element = owner.element( nodeName );
+ if (element==null) element = owner.addElement( nodeName );
+ }
+ }
+
+ public boolean isWrapper(Object collection) {
+ return element==collection;
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ String indexNode = getIndexAttributeName(persister);
+ HashMap snapshot = (HashMap) getSnapshot();
+ List elements = element.elements( persister.getElementNodeName() );
+ if ( snapshot.size()!= elements.size() ) return false;
+ for ( int i=0; i<snapshot.size(); i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object old = snapshot.get( getIndex(elem, indexNode, i) );
+ Object current = elementType.fromXMLNode( elem, persister.getFactory() );
+ if ( elementType.isDirty( old, current, getSession() ) ) return false;
+ }
+ return true;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (HashMap) snapshot ).isEmpty();
+ }
+
+ public boolean empty() {
+ return !element.elementIterator().hasNext();
+ }
+
+ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException {
+ Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ final Type elementType = persister.getElementType();
+ final SessionFactoryImplementor factory = persister.getFactory();
+ String indexNode = getIndexAttributeName(persister);
+
+ Element elem = element.addElement( persister.getElementNodeName() );
+ elementType.setToXMLNode( elem, object, factory );
+
+ final Type indexType = persister.getIndexType();
+ final Object indexValue = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
+ final String index = ( (NullableType) indexType ).toXMLString( indexValue, factory );
+ setIndex(elem, indexNode, index);
+ return object;
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+
+ final Type elementType = persister.getElementType();
+ String indexNode = getIndexAttributeName(persister);
+ List elements = element.elements( persister.getElementNodeName() );
+ int length = elements.size();
+ List result = new ArrayList(length);
+ for ( int i=0; i<length; i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object object = elementType.fromXMLNode( elem, persister.getFactory() );
+ result.add( new IndexedValue( getIndex(elem, indexNode, i), object ) );
+ }
+ return result.iterator();
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {}
+
+ public boolean isDirectlyAccessible() {
+ return true;
+ }
+
+ public Object getValue() {
+ return element;
+ }
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
+ throws HibernateException {
+
+ final Type indexType = persister.getIndexType();
+ HashMap snapshot = (HashMap) getSnapshot();
+ HashMap deletes = (HashMap) snapshot.clone();
+ deletes.keySet().removeAll( ( (HashMap) getSnapshot(persister) ).keySet() );
+ ArrayList deleteList = new ArrayList( deletes.size() );
+ Iterator iter = deletes.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry me = (Map.Entry) iter.next();
+ final Object object = indexIsFormula ?
+ me.getValue() :
+ ( (NullableType) indexType ).fromXMLString( (String) me.getKey(), persister.getFactory() );
+ if (object!=null) deleteList.add(object);
+ }
+
+ return deleteList.iterator();
+
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elementType)
+ throws HibernateException {
+ HashMap snapshot = (HashMap) getSnapshot();
+ IndexedValue iv = (IndexedValue) entry;
+ return iv.value!=null && snapshot.get( iv.index )==null;
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elementType)
+ throws HibernateException {
+ HashMap snapshot = (HashMap) getSnapshot();
+ IndexedValue iv = (IndexedValue) entry;
+ Object old = snapshot.get( iv.index );
+ return old!=null && elementType.isDirty( old, iv.value, getSession() );
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ String index = ( (IndexedValue) entry ).index;
+ final Type indexType = persister.getIndexType();
+ return ( (NullableType) indexType ).fromXMLString( index, persister.getFactory() );
+ }
+
+ public Object getElement(Object entry) {
+ return ( (IndexedValue) entry ).value;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ return ( (HashMap) getSnapshot() ).get( ( (IndexedValue) entry ).index );
+ }
+
+ public boolean entryExists(Object entry, int i) {
+ return entry!=null;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentList.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,579 +0,0 @@
-//$Id: PersistentList.java 10738 2006-11-06 21:56:38Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-/**
- * A persistent wrapper for a <tt>java.util.List</tt>. Underlying
- * collection is an <tt>ArrayList</tt>.
- *
- * @see java.util.ArrayList
- * @author Gavin King
- */
-public class PersistentList extends AbstractPersistentCollection implements List {
-
- protected List list;
-
- public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
-
- EntityMode entityMode = getSession().getEntityMode();
-
- ArrayList clonedList = new ArrayList( list.size() );
- Iterator iter = list.iterator();
- while ( iter.hasNext() ) {
- Object deepCopy = persister.getElementType()
- .deepCopy( iter.next(), entityMode, persister.getFactory() );
- clonedList.add( deepCopy );
- }
- return clonedList;
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
- List sn = (List) snapshot;
- return getOrphans( sn, list, entityName, getSession() );
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- List sn = (List) getSnapshot();
- if ( sn.size()!=this.list.size() ) return false;
- Iterator iter = list.iterator();
- Iterator sniter = sn.iterator();
- while ( iter.hasNext() ) {
- if ( elementType.isDirty( iter.next(), sniter.next(), getSession() ) ) return false;
- }
- return true;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (Collection) snapshot ).isEmpty();
- }
-
- public PersistentList(SessionImplementor session) {
- super(session);
- }
-
- public PersistentList(SessionImplementor session, List list) {
- super(session);
- this.list = list;
- setInitialized();
- setDirectlyAccessible(true);
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
- this.list = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
- }
-
- public boolean isWrapper(Object collection) {
- return list==collection;
- }
-
- public PersistentList() {} //needed for SOAP libraries, etc
-
- /**
- * @see java.util.List#size()
- */
- public int size() {
- return readSize() ? getCachedSize() : list.size();
- }
-
- /**
- * @see java.util.List#isEmpty()
- */
- public boolean isEmpty() {
- return readSize() ? getCachedSize()==0 : list.isEmpty();
- }
-
- /**
- * @see java.util.List#contains(Object)
- */
- public boolean contains(Object object) {
- Boolean exists = readElementExistence(object);
- return exists==null ?
- list.contains(object) :
- exists.booleanValue();
- }
-
- /**
- * @see java.util.List#iterator()
- */
- public Iterator iterator() {
- read();
- return new IteratorProxy( list.iterator() );
- }
-
- /**
- * @see java.util.List#toArray()
- */
- public Object[] toArray() {
- read();
- return list.toArray();
- }
-
- /**
- * @see java.util.List#toArray(Object[])
- */
- public Object[] toArray(Object[] array) {
- read();
- return list.toArray(array);
- }
-
- /**
- * @see java.util.List#add(Object)
- */
- public boolean add(Object object) {
- if ( !isOperationQueueEnabled() ) {
- write();
- return list.add(object);
- }
- else {
- queueOperation( new SimpleAdd(object) );
- return true;
- }
- }
-
- /**
- * @see java.util.List#remove(Object)
- */
- public boolean remove(Object value) {
- Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
- if ( exists == null ) {
- initialize( true );
- if ( list.remove( value ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else if ( exists.booleanValue() ) {
- queueOperation( new SimpleRemove(value) );
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.List#containsAll(Collection)
- */
- public boolean containsAll(Collection coll) {
- read();
- return list.containsAll(coll);
- }
-
- /**
- * @see java.util.List#addAll(Collection)
- */
- public boolean addAll(Collection values) {
- if ( values.size()==0 ) {
- return false;
- }
- if ( !isOperationQueueEnabled() ) {
- write();
- return list.addAll(values);
- }
- else {
- Iterator iter = values.iterator();
- while ( iter.hasNext() ) {
- queueOperation( new SimpleAdd( iter.next() ) );
- }
- return values.size()>0;
- }
- }
-
- /**
- * @see java.util.List#addAll(int, Collection)
- */
- public boolean addAll(int index, Collection coll) {
- if ( coll.size()>0 ) {
- write();
- return list.addAll(index, coll);
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.List#removeAll(Collection)
- */
- public boolean removeAll(Collection coll) {
- if ( coll.size()>0 ) {
- initialize( true );
- if ( list.removeAll( coll ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.List#retainAll(Collection)
- */
- public boolean retainAll(Collection coll) {
- initialize( true );
- if ( list.retainAll( coll ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.List#clear()
- */
- public void clear() {
- if ( isClearQueueEnabled() ) {
- queueOperation( new Clear() );
- }
- else {
- initialize( true );
- if ( ! list.isEmpty() ) {
- list.clear();
- dirty();
- }
- }
- }
-
- /**
- * @see java.util.List#get(int)
- */
- public Object get(int index) {
- if (index<0) {
- throw new ArrayIndexOutOfBoundsException("negative index");
- }
- Object result = readElementByIndex( new Integer(index) );
- return result==UNKNOWN ? list.get(index) : result;
- }
-
- /**
- * @see java.util.List#set(int, Object)
- */
- public Object set(int index, Object value) {
- if (index<0) {
- throw new ArrayIndexOutOfBoundsException("negative index");
- }
- Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN;
- if ( old==UNKNOWN ) {
- write();
- return list.set(index, value);
- }
- else {
- queueOperation( new Set(index, value, old) );
- return old;
- }
- }
-
- /**
- * @see java.util.List#add(int, Object)
- */
- public void add(int index, Object value) {
- if (index<0) {
- throw new ArrayIndexOutOfBoundsException("negative index");
- }
- if ( !isOperationQueueEnabled() ) {
- write();
- list.add(index, value);
- }
- else {
- queueOperation( new Add(index, value) );
- }
- }
-
- /**
- * @see java.util.List#remove(int)
- */
- public Object remove(int index) {
- if (index<0) {
- throw new ArrayIndexOutOfBoundsException("negative index");
- }
- Object old = isPutQueueEnabled() ?
- readElementByIndex( new Integer(index) ) : UNKNOWN;
- if ( old==UNKNOWN ) {
- write();
- return list.remove(index);
- }
- else {
- queueOperation( new Remove(index, old) );
- return old;
- }
- }
-
- /**
- * @see java.util.List#indexOf(Object)
- */
- public int indexOf(Object value) {
- read();
- return list.indexOf(value);
- }
-
- /**
- * @see java.util.List#lastIndexOf(Object)
- */
- public int lastIndexOf(Object value) {
- read();
- return list.lastIndexOf(value);
- }
-
- /**
- * @see java.util.List#listIterator()
- */
- public ListIterator listIterator() {
- read();
- return new ListIteratorProxy( list.listIterator() );
- }
-
- /**
- * @see java.util.List#listIterator(int)
- */
- public ListIterator listIterator(int index) {
- read();
- return new ListIteratorProxy( list.listIterator(index) );
- }
-
- /**
- * @see java.util.List#subList(int, int)
- */
- public java.util.List subList(int from, int to) {
- read();
- return new ListProxy( list.subList(from, to) );
- }
-
- public boolean empty() {
- return list.isEmpty();
- }
-
- public String toString() {
- read();
- return list.toString();
- }
-
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
- int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
-
- //pad with nulls from the current last element up to the new index
- for ( int i = list.size(); i<=index; i++) {
- list.add(i, null);
- }
-
- list.set(index, element);
- return element;
- }
-
- public Iterator entries(CollectionPersister persister) {
- return list.iterator();
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
- Serializable[] array = ( Serializable[] ) disassembled;
- int size = array.length;
- beforeInitialize( persister, size );
- for ( int i = 0; i < size; i++ ) {
- list.add( persister.getElementType().assemble( array[i], getSession(), owner ) );
- }
- }
-
- public Serializable disassemble(CollectionPersister persister)
- throws HibernateException {
-
- int length = list.size();
- Serializable[] result = new Serializable[length];
- for ( int i=0; i<length; i++ ) {
- result[i] = persister.getElementType().disassemble( list.get(i), getSession(), null );
- }
- return result;
- }
-
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
- List deletes = new ArrayList();
- List sn = (List) getSnapshot();
- int end;
- if ( sn.size() > list.size() ) {
- for ( int i=list.size(); i<sn.size(); i++ ) {
- deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) );
- }
- end = list.size();
- }
- else {
- end = sn.size();
- }
- for ( int i=0; i<end; i++ ) {
- if ( list.get(i)==null && sn.get(i)!=null ) {
- deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) );
- }
- }
- return deletes.iterator();
- }
-
- public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
- final List sn = (List) getSnapshot();
- return list.get(i)!=null && ( i >= sn.size() || sn.get(i)==null );
- }
-
- public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
- final List sn = (List) getSnapshot();
- return i<sn.size() && sn.get(i)!=null && list.get(i)!=null &&
- elemType.isDirty( list.get(i), sn.get(i), getSession() );
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- return new Integer(i);
- }
-
- public Object getElement(Object entry) {
- return entry;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- final List sn = (List) getSnapshot();
- return sn.get(i);
- }
-
- public boolean equals(Object other) {
- read();
- return list.equals(other);
- }
-
- public int hashCode() {
- read();
- return list.hashCode();
- }
-
- public boolean entryExists(Object entry, int i) {
- return entry!=null;
- }
-
- final class Clear implements DelayedOperation {
- public void operate() {
- list.clear();
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
- }
- }
-
- final class SimpleAdd implements DelayedOperation {
- private Object value;
-
- public SimpleAdd(Object value) {
- this.value = value;
- }
- public void operate() {
- list.add(value);
- }
- public Object getAddedInstance() {
- return value;
- }
- public Object getOrphan() {
- return null;
- }
- }
-
- final class Add implements DelayedOperation {
- private int index;
- private Object value;
-
- public Add(int index, Object value) {
- this.index = index;
- this.value = value;
- }
- public void operate() {
- list.add(index, value);
- }
- public Object getAddedInstance() {
- return value;
- }
- public Object getOrphan() {
- return null;
- }
- }
-
- final class Set implements DelayedOperation {
- private int index;
- private Object value;
- private Object old;
-
- public Set(int index, Object value, Object old) {
- this.index = index;
- this.value = value;
- this.old = old;
- }
- public void operate() {
- list.set(index, value);
- }
- public Object getAddedInstance() {
- return value;
- }
- public Object getOrphan() {
- return old;
- }
- }
-
- final class Remove implements DelayedOperation {
- private int index;
- private Object old;
-
- public Remove(int index, Object old) {
- this.index = index;
- this.old = old;
- }
- public void operate() {
- list.remove(index);
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- return old;
- }
- }
-
- final class SimpleRemove implements DelayedOperation {
- private Object value;
-
- public SimpleRemove(Object value) {
- this.value = value;
- }
- public void operate() {
- list.remove(value);
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- return value;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentList.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentList.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,602 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * A persistent wrapper for a <tt>java.util.List</tt>. Underlying
+ * collection is an <tt>ArrayList</tt>.
+ *
+ * @see java.util.ArrayList
+ * @author Gavin King
+ */
+public class PersistentList extends AbstractPersistentCollection implements List {
+
+ protected List list;
+
+ public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
+
+ EntityMode entityMode = getSession().getEntityMode();
+
+ ArrayList clonedList = new ArrayList( list.size() );
+ Iterator iter = list.iterator();
+ while ( iter.hasNext() ) {
+ Object deepCopy = persister.getElementType()
+ .deepCopy( iter.next(), entityMode, persister.getFactory() );
+ clonedList.add( deepCopy );
+ }
+ return clonedList;
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
+ List sn = (List) snapshot;
+ return getOrphans( sn, list, entityName, getSession() );
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ List sn = (List) getSnapshot();
+ if ( sn.size()!=this.list.size() ) return false;
+ Iterator iter = list.iterator();
+ Iterator sniter = sn.iterator();
+ while ( iter.hasNext() ) {
+ if ( elementType.isDirty( iter.next(), sniter.next(), getSession() ) ) return false;
+ }
+ return true;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (Collection) snapshot ).isEmpty();
+ }
+
+ public PersistentList(SessionImplementor session) {
+ super(session);
+ }
+
+ public PersistentList(SessionImplementor session, List list) {
+ super(session);
+ this.list = list;
+ setInitialized();
+ setDirectlyAccessible(true);
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
+ this.list = ( List ) persister.getCollectionType().instantiate( anticipatedSize );
+ }
+
+ public boolean isWrapper(Object collection) {
+ return list==collection;
+ }
+
+ public PersistentList() {} //needed for SOAP libraries, etc
+
+ /**
+ * @see java.util.List#size()
+ */
+ public int size() {
+ return readSize() ? getCachedSize() : list.size();
+ }
+
+ /**
+ * @see java.util.List#isEmpty()
+ */
+ public boolean isEmpty() {
+ return readSize() ? getCachedSize()==0 : list.isEmpty();
+ }
+
+ /**
+ * @see java.util.List#contains(Object)
+ */
+ public boolean contains(Object object) {
+ Boolean exists = readElementExistence(object);
+ return exists==null ?
+ list.contains(object) :
+ exists.booleanValue();
+ }
+
+ /**
+ * @see java.util.List#iterator()
+ */
+ public Iterator iterator() {
+ read();
+ return new IteratorProxy( list.iterator() );
+ }
+
+ /**
+ * @see java.util.List#toArray()
+ */
+ public Object[] toArray() {
+ read();
+ return list.toArray();
+ }
+
+ /**
+ * @see java.util.List#toArray(Object[])
+ */
+ public Object[] toArray(Object[] array) {
+ read();
+ return list.toArray(array);
+ }
+
+ /**
+ * @see java.util.List#add(Object)
+ */
+ public boolean add(Object object) {
+ if ( !isOperationQueueEnabled() ) {
+ write();
+ return list.add(object);
+ }
+ else {
+ queueOperation( new SimpleAdd(object) );
+ return true;
+ }
+ }
+
+ /**
+ * @see java.util.List#remove(Object)
+ */
+ public boolean remove(Object value) {
+ Boolean exists = isPutQueueEnabled() ? readElementExistence(value) : null;
+ if ( exists == null ) {
+ initialize( true );
+ if ( list.remove( value ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else if ( exists.booleanValue() ) {
+ queueOperation( new SimpleRemove(value) );
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.List#containsAll(Collection)
+ */
+ public boolean containsAll(Collection coll) {
+ read();
+ return list.containsAll(coll);
+ }
+
+ /**
+ * @see java.util.List#addAll(Collection)
+ */
+ public boolean addAll(Collection values) {
+ if ( values.size()==0 ) {
+ return false;
+ }
+ if ( !isOperationQueueEnabled() ) {
+ write();
+ return list.addAll(values);
+ }
+ else {
+ Iterator iter = values.iterator();
+ while ( iter.hasNext() ) {
+ queueOperation( new SimpleAdd( iter.next() ) );
+ }
+ return values.size()>0;
+ }
+ }
+
+ /**
+ * @see java.util.List#addAll(int, Collection)
+ */
+ public boolean addAll(int index, Collection coll) {
+ if ( coll.size()>0 ) {
+ write();
+ return list.addAll(index, coll);
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.List#removeAll(Collection)
+ */
+ public boolean removeAll(Collection coll) {
+ if ( coll.size()>0 ) {
+ initialize( true );
+ if ( list.removeAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.List#retainAll(Collection)
+ */
+ public boolean retainAll(Collection coll) {
+ initialize( true );
+ if ( list.retainAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.List#clear()
+ */
+ public void clear() {
+ if ( isClearQueueEnabled() ) {
+ queueOperation( new Clear() );
+ }
+ else {
+ initialize( true );
+ if ( ! list.isEmpty() ) {
+ list.clear();
+ dirty();
+ }
+ }
+ }
+
+ /**
+ * @see java.util.List#get(int)
+ */
+ public Object get(int index) {
+ if (index<0) {
+ throw new ArrayIndexOutOfBoundsException("negative index");
+ }
+ Object result = readElementByIndex( new Integer(index) );
+ return result==UNKNOWN ? list.get(index) : result;
+ }
+
+ /**
+ * @see java.util.List#set(int, Object)
+ */
+ public Object set(int index, Object value) {
+ if (index<0) {
+ throw new ArrayIndexOutOfBoundsException("negative index");
+ }
+ Object old = isPutQueueEnabled() ? readElementByIndex( new Integer(index) ) : UNKNOWN;
+ if ( old==UNKNOWN ) {
+ write();
+ return list.set(index, value);
+ }
+ else {
+ queueOperation( new Set(index, value, old) );
+ return old;
+ }
+ }
+
+ /**
+ * @see java.util.List#add(int, Object)
+ */
+ public void add(int index, Object value) {
+ if (index<0) {
+ throw new ArrayIndexOutOfBoundsException("negative index");
+ }
+ if ( !isOperationQueueEnabled() ) {
+ write();
+ list.add(index, value);
+ }
+ else {
+ queueOperation( new Add(index, value) );
+ }
+ }
+
+ /**
+ * @see java.util.List#remove(int)
+ */
+ public Object remove(int index) {
+ if (index<0) {
+ throw new ArrayIndexOutOfBoundsException("negative index");
+ }
+ Object old = isPutQueueEnabled() ?
+ readElementByIndex( new Integer(index) ) : UNKNOWN;
+ if ( old==UNKNOWN ) {
+ write();
+ return list.remove(index);
+ }
+ else {
+ queueOperation( new Remove(index, old) );
+ return old;
+ }
+ }
+
+ /**
+ * @see java.util.List#indexOf(Object)
+ */
+ public int indexOf(Object value) {
+ read();
+ return list.indexOf(value);
+ }
+
+ /**
+ * @see java.util.List#lastIndexOf(Object)
+ */
+ public int lastIndexOf(Object value) {
+ read();
+ return list.lastIndexOf(value);
+ }
+
+ /**
+ * @see java.util.List#listIterator()
+ */
+ public ListIterator listIterator() {
+ read();
+ return new ListIteratorProxy( list.listIterator() );
+ }
+
+ /**
+ * @see java.util.List#listIterator(int)
+ */
+ public ListIterator listIterator(int index) {
+ read();
+ return new ListIteratorProxy( list.listIterator(index) );
+ }
+
+ /**
+ * @see java.util.List#subList(int, int)
+ */
+ public java.util.List subList(int from, int to) {
+ read();
+ return new ListProxy( list.subList(from, to) );
+ }
+
+ public boolean empty() {
+ return list.isEmpty();
+ }
+
+ public String toString() {
+ read();
+ return list.toString();
+ }
+
+ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException {
+ Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
+ int index = ( (Integer) persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() ) ).intValue();
+
+ //pad with nulls from the current last element up to the new index
+ for ( int i = list.size(); i<=index; i++) {
+ list.add(i, null);
+ }
+
+ list.set(index, element);
+ return element;
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+ return list.iterator();
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+ Serializable[] array = ( Serializable[] ) disassembled;
+ int size = array.length;
+ beforeInitialize( persister, size );
+ for ( int i = 0; i < size; i++ ) {
+ list.add( persister.getElementType().assemble( array[i], getSession(), owner ) );
+ }
+ }
+
+ public Serializable disassemble(CollectionPersister persister)
+ throws HibernateException {
+
+ int length = list.size();
+ Serializable[] result = new Serializable[length];
+ for ( int i=0; i<length; i++ ) {
+ result[i] = persister.getElementType().disassemble( list.get(i), getSession(), null );
+ }
+ return result;
+ }
+
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
+ List deletes = new ArrayList();
+ List sn = (List) getSnapshot();
+ int end;
+ if ( sn.size() > list.size() ) {
+ for ( int i=list.size(); i<sn.size(); i++ ) {
+ deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) );
+ }
+ end = list.size();
+ }
+ else {
+ end = sn.size();
+ }
+ for ( int i=0; i<end; i++ ) {
+ if ( list.get(i)==null && sn.get(i)!=null ) {
+ deletes.add( indexIsFormula ? sn.get(i) : new Integer(i) );
+ }
+ }
+ return deletes.iterator();
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
+ final List sn = (List) getSnapshot();
+ return list.get(i)!=null && ( i >= sn.size() || sn.get(i)==null );
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
+ final List sn = (List) getSnapshot();
+ return i<sn.size() && sn.get(i)!=null && list.get(i)!=null &&
+ elemType.isDirty( list.get(i), sn.get(i), getSession() );
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ return new Integer(i);
+ }
+
+ public Object getElement(Object entry) {
+ return entry;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ final List sn = (List) getSnapshot();
+ return sn.get(i);
+ }
+
+ public boolean equals(Object other) {
+ read();
+ return list.equals(other);
+ }
+
+ public int hashCode() {
+ read();
+ return list.hashCode();
+ }
+
+ public boolean entryExists(Object entry, int i) {
+ return entry!=null;
+ }
+
+ final class Clear implements DelayedOperation {
+ public void operate() {
+ list.clear();
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
+ }
+ }
+
+ final class SimpleAdd implements DelayedOperation {
+ private Object value;
+
+ public SimpleAdd(Object value) {
+ this.value = value;
+ }
+ public void operate() {
+ list.add(value);
+ }
+ public Object getAddedInstance() {
+ return value;
+ }
+ public Object getOrphan() {
+ return null;
+ }
+ }
+
+ final class Add implements DelayedOperation {
+ private int index;
+ private Object value;
+
+ public Add(int index, Object value) {
+ this.index = index;
+ this.value = value;
+ }
+ public void operate() {
+ list.add(index, value);
+ }
+ public Object getAddedInstance() {
+ return value;
+ }
+ public Object getOrphan() {
+ return null;
+ }
+ }
+
+ final class Set implements DelayedOperation {
+ private int index;
+ private Object value;
+ private Object old;
+
+ public Set(int index, Object value, Object old) {
+ this.index = index;
+ this.value = value;
+ this.old = old;
+ }
+ public void operate() {
+ list.set(index, value);
+ }
+ public Object getAddedInstance() {
+ return value;
+ }
+ public Object getOrphan() {
+ return old;
+ }
+ }
+
+ final class Remove implements DelayedOperation {
+ private int index;
+ private Object old;
+
+ public Remove(int index, Object old) {
+ this.index = index;
+ this.old = old;
+ }
+ public void operate() {
+ list.remove(index);
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ return old;
+ }
+ }
+
+ final class SimpleRemove implements DelayedOperation {
+ private Object value;
+
+ public SimpleRemove(Object value) {
+ this.value = value;
+ }
+ public void operate() {
+ list.remove(value);
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ return value;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,60 +0,0 @@
-//$Id: PersistentListElementHolder.java 6838 2005-05-20 19:50:07Z oneovthafew $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.dom4j.Element;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-/**
- * @author Gavin King
- */
-public class PersistentListElementHolder extends PersistentIndexedElementHolder {
-
- public PersistentListElementHolder(SessionImplementor session, Element element) {
- super( session, element );
- }
-
- public PersistentListElementHolder(SessionImplementor session, CollectionPersister persister,
- Serializable key) throws HibernateException {
- super( session, persister, key );
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
-
- Type elementType = persister.getElementType();
- final String indexNodeName = getIndexAttributeName(persister);
- Serializable[] cached = (Serializable[]) disassembled;
- for ( int i=0; i<cached.length; i++ ) {
- Object object = elementType.assemble( cached[i], getSession(), owner );
- Element subelement = element.addElement( persister.getElementNodeName() );
- elementType.setToXMLNode( subelement, object, persister.getFactory() );
- setIndex( subelement, indexNodeName, Integer.toString(i) );
- }
-
- }
-
- public Serializable disassemble(CollectionPersister persister) throws HibernateException {
-
- Type elementType = persister.getElementType();
- final String indexNodeName = getIndexAttributeName(persister);
- List elements = element.elements( persister.getElementNodeName() );
- int length = elements.size();
- Serializable[] result = new Serializable[length];
- for ( int i=0; i<length; i++ ) {
- Element elem = (Element) elements.get(i);
- Object object = elementType.fromXMLNode( elem, persister.getFactory() );
- Integer index = (Integer) Hibernate.INTEGER.fromStringValue( getIndex(elem, indexNodeName, i) );
- result[ index.intValue() ] = elementType.disassemble( object, getSession(), null );
- }
- return result;
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentListElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.dom4j.Element;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * @author Gavin King
+ */
+public class PersistentListElementHolder extends PersistentIndexedElementHolder {
+
+ public PersistentListElementHolder(SessionImplementor session, Element element) {
+ super( session, element );
+ }
+
+ public PersistentListElementHolder(SessionImplementor session, CollectionPersister persister,
+ Serializable key) throws HibernateException {
+ super( session, persister, key );
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ final String indexNodeName = getIndexAttributeName(persister);
+ Serializable[] cached = (Serializable[]) disassembled;
+ for ( int i=0; i<cached.length; i++ ) {
+ Object object = elementType.assemble( cached[i], getSession(), owner );
+ Element subelement = element.addElement( persister.getElementNodeName() );
+ elementType.setToXMLNode( subelement, object, persister.getFactory() );
+ setIndex( subelement, indexNodeName, Integer.toString(i) );
+ }
+
+ }
+
+ public Serializable disassemble(CollectionPersister persister) throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ final String indexNodeName = getIndexAttributeName(persister);
+ List elements = element.elements( persister.getElementNodeName() );
+ int length = elements.size();
+ Serializable[] result = new Serializable[length];
+ for ( int i=0; i<length; i++ ) {
+ Element elem = (Element) elements.get(i);
+ Object object = elementType.fromXMLNode( elem, persister.getFactory() );
+ Integer index = (Integer) Hibernate.INTEGER.fromStringValue( getIndex(elem, indexNodeName, i) );
+ result[ index.intValue() ] = elementType.disassemble( object, getSession(), null );
+ }
+ return result;
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,491 +0,0 @@
-//$Id: PersistentMap.java 11255 2007-03-07 19:30:27Z steve.ebersole(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-
-/**
- * A persistent wrapper for a <tt>java.util.Map</tt>. Underlying collection
- * is a <tt>HashMap</tt>.
- *
- * @see java.util.HashMap
- * @author Gavin King
- */
-public class PersistentMap extends AbstractPersistentCollection implements Map {
-
- protected Map map;
-
- /**
- * Empty constructor.
- * <p/>
- * Note: this form is not ever ever ever used by Hibernate; it is, however,
- * needed for SOAP libraries and other such marshalling code.
- */
- public PersistentMap() {
- // intentionally empty
- }
-
- /**
- * Instantiates a lazy map (the underlying map is un-initialized).
- *
- * @param session The session to which this map will belong.
- */
- public PersistentMap(SessionImplementor session) {
- super(session);
- }
-
- /**
- * Instantiates a non-lazy map (the underlying map is constructed
- * from the incoming map reference).
- *
- * @param session The session to which this map will belong.
- * @param map The underlying map data.
- */
- public PersistentMap(SessionImplementor session, Map map) {
- super(session);
- this.map = map;
- setInitialized();
- setDirectlyAccessible(true);
- }
-
- public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
- EntityMode entityMode = getSession().getEntityMode();
- HashMap clonedMap = new HashMap( map.size() );
- Iterator iter = map.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry e = (Map.Entry) iter.next();
- final Object copy = persister.getElementType()
- .deepCopy( e.getValue(), entityMode, persister.getFactory() );
- clonedMap.put( e.getKey(), copy );
- }
- return clonedMap;
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
- Map sn = (Map) snapshot;
- return getOrphans( sn.values(), map.values(), entityName, getSession() );
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- Map xmap = (Map) getSnapshot();
- if ( xmap.size()!=this.map.size() ) return false;
- Iterator iter = map.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry entry = (Map.Entry) iter.next();
- if ( elementType.isDirty( entry.getValue(), xmap.get( entry.getKey() ), getSession() ) ) return false;
- }
- return true;
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (Map) snapshot ).isEmpty();
- }
-
- public boolean isWrapper(Object collection) {
- return map==collection;
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
- this.map = ( Map ) persister.getCollectionType().instantiate( anticipatedSize );
- }
-
-
- /**
- * @see java.util.Map#size()
- */
- public int size() {
- return readSize() ? getCachedSize() : map.size();
- }
-
- /**
- * @see java.util.Map#isEmpty()
- */
- public boolean isEmpty() {
- return readSize() ? getCachedSize()==0 : map.isEmpty();
- }
-
- /**
- * @see java.util.Map#containsKey(Object)
- */
- public boolean containsKey(Object key) {
- Boolean exists = readIndexExistence(key);
- return exists==null ? map.containsKey(key) : exists.booleanValue();
- }
-
- /**
- * @see java.util.Map#containsValue(Object)
- */
- public boolean containsValue(Object value) {
- Boolean exists = readElementExistence(value);
- return exists==null ?
- map.containsValue(value) :
- exists.booleanValue();
- }
-
- /**
- * @see java.util.Map#get(Object)
- */
- public Object get(Object key) {
- Object result = readElementByIndex(key);
- return result==UNKNOWN ? map.get(key) : result;
- }
-
- /**
- * @see java.util.Map#put(Object, Object)
- */
- public Object put(Object key, Object value) {
- if ( isPutQueueEnabled() ) {
- Object old = readElementByIndex( key );
- if ( old != UNKNOWN ) {
- queueOperation( new Put( key, value, old ) );
- return old;
- }
- }
- initialize( true );
- Object old = map.put( key, value );
- // would be better to use the element-type to determine
- // whether the old and the new are equal here; the problem being
- // we do not necessarily have access to the element type in all
- // cases
- if ( value != old ) {
- dirty();
- }
- return old;
- }
-
- /**
- * @see java.util.Map#remove(Object)
- */
- public Object remove(Object key) {
- if ( isPutQueueEnabled() ) {
- Object old = readElementByIndex( key );
- queueOperation( new Remove( key, old ) );
- return old;
- }
- else {
- // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
- initialize( true );
- if ( map.containsKey( key ) ) {
- dirty();
- }
- return map.remove( key );
- }
- }
-
- /**
- * @see java.util.Map#putAll(java.util.Map puts)
- */
- public void putAll(Map puts) {
- if ( puts.size()>0 ) {
- initialize( true );
- Iterator itr = puts.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Entry ) itr.next();
- put( entry.getKey(), entry.getValue() );
- }
- }
- }
-
- /**
- * @see java.util.Map#clear()
- */
- public void clear() {
- if ( isClearQueueEnabled() ) {
- queueOperation( new Clear() );
- }
- else {
- initialize( true );
- if ( ! map.isEmpty() ) {
- dirty();
- map.clear();
- }
- }
- }
-
- /**
- * @see java.util.Map#keySet()
- */
- public Set keySet() {
- read();
- return new SetProxy( map.keySet() );
- }
-
- /**
- * @see java.util.Map#values()
- */
- public Collection values() {
- read();
- return new SetProxy( map.values() );
- }
-
- /**
- * @see java.util.Map#entrySet()
- */
- public Set entrySet() {
- read();
- return new EntrySetProxy( map.entrySet() );
- }
-
- public boolean empty() {
- return map.isEmpty();
- }
-
- public String toString() {
- read();
- return map.toString();
- }
-
- public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
- throws HibernateException, SQLException {
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
- if ( element!=null ) map.put(index, element);
- return element;
- }
-
- public Iterator entries(CollectionPersister persister) {
- return map.entrySet().iterator();
- }
-
- /** a wrapper for Map.Entry sets */
- class EntrySetProxy implements Set {
- private final Set set;
- EntrySetProxy(Set set) {
- this.set=set;
- }
- public boolean add(Object entry) {
- //write(); -- doesn't
- return set.add(entry);
- }
- public boolean addAll(Collection entries) {
- //write(); -- doesn't
- return set.addAll(entries);
- }
- public void clear() {
- write();
- set.clear();
- }
- public boolean contains(Object entry) {
- return set.contains(entry);
- }
- public boolean containsAll(Collection entries) {
- return set.containsAll(entries);
- }
- public boolean isEmpty() {
- return set.isEmpty();
- }
- public Iterator iterator() {
- return new EntryIteratorProxy( set.iterator() );
- }
- public boolean remove(Object entry) {
- write();
- return set.remove(entry);
- }
- public boolean removeAll(Collection entries) {
- write();
- return set.removeAll(entries);
- }
- public boolean retainAll(Collection entries) {
- write();
- return set.retainAll(entries);
- }
- public int size() {
- return set.size();
- }
- // amazingly, these two will work because AbstractCollection
- // uses iterator() to fill the array
- public Object[] toArray() {
- return set.toArray();
- }
- public Object[] toArray(Object[] array) {
- return set.toArray(array);
- }
- }
- final class EntryIteratorProxy implements Iterator {
- private final Iterator iter;
- EntryIteratorProxy(Iterator iter) {
- this.iter=iter;
- }
- public boolean hasNext() {
- return iter.hasNext();
- }
- public Object next() {
- return new MapEntryProxy( (Map.Entry) iter.next() );
- }
- public void remove() {
- write();
- iter.remove();
- }
- }
-
- final class MapEntryProxy implements Map.Entry {
- private final Map.Entry me;
- MapEntryProxy( Map.Entry me ) {
- this.me = me;
- }
- public Object getKey() { return me.getKey(); }
- public Object getValue() { return me.getValue(); }
- public boolean equals(Object o) { return me.equals(o); }
- public int hashCode() { return me.hashCode(); }
- // finally, what it's all about...
- public Object setValue(Object value) {
- write();
- return me.setValue(value);
- }
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
- Serializable[] array = ( Serializable[] ) disassembled;
- int size = array.length;
- beforeInitialize( persister, size );
- for ( int i = 0; i < size; i+=2 ) {
- map.put(
- persister.getIndexType().assemble( array[i], getSession(), owner ),
- persister.getElementType().assemble( array[i+1], getSession(), owner )
- );
- }
- }
-
- public Serializable disassemble(CollectionPersister persister) throws HibernateException {
-
- Serializable[] result = new Serializable[ map.size() * 2 ];
- Iterator iter = map.entrySet().iterator();
- int i=0;
- while ( iter.hasNext() ) {
- Map.Entry e = (Map.Entry) iter.next();
- result[i++] = persister.getIndexType().disassemble( e.getKey(), getSession(), null );
- result[i++] = persister.getElementType().disassemble( e.getValue(), getSession(), null );
- }
- return result;
-
- }
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
- throws HibernateException {
- List deletes = new ArrayList();
- Iterator iter = ( (Map) getSnapshot() ).entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry e = (Map.Entry) iter.next();
- Object key = e.getKey();
- if ( e.getValue()!=null && map.get(key)==null ) {
- deletes.add( indexIsFormula ? e.getValue() : key );
- }
- }
- return deletes.iterator();
- }
-
- public boolean needsInserting(Object entry, int i, Type elemType)
- throws HibernateException {
- final Map sn = (Map) getSnapshot();
- Map.Entry e = (Map.Entry) entry;
- return e.getValue()!=null && sn.get( e.getKey() )==null;
- }
-
- public boolean needsUpdating(Object entry, int i, Type elemType)
- throws HibernateException {
- final Map sn = (Map) getSnapshot();
- Map.Entry e = (Map.Entry) entry;
- Object snValue = sn.get( e.getKey() );
- return e.getValue()!=null &&
- snValue!=null &&
- elemType.isDirty( snValue, e.getValue(), getSession() );
- }
-
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- return ( (Map.Entry) entry ).getKey();
- }
-
- public Object getElement(Object entry) {
- return ( (Map.Entry) entry ).getValue();
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- final Map sn = (Map) getSnapshot();
- return sn.get( ( (Map.Entry) entry ).getKey() );
- }
-
- public boolean equals(Object other) {
- read();
- return map.equals(other);
- }
-
- public int hashCode() {
- read();
- return map.hashCode();
- }
-
- public boolean entryExists(Object entry, int i) {
- return ( (Map.Entry) entry ).getValue()!=null;
- }
-
- final class Clear implements DelayedOperation {
- public void operate() {
- map.clear();
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
- }
- }
-
- final class Put implements DelayedOperation {
- private Object index;
- private Object value;
- private Object old;
-
- public Put(Object index, Object value, Object old) {
- this.index = index;
- this.value = value;
- this.old = old;
- }
- public void operate() {
- map.put(index, value);
- }
- public Object getAddedInstance() {
- return value;
- }
- public Object getOrphan() {
- return old;
- }
- }
-
- final class Remove implements DelayedOperation {
- private Object index;
- private Object old;
-
- public Remove(Object index, Object old) {
- this.index = index;
- this.old = old;
- }
- public void operate() {
- map.remove(index);
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- return old;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMap.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,514 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+
+/**
+ * A persistent wrapper for a <tt>java.util.Map</tt>. Underlying collection
+ * is a <tt>HashMap</tt>.
+ *
+ * @see java.util.HashMap
+ * @author Gavin King
+ */
+public class PersistentMap extends AbstractPersistentCollection implements Map {
+
+ protected Map map;
+
+ /**
+ * Empty constructor.
+ * <p/>
+ * Note: this form is not ever ever ever used by Hibernate; it is, however,
+ * needed for SOAP libraries and other such marshalling code.
+ */
+ public PersistentMap() {
+ // intentionally empty
+ }
+
+ /**
+ * Instantiates a lazy map (the underlying map is un-initialized).
+ *
+ * @param session The session to which this map will belong.
+ */
+ public PersistentMap(SessionImplementor session) {
+ super(session);
+ }
+
+ /**
+ * Instantiates a non-lazy map (the underlying map is constructed
+ * from the incoming map reference).
+ *
+ * @param session The session to which this map will belong.
+ * @param map The underlying map data.
+ */
+ public PersistentMap(SessionImplementor session, Map map) {
+ super(session);
+ this.map = map;
+ setInitialized();
+ setDirectlyAccessible(true);
+ }
+
+ public Serializable getSnapshot(CollectionPersister persister) throws HibernateException {
+ EntityMode entityMode = getSession().getEntityMode();
+ HashMap clonedMap = new HashMap( map.size() );
+ Iterator iter = map.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry e = (Map.Entry) iter.next();
+ final Object copy = persister.getElementType()
+ .deepCopy( e.getValue(), entityMode, persister.getFactory() );
+ clonedMap.put( e.getKey(), copy );
+ }
+ return clonedMap;
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
+ Map sn = (Map) snapshot;
+ return getOrphans( sn.values(), map.values(), entityName, getSession() );
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ Map xmap = (Map) getSnapshot();
+ if ( xmap.size()!=this.map.size() ) return false;
+ Iterator iter = map.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ if ( elementType.isDirty( entry.getValue(), xmap.get( entry.getKey() ), getSession() ) ) return false;
+ }
+ return true;
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (Map) snapshot ).isEmpty();
+ }
+
+ public boolean isWrapper(Object collection) {
+ return map==collection;
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
+ this.map = ( Map ) persister.getCollectionType().instantiate( anticipatedSize );
+ }
+
+
+ /**
+ * @see java.util.Map#size()
+ */
+ public int size() {
+ return readSize() ? getCachedSize() : map.size();
+ }
+
+ /**
+ * @see java.util.Map#isEmpty()
+ */
+ public boolean isEmpty() {
+ return readSize() ? getCachedSize()==0 : map.isEmpty();
+ }
+
+ /**
+ * @see java.util.Map#containsKey(Object)
+ */
+ public boolean containsKey(Object key) {
+ Boolean exists = readIndexExistence(key);
+ return exists==null ? map.containsKey(key) : exists.booleanValue();
+ }
+
+ /**
+ * @see java.util.Map#containsValue(Object)
+ */
+ public boolean containsValue(Object value) {
+ Boolean exists = readElementExistence(value);
+ return exists==null ?
+ map.containsValue(value) :
+ exists.booleanValue();
+ }
+
+ /**
+ * @see java.util.Map#get(Object)
+ */
+ public Object get(Object key) {
+ Object result = readElementByIndex(key);
+ return result==UNKNOWN ? map.get(key) : result;
+ }
+
+ /**
+ * @see java.util.Map#put(Object, Object)
+ */
+ public Object put(Object key, Object value) {
+ if ( isPutQueueEnabled() ) {
+ Object old = readElementByIndex( key );
+ if ( old != UNKNOWN ) {
+ queueOperation( new Put( key, value, old ) );
+ return old;
+ }
+ }
+ initialize( true );
+ Object old = map.put( key, value );
+ // would be better to use the element-type to determine
+ // whether the old and the new are equal here; the problem being
+ // we do not necessarily have access to the element type in all
+ // cases
+ if ( value != old ) {
+ dirty();
+ }
+ return old;
+ }
+
+ /**
+ * @see java.util.Map#remove(Object)
+ */
+ public Object remove(Object key) {
+ if ( isPutQueueEnabled() ) {
+ Object old = readElementByIndex( key );
+ queueOperation( new Remove( key, old ) );
+ return old;
+ }
+ else {
+ // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
+ initialize( true );
+ if ( map.containsKey( key ) ) {
+ dirty();
+ }
+ return map.remove( key );
+ }
+ }
+
+ /**
+ * @see java.util.Map#putAll(java.util.Map puts)
+ */
+ public void putAll(Map puts) {
+ if ( puts.size()>0 ) {
+ initialize( true );
+ Iterator itr = puts.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Entry ) itr.next();
+ put( entry.getKey(), entry.getValue() );
+ }
+ }
+ }
+
+ /**
+ * @see java.util.Map#clear()
+ */
+ public void clear() {
+ if ( isClearQueueEnabled() ) {
+ queueOperation( new Clear() );
+ }
+ else {
+ initialize( true );
+ if ( ! map.isEmpty() ) {
+ dirty();
+ map.clear();
+ }
+ }
+ }
+
+ /**
+ * @see java.util.Map#keySet()
+ */
+ public Set keySet() {
+ read();
+ return new SetProxy( map.keySet() );
+ }
+
+ /**
+ * @see java.util.Map#values()
+ */
+ public Collection values() {
+ read();
+ return new SetProxy( map.values() );
+ }
+
+ /**
+ * @see java.util.Map#entrySet()
+ */
+ public Set entrySet() {
+ read();
+ return new EntrySetProxy( map.entrySet() );
+ }
+
+ public boolean empty() {
+ return map.isEmpty();
+ }
+
+ public String toString() {
+ read();
+ return map.toString();
+ }
+
+ public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
+ throws HibernateException, SQLException {
+ Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ Object index = persister.readIndex( rs, descriptor.getSuffixedIndexAliases(), getSession() );
+ if ( element!=null ) map.put(index, element);
+ return element;
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+ return map.entrySet().iterator();
+ }
+
+ /** a wrapper for Map.Entry sets */
+ class EntrySetProxy implements Set {
+ private final Set set;
+ EntrySetProxy(Set set) {
+ this.set=set;
+ }
+ public boolean add(Object entry) {
+ //write(); -- doesn't
+ return set.add(entry);
+ }
+ public boolean addAll(Collection entries) {
+ //write(); -- doesn't
+ return set.addAll(entries);
+ }
+ public void clear() {
+ write();
+ set.clear();
+ }
+ public boolean contains(Object entry) {
+ return set.contains(entry);
+ }
+ public boolean containsAll(Collection entries) {
+ return set.containsAll(entries);
+ }
+ public boolean isEmpty() {
+ return set.isEmpty();
+ }
+ public Iterator iterator() {
+ return new EntryIteratorProxy( set.iterator() );
+ }
+ public boolean remove(Object entry) {
+ write();
+ return set.remove(entry);
+ }
+ public boolean removeAll(Collection entries) {
+ write();
+ return set.removeAll(entries);
+ }
+ public boolean retainAll(Collection entries) {
+ write();
+ return set.retainAll(entries);
+ }
+ public int size() {
+ return set.size();
+ }
+ // amazingly, these two will work because AbstractCollection
+ // uses iterator() to fill the array
+ public Object[] toArray() {
+ return set.toArray();
+ }
+ public Object[] toArray(Object[] array) {
+ return set.toArray(array);
+ }
+ }
+ final class EntryIteratorProxy implements Iterator {
+ private final Iterator iter;
+ EntryIteratorProxy(Iterator iter) {
+ this.iter=iter;
+ }
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+ public Object next() {
+ return new MapEntryProxy( (Map.Entry) iter.next() );
+ }
+ public void remove() {
+ write();
+ iter.remove();
+ }
+ }
+
+ final class MapEntryProxy implements Map.Entry {
+ private final Map.Entry me;
+ MapEntryProxy( Map.Entry me ) {
+ this.me = me;
+ }
+ public Object getKey() { return me.getKey(); }
+ public Object getValue() { return me.getValue(); }
+ public boolean equals(Object o) { return me.equals(o); }
+ public int hashCode() { return me.hashCode(); }
+ // finally, what it's all about...
+ public Object setValue(Object value) {
+ write();
+ return me.setValue(value);
+ }
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+ Serializable[] array = ( Serializable[] ) disassembled;
+ int size = array.length;
+ beforeInitialize( persister, size );
+ for ( int i = 0; i < size; i+=2 ) {
+ map.put(
+ persister.getIndexType().assemble( array[i], getSession(), owner ),
+ persister.getElementType().assemble( array[i+1], getSession(), owner )
+ );
+ }
+ }
+
+ public Serializable disassemble(CollectionPersister persister) throws HibernateException {
+
+ Serializable[] result = new Serializable[ map.size() * 2 ];
+ Iterator iter = map.entrySet().iterator();
+ int i=0;
+ while ( iter.hasNext() ) {
+ Map.Entry e = (Map.Entry) iter.next();
+ result[i++] = persister.getIndexType().disassemble( e.getKey(), getSession(), null );
+ result[i++] = persister.getElementType().disassemble( e.getValue(), getSession(), null );
+ }
+ return result;
+
+ }
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula)
+ throws HibernateException {
+ List deletes = new ArrayList();
+ Iterator iter = ( (Map) getSnapshot() ).entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry e = (Map.Entry) iter.next();
+ Object key = e.getKey();
+ if ( e.getValue()!=null && map.get(key)==null ) {
+ deletes.add( indexIsFormula ? e.getValue() : key );
+ }
+ }
+ return deletes.iterator();
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elemType)
+ throws HibernateException {
+ final Map sn = (Map) getSnapshot();
+ Map.Entry e = (Map.Entry) entry;
+ return e.getValue()!=null && sn.get( e.getKey() )==null;
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elemType)
+ throws HibernateException {
+ final Map sn = (Map) getSnapshot();
+ Map.Entry e = (Map.Entry) entry;
+ Object snValue = sn.get( e.getKey() );
+ return e.getValue()!=null &&
+ snValue!=null &&
+ elemType.isDirty( snValue, e.getValue(), getSession() );
+ }
+
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ return ( (Map.Entry) entry ).getKey();
+ }
+
+ public Object getElement(Object entry) {
+ return ( (Map.Entry) entry ).getValue();
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ final Map sn = (Map) getSnapshot();
+ return sn.get( ( (Map.Entry) entry ).getKey() );
+ }
+
+ public boolean equals(Object other) {
+ read();
+ return map.equals(other);
+ }
+
+ public int hashCode() {
+ read();
+ return map.hashCode();
+ }
+
+ public boolean entryExists(Object entry, int i) {
+ return ( (Map.Entry) entry ).getValue()!=null;
+ }
+
+ final class Clear implements DelayedOperation {
+ public void operate() {
+ map.clear();
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
+ }
+ }
+
+ final class Put implements DelayedOperation {
+ private Object index;
+ private Object value;
+ private Object old;
+
+ public Put(Object index, Object value, Object old) {
+ this.index = index;
+ this.value = value;
+ this.old = old;
+ }
+ public void operate() {
+ map.put(index, value);
+ }
+ public Object getAddedInstance() {
+ return value;
+ }
+ public Object getOrphan() {
+ return old;
+ }
+ }
+
+ final class Remove implements DelayedOperation {
+ private Object index;
+ private Object old;
+
+ public Remove(Object index, Object old) {
+ this.index = index;
+ this.old = old;
+ }
+ public void operate() {
+ map.remove(index);
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ return old;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,71 +0,0 @@
-//$Id: PersistentMapElementHolder.java 6838 2005-05-20 19:50:07Z oneovthafew $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.util.List;
-
-import org.dom4j.Element;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.NullableType;
-import org.hibernate.type.Type;
-
-/**
- * @author Gavin King
- */
-public class PersistentMapElementHolder extends PersistentIndexedElementHolder {
-
- public PersistentMapElementHolder(SessionImplementor session, Element element) {
- super( session, element );
- }
-
- public PersistentMapElementHolder(SessionImplementor session, CollectionPersister persister,
- Serializable key) throws HibernateException {
- super( session, persister, key );
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
-
- Type elementType = persister.getElementType();
- Type indexType = persister.getIndexType();
- final String indexNodeName = getIndexAttributeName(persister);
-
- Serializable[] cached = (Serializable[]) disassembled;
-
- for ( int i=0; i<cached.length; ) {
- Object index = indexType.assemble( cached[i++], getSession(), owner );
- Object object = elementType.assemble( cached[i++], getSession(), owner );
-
- Element subelement = element.addElement( persister.getElementNodeName() );
- elementType.setToXMLNode( subelement, object, persister.getFactory() );
-
- String indexString = ( (NullableType) indexType ).toXMLString( index, persister.getFactory() );
- setIndex( subelement, indexNodeName, indexString );
- }
-
- }
-
- public Serializable disassemble(CollectionPersister persister) throws HibernateException {
-
- Type elementType = persister.getElementType();
- Type indexType = persister.getIndexType();
- final String indexNodeName = getIndexAttributeName(persister);
-
- List elements = element.elements( persister.getElementNodeName() );
- int length = elements.size();
- Serializable[] result = new Serializable[length*2];
- for ( int i=0; i<length*2; ) {
- Element elem = (Element) elements.get(i/2);
- Object object = elementType.fromXMLNode( elem, persister.getFactory() );
- final String indexString = getIndex(elem, indexNodeName, i);
- Object index = ( (NullableType) indexType ).fromXMLString( indexString, persister.getFactory() );
- result[i++] = indexType.disassemble( index, getSession(), null );
- result[i++] = elementType.disassemble( object, getSession(), null );
- }
- return result;
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentMapElementHolder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,94 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.dom4j.Element;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.NullableType;
+import org.hibernate.type.Type;
+
+/**
+ * @author Gavin King
+ */
+public class PersistentMapElementHolder extends PersistentIndexedElementHolder {
+
+ public PersistentMapElementHolder(SessionImplementor session, Element element) {
+ super( session, element );
+ }
+
+ public PersistentMapElementHolder(SessionImplementor session, CollectionPersister persister,
+ Serializable key) throws HibernateException {
+ super( session, persister, key );
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ Type indexType = persister.getIndexType();
+ final String indexNodeName = getIndexAttributeName(persister);
+
+ Serializable[] cached = (Serializable[]) disassembled;
+
+ for ( int i=0; i<cached.length; ) {
+ Object index = indexType.assemble( cached[i++], getSession(), owner );
+ Object object = elementType.assemble( cached[i++], getSession(), owner );
+
+ Element subelement = element.addElement( persister.getElementNodeName() );
+ elementType.setToXMLNode( subelement, object, persister.getFactory() );
+
+ String indexString = ( (NullableType) indexType ).toXMLString( index, persister.getFactory() );
+ setIndex( subelement, indexNodeName, indexString );
+ }
+
+ }
+
+ public Serializable disassemble(CollectionPersister persister) throws HibernateException {
+
+ Type elementType = persister.getElementType();
+ Type indexType = persister.getIndexType();
+ final String indexNodeName = getIndexAttributeName(persister);
+
+ List elements = element.elements( persister.getElementNodeName() );
+ int length = elements.size();
+ Serializable[] result = new Serializable[length*2];
+ for ( int i=0; i<length*2; ) {
+ Element elem = (Element) elements.get(i/2);
+ Object object = elementType.fromXMLNode( elem, persister.getFactory() );
+ final String indexString = getIndex(elem, indexNodeName, i);
+ Object index = ( (NullableType) indexType ).fromXMLString( indexString, persister.getFactory() );
+ result[i++] = indexType.disassemble( index, getSession(), null );
+ result[i++] = elementType.disassemble( object, getSession(), null );
+ }
+ return result;
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentSet.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,468 +0,0 @@
-//$Id: PersistentSet.java 10589 2006-10-16 15:47:37Z max.andersen(a)jboss.com $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.loader.CollectionAliases;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.type.Type;
-
-
-/**
- * A persistent wrapper for a <tt>java.util.Set</tt>. The underlying
- * collection is a <tt>HashSet</tt>.
- *
- * @see java.util.HashSet
- * @author Gavin King
- */
-public class PersistentSet extends AbstractPersistentCollection implements java.util.Set {
-
- protected Set set;
- protected transient List tempList;
-
- /**
- * Empty constructor.
- * <p/>
- * Note: this form is not ever ever ever used by Hibernate; it is, however,
- * needed for SOAP libraries and other such marshalling code.
- */
- public PersistentSet() {
- // intentionally empty
- }
-
- /**
- * Constructor matching super. Instantiates a lazy set (the underlying
- * set is un-initialized).
- *
- * @param session The session to which this set will belong.
- */
- public PersistentSet(SessionImplementor session) {
- super( session );
- }
-
- /**
- * Instantiates a non-lazy set (the underlying set is constructed
- * from the incoming set reference).
- *
- * @param session The session to which this set will belong.
- * @param set The underlying set data.
- */
- public PersistentSet(SessionImplementor session, java.util.Set set) {
- super(session);
- // Sets can be just a view of a part of another collection.
- // do we need to copy it to be sure it won't be changing
- // underneath us?
- // ie. this.set.addAll(set);
- this.set = set;
- setInitialized();
- setDirectlyAccessible(true);
- }
-
-
- public Serializable getSnapshot(CollectionPersister persister)
- throws HibernateException {
- EntityMode entityMode = getSession().getEntityMode();
-
- //if (set==null) return new Set(session);
- HashMap clonedSet = new HashMap( set.size() );
- Iterator iter = set.iterator();
- while ( iter.hasNext() ) {
- Object copied = persister.getElementType()
- .deepCopy( iter.next(), entityMode, persister.getFactory() );
- clonedSet.put(copied, copied);
- }
- return clonedSet;
- }
-
- public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
- java.util.Map sn = (java.util.Map) snapshot;
- return getOrphans( sn.keySet(), set, entityName, getSession() );
- }
-
- public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
- Type elementType = persister.getElementType();
- java.util.Map sn = (java.util.Map) getSnapshot();
- if ( sn.size()!=set.size() ) {
- return false;
- }
- else {
- Iterator iter = set.iterator();
- while ( iter.hasNext() ) {
- Object test = iter.next();
- Object oldValue = sn.get(test);
- if ( oldValue==null || elementType.isDirty( oldValue, test, getSession() ) ) return false;
- }
- return true;
- }
- }
-
- public boolean isSnapshotEmpty(Serializable snapshot) {
- return ( (java.util.Map) snapshot ).isEmpty();
- }
-
- public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
- this.set = ( Set ) persister.getCollectionType().instantiate( anticipatedSize );
- }
-
- public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
- throws HibernateException {
- Serializable[] array = ( Serializable[] ) disassembled;
- int size = array.length;
- beforeInitialize( persister, size );
- for (int i = 0; i < size; i++ ) {
- Object element = persister.getElementType().assemble( array[i], getSession(), owner );
- if ( element != null ) {
- set.add( element );
- }
- }
- }
-
- public boolean empty() {
- return set.isEmpty();
- }
-
- /**
- * @see java.util.Set#size()
- */
- public int size() {
- return readSize() ? getCachedSize() : set.size();
- }
-
- /**
- * @see java.util.Set#isEmpty()
- */
- public boolean isEmpty() {
- return readSize() ? getCachedSize()==0 : set.isEmpty();
- }
-
- /**
- * @see java.util.Set#contains(Object)
- */
- public boolean contains(Object object) {
- Boolean exists = readElementExistence(object);
- return exists==null ?
- set.contains(object) :
- exists.booleanValue();
- }
-
- /**
- * @see java.util.Set#iterator()
- */
- public Iterator iterator() {
- read();
- return new IteratorProxy( set.iterator() );
- }
-
- /**
- * @see java.util.Set#toArray()
- */
- public Object[] toArray() {
- read();
- return set.toArray();
- }
-
- /**
- * @see java.util.Set#toArray(Object[])
- */
- public Object[] toArray(Object[] array) {
- read();
- return set.toArray(array);
- }
-
- /**
- * @see java.util.Set#add(Object)
- */
- public boolean add(Object value) {
- Boolean exists = isOperationQueueEnabled() ? readElementExistence( value ) : null;
- if ( exists == null ) {
- initialize( true );
- if ( set.add( value ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else if ( exists.booleanValue() ) {
- return false;
- }
- else {
- queueOperation( new SimpleAdd(value) );
- return true;
- }
- }
-
- /**
- * @see java.util.Set#remove(Object)
- */
- public boolean remove(Object value) {
- Boolean exists = isPutQueueEnabled() ? readElementExistence( value ) : null;
- if ( exists==null ) {
- initialize( true );
- if ( set.remove( value ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else if ( exists.booleanValue() ) {
- queueOperation( new SimpleRemove(value) );
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Set#containsAll(Collection)
- */
- public boolean containsAll(Collection coll) {
- read();
- return set.containsAll(coll);
- }
-
- /**
- * @see java.util.Set#addAll(Collection)
- */
- public boolean addAll(Collection coll) {
- if ( coll.size() > 0 ) {
- initialize( true );
- if ( set.addAll( coll ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Set#retainAll(Collection)
- */
- public boolean retainAll(Collection coll) {
- initialize( true );
- if ( set.retainAll( coll ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Set#removeAll(Collection)
- */
- public boolean removeAll(Collection coll) {
- if ( coll.size() > 0 ) {
- initialize( true );
- if ( set.removeAll( coll ) ) {
- dirty();
- return true;
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- }
-
- /**
- * @see java.util.Set#clear()
- */
- public void clear() {
- if ( isClearQueueEnabled() ) {
- queueOperation( new Clear() );
- }
- else {
- initialize( true );
- if ( !set.isEmpty() ) {
- set.clear();
- dirty();
- }
- }
- }
-
- public String toString() {
- //if (needLoading) return "asleep";
- read();
- return set.toString();
- }
-
- public Object readFrom(
- ResultSet rs,
- CollectionPersister persister,
- CollectionAliases descriptor,
- Object owner) throws HibernateException, SQLException {
- Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
- if (element!=null) tempList.add(element);
- return element;
- }
-
- public void beginRead() {
- super.beginRead();
- tempList = new ArrayList();
- }
-
- public boolean endRead() {
- set.addAll(tempList);
- tempList = null;
- setInitialized();
- return true;
- }
-
- public Iterator entries(CollectionPersister persister) {
- return set.iterator();
- }
-
- public Serializable disassemble(CollectionPersister persister)
- throws HibernateException {
-
- Serializable[] result = new Serializable[ set.size() ];
- Iterator iter = set.iterator();
- int i=0;
- while ( iter.hasNext() ) {
- result[i++] = persister.getElementType().disassemble( iter.next(), getSession(), null );
- }
- return result;
-
- }
-
- public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
- Type elementType = persister.getElementType();
- final java.util.Map sn = (java.util.Map) getSnapshot();
- ArrayList deletes = new ArrayList( sn.size() );
- Iterator iter = sn.keySet().iterator();
- while ( iter.hasNext() ) {
- Object test = iter.next();
- if ( !set.contains(test) ) {
- // the element has been removed from the set
- deletes.add(test);
- }
- }
- iter = set.iterator();
- while ( iter.hasNext() ) {
- Object test = iter.next();
- Object oldValue = sn.get(test);
- if ( oldValue!=null && elementType.isDirty( test, oldValue, getSession() ) ) {
- // the element has changed
- deletes.add(oldValue);
- }
- }
- return deletes.iterator();
- }
-
- public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
- final java.util.Map sn = (java.util.Map) getSnapshot();
- Object oldValue = sn.get(entry);
- // note that it might be better to iterate the snapshot but this is safe,
- // assuming the user implements equals() properly, as required by the Set
- // contract!
- return oldValue==null || elemType.isDirty( oldValue, entry, getSession() );
- }
-
- public boolean needsUpdating(Object entry, int i, Type elemType) {
- return false;
- }
-
- public boolean isRowUpdatePossible() {
- return false;
- }
-
- public Object getIndex(Object entry, int i, CollectionPersister persister) {
- throw new UnsupportedOperationException("Sets don't have indexes");
- }
-
- public Object getElement(Object entry) {
- return entry;
- }
-
- public Object getSnapshotElement(Object entry, int i) {
- throw new UnsupportedOperationException("Sets don't support updating by element");
- }
-
- public boolean equals(Object other) {
- read();
- return set.equals(other);
- }
-
- public int hashCode() {
- read();
- return set.hashCode();
- }
-
- public boolean entryExists(Object key, int i) {
- return true;
- }
-
- public boolean isWrapper(Object collection) {
- return set==collection;
- }
-
- final class Clear implements DelayedOperation {
- public void operate() {
- set.clear();
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
- }
- }
-
- final class SimpleAdd implements DelayedOperation {
- private Object value;
-
- public SimpleAdd(Object value) {
- this.value = value;
- }
- public void operate() {
- set.add(value);
- }
- public Object getAddedInstance() {
- return value;
- }
- public Object getOrphan() {
- return null;
- }
- }
-
- final class SimpleRemove implements DelayedOperation {
- private Object value;
-
- public SimpleRemove(Object value) {
- this.value = value;
- }
- public void operate() {
- set.remove(value);
- }
- public Object getAddedInstance() {
- return null;
- }
- public Object getOrphan() {
- return value;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentSet.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSet.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,491 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.loader.CollectionAliases;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+
+/**
+ * A persistent wrapper for a <tt>java.util.Set</tt>. The underlying
+ * collection is a <tt>HashSet</tt>.
+ *
+ * @see java.util.HashSet
+ * @author Gavin King
+ */
+public class PersistentSet extends AbstractPersistentCollection implements java.util.Set {
+
+ protected Set set;
+ protected transient List tempList;
+
+ /**
+ * Empty constructor.
+ * <p/>
+ * Note: this form is not ever ever ever used by Hibernate; it is, however,
+ * needed for SOAP libraries and other such marshalling code.
+ */
+ public PersistentSet() {
+ // intentionally empty
+ }
+
+ /**
+ * Constructor matching super. Instantiates a lazy set (the underlying
+ * set is un-initialized).
+ *
+ * @param session The session to which this set will belong.
+ */
+ public PersistentSet(SessionImplementor session) {
+ super( session );
+ }
+
+ /**
+ * Instantiates a non-lazy set (the underlying set is constructed
+ * from the incoming set reference).
+ *
+ * @param session The session to which this set will belong.
+ * @param set The underlying set data.
+ */
+ public PersistentSet(SessionImplementor session, java.util.Set set) {
+ super(session);
+ // Sets can be just a view of a part of another collection.
+ // do we need to copy it to be sure it won't be changing
+ // underneath us?
+ // ie. this.set.addAll(set);
+ this.set = set;
+ setInitialized();
+ setDirectlyAccessible(true);
+ }
+
+
+ public Serializable getSnapshot(CollectionPersister persister)
+ throws HibernateException {
+ EntityMode entityMode = getSession().getEntityMode();
+
+ //if (set==null) return new Set(session);
+ HashMap clonedSet = new HashMap( set.size() );
+ Iterator iter = set.iterator();
+ while ( iter.hasNext() ) {
+ Object copied = persister.getElementType()
+ .deepCopy( iter.next(), entityMode, persister.getFactory() );
+ clonedSet.put(copied, copied);
+ }
+ return clonedSet;
+ }
+
+ public Collection getOrphans(Serializable snapshot, String entityName) throws HibernateException {
+ java.util.Map sn = (java.util.Map) snapshot;
+ return getOrphans( sn.keySet(), set, entityName, getSession() );
+ }
+
+ public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
+ Type elementType = persister.getElementType();
+ java.util.Map sn = (java.util.Map) getSnapshot();
+ if ( sn.size()!=set.size() ) {
+ return false;
+ }
+ else {
+ Iterator iter = set.iterator();
+ while ( iter.hasNext() ) {
+ Object test = iter.next();
+ Object oldValue = sn.get(test);
+ if ( oldValue==null || elementType.isDirty( oldValue, test, getSession() ) ) return false;
+ }
+ return true;
+ }
+ }
+
+ public boolean isSnapshotEmpty(Serializable snapshot) {
+ return ( (java.util.Map) snapshot ).isEmpty();
+ }
+
+ public void beforeInitialize(CollectionPersister persister, int anticipatedSize) {
+ this.set = ( Set ) persister.getCollectionType().instantiate( anticipatedSize );
+ }
+
+ public void initializeFromCache(CollectionPersister persister, Serializable disassembled, Object owner)
+ throws HibernateException {
+ Serializable[] array = ( Serializable[] ) disassembled;
+ int size = array.length;
+ beforeInitialize( persister, size );
+ for (int i = 0; i < size; i++ ) {
+ Object element = persister.getElementType().assemble( array[i], getSession(), owner );
+ if ( element != null ) {
+ set.add( element );
+ }
+ }
+ }
+
+ public boolean empty() {
+ return set.isEmpty();
+ }
+
+ /**
+ * @see java.util.Set#size()
+ */
+ public int size() {
+ return readSize() ? getCachedSize() : set.size();
+ }
+
+ /**
+ * @see java.util.Set#isEmpty()
+ */
+ public boolean isEmpty() {
+ return readSize() ? getCachedSize()==0 : set.isEmpty();
+ }
+
+ /**
+ * @see java.util.Set#contains(Object)
+ */
+ public boolean contains(Object object) {
+ Boolean exists = readElementExistence(object);
+ return exists==null ?
+ set.contains(object) :
+ exists.booleanValue();
+ }
+
+ /**
+ * @see java.util.Set#iterator()
+ */
+ public Iterator iterator() {
+ read();
+ return new IteratorProxy( set.iterator() );
+ }
+
+ /**
+ * @see java.util.Set#toArray()
+ */
+ public Object[] toArray() {
+ read();
+ return set.toArray();
+ }
+
+ /**
+ * @see java.util.Set#toArray(Object[])
+ */
+ public Object[] toArray(Object[] array) {
+ read();
+ return set.toArray(array);
+ }
+
+ /**
+ * @see java.util.Set#add(Object)
+ */
+ public boolean add(Object value) {
+ Boolean exists = isOperationQueueEnabled() ? readElementExistence( value ) : null;
+ if ( exists == null ) {
+ initialize( true );
+ if ( set.add( value ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else if ( exists.booleanValue() ) {
+ return false;
+ }
+ else {
+ queueOperation( new SimpleAdd(value) );
+ return true;
+ }
+ }
+
+ /**
+ * @see java.util.Set#remove(Object)
+ */
+ public boolean remove(Object value) {
+ Boolean exists = isPutQueueEnabled() ? readElementExistence( value ) : null;
+ if ( exists==null ) {
+ initialize( true );
+ if ( set.remove( value ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else if ( exists.booleanValue() ) {
+ queueOperation( new SimpleRemove(value) );
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Set#containsAll(Collection)
+ */
+ public boolean containsAll(Collection coll) {
+ read();
+ return set.containsAll(coll);
+ }
+
+ /**
+ * @see java.util.Set#addAll(Collection)
+ */
+ public boolean addAll(Collection coll) {
+ if ( coll.size() > 0 ) {
+ initialize( true );
+ if ( set.addAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Set#retainAll(Collection)
+ */
+ public boolean retainAll(Collection coll) {
+ initialize( true );
+ if ( set.retainAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Set#removeAll(Collection)
+ */
+ public boolean removeAll(Collection coll) {
+ if ( coll.size() > 0 ) {
+ initialize( true );
+ if ( set.removeAll( coll ) ) {
+ dirty();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see java.util.Set#clear()
+ */
+ public void clear() {
+ if ( isClearQueueEnabled() ) {
+ queueOperation( new Clear() );
+ }
+ else {
+ initialize( true );
+ if ( !set.isEmpty() ) {
+ set.clear();
+ dirty();
+ }
+ }
+ }
+
+ public String toString() {
+ //if (needLoading) return "asleep";
+ read();
+ return set.toString();
+ }
+
+ public Object readFrom(
+ ResultSet rs,
+ CollectionPersister persister,
+ CollectionAliases descriptor,
+ Object owner) throws HibernateException, SQLException {
+ Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
+ if (element!=null) tempList.add(element);
+ return element;
+ }
+
+ public void beginRead() {
+ super.beginRead();
+ tempList = new ArrayList();
+ }
+
+ public boolean endRead() {
+ set.addAll(tempList);
+ tempList = null;
+ setInitialized();
+ return true;
+ }
+
+ public Iterator entries(CollectionPersister persister) {
+ return set.iterator();
+ }
+
+ public Serializable disassemble(CollectionPersister persister)
+ throws HibernateException {
+
+ Serializable[] result = new Serializable[ set.size() ];
+ Iterator iter = set.iterator();
+ int i=0;
+ while ( iter.hasNext() ) {
+ result[i++] = persister.getElementType().disassemble( iter.next(), getSession(), null );
+ }
+ return result;
+
+ }
+
+ public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
+ Type elementType = persister.getElementType();
+ final java.util.Map sn = (java.util.Map) getSnapshot();
+ ArrayList deletes = new ArrayList( sn.size() );
+ Iterator iter = sn.keySet().iterator();
+ while ( iter.hasNext() ) {
+ Object test = iter.next();
+ if ( !set.contains(test) ) {
+ // the element has been removed from the set
+ deletes.add(test);
+ }
+ }
+ iter = set.iterator();
+ while ( iter.hasNext() ) {
+ Object test = iter.next();
+ Object oldValue = sn.get(test);
+ if ( oldValue!=null && elementType.isDirty( test, oldValue, getSession() ) ) {
+ // the element has changed
+ deletes.add(oldValue);
+ }
+ }
+ return deletes.iterator();
+ }
+
+ public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException {
+ final java.util.Map sn = (java.util.Map) getSnapshot();
+ Object oldValue = sn.get(entry);
+ // note that it might be better to iterate the snapshot but this is safe,
+ // assuming the user implements equals() properly, as required by the Set
+ // contract!
+ return oldValue==null || elemType.isDirty( oldValue, entry, getSession() );
+ }
+
+ public boolean needsUpdating(Object entry, int i, Type elemType) {
+ return false;
+ }
+
+ public boolean isRowUpdatePossible() {
+ return false;
+ }
+
+ public Object getIndex(Object entry, int i, CollectionPersister persister) {
+ throw new UnsupportedOperationException("Sets don't have indexes");
+ }
+
+ public Object getElement(Object entry) {
+ return entry;
+ }
+
+ public Object getSnapshotElement(Object entry, int i) {
+ throw new UnsupportedOperationException("Sets don't support updating by element");
+ }
+
+ public boolean equals(Object other) {
+ read();
+ return set.equals(other);
+ }
+
+ public int hashCode() {
+ read();
+ return set.hashCode();
+ }
+
+ public boolean entryExists(Object key, int i) {
+ return true;
+ }
+
+ public boolean isWrapper(Object collection) {
+ return set==collection;
+ }
+
+ final class Clear implements DelayedOperation {
+ public void operate() {
+ set.clear();
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
+ }
+ }
+
+ final class SimpleAdd implements DelayedOperation {
+ private Object value;
+
+ public SimpleAdd(Object value) {
+ this.value = value;
+ }
+ public void operate() {
+ set.add(value);
+ }
+ public Object getAddedInstance() {
+ return value;
+ }
+ public Object getOrphan() {
+ return null;
+ }
+ }
+
+ final class SimpleRemove implements DelayedOperation {
+ private Object value;
+
+ public SimpleRemove(Object value) {
+ this.value = value;
+ }
+ public void operate() {
+ set.remove(value);
+ }
+ public Object getAddedInstance() {
+ return null;
+ }
+ public Object getOrphan() {
+ return value;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,191 +0,0 @@
-//$Id: PersistentSortedMap.java 7714 2005-08-01 16:29:33Z oneovthafew $
-package org.hibernate.collection;
-
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.BasicCollectionPersister;
-
-
-/**
- * A persistent wrapper for a <tt>java.util.SortedMap</tt>. Underlying
- * collection is a <tt>TreeMap</tt>.
- *
- * @see java.util.TreeMap
- * @author <a href="mailto:doug.currie@alum.mit.edu">e</a>
- */
-public class PersistentSortedMap extends PersistentMap implements SortedMap {
-
- protected Comparator comparator;
-
- protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode) throws HibernateException {
- TreeMap clonedMap = new TreeMap(comparator);
- Iterator iter = map.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry e = (Map.Entry) iter.next();
- clonedMap.put( e.getKey(), persister.getElementType().deepCopy( e.getValue(), entityMode, persister.getFactory() ) );
- }
- return clonedMap;
- }
-
- public PersistentSortedMap(SessionImplementor session) {
- super(session);
- }
-
- public void setComparator(Comparator comparator) {
- this.comparator = comparator;
- }
-
- public PersistentSortedMap(SessionImplementor session, SortedMap map) {
- super(session, map);
- comparator = map.comparator();
- }
-
- public PersistentSortedMap() {} //needed for SOAP libraries, etc
-
- /**
- * @see PersistentSortedMap#comparator()
- */
- public Comparator comparator() {
- return comparator;
- }
-
- /**
- * @see PersistentSortedMap#subMap(Object, Object)
- */
- public SortedMap subMap(Object fromKey, Object toKey) {
- read();
- SortedMap m = ( (SortedMap) map ).subMap(fromKey, toKey);
- return new SortedSubMap(m);
- }
-
- /**
- * @see PersistentSortedMap#headMap(Object)
- */
- public SortedMap headMap(Object toKey) {
- read();
- SortedMap m;
- m = ( (SortedMap) map ).headMap(toKey);
- return new SortedSubMap(m);
- }
-
- /**
- * @see PersistentSortedMap#tailMap(Object)
- */
- public SortedMap tailMap(Object fromKey) {
- read();
- SortedMap m;
- m = ( (SortedMap) map ).tailMap(fromKey);
- return new SortedSubMap(m);
- }
-
- /**
- * @see PersistentSortedMap#firstKey()
- */
- public Object firstKey() {
- read();
- return ( (SortedMap) map ).firstKey();
- }
-
- /**
- * @see PersistentSortedMap#lastKey()
- */
- public Object lastKey() {
- read();
- return ( (SortedMap) map ).lastKey();
- }
-
- class SortedSubMap implements SortedMap {
-
- SortedMap submap;
-
- SortedSubMap(SortedMap m) {
- this.submap = m;
- }
- // from Map
- public int size() {
- return submap.size();
- }
- public boolean isEmpty() {
- return submap.isEmpty();
- }
- public boolean containsKey(Object key) {
- return submap.containsKey(key);
- }
- public boolean containsValue(Object key) {
- return submap.containsValue(key) ;
- }
- public Object get(Object key) {
- return submap.get(key);
- }
- public Object put(Object key, Object value) {
- write();
- return submap.put(key, value);
- }
- public Object remove(Object key) {
- write();
- return submap.remove(key);
- }
- public void putAll(Map other) {
- write();
- submap.putAll(other);
- }
- public void clear() {
- write();
- submap.clear();
- }
- public Set keySet() {
- return new SetProxy( submap.keySet() );
- }
- public Collection values() {
- return new SetProxy( submap.values() );
- }
- public Set entrySet() {
- return new EntrySetProxy( submap.entrySet() );
- }
- // from SortedMap
- public Comparator comparator() {
- return submap.comparator();
- }
- public SortedMap subMap(Object fromKey, Object toKey) {
- SortedMap m;
- m = submap.subMap(fromKey, toKey);
- return new SortedSubMap( m );
- }
- public SortedMap headMap(Object toKey) {
- SortedMap m;
- m = submap.headMap(toKey);
- return new SortedSubMap(m);
- }
- public SortedMap tailMap(Object fromKey) {
- SortedMap m;
- m = submap.tailMap(fromKey);
- return new SortedSubMap(m);
- }
- public Object firstKey() {
- return submap.firstKey();
- }
- public Object lastKey() {
- return submap.lastKey();
- }
-
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedMap.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,214 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.BasicCollectionPersister;
+
+
+/**
+ * A persistent wrapper for a <tt>java.util.SortedMap</tt>. Underlying
+ * collection is a <tt>TreeMap</tt>.
+ *
+ * @see java.util.TreeMap
+ * @author <a href="mailto:doug.currie@alum.mit.edu">e</a>
+ */
+public class PersistentSortedMap extends PersistentMap implements SortedMap {
+
+ protected Comparator comparator;
+
+ protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode) throws HibernateException {
+ TreeMap clonedMap = new TreeMap(comparator);
+ Iterator iter = map.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry e = (Map.Entry) iter.next();
+ clonedMap.put( e.getKey(), persister.getElementType().deepCopy( e.getValue(), entityMode, persister.getFactory() ) );
+ }
+ return clonedMap;
+ }
+
+ public PersistentSortedMap(SessionImplementor session) {
+ super(session);
+ }
+
+ public void setComparator(Comparator comparator) {
+ this.comparator = comparator;
+ }
+
+ public PersistentSortedMap(SessionImplementor session, SortedMap map) {
+ super(session, map);
+ comparator = map.comparator();
+ }
+
+ public PersistentSortedMap() {} //needed for SOAP libraries, etc
+
+ /**
+ * @see PersistentSortedMap#comparator()
+ */
+ public Comparator comparator() {
+ return comparator;
+ }
+
+ /**
+ * @see PersistentSortedMap#subMap(Object, Object)
+ */
+ public SortedMap subMap(Object fromKey, Object toKey) {
+ read();
+ SortedMap m = ( (SortedMap) map ).subMap(fromKey, toKey);
+ return new SortedSubMap(m);
+ }
+
+ /**
+ * @see PersistentSortedMap#headMap(Object)
+ */
+ public SortedMap headMap(Object toKey) {
+ read();
+ SortedMap m;
+ m = ( (SortedMap) map ).headMap(toKey);
+ return new SortedSubMap(m);
+ }
+
+ /**
+ * @see PersistentSortedMap#tailMap(Object)
+ */
+ public SortedMap tailMap(Object fromKey) {
+ read();
+ SortedMap m;
+ m = ( (SortedMap) map ).tailMap(fromKey);
+ return new SortedSubMap(m);
+ }
+
+ /**
+ * @see PersistentSortedMap#firstKey()
+ */
+ public Object firstKey() {
+ read();
+ return ( (SortedMap) map ).firstKey();
+ }
+
+ /**
+ * @see PersistentSortedMap#lastKey()
+ */
+ public Object lastKey() {
+ read();
+ return ( (SortedMap) map ).lastKey();
+ }
+
+ class SortedSubMap implements SortedMap {
+
+ SortedMap submap;
+
+ SortedSubMap(SortedMap m) {
+ this.submap = m;
+ }
+ // from Map
+ public int size() {
+ return submap.size();
+ }
+ public boolean isEmpty() {
+ return submap.isEmpty();
+ }
+ public boolean containsKey(Object key) {
+ return submap.containsKey(key);
+ }
+ public boolean containsValue(Object key) {
+ return submap.containsValue(key) ;
+ }
+ public Object get(Object key) {
+ return submap.get(key);
+ }
+ public Object put(Object key, Object value) {
+ write();
+ return submap.put(key, value);
+ }
+ public Object remove(Object key) {
+ write();
+ return submap.remove(key);
+ }
+ public void putAll(Map other) {
+ write();
+ submap.putAll(other);
+ }
+ public void clear() {
+ write();
+ submap.clear();
+ }
+ public Set keySet() {
+ return new SetProxy( submap.keySet() );
+ }
+ public Collection values() {
+ return new SetProxy( submap.values() );
+ }
+ public Set entrySet() {
+ return new EntrySetProxy( submap.entrySet() );
+ }
+ // from SortedMap
+ public Comparator comparator() {
+ return submap.comparator();
+ }
+ public SortedMap subMap(Object fromKey, Object toKey) {
+ SortedMap m;
+ m = submap.subMap(fromKey, toKey);
+ return new SortedSubMap( m );
+ }
+ public SortedMap headMap(Object toKey) {
+ SortedMap m;
+ m = submap.headMap(toKey);
+ return new SortedSubMap(m);
+ }
+ public SortedMap tailMap(Object fromKey) {
+ SortedMap m;
+ m = submap.tailMap(fromKey);
+ return new SortedSubMap(m);
+ }
+ public Object firstKey() {
+ return submap.firstKey();
+ }
+ public Object lastKey() {
+ return submap.lastKey();
+ }
+
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,145 +0,0 @@
-//$Id: PersistentSortedSet.java 7714 2005-08-01 16:29:33Z oneovthafew $
-package org.hibernate.collection;
-
-import java.io.Serializable;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.SortedSet;
-import java.util.TreeMap;
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.BasicCollectionPersister;
-
-
-/**
- * A persistent wrapper for a <tt>java.util.SortedSet</tt>. Underlying
- * collection is a <tt>TreeSet</tt>.
- *
- * @see java.util.TreeSet
- * @author <a href="mailto:doug.currie@alum.mit.edu">e</a>
- */
-public class PersistentSortedSet extends PersistentSet implements SortedSet {
-
- protected Comparator comparator;
-
- protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode)
- throws HibernateException {
- //if (set==null) return new Set(session);
- TreeMap clonedSet = new TreeMap(comparator);
- Iterator iter = set.iterator();
- while ( iter.hasNext() ) {
- Object copy = persister.getElementType().deepCopy( iter.next(), entityMode, persister.getFactory() );
- clonedSet.put(copy, copy);
- }
- return clonedSet;
- }
-
- public void setComparator(Comparator comparator) {
- this.comparator = comparator;
- }
-
- public PersistentSortedSet(SessionImplementor session) {
- super(session);
- }
-
- public PersistentSortedSet(SessionImplementor session, SortedSet set) {
- super(session, set);
- comparator = set.comparator();
- }
-
- public PersistentSortedSet() {} //needed for SOAP libraries, etc
-
- /**
- * @see PersistentSortedSet#comparator()
- */
- public Comparator comparator() {
- return comparator;
- }
-
- /**
- * @see PersistentSortedSet#subSet(Object,Object)
- */
- public SortedSet subSet(Object fromElement, Object toElement) {
- read();
- SortedSet s;
- s = ( (SortedSet) set ).subSet(fromElement, toElement);
- return new SubSetProxy(s);
- }
-
- /**
- * @see PersistentSortedSet#headSet(Object)
- */
- public SortedSet headSet(Object toElement) {
- read();
- SortedSet s = ( (SortedSet) set ).headSet(toElement);
- return new SubSetProxy(s);
- }
-
- /**
- * @see PersistentSortedSet#tailSet(Object)
- */
- public SortedSet tailSet(Object fromElement) {
- read();
- SortedSet s = ( (SortedSet) set ).tailSet(fromElement);
- return new SubSetProxy(s);
- }
-
- /**
- * @see PersistentSortedSet#first()
- */
- public Object first() {
- read();
- return ( (SortedSet) set ).first();
- }
-
- /**
- * @see PersistentSortedSet#last()
- */
- public Object last() {
- read();
- return ( (SortedSet) set ).last();
- }
-
- /** wrapper for subSets to propagate write to its backing set */
- class SubSetProxy extends SetProxy implements SortedSet {
-
- SubSetProxy(SortedSet s) {
- super(s);
- }
-
- public Comparator comparator() {
- return ( (SortedSet) this.set ).comparator();
- }
-
- public Object first() {
- return ( (SortedSet) this.set ).first();
- }
-
- public SortedSet headSet(Object toValue) {
- return new SubSetProxy( ( (SortedSet) this.set ).headSet(toValue) );
- }
-
- public Object last() {
- return ( (SortedSet) this.set ).last();
- }
-
- public SortedSet subSet(Object fromValue, Object toValue) {
- return new SubSetProxy( ( (SortedSet) this.set ).subSet(fromValue, toValue) );
- }
-
- public SortedSet tailSet(Object fromValue) {
- return new SubSetProxy( ( (SortedSet) this.set ).tailSet(fromValue) );
- }
-
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/PersistentSortedSet.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,168 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.collection;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeMap;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.BasicCollectionPersister;
+
+
+/**
+ * A persistent wrapper for a <tt>java.util.SortedSet</tt>. Underlying
+ * collection is a <tt>TreeSet</tt>.
+ *
+ * @see java.util.TreeSet
+ * @author <a href="mailto:doug.currie@alum.mit.edu">e</a>
+ */
+public class PersistentSortedSet extends PersistentSet implements SortedSet {
+
+ protected Comparator comparator;
+
+ protected Serializable snapshot(BasicCollectionPersister persister, EntityMode entityMode)
+ throws HibernateException {
+ //if (set==null) return new Set(session);
+ TreeMap clonedSet = new TreeMap(comparator);
+ Iterator iter = set.iterator();
+ while ( iter.hasNext() ) {
+ Object copy = persister.getElementType().deepCopy( iter.next(), entityMode, persister.getFactory() );
+ clonedSet.put(copy, copy);
+ }
+ return clonedSet;
+ }
+
+ public void setComparator(Comparator comparator) {
+ this.comparator = comparator;
+ }
+
+ public PersistentSortedSet(SessionImplementor session) {
+ super(session);
+ }
+
+ public PersistentSortedSet(SessionImplementor session, SortedSet set) {
+ super(session, set);
+ comparator = set.comparator();
+ }
+
+ public PersistentSortedSet() {} //needed for SOAP libraries, etc
+
+ /**
+ * @see PersistentSortedSet#comparator()
+ */
+ public Comparator comparator() {
+ return comparator;
+ }
+
+ /**
+ * @see PersistentSortedSet#subSet(Object,Object)
+ */
+ public SortedSet subSet(Object fromElement, Object toElement) {
+ read();
+ SortedSet s;
+ s = ( (SortedSet) set ).subSet(fromElement, toElement);
+ return new SubSetProxy(s);
+ }
+
+ /**
+ * @see PersistentSortedSet#headSet(Object)
+ */
+ public SortedSet headSet(Object toElement) {
+ read();
+ SortedSet s = ( (SortedSet) set ).headSet(toElement);
+ return new SubSetProxy(s);
+ }
+
+ /**
+ * @see PersistentSortedSet#tailSet(Object)
+ */
+ public SortedSet tailSet(Object fromElement) {
+ read();
+ SortedSet s = ( (SortedSet) set ).tailSet(fromElement);
+ return new SubSetProxy(s);
+ }
+
+ /**
+ * @see PersistentSortedSet#first()
+ */
+ public Object first() {
+ read();
+ return ( (SortedSet) set ).first();
+ }
+
+ /**
+ * @see PersistentSortedSet#last()
+ */
+ public Object last() {
+ read();
+ return ( (SortedSet) set ).last();
+ }
+
+ /** wrapper for subSets to propagate write to its backing set */
+ class SubSetProxy extends SetProxy implements SortedSet {
+
+ SubSetProxy(SortedSet s) {
+ super(s);
+ }
+
+ public Comparator comparator() {
+ return ( (SortedSet) this.set ).comparator();
+ }
+
+ public Object first() {
+ return ( (SortedSet) this.set ).first();
+ }
+
+ public SortedSet headSet(Object toValue) {
+ return new SubSetProxy( ( (SortedSet) this.set ).headSet(toValue) );
+ }
+
+ public Object last() {
+ return ( (SortedSet) this.set ).last();
+ }
+
+ public SortedSet subSet(Object fromValue, Object toValue) {
+ return new SubSetProxy( ( (SortedSet) this.set ).subSet(fromValue, toValue) );
+ }
+
+ public SortedSet tailSet(Object fromValue) {
+ return new SubSetProxy( ( (SortedSet) this.set ).tailSet(fromValue) );
+ }
+
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,8 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- This package defines a framework for collection wrappers.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/collection/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/collection/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,33 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ This package defines a framework for collection wrappers.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,71 +0,0 @@
-//$Id: ConnectionProvider.java 9191 2006-02-01 14:40:34Z epbernard $
-package org.hibernate.connection;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import org.hibernate.HibernateException;
-
-/**
- * A strategy for obtaining JDBC connections.
- * <br><br>
- * Implementors might also implement connection pooling.<br>
- * <br>
- * The <tt>ConnectionProvider</tt> interface is not intended to be
- * exposed to the application. Instead it is used internally by
- * Hibernate to obtain connections.<br>
- * <br>
- * Implementors should provide a public default constructor.
- *
- * @see ConnectionProviderFactory
- * @author Gavin King
- */
-public interface ConnectionProvider {
- /**
- * Initialize the connection provider from given properties.
- * @param props <tt>SessionFactory</tt> properties
- */
- public void configure(Properties props) throws HibernateException;
- /**
- * Grab a connection, with the autocommit mode specified by
- * <tt>hibernate.connection.autocommit</tt>.
- * @return a JDBC connection
- * @throws SQLException
- */
- public Connection getConnection() throws SQLException;
- /**
- * Dispose of a used connection.
- * @param conn a JDBC connection
- * @throws SQLException
- */
- public void closeConnection(Connection conn) throws SQLException;
-
- /**
- * Release all resources held by this provider. JavaDoc requires a second sentence.
- * @throws HibernateException
- */
- public void close() throws HibernateException;
-
- /**
- * Does this connection provider support aggressive release of JDBC
- * connections and re-acquistion of those connections (if need be) later?
- * <p/>
- * This is used in conjunction with {@link org.hibernate.cfg.Environment.RELEASE_CONNECTIONS}
- * to aggressively release JDBC connections. However, the configured ConnectionProvider
- * must support re-acquisition of the same underlying connection for that semantic to work.
- * <p/>
- * Typically, this is only true in managed environments where a container
- * tracks connections by transaction or thread.
- *
- * Note that JTA semantic depends on the fact that the underlying connection provider does
- * support aggressive release.
- */
- public boolean supportsAggressiveRelease();
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,94 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.connection;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+
+/**
+ * A strategy for obtaining JDBC connections.
+ * <br><br>
+ * Implementors might also implement connection pooling.<br>
+ * <br>
+ * The <tt>ConnectionProvider</tt> interface is not intended to be
+ * exposed to the application. Instead it is used internally by
+ * Hibernate to obtain connections.<br>
+ * <br>
+ * Implementors should provide a public default constructor.
+ *
+ * @see ConnectionProviderFactory
+ * @author Gavin King
+ */
+public interface ConnectionProvider {
+ /**
+ * Initialize the connection provider from given properties.
+ * @param props <tt>SessionFactory</tt> properties
+ */
+ public void configure(Properties props) throws HibernateException;
+ /**
+ * Grab a connection, with the autocommit mode specified by
+ * <tt>hibernate.connection.autocommit</tt>.
+ * @return a JDBC connection
+ * @throws SQLException
+ */
+ public Connection getConnection() throws SQLException;
+ /**
+ * Dispose of a used connection.
+ * @param conn a JDBC connection
+ * @throws SQLException
+ */
+ public void closeConnection(Connection conn) throws SQLException;
+
+ /**
+ * Release all resources held by this provider. JavaDoc requires a second sentence.
+ * @throws HibernateException
+ */
+ public void close() throws HibernateException;
+
+ /**
+ * Does this connection provider support aggressive release of JDBC
+ * connections and re-acquistion of those connections (if need be) later?
+ * <p/>
+ * This is used in conjunction with {@link org.hibernate.cfg.Environment.RELEASE_CONNECTIONS}
+ * to aggressively release JDBC connections. However, the configured ConnectionProvider
+ * must support re-acquisition of the same underlying connection for that semantic to work.
+ * <p/>
+ * Typically, this is only true in managed environments where a container
+ * tracks connections by transaction or thread.
+ *
+ * Note that JTA semantic depends on the fact that the underlying connection provider does
+ * support aggressive release.
+ */
+ public boolean supportsAggressiveRelease();
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,164 +0,0 @@
-//$Id: ConnectionProviderFactory.java 7541 2005-07-18 22:37:31Z epbernard $
-package org.hibernate.connection;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Map;
-import java.beans.Introspector;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * Instantiates a connection provider given either <tt>System</tt> properties or
- * a <tt>java.util.Properties</tt> instance. The <tt>ConnectionProviderFactory</tt>
- * first attempts to find a name of a <tt>ConnectionProvider</tt> subclass in the
- * property <tt>hibernate.connection.provider_class</tt>. If missing, heuristics are used
- * to choose either <tt>DriverManagerConnectionProvider</tt>,
- * <tt>DatasourceConnectionProvider</tt>, <tt>C3P0ConnectionProvider</tt> or
- * <tt>DBCPConnectionProvider</tt>.
- * @see ConnectionProvider
- * @author Gavin King
- */
-
-public final class ConnectionProviderFactory {
-
- private static final Logger log = LoggerFactory.getLogger(ConnectionProviderFactory.class);
-
- /**
- * Instantiate a <tt>ConnectionProvider</tt> using <tt>System</tt> properties.
- * @return The created connection provider.
- * @throws HibernateException
- */
- public static ConnectionProvider newConnectionProvider() throws HibernateException {
- return newConnectionProvider( Environment.getProperties() );
- }
-
- /**
- * Instantiate a <tt>ConnectionProvider</tt> using given properties.
- * Method newConnectionProvider.
- * @param properties hibernate <tt>SessionFactory</tt> properties
- * @return ConnectionProvider
- * @throws HibernateException
- */
- public static ConnectionProvider newConnectionProvider(Properties properties) throws HibernateException {
- return newConnectionProvider( properties, null );
- }
-
- /**
- * Create a connection provider based on the given information.
- *
- * @param properties Properties being used to build the {@link org.hibernate.SessionFactory}.
- * @param connectionProviderInjectionData Soemthing to be injected in the conenction provided
- * @return The created connection provider
- * @throws HibernateException
- */
- public static ConnectionProvider newConnectionProvider(Properties properties, Map connectionProviderInjectionData) throws HibernateException {
- ConnectionProvider connections;
- String providerClass = properties.getProperty(Environment.CONNECTION_PROVIDER);
- if ( providerClass!=null ) {
- try {
- log.info("Initializing connection provider: " + providerClass);
- connections = (ConnectionProvider) ReflectHelper.classForName(providerClass).newInstance();
- }
- catch ( Exception e ) {
- log.error( "Could not instantiate connection provider", e );
- throw new HibernateException("Could not instantiate connection provider: " + providerClass);
- }
- }
- else if ( properties.getProperty(Environment.DATASOURCE)!=null ) {
- connections = new DatasourceConnectionProvider();
- }
- else if ( properties.getProperty(Environment.URL)!=null ) {
- connections = new DriverManagerConnectionProvider();
- }
- else {
- connections = new UserSuppliedConnectionProvider();
- }
-
- if ( connectionProviderInjectionData != null && connectionProviderInjectionData.size() != 0 ) {
- //inject the data
- try {
- BeanInfo info = Introspector.getBeanInfo( connections.getClass() );
- PropertyDescriptor[] descritors = info.getPropertyDescriptors();
- int size = descritors.length;
- for (int index = 0 ; index < size ; index++) {
- String propertyName = descritors[index].getName();
- if ( connectionProviderInjectionData.containsKey( propertyName ) ) {
- Method method = descritors[index].getWriteMethod();
- method.invoke( connections, new Object[] { connectionProviderInjectionData.get( propertyName ) } );
- }
- }
- }
- catch (IntrospectionException e) {
- throw new HibernateException("Unable to inject objects into the conenction provider", e);
- }
- catch (IllegalAccessException e) {
- throw new HibernateException("Unable to inject objects into the conenction provider", e);
- }
- catch (InvocationTargetException e) {
- throw new HibernateException("Unable to inject objects into the conenction provider", e);
- }
- }
- connections.configure(properties);
- return connections;
- }
-
- // cannot be instantiated
- private ConnectionProviderFactory() { throw new UnsupportedOperationException(); }
-
- /**
- * Transform JDBC connection properties.
- *
- * Passed in the form <tt>hibernate.connection.*</tt> to the
- * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>".
- */
- public static Properties getConnectionProperties(Properties properties) {
-
- Iterator iter = properties.keySet().iterator();
- Properties result = new Properties();
- while ( iter.hasNext() ) {
- String prop = (String) iter.next();
- if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop) ) {
- result.setProperty(
- prop.substring( Environment.CONNECTION_PREFIX.length()+1 ),
- properties.getProperty(prop)
- );
- }
- }
- String userName = properties.getProperty(Environment.USER);
- if (userName!=null) result.setProperty( "user", userName );
- return result;
- }
-
- private static final Set SPECIAL_PROPERTIES;
- static {
- SPECIAL_PROPERTIES = new HashSet();
- SPECIAL_PROPERTIES.add(Environment.DATASOURCE);
- SPECIAL_PROPERTIES.add(Environment.URL);
- SPECIAL_PROPERTIES.add(Environment.CONNECTION_PROVIDER);
- SPECIAL_PROPERTIES.add(Environment.POOL_SIZE);
- SPECIAL_PROPERTIES.add(Environment.ISOLATION);
- SPECIAL_PROPERTIES.add(Environment.DRIVER);
- SPECIAL_PROPERTIES.add(Environment.USER);
-
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,187 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.connection;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Map;
+import java.beans.Introspector;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Instantiates a connection provider given either <tt>System</tt> properties or
+ * a <tt>java.util.Properties</tt> instance. The <tt>ConnectionProviderFactory</tt>
+ * first attempts to find a name of a <tt>ConnectionProvider</tt> subclass in the
+ * property <tt>hibernate.connection.provider_class</tt>. If missing, heuristics are used
+ * to choose either <tt>DriverManagerConnectionProvider</tt>,
+ * <tt>DatasourceConnectionProvider</tt>, <tt>C3P0ConnectionProvider</tt> or
+ * <tt>DBCPConnectionProvider</tt>.
+ * @see ConnectionProvider
+ * @author Gavin King
+ */
+
+public final class ConnectionProviderFactory {
+
+ private static final Logger log = LoggerFactory.getLogger(ConnectionProviderFactory.class);
+
+ /**
+ * Instantiate a <tt>ConnectionProvider</tt> using <tt>System</tt> properties.
+ * @return The created connection provider.
+ * @throws HibernateException
+ */
+ public static ConnectionProvider newConnectionProvider() throws HibernateException {
+ return newConnectionProvider( Environment.getProperties() );
+ }
+
+ /**
+ * Instantiate a <tt>ConnectionProvider</tt> using given properties.
+ * Method newConnectionProvider.
+ * @param properties hibernate <tt>SessionFactory</tt> properties
+ * @return ConnectionProvider
+ * @throws HibernateException
+ */
+ public static ConnectionProvider newConnectionProvider(Properties properties) throws HibernateException {
+ return newConnectionProvider( properties, null );
+ }
+
+ /**
+ * Create a connection provider based on the given information.
+ *
+ * @param properties Properties being used to build the {@link org.hibernate.SessionFactory}.
+ * @param connectionProviderInjectionData Soemthing to be injected in the conenction provided
+ * @return The created connection provider
+ * @throws HibernateException
+ */
+ public static ConnectionProvider newConnectionProvider(Properties properties, Map connectionProviderInjectionData) throws HibernateException {
+ ConnectionProvider connections;
+ String providerClass = properties.getProperty(Environment.CONNECTION_PROVIDER);
+ if ( providerClass!=null ) {
+ try {
+ log.info("Initializing connection provider: " + providerClass);
+ connections = (ConnectionProvider) ReflectHelper.classForName(providerClass).newInstance();
+ }
+ catch ( Exception e ) {
+ log.error( "Could not instantiate connection provider", e );
+ throw new HibernateException("Could not instantiate connection provider: " + providerClass);
+ }
+ }
+ else if ( properties.getProperty(Environment.DATASOURCE)!=null ) {
+ connections = new DatasourceConnectionProvider();
+ }
+ else if ( properties.getProperty(Environment.URL)!=null ) {
+ connections = new DriverManagerConnectionProvider();
+ }
+ else {
+ connections = new UserSuppliedConnectionProvider();
+ }
+
+ if ( connectionProviderInjectionData != null && connectionProviderInjectionData.size() != 0 ) {
+ //inject the data
+ try {
+ BeanInfo info = Introspector.getBeanInfo( connections.getClass() );
+ PropertyDescriptor[] descritors = info.getPropertyDescriptors();
+ int size = descritors.length;
+ for (int index = 0 ; index < size ; index++) {
+ String propertyName = descritors[index].getName();
+ if ( connectionProviderInjectionData.containsKey( propertyName ) ) {
+ Method method = descritors[index].getWriteMethod();
+ method.invoke( connections, new Object[] { connectionProviderInjectionData.get( propertyName ) } );
+ }
+ }
+ }
+ catch (IntrospectionException e) {
+ throw new HibernateException("Unable to inject objects into the conenction provider", e);
+ }
+ catch (IllegalAccessException e) {
+ throw new HibernateException("Unable to inject objects into the conenction provider", e);
+ }
+ catch (InvocationTargetException e) {
+ throw new HibernateException("Unable to inject objects into the conenction provider", e);
+ }
+ }
+ connections.configure(properties);
+ return connections;
+ }
+
+ // cannot be instantiated
+ private ConnectionProviderFactory() { throw new UnsupportedOperationException(); }
+
+ /**
+ * Transform JDBC connection properties.
+ *
+ * Passed in the form <tt>hibernate.connection.*</tt> to the
+ * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>".
+ */
+ public static Properties getConnectionProperties(Properties properties) {
+
+ Iterator iter = properties.keySet().iterator();
+ Properties result = new Properties();
+ while ( iter.hasNext() ) {
+ String prop = (String) iter.next();
+ if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop) ) {
+ result.setProperty(
+ prop.substring( Environment.CONNECTION_PREFIX.length()+1 ),
+ properties.getProperty(prop)
+ );
+ }
+ }
+ String userName = properties.getProperty(Environment.USER);
+ if (userName!=null) result.setProperty( "user", userName );
+ return result;
+ }
+
+ private static final Set SPECIAL_PROPERTIES;
+ static {
+ SPECIAL_PROPERTIES = new HashSet();
+ SPECIAL_PROPERTIES.add(Environment.DATASOURCE);
+ SPECIAL_PROPERTIES.add(Environment.URL);
+ SPECIAL_PROPERTIES.add(Environment.CONNECTION_PROVIDER);
+ SPECIAL_PROPERTIES.add(Environment.POOL_SIZE);
+ SPECIAL_PROPERTIES.add(Environment.ISOLATION);
+ SPECIAL_PROPERTIES.add(Environment.DRIVER);
+ SPECIAL_PROPERTIES.add(Environment.USER);
+
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,93 +0,0 @@
-//$Id: DatasourceConnectionProvider.java 10075 2006-07-01 12:50:34Z epbernard $
-package org.hibernate.connection;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.util.NamingHelper;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A connection provider that uses a <tt>DataSource</tt> registered with JNDI.
- * Hibernate will use this <tt>ConnectionProvider</tt> by default if the
- * property <tt>hibernate.connection.datasource</tt> is set.
- * @see ConnectionProvider
- * @author Gavin King
- */
-public class DatasourceConnectionProvider implements ConnectionProvider {
- private DataSource ds;
- private String user;
- private String pass;
-
- private static final Logger log = LoggerFactory.getLogger(DatasourceConnectionProvider.class);
-
- public DataSource getDataSource() {
- return ds;
- }
-
- public void setDataSource(DataSource ds) {
- this.ds = ds;
- }
-
- public void configure(Properties props) throws HibernateException {
-
- String jndiName = props.getProperty( Environment.DATASOURCE );
- if ( jndiName == null ) {
- String msg = "datasource JNDI name was not specified by property " + Environment.DATASOURCE;
- log.error( msg );
- throw new HibernateException( msg );
- }
-
- user = props.getProperty( Environment.USER );
- pass = props.getProperty( Environment.PASS );
-
- try {
- ds = ( DataSource ) NamingHelper.getInitialContext( props ).lookup( jndiName );
- }
- catch ( Exception e ) {
- log.error( "Could not find datasource: " + jndiName, e );
- throw new HibernateException( "Could not find datasource", e );
- }
- if ( ds == null ) {
- throw new HibernateException( "Could not find datasource: " + jndiName );
- }
- log.info( "Using datasource: " + jndiName );
- }
-
- public Connection getConnection() throws SQLException {
- if (user != null || pass != null) {
- return ds.getConnection(user, pass);
- }
- else {
- return ds.getConnection();
- }
- }
-
- public void closeConnection(Connection conn) throws SQLException {
- conn.close();
- }
-
- public void close() {}
-
- /**
- * @see ConnectionProvider#supportsAggressiveRelease()
- */
- public boolean supportsAggressiveRelease() {
- return true;
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DatasourceConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,116 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.connection;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.util.NamingHelper;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A connection provider that uses a <tt>DataSource</tt> registered with JNDI.
+ * Hibernate will use this <tt>ConnectionProvider</tt> by default if the
+ * property <tt>hibernate.connection.datasource</tt> is set.
+ * @see ConnectionProvider
+ * @author Gavin King
+ */
+public class DatasourceConnectionProvider implements ConnectionProvider {
+ private DataSource ds;
+ private String user;
+ private String pass;
+
+ private static final Logger log = LoggerFactory.getLogger(DatasourceConnectionProvider.class);
+
+ public DataSource getDataSource() {
+ return ds;
+ }
+
+ public void setDataSource(DataSource ds) {
+ this.ds = ds;
+ }
+
+ public void configure(Properties props) throws HibernateException {
+
+ String jndiName = props.getProperty( Environment.DATASOURCE );
+ if ( jndiName == null ) {
+ String msg = "datasource JNDI name was not specified by property " + Environment.DATASOURCE;
+ log.error( msg );
+ throw new HibernateException( msg );
+ }
+
+ user = props.getProperty( Environment.USER );
+ pass = props.getProperty( Environment.PASS );
+
+ try {
+ ds = ( DataSource ) NamingHelper.getInitialContext( props ).lookup( jndiName );
+ }
+ catch ( Exception e ) {
+ log.error( "Could not find datasource: " + jndiName, e );
+ throw new HibernateException( "Could not find datasource", e );
+ }
+ if ( ds == null ) {
+ throw new HibernateException( "Could not find datasource: " + jndiName );
+ }
+ log.info( "Using datasource: " + jndiName );
+ }
+
+ public Connection getConnection() throws SQLException {
+ if (user != null || pass != null) {
+ return ds.getConnection(user, pass);
+ }
+ else {
+ return ds.getConnection();
+ }
+ }
+
+ public void closeConnection(Connection conn) throws SQLException {
+ conn.close();
+ }
+
+ public void close() {}
+
+ /**
+ * @see ConnectionProvider#supportsAggressiveRelease()
+ */
+ public boolean supportsAggressiveRelease() {
+ return true;
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,176 +0,0 @@
-//$Id: DriverManagerConnectionProvider.java 7888 2005-08-12 21:22:38Z oneovthafew $
-package org.hibernate.connection;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.util.PropertiesHelper;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * A connection provider that uses <tt>java.sql.DriverManager</tt>. This provider
- * also implements a very rudimentary connection pool.
- * @see ConnectionProvider
- * @author Gavin King
- */
-public class DriverManagerConnectionProvider implements ConnectionProvider {
-
- private String url;
- private Properties connectionProps;
- private Integer isolation;
- private final ArrayList pool = new ArrayList();
- private int poolSize;
- private int checkedOut = 0;
- private boolean autocommit;
-
- private static final Logger log = LoggerFactory.getLogger(DriverManagerConnectionProvider.class);
-
- public void configure(Properties props) throws HibernateException {
-
- String driverClass = props.getProperty(Environment.DRIVER);
-
- poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
- log.info("Using Hibernate built-in connection pool (not for production use!)");
- log.info("Hibernate connection pool size: " + poolSize);
-
- autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
- log.info("autocommit mode: " + autocommit);
-
- isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
- if (isolation!=null)
- log.info( "JDBC isolation level: " + Environment.isolationLevelToString( isolation.intValue() ) );
-
- if (driverClass==null) {
- log.warn("no JDBC Driver class was specified by property " + Environment.DRIVER);
- }
- else {
- try {
- // trying via forName() first to be as close to DriverManager's semantics
- Class.forName(driverClass);
- }
- catch (ClassNotFoundException cnfe) {
- try {
- ReflectHelper.classForName(driverClass);
- }
- catch (ClassNotFoundException e) {
- String msg = "JDBC Driver class not found: " + driverClass;
- log.error( msg, e );
- throw new HibernateException(msg, e);
- }
- }
- }
-
- url = props.getProperty( Environment.URL );
- if ( url == null ) {
- String msg = "JDBC URL was not specified by property " + Environment.URL;
- log.error( msg );
- throw new HibernateException( msg );
- }
-
- connectionProps = ConnectionProviderFactory.getConnectionProperties( props );
-
- log.info( "using driver: " + driverClass + " at URL: " + url );
- // if debug level is enabled, then log the password, otherwise mask it
- if ( log.isDebugEnabled() ) {
- log.info( "connection properties: " + connectionProps );
- }
- else if ( log.isInfoEnabled() ) {
- log.info( "connection properties: " + PropertiesHelper.maskOut(connectionProps, "password") );
- }
-
- }
-
- public Connection getConnection() throws SQLException {
-
- if ( log.isTraceEnabled() ) log.trace( "total checked-out connections: " + checkedOut );
-
- synchronized (pool) {
- if ( !pool.isEmpty() ) {
- int last = pool.size() - 1;
- if ( log.isTraceEnabled() ) {
- log.trace("using pooled JDBC connection, pool size: " + last);
- checkedOut++;
- }
- Connection pooled = (Connection) pool.remove(last);
- if (isolation!=null) pooled.setTransactionIsolation( isolation.intValue() );
- if ( pooled.getAutoCommit()!=autocommit ) pooled.setAutoCommit(autocommit);
- return pooled;
- }
- }
-
- log.debug("opening new JDBC connection");
- Connection conn = DriverManager.getConnection(url, connectionProps);
- if (isolation!=null) conn.setTransactionIsolation( isolation.intValue() );
- if ( conn.getAutoCommit()!=autocommit ) conn.setAutoCommit(autocommit);
-
- if ( log.isDebugEnabled() ) {
- log.debug( "created connection to: " + url + ", Isolation Level: " + conn.getTransactionIsolation() );
- }
- if ( log.isTraceEnabled() ) checkedOut++;
-
- return conn;
- }
-
- public void closeConnection(Connection conn) throws SQLException {
-
- if ( log.isDebugEnabled() ) checkedOut--;
-
- synchronized (pool) {
- int currentSize = pool.size();
- if ( currentSize < poolSize ) {
- if ( log.isTraceEnabled() ) log.trace("returning connection to pool, pool size: " + (currentSize + 1) );
- pool.add(conn);
- return;
- }
- }
-
- log.debug("closing JDBC connection");
-
- conn.close();
-
- }
-
- protected void finalize() {
- close();
- }
-
- public void close() {
-
- log.info("cleaning up connection pool: " + url);
-
- Iterator iter = pool.iterator();
- while ( iter.hasNext() ) {
- try {
- ( (Connection) iter.next() ).close();
- }
- catch (SQLException sqle) {
- log.warn("problem closing pooled connection", sqle);
- }
- }
- pool.clear();
-
- }
-
- /**
- * @see ConnectionProvider#supportsAggressiveRelease()
- */
- public boolean supportsAggressiveRelease() {
- return false;
- }
-
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/DriverManagerConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,199 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.connection;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.util.PropertiesHelper;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * A connection provider that uses <tt>java.sql.DriverManager</tt>. This provider
+ * also implements a very rudimentary connection pool.
+ * @see ConnectionProvider
+ * @author Gavin King
+ */
+public class DriverManagerConnectionProvider implements ConnectionProvider {
+
+ private String url;
+ private Properties connectionProps;
+ private Integer isolation;
+ private final ArrayList pool = new ArrayList();
+ private int poolSize;
+ private int checkedOut = 0;
+ private boolean autocommit;
+
+ private static final Logger log = LoggerFactory.getLogger(DriverManagerConnectionProvider.class);
+
+ public void configure(Properties props) throws HibernateException {
+
+ String driverClass = props.getProperty(Environment.DRIVER);
+
+ poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
+ log.info("Using Hibernate built-in connection pool (not for production use!)");
+ log.info("Hibernate connection pool size: " + poolSize);
+
+ autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
+ log.info("autocommit mode: " + autocommit);
+
+ isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
+ if (isolation!=null)
+ log.info( "JDBC isolation level: " + Environment.isolationLevelToString( isolation.intValue() ) );
+
+ if (driverClass==null) {
+ log.warn("no JDBC Driver class was specified by property " + Environment.DRIVER);
+ }
+ else {
+ try {
+ // trying via forName() first to be as close to DriverManager's semantics
+ Class.forName(driverClass);
+ }
+ catch (ClassNotFoundException cnfe) {
+ try {
+ ReflectHelper.classForName(driverClass);
+ }
+ catch (ClassNotFoundException e) {
+ String msg = "JDBC Driver class not found: " + driverClass;
+ log.error( msg, e );
+ throw new HibernateException(msg, e);
+ }
+ }
+ }
+
+ url = props.getProperty( Environment.URL );
+ if ( url == null ) {
+ String msg = "JDBC URL was not specified by property " + Environment.URL;
+ log.error( msg );
+ throw new HibernateException( msg );
+ }
+
+ connectionProps = ConnectionProviderFactory.getConnectionProperties( props );
+
+ log.info( "using driver: " + driverClass + " at URL: " + url );
+ // if debug level is enabled, then log the password, otherwise mask it
+ if ( log.isDebugEnabled() ) {
+ log.info( "connection properties: " + connectionProps );
+ }
+ else if ( log.isInfoEnabled() ) {
+ log.info( "connection properties: " + PropertiesHelper.maskOut(connectionProps, "password") );
+ }
+
+ }
+
+ public Connection getConnection() throws SQLException {
+
+ if ( log.isTraceEnabled() ) log.trace( "total checked-out connections: " + checkedOut );
+
+ synchronized (pool) {
+ if ( !pool.isEmpty() ) {
+ int last = pool.size() - 1;
+ if ( log.isTraceEnabled() ) {
+ log.trace("using pooled JDBC connection, pool size: " + last);
+ checkedOut++;
+ }
+ Connection pooled = (Connection) pool.remove(last);
+ if (isolation!=null) pooled.setTransactionIsolation( isolation.intValue() );
+ if ( pooled.getAutoCommit()!=autocommit ) pooled.setAutoCommit(autocommit);
+ return pooled;
+ }
+ }
+
+ log.debug("opening new JDBC connection");
+ Connection conn = DriverManager.getConnection(url, connectionProps);
+ if (isolation!=null) conn.setTransactionIsolation( isolation.intValue() );
+ if ( conn.getAutoCommit()!=autocommit ) conn.setAutoCommit(autocommit);
+
+ if ( log.isDebugEnabled() ) {
+ log.debug( "created connection to: " + url + ", Isolation Level: " + conn.getTransactionIsolation() );
+ }
+ if ( log.isTraceEnabled() ) checkedOut++;
+
+ return conn;
+ }
+
+ public void closeConnection(Connection conn) throws SQLException {
+
+ if ( log.isDebugEnabled() ) checkedOut--;
+
+ synchronized (pool) {
+ int currentSize = pool.size();
+ if ( currentSize < poolSize ) {
+ if ( log.isTraceEnabled() ) log.trace("returning connection to pool, pool size: " + (currentSize + 1) );
+ pool.add(conn);
+ return;
+ }
+ }
+
+ log.debug("closing JDBC connection");
+
+ conn.close();
+
+ }
+
+ protected void finalize() {
+ close();
+ }
+
+ public void close() {
+
+ log.info("cleaning up connection pool: " + url);
+
+ Iterator iter = pool.iterator();
+ while ( iter.hasNext() ) {
+ try {
+ ( (Connection) iter.next() ).close();
+ }
+ catch (SQLException sqle) {
+ log.warn("problem closing pooled connection", sqle);
+ }
+ }
+ pool.clear();
+
+ }
+
+ /**
+ * @see ConnectionProvider#supportsAggressiveRelease()
+ */
+ public boolean supportsAggressiveRelease() {
+ return false;
+ }
+
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,57 +0,0 @@
-//$Id: UserSuppliedConnectionProvider.java 6463 2005-04-19 15:39:07Z steveebersole $
-package org.hibernate.connection;
-
-import java.sql.Connection;
-import java.util.Properties;
-
-import org.slf4j.LoggerFactory;
-import org.hibernate.HibernateException;
-
-/**
- * An implementation of the <literal>ConnectionProvider</literal> interface that
- * simply throws an exception when a connection is requested. This implementation
- * indicates that the user is expected to supply a JDBC connection.
- * @see ConnectionProvider
- * @author Gavin King
- */
-public class UserSuppliedConnectionProvider implements ConnectionProvider {
-
- /**
- * @see org.hibernate.connection.ConnectionProvider#configure(Properties)
- */
- public void configure(Properties props) throws HibernateException {
- LoggerFactory.getLogger( UserSuppliedConnectionProvider.class )
- .warn( "No connection properties specified - the user must supply JDBC connections" );
- }
-
- /**
- * @see org.hibernate.connection.ConnectionProvider#getConnection()
- */
- public Connection getConnection() {
- throw new UnsupportedOperationException("The user must supply a JDBC connection");
- }
-
- /**
- * @see org.hibernate.connection.ConnectionProvider#closeConnection(Connection)
- */
- public void closeConnection(Connection conn) {
- throw new UnsupportedOperationException("The user must supply a JDBC connection");
- }
-
- public void close() {
- }
-
- /**
- * @see ConnectionProvider#supportsAggressiveRelease()
- */
- public boolean supportsAggressiveRelease() {
- return false;
- }
-
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/UserSuppliedConnectionProvider.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,80 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.connection;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import org.slf4j.LoggerFactory;
+import org.hibernate.HibernateException;
+
+/**
+ * An implementation of the <literal>ConnectionProvider</literal> interface that
+ * simply throws an exception when a connection is requested. This implementation
+ * indicates that the user is expected to supply a JDBC connection.
+ * @see ConnectionProvider
+ * @author Gavin King
+ */
+public class UserSuppliedConnectionProvider implements ConnectionProvider {
+
+ /**
+ * @see org.hibernate.connection.ConnectionProvider#configure(Properties)
+ */
+ public void configure(Properties props) throws HibernateException {
+ LoggerFactory.getLogger( UserSuppliedConnectionProvider.class )
+ .warn( "No connection properties specified - the user must supply JDBC connections" );
+ }
+
+ /**
+ * @see org.hibernate.connection.ConnectionProvider#getConnection()
+ */
+ public Connection getConnection() {
+ throw new UnsupportedOperationException("The user must supply a JDBC connection");
+ }
+
+ /**
+ * @see org.hibernate.connection.ConnectionProvider#closeConnection(Connection)
+ */
+ public void closeConnection(Connection conn) {
+ throw new UnsupportedOperationException("The user must supply a JDBC connection");
+ }
+
+ public void close() {
+ }
+
+ /**
+ * @see ConnectionProvider#supportsAggressiveRelease()
+ */
+ public boolean supportsAggressiveRelease() {
+ return false;
+ }
+
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,13 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- This package abstracts the mechanism for obtaining
- a JDBC connection.
-</p>
-<p>
- A concrete implementation of <tt>ConnectionProvider</tt> may be
- selected by specifying <tt>hibernate.connection.provider_class</tt>.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/connection/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/connection/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,38 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ This package abstracts the mechanism for obtaining
+ a JDBC connection.
+</p>
+<p>
+ A concrete implementation of <tt>ConnectionProvider</tt> may be
+ selected by specifying <tt>hibernate.connection.provider_class</tt>.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/CurrentSessionContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,60 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.context;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * Defines the contract for implementations which know how to scope the notion
- * of a {@link org.hibernate.SessionFactory#getCurrentSession() current session}.
- * <p/>
- * Implementations should adhere to the following:
- * <ul>
- * <li>contain a constructor accepting a single argument of type
- * {@link org.hibernate.engine.SessionFactoryImplementor}
- * <li>should be thread safe
- * <li>should be fully serializable
- * </ul>
- * <p/>
- * Implementors should be aware that they are also fully responsible for
- * cleanup of any generated current-sessions.
- * <p/>
- * Note that there will be exactly one instance of the configured
- * CurrentSessionContext implementation per {@link org.hibernate.SessionFactory}.
- *
- * @author Steve Ebersole
- */
-public interface CurrentSessionContext extends Serializable {
- /**
- * Retrieve the current session according to the scoping defined
- * by this implementation.
- *
- * @return The current session.
- * @throws HibernateException Typically indicates an issue
- * locating or creating the current session.
- */
- public org.hibernate.classic.Session currentSession() throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/context/CurrentSessionContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/CurrentSessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.context;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * Defines the contract for implementations which know how to scope the notion
+ * of a {@link org.hibernate.SessionFactory#getCurrentSession() current session}.
+ * <p/>
+ * Implementations should adhere to the following:
+ * <ul>
+ * <li>contain a constructor accepting a single argument of type
+ * {@link org.hibernate.engine.SessionFactoryImplementor}
+ * <li>should be thread safe
+ * <li>should be fully serializable
+ * </ul>
+ * <p/>
+ * Implementors should be aware that they are also fully responsible for
+ * cleanup of any generated current-sessions.
+ * <p/>
+ * Note that there will be exactly one instance of the configured
+ * CurrentSessionContext implementation per {@link org.hibernate.SessionFactory}.
+ *
+ * @author Steve Ebersole
+ */
+public interface CurrentSessionContext extends Serializable {
+ /**
+ * Retrieve the current session according to the scoping defined
+ * by this implementation.
+ *
+ * @return The current session.
+ * @throws HibernateException Typically indicates an issue
+ * locating or creating the current session.
+ */
+ public org.hibernate.classic.Session currentSession() throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/JTASessionContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,203 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.context;
-
-import org.hibernate.HibernateException;
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.classic.Session;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.util.JTAHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.Synchronization;
-import java.util.Map;
-import java.util.Hashtable;
-
-/**
- * An implementation of {@link CurrentSessionContext} which scopes the notion
- * of a current session to a JTA transaction. Because JTA gives us a nice
- * tie-in to clean up after ourselves, this implementation will generate
- * Sessions as needed provided a JTA transaction is in effect. If a session
- * is not already associated with the current JTA transaction at the time
- * {@link #currentSession()} is called, a new session will be opened and it
- * will be associated with that JTA transaction.
- * <p/>
- * Note that the sessions returned from this method are automatically configured with
- * both the {@link org.hibernate.cfg.Environment#FLUSH_BEFORE_COMPLETION auto-flush} and
- * {@link org.hibernate.cfg.Environment#AUTO_CLOSE_SESSION auto-close} attributes set to
- * true, meaning that the Session will be automatically flushed and closed
- * as part of the lifecycle for the JTA transaction to which it is associated.
- * Additionally, it will also be configured to aggressively release JDBC
- * connections after each statement is executed. These settings are governed
- * by the {@link #isAutoFlushEnabled()}, {@link #isAutoCloseEnabled()}, and
- * {@link #getConnectionReleaseMode()} methods; these are provided (along with
- * the {@link #buildOrObtainSession()} method) for easier subclassing for custom
- * JTA-based session tracking logic (like maybe long-session semantics).
- *
- * @author Steve Ebersole
- */
-public class JTASessionContext implements CurrentSessionContext {
-
- private static final Logger log = LoggerFactory.getLogger( JTASessionContext.class );
-
- protected final SessionFactoryImplementor factory;
- private transient Map currentSessionMap = new Hashtable();
-
- public JTASessionContext(SessionFactoryImplementor factory) {
- this.factory = factory;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session currentSession() throws HibernateException {
- TransactionManager transactionManager = factory.getTransactionManager();
- if ( transactionManager == null ) {
- throw new HibernateException( "No TransactionManagerLookup specified" );
- }
-
- Transaction txn;
- try {
- txn = transactionManager.getTransaction();
- if ( txn == null ) {
- throw new HibernateException( "Unable to locate current JTA transaction" );
- }
- if ( !JTAHelper.isInProgress( txn.getStatus() ) ) {
- // We could register the session against the transaction even though it is
- // not started, but we'd have no guarentee of ever getting the map
- // entries cleaned up (aside from spawning threads).
- throw new HibernateException( "Current transaction is not in progress" );
- }
- }
- catch ( HibernateException e ) {
- throw e;
- }
- catch ( Throwable t ) {
- throw new HibernateException( "Problem locating/validating JTA transaction", t );
- }
-
- Session currentSession = ( Session ) currentSessionMap.get( txn );
-
- if ( currentSession == null ) {
- currentSession = buildOrObtainSession();
-
- try {
- txn.registerSynchronization( buildCleanupSynch( txn ) );
- }
- catch ( Throwable t ) {
- try {
- currentSession.close();
- }
- catch ( Throwable ignore ) {
- log.debug( "Unable to release generated current-session on failed synch registration", ignore );
- }
- throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" );
- }
-
- Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
- ? txn
- : factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
- currentSessionMap.put( txnIdentifier, currentSession );
- }
-
- return currentSession;
- }
-
- private CleanupSynch buildCleanupSynch(Transaction txn) {
- return new CleanupSynch( txn, this );
- }
-
- /**
- * Strictly provided for subclassing purposes; specifically to allow long-session
- * support.
- * <p/>
- * This implementation always just opens a new session.
- *
- * @return the built or (re)obtained session.
- */
- protected Session buildOrObtainSession() {
- return factory.openSession(
- null,
- isAutoFlushEnabled(),
- isAutoCloseEnabled(),
- getConnectionReleaseMode()
- );
- }
-
- /**
- * Mainly for subclass usage. This impl always returns true.
- *
- * @return Whether or not the the session should be closed by transaction completion.
- */
- protected boolean isAutoCloseEnabled() {
- return true;
- }
-
- /**
- * Mainly for subclass usage. This impl always returns true.
- *
- * @return Whether or not the the session should be flushed prior transaction completion.
- */
- protected boolean isAutoFlushEnabled() {
- return true;
- }
-
- /**
- * Mainly for subclass usage. This impl always returns after_statement.
- *
- * @return The connection release mode for any built sessions.
- */
- protected ConnectionReleaseMode getConnectionReleaseMode() {
- return ConnectionReleaseMode.AFTER_STATEMENT;
- }
-
- /**
- * JTA transaction synch used for cleanup of the internal session map.
- */
- protected static class CleanupSynch implements Synchronization {
- private Transaction txn;
- private JTASessionContext context;
-
- public CleanupSynch(Transaction txn, JTASessionContext context) {
- this.txn = txn;
- this.context = context;
- }
-
- /**
- * {@inheritDoc}
- */
- public void beforeCompletion() {
- }
-
- /**
- * {@inheritDoc}
- */
- public void afterCompletion(int i) {
- context.currentSessionMap.remove( txn );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/context/JTASessionContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/JTASessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,204 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.context;
+
+import org.hibernate.HibernateException;
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.classic.Session;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.util.JTAHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.Synchronization;
+import java.util.Map;
+import java.util.Hashtable;
+
+/**
+ * An implementation of {@link CurrentSessionContext} which scopes the notion
+ * of a current session to a JTA transaction. Because JTA gives us a nice
+ * tie-in to clean up after ourselves, this implementation will generate
+ * Sessions as needed provided a JTA transaction is in effect. If a session
+ * is not already associated with the current JTA transaction at the time
+ * {@link #currentSession()} is called, a new session will be opened and it
+ * will be associated with that JTA transaction.
+ * <p/>
+ * Note that the sessions returned from this method are automatically configured with
+ * both the {@link org.hibernate.cfg.Environment#FLUSH_BEFORE_COMPLETION auto-flush} and
+ * {@link org.hibernate.cfg.Environment#AUTO_CLOSE_SESSION auto-close} attributes set to
+ * true, meaning that the Session will be automatically flushed and closed
+ * as part of the lifecycle for the JTA transaction to which it is associated.
+ * Additionally, it will also be configured to aggressively release JDBC
+ * connections after each statement is executed. These settings are governed
+ * by the {@link #isAutoFlushEnabled()}, {@link #isAutoCloseEnabled()}, and
+ * {@link #getConnectionReleaseMode()} methods; these are provided (along with
+ * the {@link #buildOrObtainSession()} method) for easier subclassing for custom
+ * JTA-based session tracking logic (like maybe long-session semantics).
+ *
+ * @author Steve Ebersole
+ */
+public class JTASessionContext implements CurrentSessionContext {
+
+ private static final Logger log = LoggerFactory.getLogger( JTASessionContext.class );
+
+ protected final SessionFactoryImplementor factory;
+ private transient Map currentSessionMap = new Hashtable();
+
+ public JTASessionContext(SessionFactoryImplementor factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session currentSession() throws HibernateException {
+ TransactionManager transactionManager = factory.getTransactionManager();
+ if ( transactionManager == null ) {
+ throw new HibernateException( "No TransactionManagerLookup specified" );
+ }
+
+ Transaction txn;
+ try {
+ txn = transactionManager.getTransaction();
+ if ( txn == null ) {
+ throw new HibernateException( "Unable to locate current JTA transaction" );
+ }
+ if ( !JTAHelper.isInProgress( txn.getStatus() ) ) {
+ // We could register the session against the transaction even though it is
+ // not started, but we'd have no guarentee of ever getting the map
+ // entries cleaned up (aside from spawning threads).
+ throw new HibernateException( "Current transaction is not in progress" );
+ }
+ }
+ catch ( HibernateException e ) {
+ throw e;
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "Problem locating/validating JTA transaction", t );
+ }
+
+ Session currentSession = ( Session ) currentSessionMap.get( txn );
+
+ if ( currentSession == null ) {
+ currentSession = buildOrObtainSession();
+
+ try {
+ txn.registerSynchronization( buildCleanupSynch( txn ) );
+ }
+ catch ( Throwable t ) {
+ try {
+ currentSession.close();
+ }
+ catch ( Throwable ignore ) {
+ log.debug( "Unable to release generated current-session on failed synch registration", ignore );
+ }
+ throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" );
+ }
+
+ Object txnIdentifier = factory.getSettings().getTransactionManagerLookup() == null
+ ? txn
+ : factory.getSettings().getTransactionManagerLookup().getTransactionIdentifier( txn );
+ currentSessionMap.put( txnIdentifier, currentSession );
+ }
+
+ return currentSession;
+ }
+
+ private CleanupSynch buildCleanupSynch(Transaction txn) {
+ return new CleanupSynch( txn, this );
+ }
+
+ /**
+ * Strictly provided for subclassing purposes; specifically to allow long-session
+ * support.
+ * <p/>
+ * This implementation always just opens a new session.
+ *
+ * @return the built or (re)obtained session.
+ */
+ protected Session buildOrObtainSession() {
+ return factory.openSession(
+ null,
+ isAutoFlushEnabled(),
+ isAutoCloseEnabled(),
+ getConnectionReleaseMode()
+ );
+ }
+
+ /**
+ * Mainly for subclass usage. This impl always returns true.
+ *
+ * @return Whether or not the the session should be closed by transaction completion.
+ */
+ protected boolean isAutoCloseEnabled() {
+ return true;
+ }
+
+ /**
+ * Mainly for subclass usage. This impl always returns true.
+ *
+ * @return Whether or not the the session should be flushed prior transaction completion.
+ */
+ protected boolean isAutoFlushEnabled() {
+ return true;
+ }
+
+ /**
+ * Mainly for subclass usage. This impl always returns after_statement.
+ *
+ * @return The connection release mode for any built sessions.
+ */
+ protected ConnectionReleaseMode getConnectionReleaseMode() {
+ return ConnectionReleaseMode.AFTER_STATEMENT;
+ }
+
+ /**
+ * JTA transaction synch used for cleanup of the internal session map.
+ */
+ protected static class CleanupSynch implements Synchronization {
+ private Transaction txn;
+ private JTASessionContext context;
+
+ public CleanupSynch(Transaction txn, JTASessionContext context) {
+ this.txn = txn;
+ this.context = context;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void beforeCompletion() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void afterCompletion(int i) {
+ context.currentSessionMap.remove( txn );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/ManagedSessionContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,148 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.context;
-
-import org.hibernate.classic.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.SessionFactory;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * Represents a {@link CurrentSessionContext} the notion of a contextual session
- * is managed by some external entity (generally some form of interceptor, etc).
- * This external manager is responsible for scoping these contextual sessions
- * appropriately binding/unbinding them here for exposure to the application
- * through {@link SessionFactory#getCurrentSession} calls.
- * <p/>
- * Basically exposes two interfaces. <ul>
- * <li>First is the implementation of CurrentSessionContext which is then used
- * by the {@link SessionFactory#getCurrentSession()} calls. This
- * portion is instance-based specific to the session factory owning the given
- * instance of this impl (there will be one instance of this per each session
- * factory using this strategy).
- * <li>Second is the externally facing methods {@link #hasBind}, {@link #bind},
- * and {@link #unbind} used by the external thing to manage exposure of the
- * current session it is scoping. This portion is static to allow easy
- * reference from that external thing.
- * </ul>
- * The underlying storage of the current sessions here is a static
- * {@link ThreadLocal}-based map where the sessions are keyed by the
- * the owning session factory.
- *
- * @author Steve Ebersole
- */
-public class ManagedSessionContext implements CurrentSessionContext {
-
- private static final ThreadLocal context = new ThreadLocal();
- private final SessionFactoryImplementor factory;
-
- public ManagedSessionContext(SessionFactoryImplementor factory) {
- this.factory = factory;
- }
-
- /**
- * {@inheritDoc}
- */
- public Session currentSession() {
- Session current = existingSession( factory );
- if ( current == null ) {
- throw new HibernateException( "No session currently bound to execution context" );
- }
- return current;
- }
-
- /**
- * Check to see if there is already a session associated with the current
- * thread for the given session factory.
- *
- * @param factory The factory against which to check for a given session
- * within the current thread.
- * @return True if there is currently a session bound.
- */
- public static boolean hasBind(SessionFactory factory) {
- return existingSession( factory ) != null;
- }
-
- /**
- * Binds the given session to the current context for its session factory.
- *
- * @param session The session to be bound.
- * @return Any previously bound session (should be null in most cases).
- */
- public static Session bind(Session session) {
- return ( Session ) sessionMap( true ).put( session.getSessionFactory(), session );
- }
-
- /**
- * Unbinds the session (if one) current associated with the context for the
- * given session.
- *
- * @param factory The factory for which to unbind the current session.
- * @return The bound session if one, else null.
- */
- public static Session unbind(SessionFactory factory) {
- Session existing = null;
- Map sessionMap = sessionMap();
- if ( sessionMap != null ) {
- existing = ( Session ) sessionMap.remove( factory );
- doCleanup();
- }
- return existing;
- }
-
- private static Session existingSession(SessionFactory factory) {
- Map sessionMap = sessionMap();
- if ( sessionMap == null ) {
- return null;
- }
- else {
- return ( Session ) sessionMap.get( factory );
- }
- }
-
- protected static Map sessionMap() {
- return sessionMap( false );
- }
-
- private static synchronized Map sessionMap(boolean createMap) {
- Map sessionMap = ( Map ) context.get();
- if ( sessionMap == null && createMap ) {
- sessionMap = new HashMap();
- context.set( sessionMap );
- }
- return sessionMap;
- }
-
- private static synchronized void doCleanup() {
- Map sessionMap = sessionMap( false );
- if ( sessionMap != null ) {
- if ( sessionMap.isEmpty() ) {
- context.set( null );
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/context/ManagedSessionContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ManagedSessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,149 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.context;
+
+import org.hibernate.classic.Session;
+import org.hibernate.HibernateException;
+import org.hibernate.SessionFactory;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Represents a {@link CurrentSessionContext} the notion of a contextual session
+ * is managed by some external entity (generally some form of interceptor, etc).
+ * This external manager is responsible for scoping these contextual sessions
+ * appropriately binding/unbinding them here for exposure to the application
+ * through {@link SessionFactory#getCurrentSession} calls.
+ * <p/>
+ * Basically exposes two interfaces. <ul>
+ * <li>First is the implementation of CurrentSessionContext which is then used
+ * by the {@link SessionFactory#getCurrentSession()} calls. This
+ * portion is instance-based specific to the session factory owning the given
+ * instance of this impl (there will be one instance of this per each session
+ * factory using this strategy).
+ * <li>Second is the externally facing methods {@link #hasBind}, {@link #bind},
+ * and {@link #unbind} used by the external thing to manage exposure of the
+ * current session it is scoping. This portion is static to allow easy
+ * reference from that external thing.
+ * </ul>
+ * The underlying storage of the current sessions here is a static
+ * {@link ThreadLocal}-based map where the sessions are keyed by the
+ * the owning session factory.
+ *
+ * @author Steve Ebersole
+ */
+public class ManagedSessionContext implements CurrentSessionContext {
+
+ private static final ThreadLocal context = new ThreadLocal();
+ private final SessionFactoryImplementor factory;
+
+ public ManagedSessionContext(SessionFactoryImplementor factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Session currentSession() {
+ Session current = existingSession( factory );
+ if ( current == null ) {
+ throw new HibernateException( "No session currently bound to execution context" );
+ }
+ return current;
+ }
+
+ /**
+ * Check to see if there is already a session associated with the current
+ * thread for the given session factory.
+ *
+ * @param factory The factory against which to check for a given session
+ * within the current thread.
+ * @return True if there is currently a session bound.
+ */
+ public static boolean hasBind(SessionFactory factory) {
+ return existingSession( factory ) != null;
+ }
+
+ /**
+ * Binds the given session to the current context for its session factory.
+ *
+ * @param session The session to be bound.
+ * @return Any previously bound session (should be null in most cases).
+ */
+ public static Session bind(Session session) {
+ return ( Session ) sessionMap( true ).put( session.getSessionFactory(), session );
+ }
+
+ /**
+ * Unbinds the session (if one) current associated with the context for the
+ * given session.
+ *
+ * @param factory The factory for which to unbind the current session.
+ * @return The bound session if one, else null.
+ */
+ public static Session unbind(SessionFactory factory) {
+ Session existing = null;
+ Map sessionMap = sessionMap();
+ if ( sessionMap != null ) {
+ existing = ( Session ) sessionMap.remove( factory );
+ doCleanup();
+ }
+ return existing;
+ }
+
+ private static Session existingSession(SessionFactory factory) {
+ Map sessionMap = sessionMap();
+ if ( sessionMap == null ) {
+ return null;
+ }
+ else {
+ return ( Session ) sessionMap.get( factory );
+ }
+ }
+
+ protected static Map sessionMap() {
+ return sessionMap( false );
+ }
+
+ private static synchronized Map sessionMap(boolean createMap) {
+ Map sessionMap = ( Map ) context.get();
+ if ( sessionMap == null && createMap ) {
+ sessionMap = new HashMap();
+ context.set( sessionMap );
+ }
+ return sessionMap;
+ }
+
+ private static synchronized void doCleanup() {
+ Map sessionMap = sessionMap( false );
+ if ( sessionMap != null ) {
+ if ( sessionMap.isEmpty() ) {
+ context.set( null );
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,361 +0,0 @@
-package org.hibernate.context;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-import javax.transaction.Synchronization;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.HibernateException;
-import org.hibernate.SessionFactory;
-import org.hibernate.classic.Session;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * A {@link CurrentSessionContext} impl which scopes the notion of current
- * session by the current thread of execution. Unlike the JTA counterpart,
- * threads do not give us a nice hook to perform any type of cleanup making
- * it questionable for this impl to actually generate Session instances. In
- * the interest of usability, it was decided to have this default impl
- * actually generate a session upon first request and then clean it up
- * after the {@link org.hibernate.Transaction} associated with that session
- * is committed/rolled-back. In order for ensuring that happens, the sessions
- * generated here are unusable until after {@link Session#beginTransaction()}
- * has been called. If <tt>close()</tt> is called on a session managed by
- * this class, it will be automatically unbound.
- * <p/>
- * Additionally, the static {@link #bind} and {@link #unbind} methods are
- * provided to allow application code to explicitly control opening and
- * closing of these sessions. This, with some from of interception,
- * is the preferred approach. It also allows easy framework integration
- * and one possible approach for implementing long-sessions.
- * <p/>
- * The {@link #buildOrObtainSession}, {@link #isAutoCloseEnabled},
- * {@link #isAutoFlushEnabled}, {@link #getConnectionReleaseMode}, and
- * {@link #buildCleanupSynch} methods are all provided to allow easy
- * subclassing (for long-running session scenarios, for example).
- *
- * @author Steve Ebersole
- */
-public class ThreadLocalSessionContext implements CurrentSessionContext {
-
- private static final Logger log = LoggerFactory.getLogger( ThreadLocalSessionContext.class );
- private static final Class[] SESS_PROXY_INTERFACES = new Class[] {
- org.hibernate.classic.Session.class,
- org.hibernate.engine.SessionImplementor.class,
- org.hibernate.jdbc.JDBCContext.Context.class,
- org.hibernate.event.EventSource.class
- };
-
- /**
- * A ThreadLocal maintaining current sessions for the given execution thread.
- * The actual ThreadLocal variable is a java.util.Map to account for
- * the possibility for multiple SessionFactorys being used during execution
- * of the given thread.
- */
- private static final ThreadLocal context = new ThreadLocal();
-
- protected final SessionFactoryImplementor factory;
-
- public ThreadLocalSessionContext(SessionFactoryImplementor factory) {
- this.factory = factory;
- }
-
- /**
- * {@inheritDoc}
- */
- public final Session currentSession() throws HibernateException {
- Session current = existingSession( factory );
- if (current == null) {
- current = buildOrObtainSession();
- // register a cleanup synch
- current.getTransaction().registerSynchronization( buildCleanupSynch() );
- // wrap the session in the transaction-protection proxy
- if ( needsWrapping( current ) ) {
- current = wrap( current );
- }
- // then bind it
- doBind( current, factory );
- }
- return current;
- }
-
- private boolean needsWrapping(Session session) {
- // try to make sure we don't wrap and already wrapped session
- return session != null
- && ! Proxy.isProxyClass( session.getClass() )
- || ( Proxy.getInvocationHandler( session ) != null
- && ! ( Proxy.getInvocationHandler( session ) instanceof TransactionProtectionWrapper ) );
- }
-
- /**
- * Getter for property 'factory'.
- *
- * @return Value for property 'factory'.
- */
- protected SessionFactoryImplementor getFactory() {
- return factory;
- }
-
- /**
- * Strictly provided for subclassing purposes; specifically to allow long-session
- * support.
- * <p/>
- * This implementation always just opens a new session.
- *
- * @return the built or (re)obtained session.
- */
- protected Session buildOrObtainSession() {
- return factory.openSession(
- null,
- isAutoFlushEnabled(),
- isAutoCloseEnabled(),
- getConnectionReleaseMode()
- );
- }
-
- protected CleanupSynch buildCleanupSynch() {
- return new CleanupSynch( factory );
- }
-
- /**
- * Mainly for subclass usage. This impl always returns true.
- *
- * @return Whether or not the the session should be closed by transaction completion.
- */
- protected boolean isAutoCloseEnabled() {
- return true;
- }
-
- /**
- * Mainly for subclass usage. This impl always returns true.
- *
- * @return Whether or not the the session should be flushed prior transaction completion.
- */
- protected boolean isAutoFlushEnabled() {
- return true;
- }
-
- /**
- * Mainly for subclass usage. This impl always returns after_transaction.
- *
- * @return The connection release mode for any built sessions.
- */
- protected ConnectionReleaseMode getConnectionReleaseMode() {
- return factory.getSettings().getConnectionReleaseMode();
- }
-
- protected Session wrap(Session session) {
- TransactionProtectionWrapper wrapper = new TransactionProtectionWrapper( session );
- Session wrapped = ( Session ) Proxy.newProxyInstance(
- Session.class.getClassLoader(),
- SESS_PROXY_INTERFACES,
- wrapper
- );
- // yick! need this for proper serialization/deserialization handling...
- wrapper.setWrapped( wrapped );
- return wrapped;
- }
-
- /**
- * Associates the given session with the current thread of execution.
- *
- * @param session The session to bind.
- */
- public static void bind(org.hibernate.Session session) {
- SessionFactory factory = session.getSessionFactory();
- cleanupAnyOrphanedSession( factory );
- doBind( session, factory );
- }
-
- private static void cleanupAnyOrphanedSession(SessionFactory factory) {
- Session orphan = doUnbind( factory, false );
- if ( orphan != null ) {
- log.warn( "Already session bound on call to bind(); make sure you clean up your sessions!" );
- try {
- if ( orphan.getTransaction() != null && orphan.getTransaction().isActive() ) {
- try {
- orphan.getTransaction().rollback();
- }
- catch( Throwable t ) {
- log.debug( "Unable to rollback transaction for orphaned session", t );
- }
- }
- orphan.close();
- }
- catch( Throwable t ) {
- log.debug( "Unable to close orphaned session", t );
- }
- }
- }
-
- /**
- * Unassociate a previously bound session from the current thread of execution.
- *
- * @return The session which was unbound.
- */
- public static Session unbind(SessionFactory factory) {
- return doUnbind( factory, true );
- }
-
- private static Session existingSession(SessionFactory factory) {
- Map sessionMap = sessionMap();
- if ( sessionMap == null ) {
- return null;
- }
- else {
- return ( Session ) sessionMap.get( factory );
- }
- }
-
- protected static Map sessionMap() {
- return ( Map ) context.get();
- }
-
- private static void doBind(org.hibernate.Session session, SessionFactory factory) {
- Map sessionMap = sessionMap();
- if ( sessionMap == null ) {
- sessionMap = new HashMap();
- context.set( sessionMap );
- }
- sessionMap.put( factory, session );
- }
-
- private static Session doUnbind(SessionFactory factory, boolean releaseMapIfEmpty) {
- Map sessionMap = sessionMap();
- Session session = null;
- if ( sessionMap != null ) {
- session = ( Session ) sessionMap.remove( factory );
- if ( releaseMapIfEmpty && sessionMap.isEmpty() ) {
- context.set( null );
- }
- }
- return session;
- }
-
- /**
- * JTA transaction synch used for cleanup of the internal session map.
- */
- protected static class CleanupSynch implements Synchronization, Serializable {
- protected final SessionFactory factory;
-
- public CleanupSynch(SessionFactory factory) {
- this.factory = factory;
- }
-
- /**
- * {@inheritDoc}
- */
- public void beforeCompletion() {
- }
-
- /**
- * {@inheritDoc}
- */
- public void afterCompletion(int i) {
- unbind( factory );
- }
- }
-
- private class TransactionProtectionWrapper implements InvocationHandler, Serializable {
- private final Session realSession;
- private Session wrappedSession;
-
- public TransactionProtectionWrapper(Session realSession) {
- this.realSession = realSession;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- try {
- // If close() is called, guarantee unbind()
- if ( "close".equals( method.getName()) ) {
- unbind( realSession.getSessionFactory() );
- }
- else if ( "toString".equals( method.getName() )
- || "equals".equals( method.getName() )
- || "hashCode".equals( method.getName() )
- || "getStatistics".equals( method.getName() )
- || "isOpen".equals( method.getName() ) ) {
- // allow these to go through the the real session no matter what
- }
- else if ( !realSession.isOpen() ) {
- // essentially, if the real session is closed allow any
- // method call to pass through since the real session
- // will complain by throwing an appropriate exception;
- // NOTE that allowing close() above has the same basic effect,
- // but we capture that there simply to perform the unbind...
- }
- else if ( !realSession.getTransaction().isActive() ) {
- // limit the methods available if no transaction is active
- if ( "beginTransaction".equals( method.getName() )
- || "getTransaction".equals( method.getName() )
- || "isTransactionInProgress".equals( method.getName() )
- || "setFlushMode".equals( method.getName() )
- || "getSessionFactory".equals( method.getName() ) ) {
- log.trace( "allowing method [" + method.getName() + "] in non-transacted context" );
- }
- else if ( "reconnect".equals( method.getName() )
- || "disconnect".equals( method.getName() ) ) {
- // allow these (deprecated) methods to pass through
- }
- else {
- throw new HibernateException( method.getName() + " is not valid without active transaction" );
- }
- }
- log.trace( "allowing proxied method [" + method.getName() + "] to proceed to real session" );
- return method.invoke( realSession, args );
- }
- catch ( InvocationTargetException e ) {
- if ( e.getTargetException() instanceof RuntimeException ) {
- throw ( RuntimeException ) e.getTargetException();
- }
- else {
- throw e;
- }
- }
- }
-
- /**
- * Setter for property 'wrapped'.
- *
- * @param wrapped Value to set for property 'wrapped'.
- */
- public void setWrapped(Session wrapped) {
- this.wrappedSession = wrapped;
- }
-
-
- // serialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- private void writeObject(ObjectOutputStream oos) throws IOException {
- // if a ThreadLocalSessionContext-bound session happens to get
- // serialized, to be completely correct, we need to make sure
- // that unbinding of that session occurs.
- oos.defaultWriteObject();
- if ( existingSession( factory ) == wrappedSession ) {
- unbind( factory );
- }
- }
-
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- // on the inverse, it makes sense that if a ThreadLocalSessionContext-
- // bound session then gets deserialized to go ahead and re-bind it to
- // the ThreadLocalSessionContext session map.
- ois.defaultReadObject();
- realSession.getTransaction().registerSynchronization( buildCleanupSynch() );
- doBind( wrappedSession, factory );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/context/ThreadLocalSessionContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,385 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.context;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+import javax.transaction.Synchronization;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.HibernateException;
+import org.hibernate.SessionFactory;
+import org.hibernate.classic.Session;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * A {@link CurrentSessionContext} impl which scopes the notion of current
+ * session by the current thread of execution. Unlike the JTA counterpart,
+ * threads do not give us a nice hook to perform any type of cleanup making
+ * it questionable for this impl to actually generate Session instances. In
+ * the interest of usability, it was decided to have this default impl
+ * actually generate a session upon first request and then clean it up
+ * after the {@link org.hibernate.Transaction} associated with that session
+ * is committed/rolled-back. In order for ensuring that happens, the sessions
+ * generated here are unusable until after {@link Session#beginTransaction()}
+ * has been called. If <tt>close()</tt> is called on a session managed by
+ * this class, it will be automatically unbound.
+ * <p/>
+ * Additionally, the static {@link #bind} and {@link #unbind} methods are
+ * provided to allow application code to explicitly control opening and
+ * closing of these sessions. This, with some from of interception,
+ * is the preferred approach. It also allows easy framework integration
+ * and one possible approach for implementing long-sessions.
+ * <p/>
+ * The {@link #buildOrObtainSession}, {@link #isAutoCloseEnabled},
+ * {@link #isAutoFlushEnabled}, {@link #getConnectionReleaseMode}, and
+ * {@link #buildCleanupSynch} methods are all provided to allow easy
+ * subclassing (for long-running session scenarios, for example).
+ *
+ * @author Steve Ebersole
+ */
+public class ThreadLocalSessionContext implements CurrentSessionContext {
+
+ private static final Logger log = LoggerFactory.getLogger( ThreadLocalSessionContext.class );
+ private static final Class[] SESS_PROXY_INTERFACES = new Class[] {
+ org.hibernate.classic.Session.class,
+ org.hibernate.engine.SessionImplementor.class,
+ org.hibernate.jdbc.JDBCContext.Context.class,
+ org.hibernate.event.EventSource.class
+ };
+
+ /**
+ * A ThreadLocal maintaining current sessions for the given execution thread.
+ * The actual ThreadLocal variable is a java.util.Map to account for
+ * the possibility for multiple SessionFactorys being used during execution
+ * of the given thread.
+ */
+ private static final ThreadLocal context = new ThreadLocal();
+
+ protected final SessionFactoryImplementor factory;
+
+ public ThreadLocalSessionContext(SessionFactoryImplementor factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final Session currentSession() throws HibernateException {
+ Session current = existingSession( factory );
+ if (current == null) {
+ current = buildOrObtainSession();
+ // register a cleanup synch
+ current.getTransaction().registerSynchronization( buildCleanupSynch() );
+ // wrap the session in the transaction-protection proxy
+ if ( needsWrapping( current ) ) {
+ current = wrap( current );
+ }
+ // then bind it
+ doBind( current, factory );
+ }
+ return current;
+ }
+
+ private boolean needsWrapping(Session session) {
+ // try to make sure we don't wrap and already wrapped session
+ return session != null
+ && ! Proxy.isProxyClass( session.getClass() )
+ || ( Proxy.getInvocationHandler( session ) != null
+ && ! ( Proxy.getInvocationHandler( session ) instanceof TransactionProtectionWrapper ) );
+ }
+
+ /**
+ * Getter for property 'factory'.
+ *
+ * @return Value for property 'factory'.
+ */
+ protected SessionFactoryImplementor getFactory() {
+ return factory;
+ }
+
+ /**
+ * Strictly provided for subclassing purposes; specifically to allow long-session
+ * support.
+ * <p/>
+ * This implementation always just opens a new session.
+ *
+ * @return the built or (re)obtained session.
+ */
+ protected Session buildOrObtainSession() {
+ return factory.openSession(
+ null,
+ isAutoFlushEnabled(),
+ isAutoCloseEnabled(),
+ getConnectionReleaseMode()
+ );
+ }
+
+ protected CleanupSynch buildCleanupSynch() {
+ return new CleanupSynch( factory );
+ }
+
+ /**
+ * Mainly for subclass usage. This impl always returns true.
+ *
+ * @return Whether or not the the session should be closed by transaction completion.
+ */
+ protected boolean isAutoCloseEnabled() {
+ return true;
+ }
+
+ /**
+ * Mainly for subclass usage. This impl always returns true.
+ *
+ * @return Whether or not the the session should be flushed prior transaction completion.
+ */
+ protected boolean isAutoFlushEnabled() {
+ return true;
+ }
+
+ /**
+ * Mainly for subclass usage. This impl always returns after_transaction.
+ *
+ * @return The connection release mode for any built sessions.
+ */
+ protected ConnectionReleaseMode getConnectionReleaseMode() {
+ return factory.getSettings().getConnectionReleaseMode();
+ }
+
+ protected Session wrap(Session session) {
+ TransactionProtectionWrapper wrapper = new TransactionProtectionWrapper( session );
+ Session wrapped = ( Session ) Proxy.newProxyInstance(
+ Session.class.getClassLoader(),
+ SESS_PROXY_INTERFACES,
+ wrapper
+ );
+ // yick! need this for proper serialization/deserialization handling...
+ wrapper.setWrapped( wrapped );
+ return wrapped;
+ }
+
+ /**
+ * Associates the given session with the current thread of execution.
+ *
+ * @param session The session to bind.
+ */
+ public static void bind(org.hibernate.Session session) {
+ SessionFactory factory = session.getSessionFactory();
+ cleanupAnyOrphanedSession( factory );
+ doBind( session, factory );
+ }
+
+ private static void cleanupAnyOrphanedSession(SessionFactory factory) {
+ Session orphan = doUnbind( factory, false );
+ if ( orphan != null ) {
+ log.warn( "Already session bound on call to bind(); make sure you clean up your sessions!" );
+ try {
+ if ( orphan.getTransaction() != null && orphan.getTransaction().isActive() ) {
+ try {
+ orphan.getTransaction().rollback();
+ }
+ catch( Throwable t ) {
+ log.debug( "Unable to rollback transaction for orphaned session", t );
+ }
+ }
+ orphan.close();
+ }
+ catch( Throwable t ) {
+ log.debug( "Unable to close orphaned session", t );
+ }
+ }
+ }
+
+ /**
+ * Unassociate a previously bound session from the current thread of execution.
+ *
+ * @return The session which was unbound.
+ */
+ public static Session unbind(SessionFactory factory) {
+ return doUnbind( factory, true );
+ }
+
+ private static Session existingSession(SessionFactory factory) {
+ Map sessionMap = sessionMap();
+ if ( sessionMap == null ) {
+ return null;
+ }
+ else {
+ return ( Session ) sessionMap.get( factory );
+ }
+ }
+
+ protected static Map sessionMap() {
+ return ( Map ) context.get();
+ }
+
+ private static void doBind(org.hibernate.Session session, SessionFactory factory) {
+ Map sessionMap = sessionMap();
+ if ( sessionMap == null ) {
+ sessionMap = new HashMap();
+ context.set( sessionMap );
+ }
+ sessionMap.put( factory, session );
+ }
+
+ private static Session doUnbind(SessionFactory factory, boolean releaseMapIfEmpty) {
+ Map sessionMap = sessionMap();
+ Session session = null;
+ if ( sessionMap != null ) {
+ session = ( Session ) sessionMap.remove( factory );
+ if ( releaseMapIfEmpty && sessionMap.isEmpty() ) {
+ context.set( null );
+ }
+ }
+ return session;
+ }
+
+ /**
+ * JTA transaction synch used for cleanup of the internal session map.
+ */
+ protected static class CleanupSynch implements Synchronization, Serializable {
+ protected final SessionFactory factory;
+
+ public CleanupSynch(SessionFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void beforeCompletion() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void afterCompletion(int i) {
+ unbind( factory );
+ }
+ }
+
+ private class TransactionProtectionWrapper implements InvocationHandler, Serializable {
+ private final Session realSession;
+ private Session wrappedSession;
+
+ public TransactionProtectionWrapper(Session realSession) {
+ this.realSession = realSession;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ try {
+ // If close() is called, guarantee unbind()
+ if ( "close".equals( method.getName()) ) {
+ unbind( realSession.getSessionFactory() );
+ }
+ else if ( "toString".equals( method.getName() )
+ || "equals".equals( method.getName() )
+ || "hashCode".equals( method.getName() )
+ || "getStatistics".equals( method.getName() )
+ || "isOpen".equals( method.getName() ) ) {
+ // allow these to go through the the real session no matter what
+ }
+ else if ( !realSession.isOpen() ) {
+ // essentially, if the real session is closed allow any
+ // method call to pass through since the real session
+ // will complain by throwing an appropriate exception;
+ // NOTE that allowing close() above has the same basic effect,
+ // but we capture that there simply to perform the unbind...
+ }
+ else if ( !realSession.getTransaction().isActive() ) {
+ // limit the methods available if no transaction is active
+ if ( "beginTransaction".equals( method.getName() )
+ || "getTransaction".equals( method.getName() )
+ || "isTransactionInProgress".equals( method.getName() )
+ || "setFlushMode".equals( method.getName() )
+ || "getSessionFactory".equals( method.getName() ) ) {
+ log.trace( "allowing method [" + method.getName() + "] in non-transacted context" );
+ }
+ else if ( "reconnect".equals( method.getName() )
+ || "disconnect".equals( method.getName() ) ) {
+ // allow these (deprecated) methods to pass through
+ }
+ else {
+ throw new HibernateException( method.getName() + " is not valid without active transaction" );
+ }
+ }
+ log.trace( "allowing proxied method [" + method.getName() + "] to proceed to real session" );
+ return method.invoke( realSession, args );
+ }
+ catch ( InvocationTargetException e ) {
+ if ( e.getTargetException() instanceof RuntimeException ) {
+ throw ( RuntimeException ) e.getTargetException();
+ }
+ else {
+ throw e;
+ }
+ }
+ }
+
+ /**
+ * Setter for property 'wrapped'.
+ *
+ * @param wrapped Value to set for property 'wrapped'.
+ */
+ public void setWrapped(Session wrapped) {
+ this.wrappedSession = wrapped;
+ }
+
+
+ // serialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ // if a ThreadLocalSessionContext-bound session happens to get
+ // serialized, to be completely correct, we need to make sure
+ // that unbinding of that session occurs.
+ oos.defaultWriteObject();
+ if ( existingSession( factory ) == wrappedSession ) {
+ unbind( factory );
+ }
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ // on the inverse, it makes sense that if a ThreadLocalSessionContext-
+ // bound session then gets deserialized to go ahead and re-bind it to
+ // the ThreadLocalSessionContext session map.
+ ois.defaultReadObject();
+ realSession.getTransaction().registerSynchronization( buildCleanupSynch() );
+ doBind( wrappedSession, factory );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,86 +0,0 @@
-// $Id: AbstractEmptinessExpression.java 6670 2005-05-03 22:19:00Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.MappingException;
-import org.hibernate.QueryException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.persister.collection.QueryableCollection;
-import org.hibernate.persister.entity.Loadable;
-import org.hibernate.persister.entity.PropertyMapping;
-import org.hibernate.sql.ConditionFragment;
-import org.hibernate.type.CollectionType;
-import org.hibernate.type.Type;
-
-/**
- * Implementation of AbstractEmptinessExpression.
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractEmptinessExpression implements Criterion {
-
- private static final TypedValue[] NO_VALUES = new TypedValue[0];
-
- protected final String propertyName;
-
- protected AbstractEmptinessExpression(String propertyName) {
- this.propertyName = propertyName;
- }
-
- protected abstract boolean excludeEmpty();
-
- public final String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- String entityName = criteriaQuery.getEntityName( criteria, propertyName );
- String actualPropertyName = criteriaQuery.getPropertyName( propertyName );
- String sqlAlias = criteriaQuery.getSQLAlias( criteria, propertyName );
-
- SessionFactoryImplementor factory = criteriaQuery.getFactory();
- QueryableCollection collectionPersister = getQueryableCollection( entityName, actualPropertyName, factory );
-
- String[] collectionKeys = collectionPersister.getKeyColumnNames();
- String[] ownerKeys = ( ( Loadable ) factory.getEntityPersister( entityName ) ).getIdentifierColumnNames();
-
- String innerSelect = "(select 1 from " + collectionPersister.getTableName()
- + " where "
- + new ConditionFragment().setTableAlias( sqlAlias ).setCondition( ownerKeys, collectionKeys ).toFragmentString()
- + ")";
-
- return excludeEmpty()
- ? "exists " + innerSelect
- : "not exists " + innerSelect;
- }
-
-
- protected QueryableCollection getQueryableCollection(String entityName, String propertyName, SessionFactoryImplementor factory)
- throws HibernateException {
- PropertyMapping ownerMapping = ( PropertyMapping ) factory.getEntityPersister( entityName );
- Type type = ownerMapping.toType( propertyName );
- if ( !type.isCollectionType() ) {
- throw new MappingException(
- "Property path [" + entityName + "." + propertyName + "] does not reference a collection"
- );
- }
-
- String role = ( ( CollectionType ) type ).getRole();
- try {
- return ( QueryableCollection ) factory.getCollectionPersister( role );
- }
- catch ( ClassCastException cce ) {
- throw new QueryException( "collection role is not queryable: " + role );
- }
- catch ( Exception e ) {
- throw new QueryException( "collection role not found: " + role );
- }
- }
-
- public final TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return NO_VALUES;
- }
-
- public final String toString() {
- return propertyName + ( excludeEmpty() ? " is not empty" : " is empty" );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AbstractEmptinessExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,109 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.QueryException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.persister.entity.Loadable;
+import org.hibernate.persister.entity.PropertyMapping;
+import org.hibernate.sql.ConditionFragment;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.Type;
+
+/**
+ * Implementation of AbstractEmptinessExpression.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractEmptinessExpression implements Criterion {
+
+ private static final TypedValue[] NO_VALUES = new TypedValue[0];
+
+ protected final String propertyName;
+
+ protected AbstractEmptinessExpression(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ protected abstract boolean excludeEmpty();
+
+ public final String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
+ String entityName = criteriaQuery.getEntityName( criteria, propertyName );
+ String actualPropertyName = criteriaQuery.getPropertyName( propertyName );
+ String sqlAlias = criteriaQuery.getSQLAlias( criteria, propertyName );
+
+ SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ QueryableCollection collectionPersister = getQueryableCollection( entityName, actualPropertyName, factory );
+
+ String[] collectionKeys = collectionPersister.getKeyColumnNames();
+ String[] ownerKeys = ( ( Loadable ) factory.getEntityPersister( entityName ) ).getIdentifierColumnNames();
+
+ String innerSelect = "(select 1 from " + collectionPersister.getTableName()
+ + " where "
+ + new ConditionFragment().setTableAlias( sqlAlias ).setCondition( ownerKeys, collectionKeys ).toFragmentString()
+ + ")";
+
+ return excludeEmpty()
+ ? "exists " + innerSelect
+ : "not exists " + innerSelect;
+ }
+
+
+ protected QueryableCollection getQueryableCollection(String entityName, String propertyName, SessionFactoryImplementor factory)
+ throws HibernateException {
+ PropertyMapping ownerMapping = ( PropertyMapping ) factory.getEntityPersister( entityName );
+ Type type = ownerMapping.toType( propertyName );
+ if ( !type.isCollectionType() ) {
+ throw new MappingException(
+ "Property path [" + entityName + "." + propertyName + "] does not reference a collection"
+ );
+ }
+
+ String role = ( ( CollectionType ) type ).getRole();
+ try {
+ return ( QueryableCollection ) factory.getCollectionPersister( role );
+ }
+ catch ( ClassCastException cce ) {
+ throw new QueryException( "collection role is not queryable: " + role );
+ }
+ catch ( Exception e ) {
+ throw new QueryException( "collection role not found: " + role );
+ }
+ }
+
+ public final TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return NO_VALUES;
+ }
+
+ public final String toString() {
+ return propertyName + ( excludeEmpty() ? " is not empty" : " is empty" );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/AggregateProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,43 +0,0 @@
-//$Id: AggregateProjection.java 9908 2006-05-08 20:59:20Z max.andersen(a)jboss.com $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * An aggregation
- * @author max
- */
-public class AggregateProjection extends SimpleProjection {
-
- protected final String propertyName;
- private final String aggregate;
-
- protected AggregateProjection(String aggregate, String propertyName) {
- this.aggregate = aggregate;
- this.propertyName = propertyName;
- }
-
- public String toString() {
- return aggregate + "(" + propertyName + ')';
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new Type[] { criteriaQuery.getType(criteria, propertyName) };
- }
-
- public String toSqlString(Criteria criteria, int loc, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new StringBuffer()
- .append(aggregate)
- .append("(")
- .append( criteriaQuery.getColumn(criteria, propertyName) )
- .append(") as y")
- .append(loc)
- .append('_')
- .toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/AggregateProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AggregateProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * An aggregation
+ *
+ * @author max
+ */
+public class AggregateProjection extends SimpleProjection {
+
+ protected final String propertyName;
+ private final String aggregate;
+
+ protected AggregateProjection(String aggregate, String propertyName) {
+ this.aggregate = aggregate;
+ this.propertyName = propertyName;
+ }
+
+ public String toString() {
+ return aggregate + "(" + propertyName + ')';
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new Type[] { criteriaQuery.getType(criteria, propertyName) };
+ }
+
+ public String toSqlString(Criteria criteria, int loc, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new StringBuffer()
+ .append(aggregate)
+ .append("(")
+ .append( criteriaQuery.getColumn(criteria, propertyName) )
+ .append(") as y")
+ .append(loc)
+ .append('_')
+ .toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/AliasedProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,65 +0,0 @@
-//$Id: AliasedProjection.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * @author Gavin King
- */
-public class AliasedProjection implements Projection {
-
- private final Projection projection;
- private final String alias;
-
- public String toString() {
- return projection.toString() + " as " + alias;
- }
-
- protected AliasedProjection(Projection projection, String alias) {
- this.projection = projection;
- this.alias = alias;
- }
-
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return projection.toSqlString(criteria, position, criteriaQuery);
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return projection.toGroupSqlString(criteria, criteriaQuery);
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return projection.getTypes(criteria, criteriaQuery);
- }
-
- public String[] getColumnAliases(int loc) {
- return projection.getColumnAliases(loc);
- }
-
- public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return this.alias.equals(alias) ?
- getTypes(criteria, criteriaQuery) :
- null;
- }
-
- public String[] getColumnAliases(String alias, int loc) {
- return this.alias.equals(alias) ?
- getColumnAliases(loc) :
- null;
- }
-
- public String[] getAliases() {
- return new String[]{ alias };
- }
-
- public boolean isGrouped() {
- return projection.isGrouped();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/AliasedProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AliasedProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,88 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * @author Gavin King
+ */
+public class AliasedProjection implements Projection {
+
+ private final Projection projection;
+ private final String alias;
+
+ public String toString() {
+ return projection.toString() + " as " + alias;
+ }
+
+ protected AliasedProjection(Projection projection, String alias) {
+ this.projection = projection;
+ this.alias = alias;
+ }
+
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return projection.toSqlString(criteria, position, criteriaQuery);
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return projection.toGroupSqlString(criteria, criteriaQuery);
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return projection.getTypes(criteria, criteriaQuery);
+ }
+
+ public String[] getColumnAliases(int loc) {
+ return projection.getColumnAliases(loc);
+ }
+
+ public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return this.alias.equals(alias) ?
+ getTypes(criteria, criteriaQuery) :
+ null;
+ }
+
+ public String[] getColumnAliases(String alias, int loc) {
+ return this.alias.equals(alias) ?
+ getColumnAliases(loc) :
+ null;
+ }
+
+ public String[] getAliases() {
+ return new String[]{ alias };
+ }
+
+ public boolean isGrouped() {
+ return projection.isGrouped();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/AvgProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-//$Id: AvgProjection.java 9908 2006-05-08 20:59:20Z max.andersen(a)jboss.com $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * @author Gavin King
- */
-public class AvgProjection extends AggregateProjection {
-
- public AvgProjection(String propertyName) {
- super("avg", propertyName);
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new Type[] { Hibernate.DOUBLE };
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/AvgProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/AvgProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * An avg() projection
+ *
+ * @author Gavin King
+ */
+public class AvgProjection extends AggregateProjection {
+
+ public AvgProjection(String propertyName) {
+ super("avg", propertyName);
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new Type[] { Hibernate.DOUBLE };
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/BetweenExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,48 +0,0 @@
-//$Id: BetweenExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.util.StringHelper;
-
-/**
- * Constrains a property to between two values
- * @author Gavin King
- */
-public class BetweenExpression implements Criterion {
-
- private final String propertyName;
- private final Object lo;
- private final Object hi;
-
- protected BetweenExpression(String propertyName, Object lo, Object hi) {
- this.propertyName = propertyName;
- this.lo = lo;
- this.hi = hi;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return StringHelper.join(
- " and ",
- StringHelper.suffix( criteriaQuery.getColumnsUsingProjection(criteria, propertyName), " between ? and ?" )
- );
-
- //TODO: get SQL rendering out of this package!
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new TypedValue[] {
- criteriaQuery.getTypedValue(criteria, propertyName, lo),
- criteriaQuery.getTypedValue(criteria, propertyName, hi)
- };
- }
-
- public String toString() {
- return propertyName + " between " + lo + " and " + hi;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/BetweenExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/BetweenExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,71 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Constrains a property to between two values
+ * @author Gavin King
+ */
+public class BetweenExpression implements Criterion {
+
+ private final String propertyName;
+ private final Object lo;
+ private final Object hi;
+
+ protected BetweenExpression(String propertyName, Object lo, Object hi) {
+ this.propertyName = propertyName;
+ this.lo = lo;
+ this.hi = hi;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return StringHelper.join(
+ " and ",
+ StringHelper.suffix( criteriaQuery.getColumnsUsingProjection(criteria, propertyName), " between ? and ?" )
+ );
+
+ //TODO: get SQL rendering out of this package!
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new TypedValue[] {
+ criteriaQuery.getTypedValue(criteria, propertyName, lo),
+ criteriaQuery.getTypedValue(criteria, propertyName, hi)
+ };
+ }
+
+ public String toString() {
+ return propertyName + " between " + lo + " and " + hi;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Conjunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,13 +0,0 @@
-package org.hibernate.criterion;
-
-
-/**
- * @author Gavin King
- */
-public class Conjunction extends Junction {
-
- public Conjunction() {
- super("and");
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Conjunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Conjunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+/**
+ * @author Gavin King
+ */
+public class Conjunction extends Junction {
+
+ public Conjunction() {
+ super("and");
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/CountProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,51 +0,0 @@
-//$Id: CountProjection.java 9913 2006-05-09 07:40:11Z max.andersen(a)jboss.com $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * A count
- * @author Gavin King
- */
-public class CountProjection extends AggregateProjection {
-
- private boolean distinct;
-
- protected CountProjection(String prop) {
- super("count", prop);
- }
-
- public String toString() {
- if(distinct) {
- return "distinct " + super.toString();
- } else {
- return super.toString();
- }
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new Type[] { Hibernate.INTEGER };
- }
-
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException {
- StringBuffer buf = new StringBuffer();
- buf.append("count(");
- if (distinct) buf.append("distinct ");
- return buf.append( criteriaQuery.getColumn(criteria, propertyName) )
- .append(") as y")
- .append(position)
- .append('_')
- .toString();
- }
-
- public CountProjection setDistinct() {
- distinct = true;
- return this;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/CountProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CountProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,74 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * A count
+ * @author Gavin King
+ */
+public class CountProjection extends AggregateProjection {
+
+ private boolean distinct;
+
+ protected CountProjection(String prop) {
+ super("count", prop);
+ }
+
+ public String toString() {
+ if(distinct) {
+ return "distinct " + super.toString();
+ } else {
+ return super.toString();
+ }
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new Type[] { Hibernate.INTEGER };
+ }
+
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ StringBuffer buf = new StringBuffer();
+ buf.append("count(");
+ if (distinct) buf.append("distinct ");
+ return buf.append( criteriaQuery.getColumn(criteria, propertyName) )
+ .append(") as y")
+ .append(position)
+ .append('_')
+ .toString();
+ }
+
+ public CountProjection setDistinct() {
+ distinct = true;
+ return this;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,92 +0,0 @@
-//$Id: CriteriaQuery.java 6970 2005-05-31 20:24:41Z oneovthafew $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.type.Type;
-
-/**
- * An instance of <tt>CriteriaQuery</tt> is passed to criterion,
- * order and projection instances when actually compiling and
- * executing the query. This interface is not used by application
- * code.
- *
- * @author Gavin King
- */
-public interface CriteriaQuery {
- public SessionFactoryImplementor getFactory();
-
- /**
- * Get the names of the columns mapped by a property path,
- * ignoring projection aliases
- */
- public String getColumn(Criteria criteria, String propertyPath)
- throws HibernateException;
-
- /**
- * Get the type of a property path, ignoring projection aliases
- */
- public Type getType(Criteria criteria, String propertyPath)
- throws HibernateException;
-
- /**
- * Get the names of the columns mapped by a property path
- */
- public String[] getColumnsUsingProjection(Criteria criteria, String propertyPath)
- throws HibernateException;
-
- /**
- * Get the type of a property path
- */
- public Type getTypeUsingProjection(Criteria criteria, String propertyPath)
- throws HibernateException;
-
- /**
- * Get the a typed value for the given property value.
- */
- public TypedValue getTypedValue(Criteria criteria, String propertyPath, Object value)
- throws HibernateException;
-
- /**
- * Get the entity name of an entity
- */
- public String getEntityName(Criteria criteria);
-
- /**
- * Get the entity name of an entity, taking into account
- * the qualifier of the property path
- */
- public String getEntityName(Criteria criteria, String propertyPath);
-
- /**
- * Get the root table alias of an entity
- */
- public String getSQLAlias(Criteria subcriteria);
-
- /**
- * Get the root table alias of an entity, taking into account
- * the qualifier of the property path
- */
- public String getSQLAlias(Criteria criteria, String propertyPath);
-
- /**
- * Get the property name, given a possibly qualified property name
- */
- public String getPropertyName(String propertyName);
-
- /**
- * Get the identifier column names of this entity
- */
- public String[] getIdentifierColumns(Criteria subcriteria);
-
- /**
- * Get the identifier type of this entity
- */
- public Type getIdentifierType(Criteria subcriteria);
-
- public TypedValue getTypedIdentifierValue(Criteria subcriteria, Object value);
-
- public String generateSQLAlias();
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaQuery.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,115 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.type.Type;
+
+/**
+ * An instance of <tt>CriteriaQuery</tt> is passed to criterion,
+ * order and projection instances when actually compiling and
+ * executing the query. This interface is not used by application
+ * code.
+ *
+ * @author Gavin King
+ */
+public interface CriteriaQuery {
+ public SessionFactoryImplementor getFactory();
+
+ /**
+ * Get the names of the columns mapped by a property path,
+ * ignoring projection aliases
+ */
+ public String getColumn(Criteria criteria, String propertyPath)
+ throws HibernateException;
+
+ /**
+ * Get the type of a property path, ignoring projection aliases
+ */
+ public Type getType(Criteria criteria, String propertyPath)
+ throws HibernateException;
+
+ /**
+ * Get the names of the columns mapped by a property path
+ */
+ public String[] getColumnsUsingProjection(Criteria criteria, String propertyPath)
+ throws HibernateException;
+
+ /**
+ * Get the type of a property path
+ */
+ public Type getTypeUsingProjection(Criteria criteria, String propertyPath)
+ throws HibernateException;
+
+ /**
+ * Get the a typed value for the given property value.
+ */
+ public TypedValue getTypedValue(Criteria criteria, String propertyPath, Object value)
+ throws HibernateException;
+
+ /**
+ * Get the entity name of an entity
+ */
+ public String getEntityName(Criteria criteria);
+
+ /**
+ * Get the entity name of an entity, taking into account
+ * the qualifier of the property path
+ */
+ public String getEntityName(Criteria criteria, String propertyPath);
+
+ /**
+ * Get the root table alias of an entity
+ */
+ public String getSQLAlias(Criteria subcriteria);
+
+ /**
+ * Get the root table alias of an entity, taking into account
+ * the qualifier of the property path
+ */
+ public String getSQLAlias(Criteria criteria, String propertyPath);
+
+ /**
+ * Get the property name, given a possibly qualified property name
+ */
+ public String getPropertyName(String propertyName);
+
+ /**
+ * Get the identifier column names of this entity
+ */
+ public String[] getIdentifierColumns(Criteria subcriteria);
+
+ /**
+ * Get the identifier type of this entity
+ */
+ public Type getIdentifierType(Criteria subcriteria);
+
+ public TypedValue getTypedIdentifierValue(Criteria subcriteria, Object value);
+
+ public String generateSQLAlias();
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,55 +0,0 @@
-//$Id: CriteriaSpecification.java 9116 2006-01-23 21:21:01Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.transform.AliasToEntityMapResultTransformer;
-import org.hibernate.transform.DistinctRootEntityResultTransformer;
-import org.hibernate.transform.PassThroughResultTransformer;
-import org.hibernate.transform.ResultTransformer;
-import org.hibernate.transform.RootEntityResultTransformer;
-
-/**
- * @author Gavin King
- */
-public interface CriteriaSpecification {
-
- /**
- * The alias that refers to the "root" entity of the criteria query.
- */
- public static final String ROOT_ALIAS = "this";
-
- /**
- * Each row of results is a <tt>Map</tt> from alias to entity instance
- */
- public static final ResultTransformer ALIAS_TO_ENTITY_MAP = new AliasToEntityMapResultTransformer();
-
- /**
- * Each row of results is an instance of the root entity
- */
- public static final ResultTransformer ROOT_ENTITY = new RootEntityResultTransformer();
-
- /**
- * Each row of results is a distinct instance of the root entity
- */
- public static final ResultTransformer DISTINCT_ROOT_ENTITY = new DistinctRootEntityResultTransformer();
-
- /**
- * This result transformer is selected implicitly by calling <tt>setProjection()</tt>
- */
- public static final ResultTransformer PROJECTION = new PassThroughResultTransformer();
-
- /**
- * Specifies joining to an entity based on an inner join.
- */
- public static final int INNER_JOIN = org.hibernate.sql.JoinFragment.INNER_JOIN;
-
- /**
- * Specifies joining to an entity based on a full join.
- */
- public static final int FULL_JOIN = org.hibernate.sql.JoinFragment.FULL_JOIN;
-
- /**
- * Specifies joining to an entity based on a left outer join.
- */
- public static final int LEFT_JOIN = org.hibernate.sql.JoinFragment.LEFT_OUTER_JOIN;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/CriteriaSpecification.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.transform.AliasToEntityMapResultTransformer;
+import org.hibernate.transform.DistinctRootEntityResultTransformer;
+import org.hibernate.transform.PassThroughResultTransformer;
+import org.hibernate.transform.ResultTransformer;
+import org.hibernate.transform.RootEntityResultTransformer;
+
+/**
+ * @author Gavin King
+ */
+public interface CriteriaSpecification {
+
+ /**
+ * The alias that refers to the "root" entity of the criteria query.
+ */
+ public static final String ROOT_ALIAS = "this";
+
+ /**
+ * Each row of results is a <tt>Map</tt> from alias to entity instance
+ */
+ public static final ResultTransformer ALIAS_TO_ENTITY_MAP = new AliasToEntityMapResultTransformer();
+
+ /**
+ * Each row of results is an instance of the root entity
+ */
+ public static final ResultTransformer ROOT_ENTITY = new RootEntityResultTransformer();
+
+ /**
+ * Each row of results is a distinct instance of the root entity
+ */
+ public static final ResultTransformer DISTINCT_ROOT_ENTITY = new DistinctRootEntityResultTransformer();
+
+ /**
+ * This result transformer is selected implicitly by calling <tt>setProjection()</tt>
+ */
+ public static final ResultTransformer PROJECTION = new PassThroughResultTransformer();
+
+ /**
+ * Specifies joining to an entity based on an inner join.
+ */
+ public static final int INNER_JOIN = org.hibernate.sql.JoinFragment.INNER_JOIN;
+
+ /**
+ * Specifies joining to an entity based on a full join.
+ */
+ public static final int FULL_JOIN = org.hibernate.sql.JoinFragment.FULL_JOIN;
+
+ /**
+ * Specifies joining to an entity based on a left outer join.
+ */
+ public static final int LEFT_JOIN = org.hibernate.sql.JoinFragment.LEFT_OUTER_JOIN;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Criterion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,44 +0,0 @@
-//$Id: Criterion.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import java.io.Serializable;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-
-/**
- * An object-oriented representation of a query criterion that may be used
- * as a restriction in a <tt>Criteria</tt> query.
- * Built-in criterion types are provided by the <tt>Restrictions</tt> factory
- * class. This interface might be implemented by application classes that
- * define custom restriction criteria.
- *
- * @see Restrictions
- * @see org.hibernate.Criteria
- * @author Gavin King
- */
-public interface Criterion extends Serializable {
-
- /**
- * Render the SQL fragment
- * @param criteriaQuery
- * @param alias
- * @return String
- * @throws HibernateException
- */
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException;
-
- /**
- * Return typed values for all parameters in the rendered SQL fragment
- * @param criteria TODO
- * @param criteriaQuery
- * @return TypedValue[]
- * @throws HibernateException
- */
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Criterion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Criterion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.io.Serializable;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * An object-oriented representation of a query criterion that may be used
+ * as a restriction in a <tt>Criteria</tt> query.
+ * Built-in criterion types are provided by the <tt>Restrictions</tt> factory
+ * class. This interface might be implemented by application classes that
+ * define custom restriction criteria.
+ *
+ * @see Restrictions
+ * @see Criteria
+ * @author Gavin King
+ */
+public interface Criterion extends Serializable {
+
+ /**
+ * Render the SQL fragment
+ *
+ * @param criteria The local criteria
+ * @param criteriaQuery The overal criteria query
+ *
+ * @return The generated SQL fragment
+ * @throws org.hibernate.HibernateException Problem during rendering.
+ */
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException;
+
+ /**
+ * Return typed values for all parameters in the rendered SQL fragment
+ *
+ * @param criteria The local criteria
+ * @param criteriaQuery The overal criteria query
+ *
+ * @return The types values (for binding)
+ * @throws HibernateException Problem determining types.
+ */
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,153 +0,0 @@
-//$Id: DetachedCriteria.java 8757 2005-12-06 03:35:50Z steveebersole $
-package org.hibernate.criterion;
-
-import java.io.Serializable;
-
-import org.hibernate.Criteria;
-import org.hibernate.FetchMode;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.Session;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.transform.ResultTransformer;
-
-/**
- * Some applications need to create criteria queries in "detached
- * mode", where the Hibernate session is not available. This class
- * may be instantiated anywhere, and then a <literal>Criteria</literal>
- * may be obtained by passing a session to
- * <literal>getExecutableCriteria()</literal>. All methods have the
- * same semantics and behavior as the corresponding methods of the
- * <literal>Criteria</literal> interface.
- *
- * @see org.hibernate.Criteria
- * @author Gavin King
- */
-public class DetachedCriteria implements CriteriaSpecification, Serializable {
-
- private final CriteriaImpl impl;
- private final Criteria criteria;
-
- protected DetachedCriteria(String entityName) {
- impl = new CriteriaImpl(entityName, null);
- criteria = impl;
- }
-
- protected DetachedCriteria(String entityName, String alias) {
- impl = new CriteriaImpl(entityName, alias, null);
- criteria = impl;
- }
-
- protected DetachedCriteria(CriteriaImpl impl, Criteria criteria) {
- this.impl = impl;
- this.criteria = criteria;
- }
-
- /**
- * Get an executable instance of <literal>Criteria</literal>,
- * to actually run the query.
- */
- public Criteria getExecutableCriteria(Session session) {
- impl.setSession( ( SessionImplementor ) session );
- return impl;
- }
-
- public static DetachedCriteria forEntityName(String entityName) {
- return new DetachedCriteria(entityName);
- }
-
- public static DetachedCriteria forEntityName(String entityName, String alias) {
- return new DetachedCriteria(entityName, alias);
- }
-
- public static DetachedCriteria forClass(Class clazz) {
- return new DetachedCriteria( clazz.getName() );
- }
-
- public static DetachedCriteria forClass(Class clazz, String alias) {
- return new DetachedCriteria( clazz.getName() , alias );
- }
-
- public DetachedCriteria add(Criterion criterion) {
- criteria.add(criterion);
- return this;
- }
-
- public DetachedCriteria addOrder(Order order) {
- criteria.addOrder(order);
- return this;
- }
-
- public DetachedCriteria createAlias(String associationPath, String alias)
- throws HibernateException {
- criteria.createAlias(associationPath, alias);
- return this;
- }
-
- public DetachedCriteria createCriteria(String associationPath, String alias)
- throws HibernateException {
- return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
- }
-
- public DetachedCriteria createCriteria(String associationPath)
- throws HibernateException {
- return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
- }
-
- public String getAlias() {
- return criteria.getAlias();
- }
-
- public DetachedCriteria setFetchMode(String associationPath, FetchMode mode)
- throws HibernateException {
- criteria.setFetchMode(associationPath, mode);
- return this;
- }
-
- public DetachedCriteria setProjection(Projection projection) {
- criteria.setProjection(projection);
- return this;
- }
-
- public DetachedCriteria setResultTransformer(ResultTransformer resultTransformer) {
- criteria.setResultTransformer(resultTransformer);
- return this;
- }
-
- public String toString() {
- return "DetachableCriteria(" + criteria.toString() + ')';
- }
-
- CriteriaImpl getCriteriaImpl() {
- return impl;
- }
-
- public DetachedCriteria createAlias(String associationPath, String alias, int joinType) throws HibernateException {
- criteria.createAlias(associationPath, alias, joinType);
- return this;
- }
-
- public DetachedCriteria createCriteria(String associationPath, int joinType) throws HibernateException {
- return new DetachedCriteria(impl, criteria.createCriteria(associationPath, joinType));
- }
-
- public DetachedCriteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException {
- return new DetachedCriteria(impl, criteria.createCriteria(associationPath, alias, joinType));
- }
-
- public DetachedCriteria setComment(String comment) {
- criteria.setComment(comment);
- return this;
- }
-
- public DetachedCriteria setLockMode(LockMode lockMode) {
- criteria.setLockMode(lockMode);
- return this;
- }
-
- public DetachedCriteria setLockMode(String alias, LockMode lockMode) {
- criteria.setLockMode(alias, lockMode);
- return this;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/DetachedCriteria.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,176 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.io.Serializable;
+
+import org.hibernate.Criteria;
+import org.hibernate.FetchMode;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.impl.CriteriaImpl;
+import org.hibernate.transform.ResultTransformer;
+
+/**
+ * Some applications need to create criteria queries in "detached
+ * mode", where the Hibernate session is not available. This class
+ * may be instantiated anywhere, and then a <literal>Criteria</literal>
+ * may be obtained by passing a session to
+ * <literal>getExecutableCriteria()</literal>. All methods have the
+ * same semantics and behavior as the corresponding methods of the
+ * <literal>Criteria</literal> interface.
+ *
+ * @see org.hibernate.Criteria
+ * @author Gavin King
+ */
+public class DetachedCriteria implements CriteriaSpecification, Serializable {
+
+ private final CriteriaImpl impl;
+ private final Criteria criteria;
+
+ protected DetachedCriteria(String entityName) {
+ impl = new CriteriaImpl(entityName, null);
+ criteria = impl;
+ }
+
+ protected DetachedCriteria(String entityName, String alias) {
+ impl = new CriteriaImpl(entityName, alias, null);
+ criteria = impl;
+ }
+
+ protected DetachedCriteria(CriteriaImpl impl, Criteria criteria) {
+ this.impl = impl;
+ this.criteria = criteria;
+ }
+
+ /**
+ * Get an executable instance of <literal>Criteria</literal>,
+ * to actually run the query.
+ */
+ public Criteria getExecutableCriteria(Session session) {
+ impl.setSession( ( SessionImplementor ) session );
+ return impl;
+ }
+
+ public static DetachedCriteria forEntityName(String entityName) {
+ return new DetachedCriteria(entityName);
+ }
+
+ public static DetachedCriteria forEntityName(String entityName, String alias) {
+ return new DetachedCriteria(entityName, alias);
+ }
+
+ public static DetachedCriteria forClass(Class clazz) {
+ return new DetachedCriteria( clazz.getName() );
+ }
+
+ public static DetachedCriteria forClass(Class clazz, String alias) {
+ return new DetachedCriteria( clazz.getName() , alias );
+ }
+
+ public DetachedCriteria add(Criterion criterion) {
+ criteria.add(criterion);
+ return this;
+ }
+
+ public DetachedCriteria addOrder(Order order) {
+ criteria.addOrder(order);
+ return this;
+ }
+
+ public DetachedCriteria createAlias(String associationPath, String alias)
+ throws HibernateException {
+ criteria.createAlias(associationPath, alias);
+ return this;
+ }
+
+ public DetachedCriteria createCriteria(String associationPath, String alias)
+ throws HibernateException {
+ return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
+ }
+
+ public DetachedCriteria createCriteria(String associationPath)
+ throws HibernateException {
+ return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
+ }
+
+ public String getAlias() {
+ return criteria.getAlias();
+ }
+
+ public DetachedCriteria setFetchMode(String associationPath, FetchMode mode)
+ throws HibernateException {
+ criteria.setFetchMode(associationPath, mode);
+ return this;
+ }
+
+ public DetachedCriteria setProjection(Projection projection) {
+ criteria.setProjection(projection);
+ return this;
+ }
+
+ public DetachedCriteria setResultTransformer(ResultTransformer resultTransformer) {
+ criteria.setResultTransformer(resultTransformer);
+ return this;
+ }
+
+ public String toString() {
+ return "DetachableCriteria(" + criteria.toString() + ')';
+ }
+
+ CriteriaImpl getCriteriaImpl() {
+ return impl;
+ }
+
+ public DetachedCriteria createAlias(String associationPath, String alias, int joinType) throws HibernateException {
+ criteria.createAlias(associationPath, alias, joinType);
+ return this;
+ }
+
+ public DetachedCriteria createCriteria(String associationPath, int joinType) throws HibernateException {
+ return new DetachedCriteria(impl, criteria.createCriteria(associationPath, joinType));
+ }
+
+ public DetachedCriteria createCriteria(String associationPath, String alias, int joinType) throws HibernateException {
+ return new DetachedCriteria(impl, criteria.createCriteria(associationPath, alias, joinType));
+ }
+
+ public DetachedCriteria setComment(String comment) {
+ criteria.setComment(comment);
+ return this;
+ }
+
+ public DetachedCriteria setLockMode(LockMode lockMode) {
+ criteria.setLockMode(lockMode);
+ return this;
+ }
+
+ public DetachedCriteria setLockMode(String alias, LockMode lockMode) {
+ criteria.setLockMode(alias, lockMode);
+ return this;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Disjunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,13 +0,0 @@
-package org.hibernate.criterion;
-
-
-/**
- * @author Gavin King
- */
-public class Disjunction extends Junction {
-
- protected Disjunction() {
- super("or");
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Disjunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Disjunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+/**
+ * @author Gavin King
+ */
+public class Disjunction extends Junction {
+
+ protected Disjunction() {
+ super("or");
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Distinct.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,58 +0,0 @@
-//$Id: Distinct.java 6452 2005-04-18 17:16:57Z oneovthafew $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * @author Gavin King
- */
-public class Distinct implements Projection {
-
- private final Projection projection;
-
- public Distinct(Projection proj) {
- this.projection = proj;
- }
-
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return "distinct " + projection.toSqlString(criteria, position, criteriaQuery);
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return projection.toGroupSqlString(criteria, criteriaQuery);
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return projection.getTypes(criteria, criteriaQuery);
- }
-
- public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return projection.getTypes(alias, criteria, criteriaQuery);
- }
-
- public String[] getColumnAliases(int loc) {
- return projection.getColumnAliases(loc);
- }
-
- public String[] getColumnAliases(String alias, int loc) {
- return projection.getColumnAliases(alias, loc);
- }
-
- public String[] getAliases() {
- return projection.getAliases();
- }
-
- public boolean isGrouped() {
- return projection.isGrouped();
- }
-
- public String toString() {
- return "distinct " + projection.toString();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Distinct.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Distinct.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * @author Gavin King
+ */
+public class Distinct implements Projection {
+
+ private final Projection projection;
+
+ public Distinct(Projection proj) {
+ this.projection = proj;
+ }
+
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return "distinct " + projection.toSqlString(criteria, position, criteriaQuery);
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return projection.toGroupSqlString(criteria, criteriaQuery);
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return projection.getTypes(criteria, criteriaQuery);
+ }
+
+ public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return projection.getTypes(alias, criteria, criteriaQuery);
+ }
+
+ public String[] getColumnAliases(int loc) {
+ return projection.getColumnAliases(loc);
+ }
+
+ public String[] getColumnAliases(String alias, int loc) {
+ return projection.getColumnAliases(alias, loc);
+ }
+
+ public String[] getAliases() {
+ return projection.getAliases();
+ }
+
+ public boolean isGrouped() {
+ return projection.isGrouped();
+ }
+
+ public String toString() {
+ return "distinct " + projection.toString();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/EmptyExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,17 +0,0 @@
-//$Id: EmptyExpression.java 6661 2005-05-03 20:12:20Z steveebersole $
-package org.hibernate.criterion;
-
-/**
- * @author Gavin King
- */
-public class EmptyExpression extends AbstractEmptinessExpression implements Criterion {
-
- protected EmptyExpression(String propertyName) {
- super( propertyName );
- }
-
- protected boolean excludeEmpty() {
- return false;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/EmptyExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/EmptyExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+/**
+ * @author Gavin King
+ */
+public class EmptyExpression extends AbstractEmptinessExpression implements Criterion {
+
+ protected EmptyExpression(String propertyName) {
+ super( propertyName );
+ }
+
+ protected boolean excludeEmpty() {
+ return false;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Example.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,374 +0,0 @@
-//$Id: Example.java 10061 2006-06-28 05:20:51Z steve.ebersole(a)jboss.com $
-package org.hibernate.criterion;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.AbstractComponentType;
-import org.hibernate.type.Type;
-import org.hibernate.util.StringHelper;
-
-/**
- * Support for query by example.
- * <pre>
- * List results = session.createCriteria(Parent.class)
- * .add( Example.create(parent).ignoreCase() )
- * .createCriteria("child")
- * .add( Example.create( parent.getChild() ) )
- * .list();
- * </pre>
- * "Examples" may be mixed and matched with "Expressions" in the same <tt>Criteria</tt>.
- * @see org.hibernate.Criteria
- * @author Gavin King
- */
-
-public class Example implements Criterion {
-
- private final Object entity;
- private final Set excludedProperties = new HashSet();
- private PropertySelector selector;
- private boolean isLikeEnabled;
- private Character escapeCharacter;
- private boolean isIgnoreCaseEnabled;
- private MatchMode matchMode;
-
- /**
- * A strategy for choosing property values for inclusion in the query
- * criteria
- */
-
- public static interface PropertySelector extends Serializable {
- public boolean include(Object propertyValue, String propertyName, Type type);
- }
-
- private static final PropertySelector NOT_NULL = new NotNullPropertySelector();
- private static final PropertySelector ALL = new AllPropertySelector();
- private static final PropertySelector NOT_NULL_OR_ZERO = new NotNullOrZeroPropertySelector();
-
- static final class AllPropertySelector implements PropertySelector {
- public boolean include(Object object, String propertyName, Type type) {
- return true;
- }
-
- private Object readResolve() {
- return ALL;
- }
- }
-
- static final class NotNullPropertySelector implements PropertySelector {
- public boolean include(Object object, String propertyName, Type type) {
- return object!=null;
- }
-
- private Object readResolve() {
- return NOT_NULL;
- }
- }
-
- static final class NotNullOrZeroPropertySelector implements PropertySelector {
- public boolean include(Object object, String propertyName, Type type) {
- return object!=null && (
- !(object instanceof Number) || ( (Number) object ).longValue()!=0
- );
- }
-
- private Object readResolve() {
- return NOT_NULL_OR_ZERO;
- }
- }
-
- /**
- * Set escape character for "like" clause
- */
- public Example setEscapeCharacter(Character escapeCharacter) {
- this.escapeCharacter = escapeCharacter;
- return this;
- }
-
- /**
- * Set the property selector
- */
- public Example setPropertySelector(PropertySelector selector) {
- this.selector = selector;
- return this;
- }
-
- /**
- * Exclude zero-valued properties
- */
- public Example excludeZeroes() {
- setPropertySelector(NOT_NULL_OR_ZERO);
- return this;
- }
-
- /**
- * Don't exclude null or zero-valued properties
- */
- public Example excludeNone() {
- setPropertySelector(ALL);
- return this;
- }
-
- /**
- * Use the "like" operator for all string-valued properties
- */
- public Example enableLike(MatchMode matchMode) {
- isLikeEnabled = true;
- this.matchMode = matchMode;
- return this;
- }
-
- /**
- * Use the "like" operator for all string-valued properties
- */
- public Example enableLike() {
- return enableLike(MatchMode.EXACT);
- }
-
- /**
- * Ignore case for all string-valued properties
- */
- public Example ignoreCase() {
- isIgnoreCaseEnabled = true;
- return this;
- }
-
- /**
- * Exclude a particular named property
- */
- public Example excludeProperty(String name) {
- excludedProperties.add(name);
- return this;
- }
-
- /**
- * Create a new instance, which includes all non-null properties
- * by default
- * @param entity
- * @return a new instance of <tt>Example</tt>
- */
- public static Example create(Object entity) {
- if (entity==null) throw new NullPointerException("null example");
- return new Example(entity, NOT_NULL);
- }
-
- protected Example(Object entity, PropertySelector selector) {
- this.entity = entity;
- this.selector = selector;
- }
-
- public String toString() {
- return "example (" + entity + ')';
- }
-
- private boolean isPropertyIncluded(Object value, String name, Type type) {
- return !excludedProperties.contains(name) &&
- !type.isAssociationType() &&
- selector.include(value, name, type);
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- StringBuffer buf = new StringBuffer().append('(');
- EntityPersister meta = criteriaQuery.getFactory().getEntityPersister( criteriaQuery.getEntityName(criteria) );
- String[] propertyNames = meta.getPropertyNames();
- Type[] propertyTypes = meta.getPropertyTypes();
- //TODO: get all properties, not just the fetched ones!
- Object[] propertyValues = meta.getPropertyValues( entity, getEntityMode(criteria, criteriaQuery) );
- for (int i=0; i<propertyNames.length; i++) {
- Object propertyValue = propertyValues[i];
- String propertyName = propertyNames[i];
-
- boolean isPropertyIncluded = i!=meta.getVersionProperty() &&
- isPropertyIncluded( propertyValue, propertyName, propertyTypes[i] );
- if (isPropertyIncluded) {
- if ( propertyTypes[i].isComponentType() ) {
- appendComponentCondition(
- propertyName,
- propertyValue,
- (AbstractComponentType) propertyTypes[i],
- criteria,
- criteriaQuery,
- buf
- );
- }
- else {
- appendPropertyCondition(
- propertyName,
- propertyValue,
- criteria,
- criteriaQuery,
- buf
- );
- }
- }
- }
- if ( buf.length()==1 ) buf.append("1=1"); //yuck!
- return buf.append(')').toString();
- }
-
- private static final Object[] TYPED_VALUES = new TypedValue[0];
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- EntityPersister meta = criteriaQuery.getFactory()
- .getEntityPersister( criteriaQuery.getEntityName(criteria) );
- String[] propertyNames = meta.getPropertyNames();
- Type[] propertyTypes = meta.getPropertyTypes();
- //TODO: get all properties, not just the fetched ones!
- Object[] values = meta.getPropertyValues( entity, getEntityMode(criteria, criteriaQuery) );
- List list = new ArrayList();
- for (int i=0; i<propertyNames.length; i++) {
- Object value = values[i];
- Type type = propertyTypes[i];
- String name = propertyNames[i];
-
- boolean isPropertyIncluded = i!=meta.getVersionProperty() &&
- isPropertyIncluded(value, name, type);
-
- if (isPropertyIncluded) {
- if ( propertyTypes[i].isComponentType() ) {
- addComponentTypedValues(name, value, (AbstractComponentType) type, list, criteria, criteriaQuery);
- }
- else {
- addPropertyTypedValue(value, type, list);
- }
- }
- }
- return (TypedValue[]) list.toArray(TYPED_VALUES);
- }
-
- private EntityMode getEntityMode(Criteria criteria, CriteriaQuery criteriaQuery) {
- EntityPersister meta = criteriaQuery.getFactory()
- .getEntityPersister( criteriaQuery.getEntityName(criteria) );
- EntityMode result = meta.guessEntityMode(entity);
- if (result==null) {
- throw new ClassCastException( entity.getClass().getName() );
- }
- return result;
- }
-
- protected void addPropertyTypedValue(Object value, Type type, List list) {
- if ( value!=null ) {
- if ( value instanceof String ) {
- String string = (String) value;
- if (isIgnoreCaseEnabled) string = string.toLowerCase();
- if (isLikeEnabled) string = matchMode.toMatchString(string);
- value = string;
- }
- list.add( new TypedValue(type, value, null) );
- }
- }
-
- protected void addComponentTypedValues(
- String path,
- Object component,
- AbstractComponentType type,
- List list,
- Criteria criteria,
- CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- if (component!=null) {
- String[] propertyNames = type.getPropertyNames();
- Type[] subtypes = type.getSubtypes();
- Object[] values = type.getPropertyValues( component, getEntityMode(criteria, criteriaQuery) );
- for (int i=0; i<propertyNames.length; i++) {
- Object value = values[i];
- Type subtype = subtypes[i];
- String subpath = StringHelper.qualify( path, propertyNames[i] );
- if ( isPropertyIncluded(value, subpath, subtype) ) {
- if ( subtype.isComponentType() ) {
- addComponentTypedValues(subpath, value, (AbstractComponentType) subtype, list, criteria, criteriaQuery);
- }
- else {
- addPropertyTypedValue(value, subtype, list);
- }
- }
- }
- }
- }
-
- protected void appendPropertyCondition(
- String propertyName,
- Object propertyValue,
- Criteria criteria,
- CriteriaQuery cq,
- StringBuffer buf)
- throws HibernateException {
- Criterion crit;
- if ( propertyValue!=null ) {
- boolean isString = propertyValue instanceof String;
- if ( isLikeEnabled && isString ) {
- crit = new LikeExpression(
- propertyName,
- ( String ) propertyValue,
- matchMode,
- escapeCharacter,
- isIgnoreCaseEnabled
- );
- }
- else {
- crit = new SimpleExpression( propertyName, propertyValue, "=", isIgnoreCaseEnabled && isString );
- }
- }
- else {
- crit = new NullExpression(propertyName);
- }
- String critCondition = crit.toSqlString(criteria, cq);
- if ( buf.length()>1 && critCondition.trim().length()>0 ) buf.append(" and ");
- buf.append(critCondition);
- }
-
- protected void appendComponentCondition(
- String path,
- Object component,
- AbstractComponentType type,
- Criteria criteria,
- CriteriaQuery criteriaQuery,
- StringBuffer buf)
- throws HibernateException {
-
- if (component!=null) {
- String[] propertyNames = type.getPropertyNames();
- Object[] values = type.getPropertyValues( component, getEntityMode(criteria, criteriaQuery) );
- Type[] subtypes = type.getSubtypes();
- for (int i=0; i<propertyNames.length; i++) {
- String subpath = StringHelper.qualify( path, propertyNames[i] );
- Object value = values[i];
- if ( isPropertyIncluded( value, subpath, subtypes[i] ) ) {
- Type subtype = subtypes[i];
- if ( subtype.isComponentType() ) {
- appendComponentCondition(
- subpath,
- value,
- (AbstractComponentType) subtype,
- criteria,
- criteriaQuery,
- buf
- );
- }
- else {
- appendPropertyCondition(
- subpath,
- value,
- criteria,
- criteriaQuery,
- buf
- );
- }
- }
- }
- }
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Example.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Example.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,397 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.AbstractComponentType;
+import org.hibernate.type.Type;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Support for query by example.
+ * <pre>
+ * List results = session.createCriteria(Parent.class)
+ * .add( Example.create(parent).ignoreCase() )
+ * .createCriteria("child")
+ * .add( Example.create( parent.getChild() ) )
+ * .list();
+ * </pre>
+ * "Examples" may be mixed and matched with "Expressions" in the same <tt>Criteria</tt>.
+ * @see org.hibernate.Criteria
+ * @author Gavin King
+ */
+
+public class Example implements Criterion {
+
+ private final Object entity;
+ private final Set excludedProperties = new HashSet();
+ private PropertySelector selector;
+ private boolean isLikeEnabled;
+ private Character escapeCharacter;
+ private boolean isIgnoreCaseEnabled;
+ private MatchMode matchMode;
+
+ /**
+ * A strategy for choosing property values for inclusion in the query
+ * criteria
+ */
+
+ public static interface PropertySelector extends Serializable {
+ public boolean include(Object propertyValue, String propertyName, Type type);
+ }
+
+ private static final PropertySelector NOT_NULL = new NotNullPropertySelector();
+ private static final PropertySelector ALL = new AllPropertySelector();
+ private static final PropertySelector NOT_NULL_OR_ZERO = new NotNullOrZeroPropertySelector();
+
+ static final class AllPropertySelector implements PropertySelector {
+ public boolean include(Object object, String propertyName, Type type) {
+ return true;
+ }
+
+ private Object readResolve() {
+ return ALL;
+ }
+ }
+
+ static final class NotNullPropertySelector implements PropertySelector {
+ public boolean include(Object object, String propertyName, Type type) {
+ return object!=null;
+ }
+
+ private Object readResolve() {
+ return NOT_NULL;
+ }
+ }
+
+ static final class NotNullOrZeroPropertySelector implements PropertySelector {
+ public boolean include(Object object, String propertyName, Type type) {
+ return object!=null && (
+ !(object instanceof Number) || ( (Number) object ).longValue()!=0
+ );
+ }
+
+ private Object readResolve() {
+ return NOT_NULL_OR_ZERO;
+ }
+ }
+
+ /**
+ * Set escape character for "like" clause
+ */
+ public Example setEscapeCharacter(Character escapeCharacter) {
+ this.escapeCharacter = escapeCharacter;
+ return this;
+ }
+
+ /**
+ * Set the property selector
+ */
+ public Example setPropertySelector(PropertySelector selector) {
+ this.selector = selector;
+ return this;
+ }
+
+ /**
+ * Exclude zero-valued properties
+ */
+ public Example excludeZeroes() {
+ setPropertySelector(NOT_NULL_OR_ZERO);
+ return this;
+ }
+
+ /**
+ * Don't exclude null or zero-valued properties
+ */
+ public Example excludeNone() {
+ setPropertySelector(ALL);
+ return this;
+ }
+
+ /**
+ * Use the "like" operator for all string-valued properties
+ */
+ public Example enableLike(MatchMode matchMode) {
+ isLikeEnabled = true;
+ this.matchMode = matchMode;
+ return this;
+ }
+
+ /**
+ * Use the "like" operator for all string-valued properties
+ */
+ public Example enableLike() {
+ return enableLike(MatchMode.EXACT);
+ }
+
+ /**
+ * Ignore case for all string-valued properties
+ */
+ public Example ignoreCase() {
+ isIgnoreCaseEnabled = true;
+ return this;
+ }
+
+ /**
+ * Exclude a particular named property
+ */
+ public Example excludeProperty(String name) {
+ excludedProperties.add(name);
+ return this;
+ }
+
+ /**
+ * Create a new instance, which includes all non-null properties
+ * by default
+ * @param entity
+ * @return a new instance of <tt>Example</tt>
+ */
+ public static Example create(Object entity) {
+ if (entity==null) throw new NullPointerException("null example");
+ return new Example(entity, NOT_NULL);
+ }
+
+ protected Example(Object entity, PropertySelector selector) {
+ this.entity = entity;
+ this.selector = selector;
+ }
+
+ public String toString() {
+ return "example (" + entity + ')';
+ }
+
+ private boolean isPropertyIncluded(Object value, String name, Type type) {
+ return !excludedProperties.contains(name) &&
+ !type.isAssociationType() &&
+ selector.include(value, name, type);
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ StringBuffer buf = new StringBuffer().append('(');
+ EntityPersister meta = criteriaQuery.getFactory().getEntityPersister( criteriaQuery.getEntityName(criteria) );
+ String[] propertyNames = meta.getPropertyNames();
+ Type[] propertyTypes = meta.getPropertyTypes();
+ //TODO: get all properties, not just the fetched ones!
+ Object[] propertyValues = meta.getPropertyValues( entity, getEntityMode(criteria, criteriaQuery) );
+ for (int i=0; i<propertyNames.length; i++) {
+ Object propertyValue = propertyValues[i];
+ String propertyName = propertyNames[i];
+
+ boolean isPropertyIncluded = i!=meta.getVersionProperty() &&
+ isPropertyIncluded( propertyValue, propertyName, propertyTypes[i] );
+ if (isPropertyIncluded) {
+ if ( propertyTypes[i].isComponentType() ) {
+ appendComponentCondition(
+ propertyName,
+ propertyValue,
+ (AbstractComponentType) propertyTypes[i],
+ criteria,
+ criteriaQuery,
+ buf
+ );
+ }
+ else {
+ appendPropertyCondition(
+ propertyName,
+ propertyValue,
+ criteria,
+ criteriaQuery,
+ buf
+ );
+ }
+ }
+ }
+ if ( buf.length()==1 ) buf.append("1=1"); //yuck!
+ return buf.append(')').toString();
+ }
+
+ private static final Object[] TYPED_VALUES = new TypedValue[0];
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ EntityPersister meta = criteriaQuery.getFactory()
+ .getEntityPersister( criteriaQuery.getEntityName(criteria) );
+ String[] propertyNames = meta.getPropertyNames();
+ Type[] propertyTypes = meta.getPropertyTypes();
+ //TODO: get all properties, not just the fetched ones!
+ Object[] values = meta.getPropertyValues( entity, getEntityMode(criteria, criteriaQuery) );
+ List list = new ArrayList();
+ for (int i=0; i<propertyNames.length; i++) {
+ Object value = values[i];
+ Type type = propertyTypes[i];
+ String name = propertyNames[i];
+
+ boolean isPropertyIncluded = i!=meta.getVersionProperty() &&
+ isPropertyIncluded(value, name, type);
+
+ if (isPropertyIncluded) {
+ if ( propertyTypes[i].isComponentType() ) {
+ addComponentTypedValues(name, value, (AbstractComponentType) type, list, criteria, criteriaQuery);
+ }
+ else {
+ addPropertyTypedValue(value, type, list);
+ }
+ }
+ }
+ return (TypedValue[]) list.toArray(TYPED_VALUES);
+ }
+
+ private EntityMode getEntityMode(Criteria criteria, CriteriaQuery criteriaQuery) {
+ EntityPersister meta = criteriaQuery.getFactory()
+ .getEntityPersister( criteriaQuery.getEntityName(criteria) );
+ EntityMode result = meta.guessEntityMode(entity);
+ if (result==null) {
+ throw new ClassCastException( entity.getClass().getName() );
+ }
+ return result;
+ }
+
+ protected void addPropertyTypedValue(Object value, Type type, List list) {
+ if ( value!=null ) {
+ if ( value instanceof String ) {
+ String string = (String) value;
+ if (isIgnoreCaseEnabled) string = string.toLowerCase();
+ if (isLikeEnabled) string = matchMode.toMatchString(string);
+ value = string;
+ }
+ list.add( new TypedValue(type, value, null) );
+ }
+ }
+
+ protected void addComponentTypedValues(
+ String path,
+ Object component,
+ AbstractComponentType type,
+ List list,
+ Criteria criteria,
+ CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ if (component!=null) {
+ String[] propertyNames = type.getPropertyNames();
+ Type[] subtypes = type.getSubtypes();
+ Object[] values = type.getPropertyValues( component, getEntityMode(criteria, criteriaQuery) );
+ for (int i=0; i<propertyNames.length; i++) {
+ Object value = values[i];
+ Type subtype = subtypes[i];
+ String subpath = StringHelper.qualify( path, propertyNames[i] );
+ if ( isPropertyIncluded(value, subpath, subtype) ) {
+ if ( subtype.isComponentType() ) {
+ addComponentTypedValues(subpath, value, (AbstractComponentType) subtype, list, criteria, criteriaQuery);
+ }
+ else {
+ addPropertyTypedValue(value, subtype, list);
+ }
+ }
+ }
+ }
+ }
+
+ protected void appendPropertyCondition(
+ String propertyName,
+ Object propertyValue,
+ Criteria criteria,
+ CriteriaQuery cq,
+ StringBuffer buf)
+ throws HibernateException {
+ Criterion crit;
+ if ( propertyValue!=null ) {
+ boolean isString = propertyValue instanceof String;
+ if ( isLikeEnabled && isString ) {
+ crit = new LikeExpression(
+ propertyName,
+ ( String ) propertyValue,
+ matchMode,
+ escapeCharacter,
+ isIgnoreCaseEnabled
+ );
+ }
+ else {
+ crit = new SimpleExpression( propertyName, propertyValue, "=", isIgnoreCaseEnabled && isString );
+ }
+ }
+ else {
+ crit = new NullExpression(propertyName);
+ }
+ String critCondition = crit.toSqlString(criteria, cq);
+ if ( buf.length()>1 && critCondition.trim().length()>0 ) buf.append(" and ");
+ buf.append(critCondition);
+ }
+
+ protected void appendComponentCondition(
+ String path,
+ Object component,
+ AbstractComponentType type,
+ Criteria criteria,
+ CriteriaQuery criteriaQuery,
+ StringBuffer buf)
+ throws HibernateException {
+
+ if (component!=null) {
+ String[] propertyNames = type.getPropertyNames();
+ Object[] values = type.getPropertyValues( component, getEntityMode(criteria, criteriaQuery) );
+ Type[] subtypes = type.getSubtypes();
+ for (int i=0; i<propertyNames.length; i++) {
+ String subpath = StringHelper.qualify( path, propertyNames[i] );
+ Object value = values[i];
+ if ( isPropertyIncluded( value, subpath, subtypes[i] ) ) {
+ Type subtype = subtypes[i];
+ if ( subtype.isComponentType() ) {
+ appendComponentCondition(
+ subpath,
+ value,
+ (AbstractComponentType) subtype,
+ criteria,
+ criteriaQuery,
+ buf
+ );
+ }
+ else {
+ appendPropertyCondition(
+ subpath,
+ value,
+ criteria,
+ criteriaQuery,
+ buf
+ );
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,18 +0,0 @@
-//$Id: ExistsSubqueryExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-
-/**
- * @author Gavin King
- */
-public class ExistsSubqueryExpression extends SubqueryExpression {
-
- protected String toLeftSqlString(Criteria criteria, CriteriaQuery outerQuery) {
- return "";
- }
-
- protected ExistsSubqueryExpression(String quantifier, DetachedCriteria dc) {
- super(null, quantifier, dc);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ExistsSubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+
+/**
+ * @author Gavin King
+ */
+public class ExistsSubqueryExpression extends SubqueryExpression {
+
+ protected String toLeftSqlString(Criteria criteria, CriteriaQuery outerQuery) {
+ return "";
+ }
+
+ protected ExistsSubqueryExpression(String quantifier, DetachedCriteria dc) {
+ super(null, quantifier, dc);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Expression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,58 +0,0 @@
-//$Id: Expression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.type.Type;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * @deprecated Use <tt>Restrictions</tt>.
- * @see Restrictions
- * @author Gavin King
- */
-public final class Expression extends Restrictions {
-
- private Expression() {
- //cannot be instantiated
- }
-
- /**
- * Apply a constraint expressed in SQL, with the given JDBC
- * parameters. Any occurrences of <tt>{alias}</tt> will be
- * replaced by the table alias.
- *
- * @deprecated use {@link org.hibernate.criterion.Restrictions#sqlRestriction(String, Object[], Type[])}
- * @param sql
- * @param values
- * @param types
- * @return Criterion
- */
- public static Criterion sql(String sql, Object[] values, Type[] types) {
- return new SQLCriterion(sql, values, types);
- }
- /**
- * Apply a constraint expressed in SQL, with the given JDBC
- * parameter. Any occurrences of <tt>{alias}</tt> will be replaced
- * by the table alias.
- *
- * @deprecated use {@link org.hibernate.criterion.Restrictions#sqlRestriction(String, Object, Type)}
- * @param sql
- * @param value
- * @param type
- * @return Criterion
- */
- public static Criterion sql(String sql, Object value, Type type) {
- return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } );
- }
- /**
- * Apply a constraint expressed in SQL. Any occurrences of <tt>{alias}</tt>
- * will be replaced by the table alias.
- *
- * @deprecated use {@link org.hibernate.criterion.Restrictions#sqlRestriction(String)}
- * @param sql
- * @return Criterion
- */
- public static Criterion sql(String sql) {
- return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Expression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Expression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.type.Type;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * @deprecated Use <tt>Restrictions</tt>.
+ * @see Restrictions
+ * @author Gavin King
+ */
+public final class Expression extends Restrictions {
+
+ private Expression() {
+ //cannot be instantiated
+ }
+
+ /**
+ * Apply a constraint expressed in SQL, with the given JDBC
+ * parameters. Any occurrences of <tt>{alias}</tt> will be
+ * replaced by the table alias.
+ *
+ * @deprecated use {@link org.hibernate.criterion.Restrictions#sqlRestriction(String, Object[], Type[])}
+ * @param sql
+ * @param values
+ * @param types
+ * @return Criterion
+ */
+ public static Criterion sql(String sql, Object[] values, Type[] types) {
+ return new SQLCriterion(sql, values, types);
+ }
+ /**
+ * Apply a constraint expressed in SQL, with the given JDBC
+ * parameter. Any occurrences of <tt>{alias}</tt> will be replaced
+ * by the table alias.
+ *
+ * @deprecated use {@link org.hibernate.criterion.Restrictions#sqlRestriction(String, Object, Type)}
+ * @param sql
+ * @param value
+ * @param type
+ * @return Criterion
+ */
+ public static Criterion sql(String sql, Object value, Type type) {
+ return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } );
+ }
+ /**
+ * Apply a constraint expressed in SQL. Any occurrences of <tt>{alias}</tt>
+ * will be replaced by the table alias.
+ *
+ * @deprecated use {@link org.hibernate.criterion.Restrictions#sqlRestriction(String)}
+ * @param sql
+ * @return Criterion
+ */
+ public static Criterion sql(String sql) {
+ return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,46 +0,0 @@
-//$Id: IdentifierEqExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.util.StringHelper;
-
-/**
- * An identifier constraint
- * @author Gavin King
- */
-public class IdentifierEqExpression implements Criterion {
-
- private final Object value;
-
- protected IdentifierEqExpression(Object value) {
- this.value = value;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- String[] columns = criteriaQuery.getIdentifierColumns(criteria);
-
- String result = StringHelper.join(
- " and ",
- StringHelper.suffix( columns, " = ?" )
- );
- if (columns.length>1) result = '(' + result + ')';
- return result;
-
- //TODO: get SQL rendering out of this package!
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new TypedValue[] { criteriaQuery.getTypedIdentifierValue(criteria, value) };
- }
-
- public String toString() {
- return "id = " + value;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierEqExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.util.StringHelper;
+
+/**
+ * An identifier constraint
+ * @author Gavin King
+ */
+public class IdentifierEqExpression implements Criterion {
+
+ private final Object value;
+
+ protected IdentifierEqExpression(Object value) {
+ this.value = value;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ String[] columns = criteriaQuery.getIdentifierColumns(criteria);
+
+ String result = StringHelper.join(
+ " and ",
+ StringHelper.suffix( columns, " = ?" )
+ );
+ if (columns.length>1) result = '(' + result + ')';
+ return result;
+
+ //TODO: get SQL rendering out of this package!
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new TypedValue[] { criteriaQuery.getTypedIdentifierValue(criteria, value) };
+ }
+
+ public String toString() {
+ return "id = " + value;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,61 +0,0 @@
-//$Id: IdentifierProjection.java 6970 2005-05-31 20:24:41Z oneovthafew $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-import org.hibernate.util.StringHelper;
-
-/**
- * A property value, or grouped property value
- * @author Gavin King
- */
-public class IdentifierProjection extends SimpleProjection {
-
- private boolean grouped;
-
- protected IdentifierProjection(boolean grouped) {
- this.grouped = grouped;
- }
-
- protected IdentifierProjection() {
- this(false);
- }
-
- public String toString() {
- return "id";
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new Type[] { criteriaQuery.getIdentifierType(criteria) };
- }
-
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException {
- StringBuffer buf = new StringBuffer();
- String[] cols = criteriaQuery.getIdentifierColumns(criteria);
- for ( int i=0; i<cols.length; i++ ) {
- buf.append( cols[i] )
- .append(" as y")
- .append(position + i)
- .append('_');
- }
- return buf.toString();
- }
-
- public boolean isGrouped() {
- return grouped;
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- if (!grouped) {
- return super.toGroupSqlString(criteria, criteriaQuery);
- }
- else {
- return StringHelper.join( ", ", criteriaQuery.getIdentifierColumns(criteria) );
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IdentifierProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,84 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+import org.hibernate.util.StringHelper;
+
+/**
+ * A property value, or grouped property value
+ * @author Gavin King
+ */
+public class IdentifierProjection extends SimpleProjection {
+
+ private boolean grouped;
+
+ protected IdentifierProjection(boolean grouped) {
+ this.grouped = grouped;
+ }
+
+ protected IdentifierProjection() {
+ this(false);
+ }
+
+ public String toString() {
+ return "id";
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new Type[] { criteriaQuery.getIdentifierType(criteria) };
+ }
+
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ StringBuffer buf = new StringBuffer();
+ String[] cols = criteriaQuery.getIdentifierColumns(criteria);
+ for ( int i=0; i<cols.length; i++ ) {
+ buf.append( cols[i] )
+ .append(" as y")
+ .append(position + i)
+ .append('_');
+ }
+ return buf.toString();
+ }
+
+ public boolean isGrouped() {
+ return grouped;
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ if (!grouped) {
+ return super.toGroupSqlString(criteria, criteriaQuery);
+ }
+ else {
+ return StringHelper.join( ", ", criteriaQuery.getIdentifierColumns(criteria) );
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/IlikeExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,53 +0,0 @@
-//$Id: IlikeExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.PostgreSQLDialect;
-import org.hibernate.engine.TypedValue;
-
-/**
- * A case-insensitive "like"
- * @author Gavin King
- */
-public class IlikeExpression implements Criterion {
-
- private final String propertyName;
- private final Object value;
-
- protected IlikeExpression(String propertyName, Object value) {
- this.propertyName = propertyName;
- this.value = value;
- }
-
- protected IlikeExpression(String propertyName, String value, MatchMode matchMode) {
- this( propertyName, matchMode.toMatchString(value) );
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- Dialect dialect = criteriaQuery.getFactory().getDialect();
- String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- if (columns.length!=1) throw new HibernateException("ilike may only be used with single-column properties");
- if ( dialect instanceof PostgreSQLDialect ) {
- return columns[0] + " ilike ?";
- }
- else {
- return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?";
- }
-
- //TODO: get SQL rendering out of this package!
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new TypedValue[] { criteriaQuery.getTypedValue( criteria, propertyName, value.toString().toLowerCase() ) };
- }
-
- public String toString() {
- return propertyName + " ilike " + value;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/IlikeExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/IlikeExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,76 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.PostgreSQLDialect;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * A case-insensitive "like"
+ * @author Gavin King
+ */
+public class IlikeExpression implements Criterion {
+
+ private final String propertyName;
+ private final Object value;
+
+ protected IlikeExpression(String propertyName, Object value) {
+ this.propertyName = propertyName;
+ this.value = value;
+ }
+
+ protected IlikeExpression(String propertyName, String value, MatchMode matchMode) {
+ this( propertyName, matchMode.toMatchString(value) );
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ Dialect dialect = criteriaQuery.getFactory().getDialect();
+ String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ if (columns.length!=1) throw new HibernateException("ilike may only be used with single-column properties");
+ if ( dialect instanceof PostgreSQLDialect ) {
+ return columns[0] + " ilike ?";
+ }
+ else {
+ return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?";
+ }
+
+ //TODO: get SQL rendering out of this package!
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new TypedValue[] { criteriaQuery.getTypedValue( criteria, propertyName, value.toString().toLowerCase() ) };
+ }
+
+ public String toString() {
+ return propertyName + " ilike " + value;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/InExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,74 +0,0 @@
-//$Id: InExpression.java 7557 2005-07-19 23:25:36Z oneovthafew $
-package org.hibernate.criterion;
-
-import java.util.ArrayList;
-
-
-
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-
-
-import org.hibernate.engine.TypedValue;
-
-import org.hibernate.type.AbstractComponentType;
-import org.hibernate.type.Type;
-import org.hibernate.util.StringHelper;
-
-/**
- * Constrains the property to a specified list of values
- * @author Gavin King
- */
-public class InExpression implements Criterion {
-
- private final String propertyName;
- private final Object[] values;
-
- protected InExpression(String propertyName, Object[] values) {
- this.propertyName = propertyName;
- this.values = values;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- String singleValueParam = StringHelper.repeat( "?, ", columns.length-1 ) + "?";
- if ( columns.length>1 ) singleValueParam = '(' + singleValueParam + ')';
- String params = values.length>0 ?
- StringHelper.repeat( singleValueParam + ", ", values.length-1 ) + singleValueParam :
- "";
- String cols = StringHelper.join(", ", columns);
- if ( columns.length>1 ) cols = '(' + cols + ')';
- return cols + " in (" + params + ')';
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- ArrayList list = new ArrayList();
- Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
- if ( type.isComponentType() ) {
- AbstractComponentType actype = (AbstractComponentType) type;
- Type[] types = actype.getSubtypes();
- for ( int i=0; i<types.length; i++ ) {
- for ( int j=0; j<values.length; j++ ) {
- Object subval = values[j]==null ?
- null :
- actype.getPropertyValues( values[j], EntityMode.POJO )[i];
- list.add( new TypedValue( types[i], subval, EntityMode.POJO ) );
- }
- }
- }
- else {
- for ( int j=0; j<values.length; j++ ) {
- list.add( new TypedValue( type, values[j], EntityMode.POJO ) );
- }
- }
- return (TypedValue[]) list.toArray( new TypedValue[ list.size() ] );
- }
-
- public String toString() {
- return propertyName + " in (" + StringHelper.toString(values) + ')';
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/InExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/InExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,94 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.util.ArrayList;
+
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+
+import org.hibernate.engine.TypedValue;
+
+import org.hibernate.type.AbstractComponentType;
+import org.hibernate.type.Type;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Constrains the property to a specified list of values
+ * @author Gavin King
+ */
+public class InExpression implements Criterion {
+
+ private final String propertyName;
+ private final Object[] values;
+
+ protected InExpression(String propertyName, Object[] values) {
+ this.propertyName = propertyName;
+ this.values = values;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ String singleValueParam = StringHelper.repeat( "?, ", columns.length-1 ) + "?";
+ if ( columns.length>1 ) singleValueParam = '(' + singleValueParam + ')';
+ String params = values.length>0 ?
+ StringHelper.repeat( singleValueParam + ", ", values.length-1 ) + singleValueParam :
+ "";
+ String cols = StringHelper.join(", ", columns);
+ if ( columns.length>1 ) cols = '(' + cols + ')';
+ return cols + " in (" + params + ')';
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ ArrayList list = new ArrayList();
+ Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
+ if ( type.isComponentType() ) {
+ AbstractComponentType actype = (AbstractComponentType) type;
+ Type[] types = actype.getSubtypes();
+ for ( int i=0; i<types.length; i++ ) {
+ for ( int j=0; j<values.length; j++ ) {
+ Object subval = values[j]==null ?
+ null :
+ actype.getPropertyValues( values[j], EntityMode.POJO )[i];
+ list.add( new TypedValue( types[i], subval, EntityMode.POJO ) );
+ }
+ }
+ }
+ else {
+ for ( int j=0; j<values.length; j++ ) {
+ list.add( new TypedValue( type, values[j], EntityMode.POJO ) );
+ }
+ }
+ return (TypedValue[]) list.toArray( new TypedValue[ list.size() ] );
+ }
+
+ public String toString() {
+ return propertyName + " in (" + StringHelper.toString(values) + ')';
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Junction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,71 +0,0 @@
-package org.hibernate.criterion;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.util.StringHelper;
-
-/**
- * A sequence of a logical expressions combined by some
- * associative logical operator
- *
- * @author Gavin King
- */
-public class Junction implements Criterion {
-
- private final List criteria = new ArrayList();
- private final String op;
-
- protected Junction(String op) {
- this.op = op;
- }
-
- public Junction add(Criterion criterion) {
- criteria.add(criterion);
- return this;
- }
-
- public String getOp() {
- return op;
- }
-
- public TypedValue[] getTypedValues(Criteria crit, CriteriaQuery criteriaQuery)
- throws HibernateException {
- ArrayList typedValues = new ArrayList();
- Iterator iter = criteria.iterator();
- while ( iter.hasNext() ) {
- TypedValue[] subvalues = ( (Criterion) iter.next() ).getTypedValues(crit, criteriaQuery);
- for ( int i=0; i<subvalues.length; i++ ) {
- typedValues.add( subvalues[i] );
- }
- }
- return (TypedValue[]) typedValues.toArray( new TypedValue[ typedValues.size() ] );
- }
-
- public String toSqlString(Criteria crit, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- if ( criteria.size()==0 ) return "1=1";
-
- StringBuffer buffer = new StringBuffer()
- .append('(');
- Iterator iter = criteria.iterator();
- while ( iter.hasNext() ) {
- buffer.append( ( (Criterion) iter.next() ).toSqlString(crit, criteriaQuery) );
- if ( iter.hasNext() ) buffer.append(' ').append(op).append(' ');
- }
- return buffer.append(')').toString();
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return '(' + StringHelper.join( ' ' + op + ' ', criteria.iterator() ) + ')';
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Junction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Junction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,95 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.util.StringHelper;
+
+/**
+ * A sequence of a logical expressions combined by some
+ * associative logical operator
+ *
+ * @author Gavin King
+ */
+public class Junction implements Criterion {
+
+ private final List criteria = new ArrayList();
+ private final String op;
+
+ protected Junction(String op) {
+ this.op = op;
+ }
+
+ public Junction add(Criterion criterion) {
+ criteria.add(criterion);
+ return this;
+ }
+
+ public String getOp() {
+ return op;
+ }
+
+ public TypedValue[] getTypedValues(Criteria crit, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ ArrayList typedValues = new ArrayList();
+ Iterator iter = criteria.iterator();
+ while ( iter.hasNext() ) {
+ TypedValue[] subvalues = ( (Criterion) iter.next() ).getTypedValues(crit, criteriaQuery);
+ for ( int i=0; i<subvalues.length; i++ ) {
+ typedValues.add( subvalues[i] );
+ }
+ }
+ return (TypedValue[]) typedValues.toArray( new TypedValue[ typedValues.size() ] );
+ }
+
+ public String toSqlString(Criteria crit, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ if ( criteria.size()==0 ) return "1=1";
+
+ StringBuffer buffer = new StringBuffer()
+ .append('(');
+ Iterator iter = criteria.iterator();
+ while ( iter.hasNext() ) {
+ buffer.append( ( (Criterion) iter.next() ).toSqlString(crit, criteriaQuery) );
+ if ( iter.hasNext() ) buffer.append(' ').append(op).append(' ');
+ }
+ return buffer.append(')').toString();
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return '(' + StringHelper.join( ' ' + op + ' ', criteria.iterator() ) + ')';
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/LikeExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,75 +0,0 @@
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.engine.TypedValue;
-
-/**
- * A criterion representing a "like" expression
- *
- * @author Scott Marlow
- * @author Steve Ebersole
- */
-public class LikeExpression implements Criterion {
- private final String propertyName;
- private final Object value;
- private final Character escapeChar;
- private final boolean ignoreCase;
-
- protected LikeExpression(
- String propertyName,
- String value,
- Character escapeChar,
- boolean ignoreCase) {
- this.propertyName = propertyName;
- this.value = value;
- this.escapeChar = escapeChar;
- this.ignoreCase = ignoreCase;
- }
-
- protected LikeExpression(
- String propertyName,
- String value) {
- this( propertyName, value, null, false );
- }
-
- protected LikeExpression(
- String propertyName,
- String value,
- MatchMode matchMode) {
- this( propertyName, matchMode.toMatchString( value ) );
- }
-
- protected LikeExpression(
- String propertyName,
- String value,
- MatchMode matchMode,
- Character escapeChar,
- boolean ignoreCase) {
- this( propertyName, matchMode.toMatchString( value ), escapeChar, ignoreCase );
- }
-
- public String toSqlString(
- Criteria criteria,
- CriteriaQuery criteriaQuery) throws HibernateException {
- Dialect dialect = criteriaQuery.getFactory().getDialect();
- String[] columns = criteriaQuery.getColumnsUsingProjection( criteria, propertyName );
- if ( columns.length != 1 ) {
- throw new HibernateException( "Like may only be used with single-column properties" );
- }
- String lhs = ignoreCase
- ? dialect.getLowercaseFunction() + '(' + columns[0] + ')'
- : columns[0];
- return lhs + " like ?" + ( escapeChar == null ? "" : " escape \'" + escapeChar + "\'" );
-
- }
-
- public TypedValue[] getTypedValues(
- Criteria criteria,
- CriteriaQuery criteriaQuery) throws HibernateException {
- return new TypedValue[] {
- criteriaQuery.getTypedValue( criteria, propertyName, value.toString().toLowerCase() )
- };
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/LikeExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LikeExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,99 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * A criterion representing a "like" expression
+ *
+ * @author Scott Marlow
+ * @author Steve Ebersole
+ */
+public class LikeExpression implements Criterion {
+ private final String propertyName;
+ private final Object value;
+ private final Character escapeChar;
+ private final boolean ignoreCase;
+
+ protected LikeExpression(
+ String propertyName,
+ String value,
+ Character escapeChar,
+ boolean ignoreCase) {
+ this.propertyName = propertyName;
+ this.value = value;
+ this.escapeChar = escapeChar;
+ this.ignoreCase = ignoreCase;
+ }
+
+ protected LikeExpression(
+ String propertyName,
+ String value) {
+ this( propertyName, value, null, false );
+ }
+
+ protected LikeExpression(
+ String propertyName,
+ String value,
+ MatchMode matchMode) {
+ this( propertyName, matchMode.toMatchString( value ) );
+ }
+
+ protected LikeExpression(
+ String propertyName,
+ String value,
+ MatchMode matchMode,
+ Character escapeChar,
+ boolean ignoreCase) {
+ this( propertyName, matchMode.toMatchString( value ), escapeChar, ignoreCase );
+ }
+
+ public String toSqlString(
+ Criteria criteria,
+ CriteriaQuery criteriaQuery) throws HibernateException {
+ Dialect dialect = criteriaQuery.getFactory().getDialect();
+ String[] columns = criteriaQuery.getColumnsUsingProjection( criteria, propertyName );
+ if ( columns.length != 1 ) {
+ throw new HibernateException( "Like may only be used with single-column properties" );
+ }
+ String lhs = ignoreCase
+ ? dialect.getLowercaseFunction() + '(' + columns[0] + ')'
+ : columns[0];
+ return lhs + " like ?" + ( escapeChar == null ? "" : " escape \'" + escapeChar + "\'" );
+
+ }
+
+ public TypedValue[] getTypedValues(
+ Criteria criteria,
+ CriteriaQuery criteriaQuery) throws HibernateException {
+ return new TypedValue[] {
+ criteriaQuery.getTypedValue( criteria, propertyName, value.toString().toLowerCase() )
+ };
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/LogicalExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,55 +0,0 @@
-//$Id: LogicalExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-
-/**
- * Superclass of binary logical expressions
- * @author Gavin King
- */
-public class LogicalExpression implements Criterion {
-
- private final Criterion lhs;
- private final Criterion rhs;
- private final String op;
-
- protected LogicalExpression(Criterion lhs, Criterion rhs, String op) {
- this.lhs = lhs;
- this.rhs = rhs;
- this.op = op;
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- TypedValue[] lhstv = lhs.getTypedValues(criteria, criteriaQuery);
- TypedValue[] rhstv = rhs.getTypedValues(criteria, criteriaQuery);
- TypedValue[] result = new TypedValue[ lhstv.length + rhstv.length ];
- System.arraycopy(lhstv, 0, result, 0, lhstv.length);
- System.arraycopy(rhstv, 0, result, lhstv.length, rhstv.length);
- return result;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- return '(' +
- lhs.toSqlString(criteria, criteriaQuery) +
- ' ' +
- getOp() +
- ' ' +
- rhs.toSqlString(criteria, criteriaQuery) +
- ')';
- }
-
- public String getOp() {
- return op;
- }
-
- public String toString() {
- return lhs.toString() + ' ' + getOp() + ' ' + rhs.toString();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/LogicalExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/LogicalExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * Superclass of binary logical expressions
+ * @author Gavin King
+ */
+public class LogicalExpression implements Criterion {
+
+ private final Criterion lhs;
+ private final Criterion rhs;
+ private final String op;
+
+ protected LogicalExpression(Criterion lhs, Criterion rhs, String op) {
+ this.lhs = lhs;
+ this.rhs = rhs;
+ this.op = op;
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ TypedValue[] lhstv = lhs.getTypedValues(criteria, criteriaQuery);
+ TypedValue[] rhstv = rhs.getTypedValues(criteria, criteriaQuery);
+ TypedValue[] result = new TypedValue[ lhstv.length + rhstv.length ];
+ System.arraycopy(lhstv, 0, result, 0, lhstv.length);
+ System.arraycopy(rhstv, 0, result, lhstv.length, rhstv.length);
+ return result;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ return '(' +
+ lhs.toSqlString(criteria, criteriaQuery) +
+ ' ' +
+ getOp() +
+ ' ' +
+ rhs.toSqlString(criteria, criteriaQuery) +
+ ')';
+ }
+
+ public String getOp() {
+ return op;
+ }
+
+ public String toString() {
+ return lhs.toString() + ' ' + getOp() + ' ' + rhs.toString();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/MatchMode.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,82 +0,0 @@
-//$Id: MatchMode.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents an strategy for matching strings using "like".
- *
- * @see Example#enableLike(MatchMode)
- * @author Gavin King
- */
-public abstract class MatchMode implements Serializable {
- private final String name;
- private static final Map INSTANCES = new HashMap();
-
- protected MatchMode(String name) {
- this.name=name;
- }
- public String toString() {
- return name;
- }
-
- /**
- * Match the entire string to the pattern
- */
- public static final MatchMode EXACT = new MatchMode("EXACT") {
- public String toMatchString(String pattern) {
- return pattern;
- }
- };
-
- /**
- * Match the start of the string to the pattern
- */
- public static final MatchMode START = new MatchMode("START") {
- public String toMatchString(String pattern) {
- return pattern + '%';
- }
- };
-
- /**
- * Match the end of the string to the pattern
- */
- public static final MatchMode END = new MatchMode("END") {
- public String toMatchString(String pattern) {
- return '%' + pattern;
- }
- };
-
- /**
- * Match the pattern anywhere in the string
- */
- public static final MatchMode ANYWHERE = new MatchMode("ANYWHERE") {
- public String toMatchString(String pattern) {
- return '%' + pattern + '%';
- }
- };
-
- static {
- INSTANCES.put( EXACT.name, EXACT );
- INSTANCES.put( END.name, END );
- INSTANCES.put( START.name, START );
- INSTANCES.put( ANYWHERE.name, ANYWHERE );
- }
-
- private Object readResolve() {
- return INSTANCES.get(name);
- }
-
- /**
- * convert the pattern, by appending/prepending "%"
- */
- public abstract String toMatchString(String pattern);
-
-}
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/MatchMode.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/MatchMode.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,105 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents an strategy for matching strings using "like".
+ *
+ * @see Example#enableLike(MatchMode)
+ * @author Gavin King
+ */
+public abstract class MatchMode implements Serializable {
+ private final String name;
+ private static final Map INSTANCES = new HashMap();
+
+ protected MatchMode(String name) {
+ this.name=name;
+ }
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Match the entire string to the pattern
+ */
+ public static final MatchMode EXACT = new MatchMode("EXACT") {
+ public String toMatchString(String pattern) {
+ return pattern;
+ }
+ };
+
+ /**
+ * Match the start of the string to the pattern
+ */
+ public static final MatchMode START = new MatchMode("START") {
+ public String toMatchString(String pattern) {
+ return pattern + '%';
+ }
+ };
+
+ /**
+ * Match the end of the string to the pattern
+ */
+ public static final MatchMode END = new MatchMode("END") {
+ public String toMatchString(String pattern) {
+ return '%' + pattern;
+ }
+ };
+
+ /**
+ * Match the pattern anywhere in the string
+ */
+ public static final MatchMode ANYWHERE = new MatchMode("ANYWHERE") {
+ public String toMatchString(String pattern) {
+ return '%' + pattern + '%';
+ }
+ };
+
+ static {
+ INSTANCES.put( EXACT.name, EXACT );
+ INSTANCES.put( END.name, END );
+ INSTANCES.put( START.name, START );
+ INSTANCES.put( ANYWHERE.name, ANYWHERE );
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get(name);
+ }
+
+ /**
+ * convert the pattern, by appending/prepending "%"
+ */
+ public abstract String toMatchString(String pattern);
+
+}
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,28 +0,0 @@
-//$Id: NaturalIdentifier.java 6899 2005-05-25 01:22:07Z oneovthafew $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-
-/**
- * @author Gavin King
- */
-public class NaturalIdentifier implements Criterion {
-
- private Junction conjunction = new Conjunction();
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- return conjunction.getTypedValues(criteria, criteriaQuery);
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
- return conjunction.toSqlString(criteria, criteriaQuery);
- }
-
- public NaturalIdentifier set(String property, Object value) {
- conjunction.add( Restrictions.eq(property, value) );
- return this;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NaturalIdentifier.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * @author Gavin King
+ */
+public class NaturalIdentifier implements Criterion {
+
+ private Junction conjunction = new Conjunction();
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
+ return conjunction.getTypedValues(criteria, criteriaQuery);
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
+ return conjunction.toSqlString(criteria, criteriaQuery);
+ }
+
+ public NaturalIdentifier set(String property, Object value) {
+ conjunction.add( Restrictions.eq(property, value) );
+ return this;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,17 +0,0 @@
-//$Id: NotEmptyExpression.java 6661 2005-05-03 20:12:20Z steveebersole $
-package org.hibernate.criterion;
-
-/**
- * @author Gavin King
- */
-public class NotEmptyExpression extends AbstractEmptinessExpression implements Criterion {
-
- protected NotEmptyExpression(String propertyName) {
- super( propertyName );
- }
-
- protected boolean excludeEmpty() {
- return true;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotEmptyExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+/**
+ * @author Gavin King
+ */
+public class NotEmptyExpression extends AbstractEmptinessExpression implements Criterion {
+
+ protected NotEmptyExpression(String propertyName) {
+ super( propertyName );
+ }
+
+ protected boolean excludeEmpty() {
+ return true;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/NotExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,42 +0,0 @@
-//$Id: NotExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.engine.TypedValue;
-
-/**
- * Negates another criterion
- * @author Gavin King
- */
-public class NotExpression implements Criterion {
-
- private Criterion criterion;
-
- protected NotExpression(Criterion criterion) {
- this.criterion = criterion;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- if ( criteriaQuery.getFactory().getDialect() instanceof MySQLDialect ) {
- return "not (" + criterion.toSqlString(criteria, criteriaQuery) + ')';
- }
- else {
- return "not " + criterion.toSqlString(criteria, criteriaQuery);
- }
- }
-
- public TypedValue[] getTypedValues(
- Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return criterion.getTypedValues(criteria, criteriaQuery);
- }
-
- public String toString() {
- return "not " + criterion.toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/NotExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,65 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * Negates another criterion
+ * @author Gavin King
+ */
+public class NotExpression implements Criterion {
+
+ private Criterion criterion;
+
+ protected NotExpression(Criterion criterion) {
+ this.criterion = criterion;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ if ( criteriaQuery.getFactory().getDialect() instanceof MySQLDialect ) {
+ return "not (" + criterion.toSqlString(criteria, criteriaQuery) + ')';
+ }
+ else {
+ return "not " + criterion.toSqlString(criteria, criteriaQuery);
+ }
+ }
+
+ public TypedValue[] getTypedValues(
+ Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return criterion.getTypedValues(criteria, criteriaQuery);
+ }
+
+ public String toString() {
+ return "not " + criterion.toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/NotNullExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,46 +0,0 @@
-//$Id: NotNullExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.util.StringHelper;
-
-/**
- * Constrains a property to be non-null
- * @author Gavin King
- */
-public class NotNullExpression implements Criterion {
-
- private final String propertyName;
-
- private static final TypedValue[] NO_VALUES = new TypedValue[0];
-
- protected NotNullExpression(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- String result = StringHelper.join(
- " or ",
- StringHelper.suffix( columns, " is not null" )
- );
- if (columns.length>1) result = '(' + result + ')';
- return result;
-
- //TODO: get SQL rendering out of this package!
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return NO_VALUES;
- }
-
- public String toString() {
- return propertyName + " is not null";
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/NotNullExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NotNullExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Constrains a property to be non-null
+ * @author Gavin King
+ */
+public class NotNullExpression implements Criterion {
+
+ private final String propertyName;
+
+ private static final TypedValue[] NO_VALUES = new TypedValue[0];
+
+ protected NotNullExpression(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ String result = StringHelper.join(
+ " or ",
+ StringHelper.suffix( columns, " is not null" )
+ );
+ if (columns.length>1) result = '(' + result + ')';
+ return result;
+
+ //TODO: get SQL rendering out of this package!
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return NO_VALUES;
+ }
+
+ public String toString() {
+ return propertyName + " is not null";
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/NullExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,46 +0,0 @@
-//$Id: NullExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.util.StringHelper;
-
-/**
- * Constrains a property to be null
- * @author Gavin King
- */
-public class NullExpression implements Criterion {
-
- private final String propertyName;
-
- private static final TypedValue[] NO_VALUES = new TypedValue[0];
-
- protected NullExpression(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- String result = StringHelper.join(
- " and ",
- StringHelper.suffix( columns, " is null" )
- );
- if (columns.length>1) result = '(' + result + ')';
- return result;
-
- //TODO: get SQL rendering out of this package!
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return NO_VALUES;
- }
-
- public String toString() {
- return propertyName + " is null";
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/NullExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/NullExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Constrains a property to be null
+ * @author Gavin King
+ */
+public class NullExpression implements Criterion {
+
+ private final String propertyName;
+
+ private static final TypedValue[] NO_VALUES = new TypedValue[0];
+
+ protected NullExpression(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ String result = StringHelper.join(
+ " and ",
+ StringHelper.suffix( columns, " is null" )
+ );
+ if (columns.length>1) result = '(' + result + ')';
+ return result;
+
+ //TODO: get SQL rendering out of this package!
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return NO_VALUES;
+ }
+
+ public String toString() {
+ return propertyName + " is null";
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Order.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,83 +0,0 @@
-//$Id: Order.java 7495 2005-07-15 16:52:10Z oneovthafew $
-package org.hibernate.criterion;
-
-import java.io.Serializable;
-import java.sql.Types;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Represents an order imposed upon a <tt>Criteria</tt> result set
- * @author Gavin King
- */
-public class Order implements Serializable {
-
- private boolean ascending;
- private boolean ignoreCase;
- private String propertyName;
-
- public String toString() {
- return propertyName + ' ' + (ascending?"asc":"desc");
- }
-
- public Order ignoreCase() {
- ignoreCase = true;
- return this;
- }
-
- /**
- * Constructor for Order.
- */
- protected Order(String propertyName, boolean ascending) {
- this.propertyName = propertyName;
- this.ascending = ascending;
- }
-
- /**
- * Render the SQL fragment
- *
- */
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
- StringBuffer fragment = new StringBuffer();
- for ( int i=0; i<columns.length; i++ ) {
- SessionFactoryImplementor factory = criteriaQuery.getFactory();
- boolean lower = ignoreCase && type.sqlTypes( factory )[i]==Types.VARCHAR;
- if (lower) {
- fragment.append( factory.getDialect().getLowercaseFunction() )
- .append('(');
- }
- fragment.append( columns[i] );
- if (lower) fragment.append(')');
- fragment.append( ascending ? " asc" : " desc" );
- if ( i<columns.length-1 ) fragment.append(", ");
- }
- return fragment.toString();
- }
-
- /**
- * Ascending order
- *
- * @param propertyName
- * @return Order
- */
- public static Order asc(String propertyName) {
- return new Order(propertyName, true);
- }
-
- /**
- * Descending order
- *
- * @param propertyName
- * @return Order
- */
- public static Order desc(String propertyName) {
- return new Order(propertyName, false);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Order.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Order.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,106 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.io.Serializable;
+import java.sql.Types;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Represents an order imposed upon a <tt>Criteria</tt> result set
+ * @author Gavin King
+ */
+public class Order implements Serializable {
+
+ private boolean ascending;
+ private boolean ignoreCase;
+ private String propertyName;
+
+ public String toString() {
+ return propertyName + ' ' + (ascending?"asc":"desc");
+ }
+
+ public Order ignoreCase() {
+ ignoreCase = true;
+ return this;
+ }
+
+ /**
+ * Constructor for Order.
+ */
+ protected Order(String propertyName, boolean ascending) {
+ this.propertyName = propertyName;
+ this.ascending = ascending;
+ }
+
+ /**
+ * Render the SQL fragment
+ *
+ */
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
+ StringBuffer fragment = new StringBuffer();
+ for ( int i=0; i<columns.length; i++ ) {
+ SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ boolean lower = ignoreCase && type.sqlTypes( factory )[i]==Types.VARCHAR;
+ if (lower) {
+ fragment.append( factory.getDialect().getLowercaseFunction() )
+ .append('(');
+ }
+ fragment.append( columns[i] );
+ if (lower) fragment.append(')');
+ fragment.append( ascending ? " asc" : " desc" );
+ if ( i<columns.length-1 ) fragment.append(", ");
+ }
+ return fragment.toString();
+ }
+
+ /**
+ * Ascending order
+ *
+ * @param propertyName
+ * @return Order
+ */
+ public static Order asc(String propertyName) {
+ return new Order(propertyName, true);
+ }
+
+ /**
+ * Descending order
+ *
+ * @param propertyName
+ * @return Order
+ */
+ public static Order desc(String propertyName) {
+ return new Order(propertyName, false);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Projection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,81 +0,0 @@
-//$Id: Projection.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import java.io.Serializable;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * An object-oriented representation of a query result set projection
- * in a <tt>Criteria</tt> query. Built-in projection types are provided
- * by the <tt>Projections</tt> factory class.
- * This interface might be implemented by application classes that
- * define custom projections.
- *
- * @see Projections
- * @see org.hibernate.Criteria
- * @author Gavin King
- */
-public interface Projection extends Serializable {
-
- /**
- * Render the SQL fragment
- * @param criteriaQuery
- * @param columnAlias
- * @return String
- * @throws HibernateException
- */
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException;
-
- /**
- * Render the SQL fragment to be used in the group by clause
- * @param criteriaQuery
- * @param columnAlias
- * @return String
- * @throws HibernateException
- */
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException;
-
- /**
- * Return types returned by the rendered SQL fragment
- * @param criteria
- * @param criteriaQuery
- * @return Type[]
- * @throws HibernateException
- */
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException;
- /**
- * Return types for a particular user-visible alias
- */
- public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException;
-
- /**
- * Get the SQL select clause column aliases
- */
- public String[] getColumnAliases(int loc);
- /**
- * Get the SQL select clause column aliases for a particular
- * user-visible alias
- */
- public String[] getColumnAliases(String alias, int loc);
-
- /**
- * Get the user-visible aliases for this projection
- * (ie. the ones that will be passed to the
- * <tt>ResultTransformer</tt>)
- */
- public String[] getAliases();
-
- /**
- * Does this projection specify grouping attributes?
- */
- public boolean isGrouped();
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Projection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,104 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import java.io.Serializable;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * An object-oriented representation of a query result set projection
+ * in a <tt>Criteria</tt> query. Built-in projection types are provided
+ * by the <tt>Projections</tt> factory class.
+ * This interface might be implemented by application classes that
+ * define custom projections.
+ *
+ * @see Projections
+ * @see org.hibernate.Criteria
+ * @author Gavin King
+ */
+public interface Projection extends Serializable {
+
+ /**
+ * Render the SQL fragment
+ * @param criteriaQuery
+ * @param columnAlias
+ * @return String
+ * @throws HibernateException
+ */
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException;
+
+ /**
+ * Render the SQL fragment to be used in the group by clause
+ * @param criteriaQuery
+ * @param columnAlias
+ * @return String
+ * @throws HibernateException
+ */
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException;
+
+ /**
+ * Return types returned by the rendered SQL fragment
+ * @param criteria
+ * @param criteriaQuery
+ * @return Type[]
+ * @throws HibernateException
+ */
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException;
+ /**
+ * Return types for a particular user-visible alias
+ */
+ public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException;
+
+ /**
+ * Get the SQL select clause column aliases
+ */
+ public String[] getColumnAliases(int loc);
+ /**
+ * Get the SQL select clause column aliases for a particular
+ * user-visible alias
+ */
+ public String[] getColumnAliases(String alias, int loc);
+
+ /**
+ * Get the user-visible aliases for this projection
+ * (ie. the ones that will be passed to the
+ * <tt>ResultTransformer</tt>)
+ */
+ public String[] getAliases();
+
+ /**
+ * Does this projection specify grouping attributes?
+ */
+ public boolean isGrouped();
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/ProjectionList.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,125 +0,0 @@
-//$Id: ProjectionList.java 6490 2005-04-23 07:09:03Z oneovthafew $
-package org.hibernate.criterion;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * @author Gavin King
- */
-public class ProjectionList implements Projection {
-
- private List elements = new ArrayList();
-
- protected ProjectionList() {}
-
- public ProjectionList create() {
- return new ProjectionList();
- }
-
- public ProjectionList add(Projection proj) {
- elements.add(proj);
- return this;
- }
-
- public ProjectionList add(Projection projection, String alias) {
- return add( Projections.alias(projection, alias) );
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- List types = new ArrayList( getLength() );
- for ( int i=0; i<getLength(); i++ ) {
- Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery);
- ArrayHelper.addAll(types, elemTypes);
- }
- return ArrayHelper.toTypeArray(types);
- }
-
- public String toSqlString(Criteria criteria, int loc, CriteriaQuery criteriaQuery)
- throws HibernateException {
- StringBuffer buf = new StringBuffer();
- for ( int i=0; i<getLength(); i++ ) {
- Projection proj = getProjection(i);
- buf.append( proj.toSqlString(criteria, loc, criteriaQuery) );
- loc += proj.getColumnAliases(loc).length;
- if ( i<elements.size()-1 ) buf.append(", ");
- }
- return buf.toString();
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- StringBuffer buf = new StringBuffer();
- for ( int i=0; i<getLength(); i++ ) {
- Projection proj = getProjection(i);
- if ( proj.isGrouped() ) {
- buf.append( proj.toGroupSqlString(criteria, criteriaQuery) )
- .append(", ");
- }
- }
- if ( buf.length()>2 ) buf.setLength( buf.length()-2 ); //pull off the last ", "
- return buf.toString();
- }
-
- public String[] getColumnAliases(int loc) {
- List result = new ArrayList( getLength() );
- for ( int i=0; i<getLength(); i++ ) {
- String[] colAliases = getProjection(i).getColumnAliases(loc);
- ArrayHelper.addAll(result, colAliases);
- loc+=colAliases.length;
- }
- return ArrayHelper.toStringArray(result);
- }
-
- public String[] getColumnAliases(String alias, int loc) {
- for ( int i=0; i<getLength(); i++ ) {
- String[] result = getProjection(i).getColumnAliases(alias, loc);
- if (result!=null) return result;
- loc += getProjection(i).getColumnAliases(loc).length;
- }
- return null;
- }
-
- public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery) {
- for ( int i=0; i<getLength(); i++ ) {
- Type[] result = getProjection(i).getTypes(alias, criteria, criteriaQuery);
- if (result!=null) return result;
- }
- return null;
- }
-
- public String[] getAliases() {
- List result = new ArrayList( getLength() );
- for ( int i=0; i<getLength(); i++ ) {
- String[] aliases = getProjection(i).getAliases();
- ArrayHelper.addAll(result, aliases);
- }
- return ArrayHelper.toStringArray(result);
-
- }
-
- public Projection getProjection(int i) {
- return (Projection) elements.get(i);
- }
-
- public int getLength() {
- return elements.size();
- }
-
- public String toString() {
- return elements.toString();
- }
-
- public boolean isGrouped() {
- for ( int i=0; i<getLength(); i++ ) {
- if ( getProjection(i).isGrouped() ) return true;
- }
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/ProjectionList.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/ProjectionList.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,148 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * @author Gavin King
+ */
+public class ProjectionList implements Projection {
+
+ private List elements = new ArrayList();
+
+ protected ProjectionList() {}
+
+ public ProjectionList create() {
+ return new ProjectionList();
+ }
+
+ public ProjectionList add(Projection proj) {
+ elements.add(proj);
+ return this;
+ }
+
+ public ProjectionList add(Projection projection, String alias) {
+ return add( Projections.alias(projection, alias) );
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ List types = new ArrayList( getLength() );
+ for ( int i=0; i<getLength(); i++ ) {
+ Type[] elemTypes = getProjection(i).getTypes(criteria, criteriaQuery);
+ ArrayHelper.addAll(types, elemTypes);
+ }
+ return ArrayHelper.toTypeArray(types);
+ }
+
+ public String toSqlString(Criteria criteria, int loc, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ StringBuffer buf = new StringBuffer();
+ for ( int i=0; i<getLength(); i++ ) {
+ Projection proj = getProjection(i);
+ buf.append( proj.toSqlString(criteria, loc, criteriaQuery) );
+ loc += proj.getColumnAliases(loc).length;
+ if ( i<elements.size()-1 ) buf.append(", ");
+ }
+ return buf.toString();
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ StringBuffer buf = new StringBuffer();
+ for ( int i=0; i<getLength(); i++ ) {
+ Projection proj = getProjection(i);
+ if ( proj.isGrouped() ) {
+ buf.append( proj.toGroupSqlString(criteria, criteriaQuery) )
+ .append(", ");
+ }
+ }
+ if ( buf.length()>2 ) buf.setLength( buf.length()-2 ); //pull off the last ", "
+ return buf.toString();
+ }
+
+ public String[] getColumnAliases(int loc) {
+ List result = new ArrayList( getLength() );
+ for ( int i=0; i<getLength(); i++ ) {
+ String[] colAliases = getProjection(i).getColumnAliases(loc);
+ ArrayHelper.addAll(result, colAliases);
+ loc+=colAliases.length;
+ }
+ return ArrayHelper.toStringArray(result);
+ }
+
+ public String[] getColumnAliases(String alias, int loc) {
+ for ( int i=0; i<getLength(); i++ ) {
+ String[] result = getProjection(i).getColumnAliases(alias, loc);
+ if (result!=null) return result;
+ loc += getProjection(i).getColumnAliases(loc).length;
+ }
+ return null;
+ }
+
+ public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery) {
+ for ( int i=0; i<getLength(); i++ ) {
+ Type[] result = getProjection(i).getTypes(alias, criteria, criteriaQuery);
+ if (result!=null) return result;
+ }
+ return null;
+ }
+
+ public String[] getAliases() {
+ List result = new ArrayList( getLength() );
+ for ( int i=0; i<getLength(); i++ ) {
+ String[] aliases = getProjection(i).getAliases();
+ ArrayHelper.addAll(result, aliases);
+ }
+ return ArrayHelper.toStringArray(result);
+
+ }
+
+ public Projection getProjection(int i) {
+ return (Projection) elements.get(i);
+ }
+
+ public int getLength() {
+ return elements.size();
+ }
+
+ public String toString() {
+ return elements.toString();
+ }
+
+ public boolean isGrouped() {
+ for ( int i=0; i<getLength(); i++ ) {
+ if ( getProjection(i).isGrouped() ) return true;
+ }
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Projections.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,128 +0,0 @@
-//$Id: Projections.java 6970 2005-05-31 20:24:41Z oneovthafew $
-package org.hibernate.criterion;
-
-import org.hibernate.type.Type;
-
-/**
- * The <tt>criterion</tt> package may be used by applications as a framework for building
- * new kinds of <tt>Projection</tt>. However, it is intended that most applications will
- * simply use the built-in projection types via the static factory methods of this class.<br/>
- * <br/>
- * The factory methods that take an alias allow the projected value to be referred to by
- * criterion and order instances.
- *
- * @see org.hibernate.Criteria
- * @see Restrictions factory methods for <tt>Criterion</tt> instances
- * @author Gavin King
- */
-public final class Projections {
-
- private Projections() {
- //cannot be instantiated
- }
-
- /**
- * Create a distinct projection from a projection
- */
- public static Projection distinct(Projection proj) {
- return new Distinct(proj);
- }
-
- /**
- * Create a new projection list
- */
- public static ProjectionList projectionList() {
- return new ProjectionList();
- }
-
- /**
- * The query row count, ie. <tt>count(*)</tt>
- */
- public static Projection rowCount() {
- return new RowCountProjection();
- }
-
- /**
- * A property value count
- */
- public static CountProjection count(String propertyName) {
- return new CountProjection(propertyName);
- }
-
- /**
- * A distinct property value count
- */
- public static CountProjection countDistinct(String propertyName) {
- return new CountProjection(propertyName).setDistinct();
- }
-
- /**
- * A property maximum value
- */
- public static AggregateProjection max(String propertyName) {
- return new AggregateProjection("max", propertyName);
- }
-
- /**
- * A property minimum value
- */
- public static AggregateProjection min(String propertyName) {
- return new AggregateProjection("min", propertyName);
- }
-
- /**
- * A property average value
- */
- public static AggregateProjection avg(String propertyName) {
- return new AvgProjection(propertyName);
- }
-
- /**
- * A property value sum
- */
- public static AggregateProjection sum(String propertyName) {
- return new AggregateProjection("sum", propertyName);
- }
-
- /**
- * A SQL projection, a typed select clause fragment
- */
- public static Projection sqlProjection(String sql, String[] columnAliases, Type[] types) {
- return new SQLProjection(sql, columnAliases, types);
- }
-
- /**
- * A grouping SQL projection, specifying both select clause and group by clause fragments
- */
- public static Projection sqlGroupProjection(String sql, String groupBy, String[] columnAliases, Type[] types) {
- return new SQLProjection(sql, groupBy, columnAliases, types);
- }
-
- /**
- * A grouping property value
- */
- public static PropertyProjection groupProperty(String propertyName) {
- return new PropertyProjection(propertyName, true);
- }
-
- /**
- * A projected property value
- */
- public static PropertyProjection property(String propertyName) {
- return new PropertyProjection(propertyName);
- }
-
- /**
- * A projected identifier value
- */
- public static IdentifierProjection id() {
- return new IdentifierProjection();
- }
-
- /**
- * Assign an alias to a projection, by wrapping it
- */
- public static Projection alias(Projection projection, String alias) {
- return new AliasedProjection(projection, alias);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Projections.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Projections.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,151 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.type.Type;
+
+/**
+ * The <tt>criterion</tt> package may be used by applications as a framework for building
+ * new kinds of <tt>Projection</tt>. However, it is intended that most applications will
+ * simply use the built-in projection types via the static factory methods of this class.<br/>
+ * <br/>
+ * The factory methods that take an alias allow the projected value to be referred to by
+ * criterion and order instances.
+ *
+ * @see org.hibernate.Criteria
+ * @see Restrictions factory methods for <tt>Criterion</tt> instances
+ * @author Gavin King
+ */
+public final class Projections {
+
+ private Projections() {
+ //cannot be instantiated
+ }
+
+ /**
+ * Create a distinct projection from a projection
+ */
+ public static Projection distinct(Projection proj) {
+ return new Distinct(proj);
+ }
+
+ /**
+ * Create a new projection list
+ */
+ public static ProjectionList projectionList() {
+ return new ProjectionList();
+ }
+
+ /**
+ * The query row count, ie. <tt>count(*)</tt>
+ */
+ public static Projection rowCount() {
+ return new RowCountProjection();
+ }
+
+ /**
+ * A property value count
+ */
+ public static CountProjection count(String propertyName) {
+ return new CountProjection(propertyName);
+ }
+
+ /**
+ * A distinct property value count
+ */
+ public static CountProjection countDistinct(String propertyName) {
+ return new CountProjection(propertyName).setDistinct();
+ }
+
+ /**
+ * A property maximum value
+ */
+ public static AggregateProjection max(String propertyName) {
+ return new AggregateProjection("max", propertyName);
+ }
+
+ /**
+ * A property minimum value
+ */
+ public static AggregateProjection min(String propertyName) {
+ return new AggregateProjection("min", propertyName);
+ }
+
+ /**
+ * A property average value
+ */
+ public static AggregateProjection avg(String propertyName) {
+ return new AvgProjection(propertyName);
+ }
+
+ /**
+ * A property value sum
+ */
+ public static AggregateProjection sum(String propertyName) {
+ return new AggregateProjection("sum", propertyName);
+ }
+
+ /**
+ * A SQL projection, a typed select clause fragment
+ */
+ public static Projection sqlProjection(String sql, String[] columnAliases, Type[] types) {
+ return new SQLProjection(sql, columnAliases, types);
+ }
+
+ /**
+ * A grouping SQL projection, specifying both select clause and group by clause fragments
+ */
+ public static Projection sqlGroupProjection(String sql, String groupBy, String[] columnAliases, Type[] types) {
+ return new SQLProjection(sql, groupBy, columnAliases, types);
+ }
+
+ /**
+ * A grouping property value
+ */
+ public static PropertyProjection groupProperty(String propertyName) {
+ return new PropertyProjection(propertyName, true);
+ }
+
+ /**
+ * A projected property value
+ */
+ public static PropertyProjection property(String propertyName) {
+ return new PropertyProjection(propertyName);
+ }
+
+ /**
+ * A projected identifier value
+ */
+ public static IdentifierProjection id() {
+ return new IdentifierProjection();
+ }
+
+ /**
+ * Assign an alias to a projection, by wrapping it
+ */
+ public static Projection alias(Projection projection, String alias) {
+ return new AliasedProjection(projection, alias);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Property.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,235 +0,0 @@
-//$Id: Property.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import java.util.Collection;
-
-/**
- * A factory for property-specific criterion and projection instances
- * @author Gavin King
- */
-public class Property extends PropertyProjection {
- //private String propertyName;
- protected Property(String propertyName) {
- super(propertyName);
- }
-
- public Criterion between(Object min, Object max) {
- return Restrictions.between(getPropertyName(), min, max);
- }
-
- public Criterion in(Collection values) {
- return Restrictions.in(getPropertyName(), values);
- }
-
- public Criterion in(Object[] values) {
- return Restrictions.in(getPropertyName(), values);
- }
-
- public SimpleExpression like(Object value) {
- return Restrictions.like(getPropertyName(), value);
- }
-
- public SimpleExpression like(String value, MatchMode matchMode) {
- return Restrictions.like(getPropertyName(), value, matchMode);
- }
-
- public SimpleExpression eq(Object value) {
- return Restrictions.eq(getPropertyName(), value);
- }
-
- public SimpleExpression ne(Object value) {
- return Restrictions.ne(getPropertyName(), value);
- }
-
- public SimpleExpression gt(Object value) {
- return Restrictions.gt(getPropertyName(), value);
- }
-
- public SimpleExpression lt(Object value) {
- return Restrictions.lt(getPropertyName(), value);
- }
-
- public SimpleExpression le(Object value) {
- return Restrictions.le(getPropertyName(), value);
- }
-
- public SimpleExpression ge(Object value) {
- return Restrictions.ge(getPropertyName(), value);
- }
-
- public PropertyExpression eqProperty(Property other) {
- return Restrictions.eqProperty( getPropertyName(), other.getPropertyName() );
- }
-
- public PropertyExpression neProperty(Property other) {
- return Restrictions.neProperty( getPropertyName(), other.getPropertyName() );
- }
-
- public PropertyExpression leProperty(Property other) {
- return Restrictions.leProperty( getPropertyName(), other.getPropertyName() );
- }
-
- public PropertyExpression geProperty(Property other) {
- return Restrictions.geProperty( getPropertyName(), other.getPropertyName() );
- }
-
- public PropertyExpression ltProperty(Property other) {
- return Restrictions.ltProperty( getPropertyName(), other.getPropertyName() );
- }
-
- public PropertyExpression gtProperty(Property other) {
- return Restrictions.gtProperty( getPropertyName(), other.getPropertyName() );
- }
-
- public PropertyExpression eqProperty(String other) {
- return Restrictions.eqProperty( getPropertyName(), other );
- }
-
- public PropertyExpression neProperty(String other) {
- return Restrictions.neProperty( getPropertyName(), other );
- }
-
- public PropertyExpression leProperty(String other) {
- return Restrictions.leProperty( getPropertyName(), other );
- }
-
- public PropertyExpression geProperty(String other) {
- return Restrictions.geProperty( getPropertyName(), other );
- }
-
- public PropertyExpression ltProperty(String other) {
- return Restrictions.ltProperty( getPropertyName(), other );
- }
-
- public PropertyExpression gtProperty(String other) {
- return Restrictions.gtProperty( getPropertyName(), other );
- }
-
- public Criterion isNull() {
- return Restrictions.isNull(getPropertyName());
- }
-
- public Criterion isNotNull() {
- return Restrictions.isNotNull(getPropertyName());
- }
-
- public Criterion isEmpty() {
- return Restrictions.isEmpty(getPropertyName());
- }
-
- public Criterion isNotEmpty() {
- return Restrictions.isNotEmpty(getPropertyName());
- }
-
- public CountProjection count() {
- return Projections.count(getPropertyName());
- }
-
- public AggregateProjection max() {
- return Projections.max(getPropertyName());
- }
-
- public AggregateProjection min() {
- return Projections.min(getPropertyName());
- }
-
- public AggregateProjection avg() {
- return Projections.avg(getPropertyName());
- }
-
- /*public PropertyProjection project() {
- return Projections.property(getPropertyName());
- }*/
-
- public PropertyProjection group() {
- return Projections.groupProperty(getPropertyName());
- }
-
- public Order asc() {
- return Order.asc(getPropertyName());
- }
-
- public Order desc() {
- return Order.desc(getPropertyName());
- }
-
- public static Property forName(String propertyName) {
- return new Property(propertyName);
- }
-
- /**
- * Get a component attribute of this property
- */
- public Property getProperty(String propertyName) {
- return forName( getPropertyName() + '.' + propertyName );
- }
-
- public Criterion eq(DetachedCriteria subselect) {
- return Subqueries.propertyEq( getPropertyName(), subselect );
- }
-
- public Criterion ne(DetachedCriteria subselect) {
- return Subqueries.propertyNe( getPropertyName(), subselect );
- }
-
- public Criterion lt(DetachedCriteria subselect) {
- return Subqueries.propertyLt( getPropertyName(), subselect );
- }
-
- public Criterion le(DetachedCriteria subselect) {
- return Subqueries.propertyLe( getPropertyName(), subselect );
- }
-
- public Criterion gt(DetachedCriteria subselect) {
- return Subqueries.propertyGt( getPropertyName(), subselect );
- }
-
- public Criterion ge(DetachedCriteria subselect) {
- return Subqueries.propertyGe( getPropertyName(), subselect );
- }
-
- public Criterion notIn(DetachedCriteria subselect) {
- return Subqueries.propertyNotIn( getPropertyName(), subselect );
- }
-
- public Criterion in(DetachedCriteria subselect) {
- return Subqueries.propertyIn( getPropertyName(), subselect );
- }
-
- public Criterion eqAll(DetachedCriteria subselect) {
- return Subqueries.propertyEqAll( getPropertyName(), subselect );
- }
-
- public Criterion gtAll(DetachedCriteria subselect) {
- return Subqueries.propertyGtAll( getPropertyName(), subselect );
- }
-
- public Criterion ltAll(DetachedCriteria subselect) {
- return Subqueries.propertyLtAll( getPropertyName(), subselect );
- }
-
- public Criterion leAll(DetachedCriteria subselect) {
- return Subqueries.propertyLeAll( getPropertyName(), subselect );
- }
-
- public Criterion geAll(DetachedCriteria subselect) {
- return Subqueries.propertyGeAll( getPropertyName(), subselect );
- }
-
- public Criterion gtSome(DetachedCriteria subselect) {
- return Subqueries.propertyGtSome( getPropertyName(), subselect );
- }
-
- public Criterion ltSome(DetachedCriteria subselect) {
- return Subqueries.propertyLtSome( getPropertyName(), subselect );
- }
-
- public Criterion leSome(DetachedCriteria subselect) {
- return Subqueries.propertyLeSome( getPropertyName(), subselect );
- }
-
- public Criterion geSome(DetachedCriteria subselect) {
- return Subqueries.propertyGeSome( getPropertyName(), subselect );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Property.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Property.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,258 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.util.Collection;
+
+/**
+ * A factory for property-specific criterion and projection instances
+ * @author Gavin King
+ */
+public class Property extends PropertyProjection {
+ //private String propertyName;
+ protected Property(String propertyName) {
+ super(propertyName);
+ }
+
+ public Criterion between(Object min, Object max) {
+ return Restrictions.between(getPropertyName(), min, max);
+ }
+
+ public Criterion in(Collection values) {
+ return Restrictions.in(getPropertyName(), values);
+ }
+
+ public Criterion in(Object[] values) {
+ return Restrictions.in(getPropertyName(), values);
+ }
+
+ public SimpleExpression like(Object value) {
+ return Restrictions.like(getPropertyName(), value);
+ }
+
+ public SimpleExpression like(String value, MatchMode matchMode) {
+ return Restrictions.like(getPropertyName(), value, matchMode);
+ }
+
+ public SimpleExpression eq(Object value) {
+ return Restrictions.eq(getPropertyName(), value);
+ }
+
+ public SimpleExpression ne(Object value) {
+ return Restrictions.ne(getPropertyName(), value);
+ }
+
+ public SimpleExpression gt(Object value) {
+ return Restrictions.gt(getPropertyName(), value);
+ }
+
+ public SimpleExpression lt(Object value) {
+ return Restrictions.lt(getPropertyName(), value);
+ }
+
+ public SimpleExpression le(Object value) {
+ return Restrictions.le(getPropertyName(), value);
+ }
+
+ public SimpleExpression ge(Object value) {
+ return Restrictions.ge(getPropertyName(), value);
+ }
+
+ public PropertyExpression eqProperty(Property other) {
+ return Restrictions.eqProperty( getPropertyName(), other.getPropertyName() );
+ }
+
+ public PropertyExpression neProperty(Property other) {
+ return Restrictions.neProperty( getPropertyName(), other.getPropertyName() );
+ }
+
+ public PropertyExpression leProperty(Property other) {
+ return Restrictions.leProperty( getPropertyName(), other.getPropertyName() );
+ }
+
+ public PropertyExpression geProperty(Property other) {
+ return Restrictions.geProperty( getPropertyName(), other.getPropertyName() );
+ }
+
+ public PropertyExpression ltProperty(Property other) {
+ return Restrictions.ltProperty( getPropertyName(), other.getPropertyName() );
+ }
+
+ public PropertyExpression gtProperty(Property other) {
+ return Restrictions.gtProperty( getPropertyName(), other.getPropertyName() );
+ }
+
+ public PropertyExpression eqProperty(String other) {
+ return Restrictions.eqProperty( getPropertyName(), other );
+ }
+
+ public PropertyExpression neProperty(String other) {
+ return Restrictions.neProperty( getPropertyName(), other );
+ }
+
+ public PropertyExpression leProperty(String other) {
+ return Restrictions.leProperty( getPropertyName(), other );
+ }
+
+ public PropertyExpression geProperty(String other) {
+ return Restrictions.geProperty( getPropertyName(), other );
+ }
+
+ public PropertyExpression ltProperty(String other) {
+ return Restrictions.ltProperty( getPropertyName(), other );
+ }
+
+ public PropertyExpression gtProperty(String other) {
+ return Restrictions.gtProperty( getPropertyName(), other );
+ }
+
+ public Criterion isNull() {
+ return Restrictions.isNull(getPropertyName());
+ }
+
+ public Criterion isNotNull() {
+ return Restrictions.isNotNull(getPropertyName());
+ }
+
+ public Criterion isEmpty() {
+ return Restrictions.isEmpty(getPropertyName());
+ }
+
+ public Criterion isNotEmpty() {
+ return Restrictions.isNotEmpty(getPropertyName());
+ }
+
+ public CountProjection count() {
+ return Projections.count(getPropertyName());
+ }
+
+ public AggregateProjection max() {
+ return Projections.max(getPropertyName());
+ }
+
+ public AggregateProjection min() {
+ return Projections.min(getPropertyName());
+ }
+
+ public AggregateProjection avg() {
+ return Projections.avg(getPropertyName());
+ }
+
+ /*public PropertyProjection project() {
+ return Projections.property(getPropertyName());
+ }*/
+
+ public PropertyProjection group() {
+ return Projections.groupProperty(getPropertyName());
+ }
+
+ public Order asc() {
+ return Order.asc(getPropertyName());
+ }
+
+ public Order desc() {
+ return Order.desc(getPropertyName());
+ }
+
+ public static Property forName(String propertyName) {
+ return new Property(propertyName);
+ }
+
+ /**
+ * Get a component attribute of this property
+ */
+ public Property getProperty(String propertyName) {
+ return forName( getPropertyName() + '.' + propertyName );
+ }
+
+ public Criterion eq(DetachedCriteria subselect) {
+ return Subqueries.propertyEq( getPropertyName(), subselect );
+ }
+
+ public Criterion ne(DetachedCriteria subselect) {
+ return Subqueries.propertyNe( getPropertyName(), subselect );
+ }
+
+ public Criterion lt(DetachedCriteria subselect) {
+ return Subqueries.propertyLt( getPropertyName(), subselect );
+ }
+
+ public Criterion le(DetachedCriteria subselect) {
+ return Subqueries.propertyLe( getPropertyName(), subselect );
+ }
+
+ public Criterion gt(DetachedCriteria subselect) {
+ return Subqueries.propertyGt( getPropertyName(), subselect );
+ }
+
+ public Criterion ge(DetachedCriteria subselect) {
+ return Subqueries.propertyGe( getPropertyName(), subselect );
+ }
+
+ public Criterion notIn(DetachedCriteria subselect) {
+ return Subqueries.propertyNotIn( getPropertyName(), subselect );
+ }
+
+ public Criterion in(DetachedCriteria subselect) {
+ return Subqueries.propertyIn( getPropertyName(), subselect );
+ }
+
+ public Criterion eqAll(DetachedCriteria subselect) {
+ return Subqueries.propertyEqAll( getPropertyName(), subselect );
+ }
+
+ public Criterion gtAll(DetachedCriteria subselect) {
+ return Subqueries.propertyGtAll( getPropertyName(), subselect );
+ }
+
+ public Criterion ltAll(DetachedCriteria subselect) {
+ return Subqueries.propertyLtAll( getPropertyName(), subselect );
+ }
+
+ public Criterion leAll(DetachedCriteria subselect) {
+ return Subqueries.propertyLeAll( getPropertyName(), subselect );
+ }
+
+ public Criterion geAll(DetachedCriteria subselect) {
+ return Subqueries.propertyGeAll( getPropertyName(), subselect );
+ }
+
+ public Criterion gtSome(DetachedCriteria subselect) {
+ return Subqueries.propertyGtSome( getPropertyName(), subselect );
+ }
+
+ public Criterion ltSome(DetachedCriteria subselect) {
+ return Subqueries.propertyLtSome( getPropertyName(), subselect );
+ }
+
+ public Criterion leSome(DetachedCriteria subselect) {
+ return Subqueries.propertyLeSome( getPropertyName(), subselect );
+ }
+
+ public Criterion geSome(DetachedCriteria subselect) {
+ return Subqueries.propertyGeSome( getPropertyName(), subselect );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/PropertyExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,54 +0,0 @@
-//$Id: PropertyExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.util.StringHelper;
-
-/**
- * superclass for comparisons between two properties (with SQL binary operators)
- * @author Gavin King
- */
-public class PropertyExpression implements Criterion {
-
- private final String propertyName;
- private final String otherPropertyName;
- private final String op;
-
- private static final TypedValue[] NO_TYPED_VALUES = new TypedValue[0];
-
- protected PropertyExpression(String propertyName, String otherPropertyName, String op) {
- this.propertyName = propertyName;
- this.otherPropertyName = otherPropertyName;
- this.op = op;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- String[] xcols = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- String[] ycols = criteriaQuery.getColumnsUsingProjection(criteria, otherPropertyName);
- String result = StringHelper.join(
- " and ",
- StringHelper.add(xcols, getOp(), ycols)
- );
- if (xcols.length>1) result = '(' + result + ')';
- return result;
- //TODO: get SQL rendering out of this package!
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return NO_TYPED_VALUES;
- }
-
- public String toString() {
- return propertyName + getOp() + otherPropertyName;
- }
-
- public String getOp() {
- return op;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/PropertyExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,76 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.util.StringHelper;
+
+/**
+ * superclass for comparisons between two properties (with SQL binary operators)
+ * @author Gavin King
+ */
+public class PropertyExpression implements Criterion {
+
+ private final String propertyName;
+ private final String otherPropertyName;
+ private final String op;
+
+ private static final TypedValue[] NO_TYPED_VALUES = new TypedValue[0];
+
+ protected PropertyExpression(String propertyName, String otherPropertyName, String op) {
+ this.propertyName = propertyName;
+ this.otherPropertyName = otherPropertyName;
+ this.op = op;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ String[] xcols = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ String[] ycols = criteriaQuery.getColumnsUsingProjection(criteria, otherPropertyName);
+ String result = StringHelper.join(
+ " and ",
+ StringHelper.add(xcols, getOp(), ycols)
+ );
+ if (xcols.length>1) result = '(' + result + ')';
+ return result;
+ //TODO: get SQL rendering out of this package!
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return NO_TYPED_VALUES;
+ }
+
+ public String toString() {
+ return propertyName + getOp() + otherPropertyName;
+ }
+
+ public String getOp() {
+ return op;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/PropertyProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,63 +0,0 @@
-//$Id: PropertyProjection.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * A property value, or grouped property value
- * @author Gavin King
- */
-public class PropertyProjection extends SimpleProjection {
-
- private String propertyName;
- private boolean grouped;
-
- protected PropertyProjection(String prop, boolean grouped) {
- this.propertyName = prop;
- this.grouped = grouped;
- }
-
- protected PropertyProjection(String prop) {
- this(prop, false);
- }
-
- public String getPropertyName() {
- return propertyName;
- }
-
- public String toString() {
- return propertyName;
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new Type[] { criteriaQuery.getType(criteria, propertyName) };
- }
-
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new StringBuffer()
- .append( criteriaQuery.getColumn(criteria, propertyName) )
- .append(" as y")
- .append(position)
- .append('_')
- .toString();
- }
-
- public boolean isGrouped() {
- return grouped;
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- if (!grouped) {
- return super.toGroupSqlString(criteria, criteriaQuery);
- }
- else {
- return criteriaQuery.getColumn(criteria, propertyName);
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/PropertyProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertyProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * A property value, or grouped property value
+ * @author Gavin King
+ */
+public class PropertyProjection extends SimpleProjection {
+
+ private String propertyName;
+ private boolean grouped;
+
+ protected PropertyProjection(String prop, boolean grouped) {
+ this.propertyName = prop;
+ this.grouped = grouped;
+ }
+
+ protected PropertyProjection(String prop) {
+ this(prop, false);
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public String toString() {
+ return propertyName;
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new Type[] { criteriaQuery.getType(criteria, propertyName) };
+ }
+
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new StringBuffer()
+ .append( criteriaQuery.getColumn(criteria, propertyName) )
+ .append(" as y")
+ .append(position)
+ .append('_')
+ .toString();
+ }
+
+ public boolean isGrouped() {
+ return grouped;
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ if (!grouped) {
+ return super.toGroupSqlString(criteria, criteriaQuery);
+ }
+ else {
+ return criteriaQuery.getColumn(criteria, propertyName);
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,23 +0,0 @@
-//$Id: PropertySubqueryExpression.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-
-/**
- * A comparison between a property value in the outer query and the
- * result of a subquery
- * @author Gavin King
- */
-public class PropertySubqueryExpression extends SubqueryExpression {
- private String propertyName;
-
- protected PropertySubqueryExpression(String propertyName, String op, String quantifier, DetachedCriteria dc) {
- super(op, quantifier, dc);
- this.propertyName = propertyName;
- }
-
- protected String toLeftSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
- return criteriaQuery.getColumn(criteria, propertyName);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/PropertySubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+
+/**
+ * A comparison between a property value in the outer query and the
+ * result of a subquery
+ * @author Gavin King
+ */
+public class PropertySubqueryExpression extends SubqueryExpression {
+ private String propertyName;
+
+ protected PropertySubqueryExpression(String propertyName, String op, String quantifier, DetachedCriteria dc) {
+ super(op, quantifier, dc);
+ this.propertyName = propertyName;
+ }
+
+ protected String toLeftSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
+ return criteriaQuery.getColumn(criteria, propertyName);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Restrictions.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,368 +0,0 @@
-//$Id: Restrictions.java 7844 2005-08-11 07:26:26Z oneovthafew $
-package org.hibernate.criterion;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.hibernate.type.Type;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * The <tt>criterion</tt> package may be used by applications as a framework for building
- * new kinds of <tt>Criterion</tt>. However, it is intended that most applications will
- * simply use the built-in criterion types via the static factory methods of this class.
- *
- * @see org.hibernate.Criteria
- * @see Projections factory methods for <tt>Projection</tt> instances
- * @author Gavin King
- */
-public class Restrictions {
-
- Restrictions() {
- //cannot be instantiated
- }
-
- /**
- * Apply an "equal" constraint to the identifier property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static Criterion idEq(Object value) {
- return new IdentifierEqExpression(value);
- }
- /**
- * Apply an "equal" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression eq(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, "=");
- }
- /**
- * Apply a "not equal" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression ne(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, "<>");
- }
- /**
- * Apply a "like" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression like(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, " like ");
- }
- /**
- * Apply a "like" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression like(String propertyName, String value, MatchMode matchMode) {
- return new SimpleExpression(propertyName, matchMode.toMatchString(value), " like " );
- }
- /**
- * A case-insensitive "like", similar to Postgres <tt>ilike</tt>
- * operator
- *
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static Criterion ilike(String propertyName, String value, MatchMode matchMode) {
- return new IlikeExpression(propertyName, value, matchMode);
- }
- /**
- * A case-insensitive "like", similar to Postgres <tt>ilike</tt>
- * operator
- *
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static Criterion ilike(String propertyName, Object value) {
- return new IlikeExpression(propertyName, value);
- }
- /**
- * Apply a "greater than" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression gt(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, ">");
- }
- /**
- * Apply a "less than" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression lt(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, "<");
- }
- /**
- * Apply a "less than or equal" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression le(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, "<=");
- }
- /**
- * Apply a "greater than or equal" constraint to the named property
- * @param propertyName
- * @param value
- * @return Criterion
- */
- public static SimpleExpression ge(String propertyName, Object value) {
- return new SimpleExpression(propertyName, value, ">=");
- }
- /**
- * Apply a "between" constraint to the named property
- * @param propertyName
- * @param lo value
- * @param hi value
- * @return Criterion
- */
- public static Criterion between(String propertyName, Object lo, Object hi) {
- return new BetweenExpression(propertyName, lo, hi);
- }
- /**
- * Apply an "in" constraint to the named property
- * @param propertyName
- * @param values
- * @return Criterion
- */
- public static Criterion in(String propertyName, Object[] values) {
- return new InExpression(propertyName, values);
- }
- /**
- * Apply an "in" constraint to the named property
- * @param propertyName
- * @param values
- * @return Criterion
- */
- public static Criterion in(String propertyName, Collection values) {
- return new InExpression( propertyName, values.toArray() );
- }
- /**
- * Apply an "is null" constraint to the named property
- * @return Criterion
- */
- public static Criterion isNull(String propertyName) {
- return new NullExpression(propertyName);
- }
- /**
- * Apply an "equal" constraint to two properties
- */
- public static PropertyExpression eqProperty(String propertyName, String otherPropertyName) {
- return new PropertyExpression(propertyName, otherPropertyName, "=");
- }
- /**
- * Apply a "not equal" constraint to two properties
- */
- public static PropertyExpression neProperty(String propertyName, String otherPropertyName) {
- return new PropertyExpression(propertyName, otherPropertyName, "<>");
- }
- /**
- * Apply a "less than" constraint to two properties
- */
- public static PropertyExpression ltProperty(String propertyName, String otherPropertyName) {
- return new PropertyExpression(propertyName, otherPropertyName, "<");
- }
- /**
- * Apply a "less than or equal" constraint to two properties
- */
- public static PropertyExpression leProperty(String propertyName, String otherPropertyName) {
- return new PropertyExpression(propertyName, otherPropertyName, "<=");
- }
- /**
- * Apply a "greater than" constraint to two properties
- */
- public static PropertyExpression gtProperty(String propertyName, String otherPropertyName) {
- return new PropertyExpression(propertyName, otherPropertyName, ">");
- }
- /**
- * Apply a "greater than or equal" constraint to two properties
- */
- public static PropertyExpression geProperty(String propertyName, String otherPropertyName) {
- return new PropertyExpression(propertyName, otherPropertyName, ">=");
- }
- /**
- * Apply an "is not null" constraint to the named property
- * @return Criterion
- */
- public static Criterion isNotNull(String propertyName) {
- return new NotNullExpression(propertyName);
- }
- /**
- * Return the conjuction of two expressions
- *
- * @param lhs
- * @param rhs
- * @return Criterion
- */
- public static LogicalExpression and(Criterion lhs, Criterion rhs) {
- return new LogicalExpression(lhs, rhs, "and");
- }
- /**
- * Return the disjuction of two expressions
- *
- * @param lhs
- * @param rhs
- * @return Criterion
- */
- public static LogicalExpression or(Criterion lhs, Criterion rhs) {
- return new LogicalExpression(lhs, rhs, "or");
- }
- /**
- * Return the negation of an expression
- *
- * @param expression
- * @return Criterion
- */
- public static Criterion not(Criterion expression) {
- return new NotExpression(expression);
- }
- /**
- * Apply a constraint expressed in SQL, with the given JDBC
- * parameters. Any occurrences of <tt>{alias}</tt> will be
- * replaced by the table alias.
- *
- * @param sql
- * @param values
- * @param types
- * @return Criterion
- */
- public static Criterion sqlRestriction(String sql, Object[] values, Type[] types) {
- return new SQLCriterion(sql, values, types);
- }
- /**
- * Apply a constraint expressed in SQL, with the given JDBC
- * parameter. Any occurrences of <tt>{alias}</tt> will be replaced
- * by the table alias.
- *
- * @param sql
- * @param value
- * @param type
- * @return Criterion
- */
- public static Criterion sqlRestriction(String sql, Object value, Type type) {
- return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } );
- }
- /**
- * Apply a constraint expressed in SQL. Any occurrences of <tt>{alias}</tt>
- * will be replaced by the table alias.
- *
- * @param sql
- * @return Criterion
- */
- public static Criterion sqlRestriction(String sql) {
- return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY);
- }
-
- /**
- * Group expressions together in a single conjunction (A and B and C...)
- *
- * @return Conjunction
- */
- public static Conjunction conjunction() {
- return new Conjunction();
- }
-
- /**
- * Group expressions together in a single disjunction (A or B or C...)
- *
- * @return Conjunction
- */
- public static Disjunction disjunction() {
- return new Disjunction();
- }
-
- /**
- * Apply an "equals" constraint to each property in the
- * key set of a <tt>Map</tt>
- *
- * @param propertyNameValues a map from property names to values
- * @return Criterion
- */
- public static Criterion allEq(Map propertyNameValues) {
- Conjunction conj = conjunction();
- Iterator iter = propertyNameValues.entrySet().iterator();
- while ( iter.hasNext() ) {
- Map.Entry me = (Map.Entry) iter.next();
- conj.add( eq( (String) me.getKey(), me.getValue() ) );
- }
- return conj;
- }
-
- /**
- * Constrain a collection valued property to be empty
- */
- public static Criterion isEmpty(String propertyName) {
- return new EmptyExpression(propertyName);
- }
-
- /**
- * Constrain a collection valued property to be non-empty
- */
- public static Criterion isNotEmpty(String propertyName) {
- return new NotEmptyExpression(propertyName);
- }
-
- /**
- * Constrain a collection valued property by size
- */
- public static Criterion sizeEq(String propertyName, int size) {
- return new SizeExpression(propertyName, size, "=");
- }
-
- /**
- * Constrain a collection valued property by size
- */
- public static Criterion sizeNe(String propertyName, int size) {
- return new SizeExpression(propertyName, size, "<>");
- }
-
- /**
- * Constrain a collection valued property by size
- */
- public static Criterion sizeGt(String propertyName, int size) {
- return new SizeExpression(propertyName, size, "<");
- }
-
- /**
- * Constrain a collection valued property by size
- */
- public static Criterion sizeLt(String propertyName, int size) {
- return new SizeExpression(propertyName, size, ">");
- }
-
- /**
- * Constrain a collection valued property by size
- */
- public static Criterion sizeGe(String propertyName, int size) {
- return new SizeExpression(propertyName, size, "<=");
- }
-
- /**
- * Constrain a collection valued property by size
- */
- public static Criterion sizeLe(String propertyName, int size) {
- return new SizeExpression(propertyName, size, ">=");
- }
-
- public static NaturalIdentifier naturalId() {
- return new NaturalIdentifier();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Restrictions.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Restrictions.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,391 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.hibernate.type.Type;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * The <tt>criterion</tt> package may be used by applications as a framework for building
+ * new kinds of <tt>Criterion</tt>. However, it is intended that most applications will
+ * simply use the built-in criterion types via the static factory methods of this class.
+ *
+ * @see org.hibernate.Criteria
+ * @see Projections factory methods for <tt>Projection</tt> instances
+ * @author Gavin King
+ */
+public class Restrictions {
+
+ Restrictions() {
+ //cannot be instantiated
+ }
+
+ /**
+ * Apply an "equal" constraint to the identifier property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static Criterion idEq(Object value) {
+ return new IdentifierEqExpression(value);
+ }
+ /**
+ * Apply an "equal" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression eq(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, "=");
+ }
+ /**
+ * Apply a "not equal" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression ne(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, "<>");
+ }
+ /**
+ * Apply a "like" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression like(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, " like ");
+ }
+ /**
+ * Apply a "like" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression like(String propertyName, String value, MatchMode matchMode) {
+ return new SimpleExpression(propertyName, matchMode.toMatchString(value), " like " );
+ }
+ /**
+ * A case-insensitive "like", similar to Postgres <tt>ilike</tt>
+ * operator
+ *
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static Criterion ilike(String propertyName, String value, MatchMode matchMode) {
+ return new IlikeExpression(propertyName, value, matchMode);
+ }
+ /**
+ * A case-insensitive "like", similar to Postgres <tt>ilike</tt>
+ * operator
+ *
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static Criterion ilike(String propertyName, Object value) {
+ return new IlikeExpression(propertyName, value);
+ }
+ /**
+ * Apply a "greater than" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression gt(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, ">");
+ }
+ /**
+ * Apply a "less than" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression lt(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, "<");
+ }
+ /**
+ * Apply a "less than or equal" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression le(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, "<=");
+ }
+ /**
+ * Apply a "greater than or equal" constraint to the named property
+ * @param propertyName
+ * @param value
+ * @return Criterion
+ */
+ public static SimpleExpression ge(String propertyName, Object value) {
+ return new SimpleExpression(propertyName, value, ">=");
+ }
+ /**
+ * Apply a "between" constraint to the named property
+ * @param propertyName
+ * @param lo value
+ * @param hi value
+ * @return Criterion
+ */
+ public static Criterion between(String propertyName, Object lo, Object hi) {
+ return new BetweenExpression(propertyName, lo, hi);
+ }
+ /**
+ * Apply an "in" constraint to the named property
+ * @param propertyName
+ * @param values
+ * @return Criterion
+ */
+ public static Criterion in(String propertyName, Object[] values) {
+ return new InExpression(propertyName, values);
+ }
+ /**
+ * Apply an "in" constraint to the named property
+ * @param propertyName
+ * @param values
+ * @return Criterion
+ */
+ public static Criterion in(String propertyName, Collection values) {
+ return new InExpression( propertyName, values.toArray() );
+ }
+ /**
+ * Apply an "is null" constraint to the named property
+ * @return Criterion
+ */
+ public static Criterion isNull(String propertyName) {
+ return new NullExpression(propertyName);
+ }
+ /**
+ * Apply an "equal" constraint to two properties
+ */
+ public static PropertyExpression eqProperty(String propertyName, String otherPropertyName) {
+ return new PropertyExpression(propertyName, otherPropertyName, "=");
+ }
+ /**
+ * Apply a "not equal" constraint to two properties
+ */
+ public static PropertyExpression neProperty(String propertyName, String otherPropertyName) {
+ return new PropertyExpression(propertyName, otherPropertyName, "<>");
+ }
+ /**
+ * Apply a "less than" constraint to two properties
+ */
+ public static PropertyExpression ltProperty(String propertyName, String otherPropertyName) {
+ return new PropertyExpression(propertyName, otherPropertyName, "<");
+ }
+ /**
+ * Apply a "less than or equal" constraint to two properties
+ */
+ public static PropertyExpression leProperty(String propertyName, String otherPropertyName) {
+ return new PropertyExpression(propertyName, otherPropertyName, "<=");
+ }
+ /**
+ * Apply a "greater than" constraint to two properties
+ */
+ public static PropertyExpression gtProperty(String propertyName, String otherPropertyName) {
+ return new PropertyExpression(propertyName, otherPropertyName, ">");
+ }
+ /**
+ * Apply a "greater than or equal" constraint to two properties
+ */
+ public static PropertyExpression geProperty(String propertyName, String otherPropertyName) {
+ return new PropertyExpression(propertyName, otherPropertyName, ">=");
+ }
+ /**
+ * Apply an "is not null" constraint to the named property
+ * @return Criterion
+ */
+ public static Criterion isNotNull(String propertyName) {
+ return new NotNullExpression(propertyName);
+ }
+ /**
+ * Return the conjuction of two expressions
+ *
+ * @param lhs
+ * @param rhs
+ * @return Criterion
+ */
+ public static LogicalExpression and(Criterion lhs, Criterion rhs) {
+ return new LogicalExpression(lhs, rhs, "and");
+ }
+ /**
+ * Return the disjuction of two expressions
+ *
+ * @param lhs
+ * @param rhs
+ * @return Criterion
+ */
+ public static LogicalExpression or(Criterion lhs, Criterion rhs) {
+ return new LogicalExpression(lhs, rhs, "or");
+ }
+ /**
+ * Return the negation of an expression
+ *
+ * @param expression
+ * @return Criterion
+ */
+ public static Criterion not(Criterion expression) {
+ return new NotExpression(expression);
+ }
+ /**
+ * Apply a constraint expressed in SQL, with the given JDBC
+ * parameters. Any occurrences of <tt>{alias}</tt> will be
+ * replaced by the table alias.
+ *
+ * @param sql
+ * @param values
+ * @param types
+ * @return Criterion
+ */
+ public static Criterion sqlRestriction(String sql, Object[] values, Type[] types) {
+ return new SQLCriterion(sql, values, types);
+ }
+ /**
+ * Apply a constraint expressed in SQL, with the given JDBC
+ * parameter. Any occurrences of <tt>{alias}</tt> will be replaced
+ * by the table alias.
+ *
+ * @param sql
+ * @param value
+ * @param type
+ * @return Criterion
+ */
+ public static Criterion sqlRestriction(String sql, Object value, Type type) {
+ return new SQLCriterion(sql, new Object[] { value }, new Type[] { type } );
+ }
+ /**
+ * Apply a constraint expressed in SQL. Any occurrences of <tt>{alias}</tt>
+ * will be replaced by the table alias.
+ *
+ * @param sql
+ * @return Criterion
+ */
+ public static Criterion sqlRestriction(String sql) {
+ return new SQLCriterion(sql, ArrayHelper.EMPTY_OBJECT_ARRAY, ArrayHelper.EMPTY_TYPE_ARRAY);
+ }
+
+ /**
+ * Group expressions together in a single conjunction (A and B and C...)
+ *
+ * @return Conjunction
+ */
+ public static Conjunction conjunction() {
+ return new Conjunction();
+ }
+
+ /**
+ * Group expressions together in a single disjunction (A or B or C...)
+ *
+ * @return Conjunction
+ */
+ public static Disjunction disjunction() {
+ return new Disjunction();
+ }
+
+ /**
+ * Apply an "equals" constraint to each property in the
+ * key set of a <tt>Map</tt>
+ *
+ * @param propertyNameValues a map from property names to values
+ * @return Criterion
+ */
+ public static Criterion allEq(Map propertyNameValues) {
+ Conjunction conj = conjunction();
+ Iterator iter = propertyNameValues.entrySet().iterator();
+ while ( iter.hasNext() ) {
+ Map.Entry me = (Map.Entry) iter.next();
+ conj.add( eq( (String) me.getKey(), me.getValue() ) );
+ }
+ return conj;
+ }
+
+ /**
+ * Constrain a collection valued property to be empty
+ */
+ public static Criterion isEmpty(String propertyName) {
+ return new EmptyExpression(propertyName);
+ }
+
+ /**
+ * Constrain a collection valued property to be non-empty
+ */
+ public static Criterion isNotEmpty(String propertyName) {
+ return new NotEmptyExpression(propertyName);
+ }
+
+ /**
+ * Constrain a collection valued property by size
+ */
+ public static Criterion sizeEq(String propertyName, int size) {
+ return new SizeExpression(propertyName, size, "=");
+ }
+
+ /**
+ * Constrain a collection valued property by size
+ */
+ public static Criterion sizeNe(String propertyName, int size) {
+ return new SizeExpression(propertyName, size, "<>");
+ }
+
+ /**
+ * Constrain a collection valued property by size
+ */
+ public static Criterion sizeGt(String propertyName, int size) {
+ return new SizeExpression(propertyName, size, "<");
+ }
+
+ /**
+ * Constrain a collection valued property by size
+ */
+ public static Criterion sizeLt(String propertyName, int size) {
+ return new SizeExpression(propertyName, size, ">");
+ }
+
+ /**
+ * Constrain a collection valued property by size
+ */
+ public static Criterion sizeGe(String propertyName, int size) {
+ return new SizeExpression(propertyName, size, "<=");
+ }
+
+ /**
+ * Constrain a collection valued property by size
+ */
+ public static Criterion sizeLe(String propertyName, int size) {
+ return new SizeExpression(propertyName, size, ">=");
+ }
+
+ public static NaturalIdentifier naturalId() {
+ return new NaturalIdentifier();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/RowCountProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,35 +0,0 @@
-//$Id: RowCountProjection.java 9908 2006-05-08 20:59:20Z max.andersen(a)jboss.com $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-/**
- * A row count
- * @author Gavin King
- */
-public class RowCountProjection extends SimpleProjection {
-
- protected RowCountProjection() {}
-
- public String toString() {
- return "count(*)";
- }
-
- public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new Type[] { Hibernate.INTEGER };
- }
-
- public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new StringBuffer()
- .append("count(*) as y")
- .append(position)
- .append('_')
- .toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/RowCountProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/RowCountProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+/**
+ * A row count
+ * @author Gavin King
+ */
+public class RowCountProjection extends SimpleProjection {
+
+ protected RowCountProjection() {}
+
+ public String toString() {
+ return "count(*)";
+ }
+
+ public Type[] getTypes(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new Type[] { Hibernate.INTEGER };
+ }
+
+ public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new StringBuffer()
+ .append("count(*) as y")
+ .append(position)
+ .append('_')
+ .toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SQLCriterion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: SQLCriterion.java 5757 2005-02-18 03:47:27Z oneovthafew $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.type.Type;
-import org.hibernate.util.StringHelper;
-
-/**
- * A SQL fragment. The string {alias} will be replaced by the
- * alias of the root entity.
- */
-public class SQLCriterion implements Criterion {
-
- private final String sql;
- private final TypedValue[] typedValues;
-
- public String toSqlString(
- Criteria criteria,
- CriteriaQuery criteriaQuery)
- throws HibernateException {
- return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return typedValues;
- }
-
- public String toString() {
- return sql;
- }
-
- protected SQLCriterion(String sql, Object[] values, Type[] types) {
- this.sql = sql;
- typedValues = new TypedValue[values.length];
- for ( int i=0; i<typedValues.length; i++ ) {
- typedValues[i] = new TypedValue( types[i], values[i], EntityMode.POJO );
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SQLCriterion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLCriterion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.type.Type;
+import org.hibernate.util.StringHelper;
+
+/**
+ * A SQL fragment. The string {alias} will be replaced by the
+ * alias of the root entity.
+ */
+public class SQLCriterion implements Criterion {
+
+ private final String sql;
+ private final TypedValue[] typedValues;
+
+ public String toSqlString(
+ Criteria criteria,
+ CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return typedValues;
+ }
+
+ public String toString() {
+ return sql;
+ }
+
+ protected SQLCriterion(String sql, Object[] values, Type[] types) {
+ this.sql = sql;
+ typedValues = new TypedValue[values.length];
+ for ( int i=0; i<typedValues.length; i++ ) {
+ typedValues[i] = new TypedValue( types[i], values[i], EntityMode.POJO );
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SQLProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,77 +0,0 @@
-//$Id: SQLProjection.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-import org.hibernate.util.StringHelper;
-
-/**
- * A SQL fragment. The string {alias} will be replaced by the
- * alias of the root entity.
- */
-public class SQLProjection implements Projection {
-
- private final String sql;
- private final String groupBy;
- private final Type[] types;
- private String[] aliases;
- private String[] columnAliases;
- private boolean grouped;
-
- public String toSqlString(
- Criteria criteria,
- int loc,
- CriteriaQuery criteriaQuery)
- throws HibernateException {
- return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return StringHelper.replace( groupBy, "{alias}", criteriaQuery.getSQLAlias(criteria) );
- }
-
- public Type[] getTypes(Criteria crit, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return types;
- }
-
- public String toString() {
- return sql;
- }
-
- protected SQLProjection(String sql, String[] columnAliases, Type[] types) {
- this(sql, null, columnAliases, types);
- }
-
- protected SQLProjection(String sql, String groupBy, String[] columnAliases, Type[] types) {
- this.sql = sql;
- this.types = types;
- this.aliases = columnAliases;
- this.columnAliases = columnAliases;
- this.grouped = groupBy!=null;
- this.groupBy = groupBy;
- }
-
- public String[] getAliases() {
- return aliases;
- }
-
- public String[] getColumnAliases(int loc) {
- return columnAliases;
- }
-
- public boolean isGrouped() {
- return grouped;
- }
-
- public Type[] getTypes(String alias, Criteria crit, CriteriaQuery criteriaQuery) {
- return null; //unsupported
- }
-
- public String[] getColumnAliases(String alias, int loc) {
- return null; //unsupported
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SQLProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SQLProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,100 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+import org.hibernate.util.StringHelper;
+
+/**
+ * A SQL fragment. The string {alias} will be replaced by the
+ * alias of the root entity.
+ */
+public class SQLProjection implements Projection {
+
+ private final String sql;
+ private final String groupBy;
+ private final Type[] types;
+ private String[] aliases;
+ private String[] columnAliases;
+ private boolean grouped;
+
+ public String toSqlString(
+ Criteria criteria,
+ int loc,
+ CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return StringHelper.replace( sql, "{alias}", criteriaQuery.getSQLAlias(criteria) );
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return StringHelper.replace( groupBy, "{alias}", criteriaQuery.getSQLAlias(criteria) );
+ }
+
+ public Type[] getTypes(Criteria crit, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return types;
+ }
+
+ public String toString() {
+ return sql;
+ }
+
+ protected SQLProjection(String sql, String[] columnAliases, Type[] types) {
+ this(sql, null, columnAliases, types);
+ }
+
+ protected SQLProjection(String sql, String groupBy, String[] columnAliases, Type[] types) {
+ this.sql = sql;
+ this.types = types;
+ this.aliases = columnAliases;
+ this.columnAliases = columnAliases;
+ this.grouped = groupBy!=null;
+ this.groupBy = groupBy;
+ }
+
+ public String[] getAliases() {
+ return aliases;
+ }
+
+ public String[] getColumnAliases(int loc) {
+ return columnAliases;
+ }
+
+ public boolean isGrouped() {
+ return grouped;
+ }
+
+ public Type[] getTypes(String alias, Criteria crit, CriteriaQuery criteriaQuery) {
+ return null; //unsupported
+ }
+
+ public String[] getColumnAliases(String alias, int loc) {
+ return null; //unsupported
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SimpleExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,82 +0,0 @@
-//$Id: SimpleExpression.java 7641 2005-07-25 04:57:05Z oneovthafew $
-package org.hibernate.criterion;
-
-
-import java.sql.Types;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.type.Type;
-
-/**
- * superclass for "simple" comparisons (with SQL binary operators)
- * @author Gavin King
- */
-public class SimpleExpression implements Criterion {
-
- private final String propertyName;
- private final Object value;
- private boolean ignoreCase;
- private final String op;
-
- protected SimpleExpression(String propertyName, Object value, String op) {
- this.propertyName = propertyName;
- this.value = value;
- this.op = op;
- }
-
- protected SimpleExpression(String propertyName, Object value, String op, boolean ignoreCase) {
- this.propertyName = propertyName;
- this.value = value;
- this.ignoreCase = ignoreCase;
- this.op = op;
- }
-
- public SimpleExpression ignoreCase() {
- ignoreCase = true;
- return this;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
- Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
- StringBuffer fragment = new StringBuffer();
- if (columns.length>1) fragment.append('(');
- SessionFactoryImplementor factory = criteriaQuery.getFactory();
- int[] sqlTypes = type.sqlTypes( factory );
- for ( int i=0; i<columns.length; i++ ) {
- boolean lower = ignoreCase &&
- ( sqlTypes[i]==Types.VARCHAR || sqlTypes[i]==Types.CHAR );
- if (lower) {
- fragment.append( factory.getDialect().getLowercaseFunction() )
- .append('(');
- }
- fragment.append( columns[i] );
- if (lower) fragment.append(')');
- fragment.append( getOp() ).append("?");
- if ( i<columns.length-1 ) fragment.append(" and ");
- }
- if (columns.length>1) fragment.append(')');
- return fragment.toString();
-
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- Object icvalue = ignoreCase ? value.toString().toLowerCase() : value;
- return new TypedValue[] { criteriaQuery.getTypedValue(criteria, propertyName, icvalue) };
- }
-
- public String toString() {
- return propertyName + getOp() + value;
- }
-
- protected final String getOp() {
- return op;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SimpleExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,105 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+
+import java.sql.Types;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.type.Type;
+
+/**
+ * superclass for "simple" comparisons (with SQL binary operators)
+ * @author Gavin King
+ */
+public class SimpleExpression implements Criterion {
+
+ private final String propertyName;
+ private final Object value;
+ private boolean ignoreCase;
+ private final String op;
+
+ protected SimpleExpression(String propertyName, Object value, String op) {
+ this.propertyName = propertyName;
+ this.value = value;
+ this.op = op;
+ }
+
+ protected SimpleExpression(String propertyName, Object value, String op, boolean ignoreCase) {
+ this.propertyName = propertyName;
+ this.value = value;
+ this.ignoreCase = ignoreCase;
+ this.op = op;
+ }
+
+ public SimpleExpression ignoreCase() {
+ ignoreCase = true;
+ return this;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
+ Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
+ StringBuffer fragment = new StringBuffer();
+ if (columns.length>1) fragment.append('(');
+ SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ int[] sqlTypes = type.sqlTypes( factory );
+ for ( int i=0; i<columns.length; i++ ) {
+ boolean lower = ignoreCase &&
+ ( sqlTypes[i]==Types.VARCHAR || sqlTypes[i]==Types.CHAR );
+ if (lower) {
+ fragment.append( factory.getDialect().getLowercaseFunction() )
+ .append('(');
+ }
+ fragment.append( columns[i] );
+ if (lower) fragment.append(')');
+ fragment.append( getOp() ).append("?");
+ if ( i<columns.length-1 ) fragment.append(" and ");
+ }
+ if (columns.length>1) fragment.append(')');
+ return fragment.toString();
+
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ Object icvalue = ignoreCase ? value.toString().toLowerCase() : value;
+ return new TypedValue[] { criteriaQuery.getTypedValue(criteria, propertyName, icvalue) };
+ }
+
+ public String toString() {
+ return propertyName + getOp() + value;
+ }
+
+ protected final String getOp() {
+ return op;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SimpleProjection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: SimpleProjection.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-
-
-/**
- * A single-column projection that may be aliased
- * @author Gavin King
- */
-public abstract class SimpleProjection implements Projection {
-
- public Projection as(String alias) {
- return Projections.alias(this, alias);
- }
-
- public String[] getColumnAliases(String alias, int loc) {
- return null;
- }
-
- public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return null;
- }
-
- public String[] getColumnAliases(int loc) {
- return new String[] { "y" + loc + "_" };
- }
-
- public String[] getAliases() {
- return new String[1];
- }
-
- public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- throw new UnsupportedOperationException("not a grouping projection");
- }
-
- public boolean isGrouped() {
- return false;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SimpleProjection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleProjection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+
+
+/**
+ * A single-column projection that may be aliased
+ * @author Gavin King
+ */
+public abstract class SimpleProjection implements Projection {
+
+ public Projection as(String alias) {
+ return Projections.alias(this, alias);
+ }
+
+ public String[] getColumnAliases(String alias, int loc) {
+ return null;
+ }
+
+ public Type[] getTypes(String alias, Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return null;
+ }
+
+ public String[] getColumnAliases(int loc) {
+ return new String[] { "y" + loc + "_" };
+ }
+
+ public String[] getAliases() {
+ return new String[1];
+ }
+
+ public String toGroupSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ throw new UnsupportedOperationException("not a grouping projection");
+ }
+
+ public boolean isGrouped() {
+ return false;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,35 +0,0 @@
-//$Id: SimpleSubqueryExpression.java 5757 2005-02-18 03:47:27Z oneovthafew $
-package org.hibernate.criterion;
-
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-
-/**
- * A comparison between a constant value and the the result of a subquery
- * @author Gavin King
- */
-public class SimpleSubqueryExpression extends SubqueryExpression {
-
- private Object value;
-
- protected SimpleSubqueryExpression(Object value, String op, String quantifier, DetachedCriteria dc) {
- super(op, quantifier, dc);
- this.value = value;
- }
-
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- TypedValue[] superTv = super.getTypedValues(criteria, criteriaQuery);
- TypedValue[] result = new TypedValue[superTv.length+1];
- System.arraycopy(superTv, 0, result, 1, superTv.length);
- result[0] = new TypedValue( getTypes()[0], value, EntityMode.POJO );
- return result;
- }
-
- protected String toLeftSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
- return "?";
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SimpleSubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+
+/**
+ * A comparison between a constant value and the the result of a subquery
+ * @author Gavin King
+ */
+public class SimpleSubqueryExpression extends SubqueryExpression {
+
+ private Object value;
+
+ protected SimpleSubqueryExpression(Object value, String op, String quantifier, DetachedCriteria dc) {
+ super(op, quantifier, dc);
+ this.value = value;
+ }
+
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ TypedValue[] superTv = super.getTypedValues(criteria, criteriaQuery);
+ TypedValue[] result = new TypedValue[superTv.length+1];
+ System.arraycopy(superTv, 0, result, 1, superTv.length);
+ result[0] = new TypedValue( getTypes()[0], value, EntityMode.POJO );
+ return result;
+ }
+
+ protected String toLeftSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
+ return "?";
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SizeExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,63 +0,0 @@
-//$Id: SizeExpression.java 7844 2005-08-11 07:26:26Z oneovthafew $
-package org.hibernate.criterion;
-
-
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.persister.collection.QueryableCollection;
-import org.hibernate.persister.entity.Loadable;
-import org.hibernate.sql.ConditionFragment;
-
-/**
- * @author Gavin King
- */
-public class SizeExpression implements Criterion {
-
- private final String propertyName;
- private final int size;
- private final String op;
-
- protected SizeExpression(String propertyName, int size, String op) {
- this.propertyName = propertyName;
- this.size = size;
- this.op = op;
- }
-
- public String toString() {
- return propertyName + ".size" + op + size;
- }
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- String role = criteriaQuery.getEntityName(criteria, propertyName) +
- '.' +
- criteriaQuery.getPropertyName(propertyName);
- QueryableCollection cp = (QueryableCollection) criteriaQuery.getFactory()
- .getCollectionPersister(role);
- //String[] fk = StringHelper.qualify( "collection_", cp.getKeyColumnNames() );
- String[] fk = cp.getKeyColumnNames();
- String[] pk = ( (Loadable) cp.getOwnerEntityPersister() ).getIdentifierColumnNames(); //TODO: handle property-ref
- return "? " +
- op +
- " (select count(*) from " +
- cp.getTableName() +
- //" collection_ where " +
- " where " +
- new ConditionFragment()
- .setTableAlias( criteriaQuery.getSQLAlias(criteria, propertyName) )
- .setCondition(pk, fk)
- .toFragmentString() +
- ")";
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- return new TypedValue[] {
- new TypedValue( Hibernate.INTEGER, new Integer(size), EntityMode.POJO )
- };
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SizeExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SizeExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,85 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.persister.entity.Loadable;
+import org.hibernate.sql.ConditionFragment;
+
+/**
+ * @author Gavin King
+ */
+public class SizeExpression implements Criterion {
+
+ private final String propertyName;
+ private final int size;
+ private final String op;
+
+ protected SizeExpression(String propertyName, int size, String op) {
+ this.propertyName = propertyName;
+ this.size = size;
+ this.op = op;
+ }
+
+ public String toString() {
+ return propertyName + ".size" + op + size;
+ }
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ String role = criteriaQuery.getEntityName(criteria, propertyName) +
+ '.' +
+ criteriaQuery.getPropertyName(propertyName);
+ QueryableCollection cp = (QueryableCollection) criteriaQuery.getFactory()
+ .getCollectionPersister(role);
+ //String[] fk = StringHelper.qualify( "collection_", cp.getKeyColumnNames() );
+ String[] fk = cp.getKeyColumnNames();
+ String[] pk = ( (Loadable) cp.getOwnerEntityPersister() ).getIdentifierColumnNames(); //TODO: handle property-ref
+ return "? " +
+ op +
+ " (select count(*) from " +
+ cp.getTableName() +
+ //" collection_ where " +
+ " where " +
+ new ConditionFragment()
+ .setTableAlias( criteriaQuery.getSQLAlias(criteria, propertyName) )
+ .setCondition(pk, fk)
+ .toFragmentString() +
+ ")";
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ return new TypedValue[] {
+ new TypedValue( Hibernate.INTEGER, new Integer(size), EntityMode.POJO )
+ };
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/Subqueries.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,160 +0,0 @@
-//$Id: Subqueries.java 8467 2005-10-26 21:20:17Z oneovthafew $
-package org.hibernate.criterion;
-
-/**
- * Factory class for criterion instances that represent expressions
- * involving subqueries.
- *
- * @see Restriction
- * @see Projection
- * @see org.hibernate.Criteria
- * @author Gavin King
- */
-public class Subqueries {
-
- public static Criterion exists(DetachedCriteria dc) {
- return new ExistsSubqueryExpression("exists", dc);
- }
-
- public static Criterion notExists(DetachedCriteria dc) {
- return new ExistsSubqueryExpression("not exists", dc);
- }
-
- public static Criterion propertyEqAll(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "=", "all", dc);
- }
-
- public static Criterion propertyIn(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "in", null, dc);
- }
-
- public static Criterion propertyNotIn(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "not in", null, dc);
- }
-
- public static Criterion propertyEq(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "=", null, dc);
- }
-
- public static Criterion propertyNe(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<>", null, dc);
- }
-
- public static Criterion propertyGt(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, ">", null, dc);
- }
-
- public static Criterion propertyLt(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<", null, dc);
- }
-
- public static Criterion propertyGe(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, ">=", null, dc);
- }
-
- public static Criterion propertyLe(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<=", null, dc);
- }
-
- public static Criterion propertyGtAll(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, ">", "all", dc);
- }
-
- public static Criterion propertyLtAll(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<", "all", dc);
- }
-
- public static Criterion propertyGeAll(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, ">=", "all", dc);
- }
-
- public static Criterion propertyLeAll(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<=", "all", dc);
- }
-
- public static Criterion propertyGtSome(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, ">", "some", dc);
- }
-
- public static Criterion propertyLtSome(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<", "some", dc);
- }
-
- public static Criterion propertyGeSome(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, ">=", "some", dc);
- }
-
- public static Criterion propertyLeSome(String propertyName, DetachedCriteria dc) {
- return new PropertySubqueryExpression(propertyName, "<=", "some", dc);
- }
-
- public static Criterion eqAll(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "=", "all", dc);
- }
-
- public static Criterion in(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "in", null, dc);
- }
-
- public static Criterion notIn(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "not in", null, dc);
- }
-
- public static Criterion eq(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "=", null, dc);
- }
-
- public static Criterion gt(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, ">", null, dc);
- }
-
- public static Criterion lt(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<", null, dc);
- }
-
- public static Criterion ge(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, ">=", null, dc);
- }
-
- public static Criterion le(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<=", null, dc);
- }
-
- public static Criterion ne(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<>", null, dc);
- }
-
- public static Criterion gtAll(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, ">", "all", dc);
- }
-
- public static Criterion ltAll(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<", "all", dc);
- }
-
- public static Criterion geAll(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, ">=", "all", dc);
- }
-
- public static Criterion leAll(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<=", "all", dc);
- }
-
- public static Criterion gtSome(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, ">", "some", dc);
- }
-
- public static Criterion ltSome(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<", "some", dc);
- }
-
- public static Criterion geSome(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, ">=", "some", dc);
- }
-
- public static Criterion leSome(Object value, DetachedCriteria dc) {
- return new SimpleSubqueryExpression(value, "<=", "some", dc);
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/Subqueries.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/Subqueries.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,183 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+/**
+ * Factory class for criterion instances that represent expressions
+ * involving subqueries.
+ *
+ * @see Restriction
+ * @see Projection
+ * @see org.hibernate.Criteria
+ * @author Gavin King
+ */
+public class Subqueries {
+
+ public static Criterion exists(DetachedCriteria dc) {
+ return new ExistsSubqueryExpression("exists", dc);
+ }
+
+ public static Criterion notExists(DetachedCriteria dc) {
+ return new ExistsSubqueryExpression("not exists", dc);
+ }
+
+ public static Criterion propertyEqAll(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "=", "all", dc);
+ }
+
+ public static Criterion propertyIn(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "in", null, dc);
+ }
+
+ public static Criterion propertyNotIn(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "not in", null, dc);
+ }
+
+ public static Criterion propertyEq(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "=", null, dc);
+ }
+
+ public static Criterion propertyNe(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<>", null, dc);
+ }
+
+ public static Criterion propertyGt(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, ">", null, dc);
+ }
+
+ public static Criterion propertyLt(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<", null, dc);
+ }
+
+ public static Criterion propertyGe(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, ">=", null, dc);
+ }
+
+ public static Criterion propertyLe(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<=", null, dc);
+ }
+
+ public static Criterion propertyGtAll(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, ">", "all", dc);
+ }
+
+ public static Criterion propertyLtAll(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<", "all", dc);
+ }
+
+ public static Criterion propertyGeAll(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, ">=", "all", dc);
+ }
+
+ public static Criterion propertyLeAll(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<=", "all", dc);
+ }
+
+ public static Criterion propertyGtSome(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, ">", "some", dc);
+ }
+
+ public static Criterion propertyLtSome(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<", "some", dc);
+ }
+
+ public static Criterion propertyGeSome(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, ">=", "some", dc);
+ }
+
+ public static Criterion propertyLeSome(String propertyName, DetachedCriteria dc) {
+ return new PropertySubqueryExpression(propertyName, "<=", "some", dc);
+ }
+
+ public static Criterion eqAll(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "=", "all", dc);
+ }
+
+ public static Criterion in(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "in", null, dc);
+ }
+
+ public static Criterion notIn(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "not in", null, dc);
+ }
+
+ public static Criterion eq(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "=", null, dc);
+ }
+
+ public static Criterion gt(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, ">", null, dc);
+ }
+
+ public static Criterion lt(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<", null, dc);
+ }
+
+ public static Criterion ge(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, ">=", null, dc);
+ }
+
+ public static Criterion le(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<=", null, dc);
+ }
+
+ public static Criterion ne(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<>", null, dc);
+ }
+
+ public static Criterion gtAll(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, ">", "all", dc);
+ }
+
+ public static Criterion ltAll(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<", "all", dc);
+ }
+
+ public static Criterion geAll(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, ">=", "all", dc);
+ }
+
+ public static Criterion leAll(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<=", "all", dc);
+ }
+
+ public static Criterion gtSome(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, ">", "some", dc);
+ }
+
+ public static Criterion ltSome(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<", "some", dc);
+ }
+
+ public static Criterion geSome(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, ">=", "some", dc);
+ }
+
+ public static Criterion leSome(Object value, DetachedCriteria dc) {
+ return new SimpleSubqueryExpression(value, "<=", "some", dc);
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,116 +0,0 @@
-//$Id: SubqueryExpression.java 7365 2005-07-04 02:40:29Z oneovthafew $
-package org.hibernate.criterion;
-
-import java.util.HashMap;
-
-import org.hibernate.Criteria;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.QueryParameters;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.loader.criteria.CriteriaJoinWalker;
-import org.hibernate.loader.criteria.CriteriaQueryTranslator;
-import org.hibernate.persister.entity.OuterJoinLoadable;
-import org.hibernate.type.Type;
-
-/**
- * @author Gavin King
- */
-public abstract class SubqueryExpression implements Criterion {
-
- private CriteriaImpl criteriaImpl;
- private String quantifier;
- private String op;
- private QueryParameters params;
- private Type[] types;
- private CriteriaQueryTranslator innerQuery;
-
- protected Type[] getTypes() {
- return types;
- }
-
- protected SubqueryExpression(String op, String quantifier, DetachedCriteria dc) {
- this.criteriaImpl = dc.getCriteriaImpl();
- this.quantifier = quantifier;
- this.op = op;
- }
-
- protected abstract String toLeftSqlString(Criteria criteria, CriteriaQuery outerQuery);
-
- public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
-
- final SessionFactoryImplementor factory = criteriaQuery.getFactory();
- final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
-
- createAndSetInnerQuery( criteriaQuery, factory );
-
- CriteriaJoinWalker walker = new CriteriaJoinWalker(
- persister,
- innerQuery,
- factory,
- criteriaImpl,
- criteriaImpl.getEntityOrClassName(),
- new HashMap(),
- innerQuery.getRootSQLALias());
-
- String sql = walker.getSQLString();
-
- final StringBuffer buf = new StringBuffer()
- .append( toLeftSqlString(criteria, criteriaQuery) );
- if (op!=null) buf.append(' ').append(op).append(' ');
- if (quantifier!=null) buf.append(quantifier).append(' ');
- return buf.append('(').append(sql).append(')')
- .toString();
- }
-
- public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
- throws HibernateException {
- //the following two lines were added to ensure that this.params is not null, which
- //can happen with two-deep nested subqueries
- SessionFactoryImplementor factory = criteriaQuery.getFactory();
- createAndSetInnerQuery(criteriaQuery, factory);
-
- Type[] ppTypes = params.getPositionalParameterTypes();
- Object[] ppValues = params.getPositionalParameterValues();
- TypedValue[] tv = new TypedValue[ppTypes.length];
- for ( int i=0; i<ppTypes.length; i++ ) {
- tv[i] = new TypedValue( ppTypes[i], ppValues[i], EntityMode.POJO );
- }
- return tv;
- }
-
- /**
- * Creates the inner query used to extract some useful information about
- * types, since it is needed in both methods.
- * @param criteriaQuery
- * @param factory
- */
- private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
- if ( innerQuery == null ) {
- //with two-deep subqueries, the same alias would get generated for
- //both using the old method (criteriaQuery.generateSQLAlias()), so
- //that is now used as a fallback if the main criteria alias isn't set
- String alias;
- if ( this.criteriaImpl.getAlias() == null ) {
- alias = criteriaQuery.generateSQLAlias();
- }
- else {
- alias = this.criteriaImpl.getAlias() + "_";
- }
-
- innerQuery = new CriteriaQueryTranslator(
- factory,
- criteriaImpl,
- criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
- alias,
- criteriaQuery
- );
-
- params = innerQuery.getQueryParameters();
- types = innerQuery.getProjectedTypes();
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/SubqueryExpression.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,139 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.criterion;
+
+import java.util.HashMap;
+
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.QueryParameters;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.impl.CriteriaImpl;
+import org.hibernate.loader.criteria.CriteriaJoinWalker;
+import org.hibernate.loader.criteria.CriteriaQueryTranslator;
+import org.hibernate.persister.entity.OuterJoinLoadable;
+import org.hibernate.type.Type;
+
+/**
+ * @author Gavin King
+ */
+public abstract class SubqueryExpression implements Criterion {
+
+ private CriteriaImpl criteriaImpl;
+ private String quantifier;
+ private String op;
+ private QueryParameters params;
+ private Type[] types;
+ private CriteriaQueryTranslator innerQuery;
+
+ protected Type[] getTypes() {
+ return types;
+ }
+
+ protected SubqueryExpression(String op, String quantifier, DetachedCriteria dc) {
+ this.criteriaImpl = dc.getCriteriaImpl();
+ this.quantifier = quantifier;
+ this.op = op;
+ }
+
+ protected abstract String toLeftSqlString(Criteria criteria, CriteriaQuery outerQuery);
+
+ public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+
+ final SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ final OuterJoinLoadable persister = (OuterJoinLoadable) factory.getEntityPersister( criteriaImpl.getEntityOrClassName() );
+
+ createAndSetInnerQuery( criteriaQuery, factory );
+
+ CriteriaJoinWalker walker = new CriteriaJoinWalker(
+ persister,
+ innerQuery,
+ factory,
+ criteriaImpl,
+ criteriaImpl.getEntityOrClassName(),
+ new HashMap(),
+ innerQuery.getRootSQLALias());
+
+ String sql = walker.getSQLString();
+
+ final StringBuffer buf = new StringBuffer()
+ .append( toLeftSqlString(criteria, criteriaQuery) );
+ if (op!=null) buf.append(' ').append(op).append(' ');
+ if (quantifier!=null) buf.append(quantifier).append(' ');
+ return buf.append('(').append(sql).append(')')
+ .toString();
+ }
+
+ public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
+ throws HibernateException {
+ //the following two lines were added to ensure that this.params is not null, which
+ //can happen with two-deep nested subqueries
+ SessionFactoryImplementor factory = criteriaQuery.getFactory();
+ createAndSetInnerQuery(criteriaQuery, factory);
+
+ Type[] ppTypes = params.getPositionalParameterTypes();
+ Object[] ppValues = params.getPositionalParameterValues();
+ TypedValue[] tv = new TypedValue[ppTypes.length];
+ for ( int i=0; i<ppTypes.length; i++ ) {
+ tv[i] = new TypedValue( ppTypes[i], ppValues[i], EntityMode.POJO );
+ }
+ return tv;
+ }
+
+ /**
+ * Creates the inner query used to extract some useful information about
+ * types, since it is needed in both methods.
+ * @param criteriaQuery
+ * @param factory
+ */
+ private void createAndSetInnerQuery(CriteriaQuery criteriaQuery, final SessionFactoryImplementor factory) {
+ if ( innerQuery == null ) {
+ //with two-deep subqueries, the same alias would get generated for
+ //both using the old method (criteriaQuery.generateSQLAlias()), so
+ //that is now used as a fallback if the main criteria alias isn't set
+ String alias;
+ if ( this.criteriaImpl.getAlias() == null ) {
+ alias = criteriaQuery.generateSQLAlias();
+ }
+ else {
+ alias = this.criteriaImpl.getAlias() + "_";
+ }
+
+ innerQuery = new CriteriaQueryTranslator(
+ factory,
+ criteriaImpl,
+ criteriaImpl.getEntityOrClassName(), //implicit polymorphism not supported (would need a union)
+ alias,
+ criteriaQuery
+ );
+
+ params = innerQuery.getQueryParameters();
+ types = innerQuery.getProjectedTypes();
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/criterion/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,8 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- A framework for defining restriction criteria and order criteria.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/criterion/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/criterion/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,33 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ A framework for defining restriction criteria and order criteria.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,655 +0,0 @@
-//$Id: $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.MappingException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.NvlFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.dialect.function.StandardJDBCEscapeFunction;
-import org.hibernate.dialect.function.ConvertFunction;
-import org.hibernate.dialect.function.ConditionalParenthesisFunction;
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.dialect.lock.UpdateLockingStrategy;
-import org.hibernate.exception.CacheSQLStateConverter;
-import org.hibernate.exception.SQLExceptionConverter;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.id.IdentityGenerator;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.sql.CacheJoinFragment;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.util.StringHelper;
-
-/**
- * Caché 2007.1 dialect. This class is required in order to use Hibernate with Intersystems Cach� SQL.<br>
- * <br>
- * Compatible with Cach� 2007.1.
- * <br>
- * <head>
- * <title>Caché and Hibernate</title>
- * </head>
- * <body>
- * <h1>Caché and Hibernate</h1>
- * <h2>PREREQUISITES</h2>
- * These setup instructions assume that both Caché and Hibernate are installed and operational.
- * <br>
- * <h2>HIBERNATE DIRECTORIES AND FILES</h2>
- * JBoss distributes the InterSystems Cache' dialect for Hibernate 3.2.1
- * For earlier versions of Hibernate please contact
- * <a href="http://www.intersystems.com/support/cache-support.html">InterSystems Worldwide Response Center</A> (WRC)
- * for the appropriate source files.
- * <br>
- * <h2>CACHÉ DOCUMENTATION</h2>
- * Documentation for Caché is available online when Caché is running.
- * It can also be obtained from the
- * <a href="http://www.intersystems.com/cache/downloads/documentation.html">InterSystems</A> website.
- * The book, "Object-oriented Application Development Using the Caché Post-relational Database:
- * is also available from Springer-Verlag.
- * <br>
- * <h2>HIBERNATE DOCUMENTATION</h2>
- * Hibernate comes with extensive electronic documentation.
- * In addition, several books on Hibernate are available from
- * <a href="http://www.manning.com">Manning Publications Co</a>.
- * Three available titles are "Hibernate Quickly", "Hibernate in Action", and "Java Persistence with Hibernate".
- * <br>
- * <h2>TO SET UP HIBERNATE FOR USE WITH CACHÉ</h2>
- * The following steps assume that the directory where Caché was installed is C:\CacheSys.
- * This is the default installation directory for Caché.
- * The default installation directory for Hibernate is assumed to be C:\Hibernate.
- * <p/>
- * If either product is installed in a different location, the pathnames that follow should be modified appropriately.
- * <p/>
- * Caché version 2007.1 and above is recommended for use with
- * Hibernate. The next step depends on the location of your
- * CacheDB.jar depending on your version of Caché.
- * <ol>
- * <li>Copy C:\CacheSys\dev\java\lib\JDK15\CacheDB.jar to C:\Hibernate\lib\CacheDB.jar.</li>
- * <p/>
- * <li>Insert the following files into your Java classpath:
- * <p/>
- * <ul>
- * <li>All jar files in the directory C:\Hibernate\lib</li>
- * <li>The directory (or directories) where hibernate.properties and/or hibernate.cfg.xml are kept.</li>
- * </ul>
- * </li>
- * <p/>
- * <li>In the file, hibernate.properties (or hibernate.cfg.xml),
- * specify the Caché dialect and the Caché version URL settings.</li>
- * </ol>
- * <p/>
- * For example, in Hibernate 3.2, typical entries in hibernate.properties would have the following
- * "name=value" pairs:
- * <p/>
- * <table cols=3 border cellpadding=5 cellspacing=0>
- * <tr>
- * <th>Property Name</th>
- * <th>Property Value</th>
- * </tr>
- * <tr>
- * <td>hibernate.dialect</td>
- * <td>org.hibernate.dialect.Cache71Dialect</td>
- * </tr>
- * <tr>
- * <td>hibernate.connection.driver_class</td>
- * <td>com.intersys.jdbc.CacheDriver</td>
- * </tr>
- * <tr>
- * <td>hibernate.connection.username</td>
- * <td>(see note 1)</td>
- * </tr>
- * <tr>
- * <td>hibernate.connection.password</td>
- * <td>(see note 1)</td>
- * </tr>
- * <tr>
- * <td>hibernate.connection.url</td>
- * <td>jdbc:Cache://127.0.0.1:1972/USER</td>
- * </tr>
- * </table>
- * <p/>
- * <dl>
- * <dt><b>Note 1</b></dt>
- * <dd>Please contact your administrator for the userid and password you should use when attempting access via JDBC.
- * By default, these are chosen to be "_SYSTEM" and "SYS" respectively as noted in the SQL standard.</dd>
- * </dl>
- * <br>
- * <h2>CACHÉ VERSION URL</h2>
- * This is the standard URL for the JDBC driver.
- * For a JDBC driver on the machine hosting Caché, use the IP "loopback" address, 127.0.0.1.
- * For 1972, the default port, specify the super server port of your Caché instance.
- * For USER, substitute the NAMESPACE which contains your Caché database data.
- * <br>
- * <h2>CACHÉ DIALECTS</h2>
- * Choices for Dialect are:
- * <br>
- * <p/>
- * <ol>
- * <li>org.hibernate.dialect.Cache71Dialect (requires Caché
- * 2007.1 or above)</li>
- * <p/>
- * </ol>
- * <br>
- * <h2>SUPPORT FOR IDENTITY COLUMNS</h2>
- * Caché 2007.1 or later supports identity columns. For
- * Hibernate to use identity columns, specify "native" as the
- * generator.
- * <br>
- * <h2>SEQUENCE DIALECTS SUPPORT SEQUENCES</h2>
- * <p/>
- * To use Hibernate sequence support with Caché in a namespace, you must FIRST load the following file into that namespace:
- * <pre>
- * etc\CacheSequences.xml
- * </pre>
- * For example, at the COS terminal prompt in the namespace, run the
- * following command:
- * <p>
- * d LoadFile^%apiOBJ("c:\hibernate\etc\CacheSequences.xml","ck")
- * <p>
- * In your Hibernate mapping you can specify sequence use.
- * <p>
- * For example, the following shows the use of a sequence generator in a Hibernate mapping:
- * <pre>
- * <id name="id" column="uid" type="long" unsaved-value="null">
- * <generator class="sequence"/>
- * </id>
- * </pre>
- * <br>
- * <p/>
- * Some versions of Hibernate under some circumstances call
- * getSelectSequenceNextValString() in the dialect. If this happens
- * you will receive the error message: new MappingException( "Dialect
- * does not support sequences" ).
- * <br>
- * <h2>HIBERNATE FILES ASSOCIATED WITH CACHÉ DIALECT</h2>
- * The following files are associated with Caché dialect:
- * <p/>
- * <ol>
- * <li>src\org\hibernate\dialect\Cache71Dialect.java</li>
- * <li>src\org\hibernate\dialect\function\ConditionalParenthesisFunction.java</li>
- * <li>src\org\hibernate\dialect\function\ConvertFunction.java</li>
- * <li>src\org\hibernate\exception\CacheSQLStateConverter.java</li>
- * <li>src\org\hibernate\sql\CacheJoinFragment.java</li>
- * </ol>
- * Cache71Dialect ships with Hibernate 3.2. All other dialects are distributed by InterSystems and subclass Cache71Dialect.
- *
- * @author Jonathan Levinson
- */
-
-public class Cache71Dialect extends Dialect {
-
- /**
- * Creates new <code>Cach�71Dialect</code> instance. Sets up the JDBC /
- * Cach� type mappings.
- */
- public Cache71Dialect() {
- super();
- commonRegistration();
- register71Functions();
- }
-
- protected final void commonRegistration() {
- // Note: For object <-> SQL datatype mappings see:
- // Configuration Manager | Advanced | SQL | System DDL Datatype Mappings
- //
- // TBD registerColumnType(Types.BINARY, "binary($1)");
- // changed 08-11-2005, jsl
- registerColumnType( Types.BINARY, "varbinary($1)" );
- registerColumnType( Types.BIGINT, "BigInt" );
- registerColumnType( Types.BIT, "bit" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.DECIMAL, "decimal" );
- registerColumnType( Types.DOUBLE, "double" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.LONGVARBINARY, "longvarbinary" ); // binary %Stream
- registerColumnType( Types.LONGVARCHAR, "longvarchar" ); // character %Stream
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- registerColumnType( Types.REAL, "real" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TINYINT, "tinyint" );
- // TBD should this be varbinary($1)?
- // registerColumnType(Types.VARBINARY, "binary($1)");
- registerColumnType( Types.VARBINARY, "longvarbinary" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.BLOB, "longvarbinary" );
- registerColumnType( Types.CLOB, "longvarchar" );
-
- getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
- getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
- //getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
-
- getDefaultProperties().setProperty( Environment.USE_SQL_COMMENTS, "false" );
-
- registerFunction( "abs", new StandardSQLFunction( "abs" ) );
- registerFunction( "acos", new StandardJDBCEscapeFunction( "acos", Hibernate.DOUBLE ) );
- registerFunction( "%alphaup", new StandardSQLFunction( "%alphaup", Hibernate.STRING ) );
- registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.STRING ) );
- registerFunction( "asin", new StandardJDBCEscapeFunction( "asin", Hibernate.DOUBLE ) );
- registerFunction( "atan", new StandardJDBCEscapeFunction( "atan", Hibernate.DOUBLE ) );
- registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "($length(?1)*8)" ) );
- // hibernate impelemnts cast in Dialect.java
- registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.INTEGER ) );
- registerFunction( "char", new StandardJDBCEscapeFunction( "char", Hibernate.CHARACTER ) );
- registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.INTEGER ) );
- registerFunction( "char_length", new StandardSQLFunction( "char_length", Hibernate.INTEGER ) );
- registerFunction( "cos", new StandardJDBCEscapeFunction( "cos", Hibernate.DOUBLE ) );
- registerFunction( "cot", new StandardJDBCEscapeFunction( "cot", Hibernate.DOUBLE ) );
- registerFunction( "coalesce", new VarArgsSQLFunction( "coalesce(", ",", ")" ) );
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "", "||", "" ) );
- registerFunction( "convert", new ConvertFunction() );
- registerFunction( "curdate", new StandardJDBCEscapeFunction( "curdate", Hibernate.DATE ) );
- registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE, false ) );
- registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME, false ) );
- registerFunction(
- "current_timestamp", new ConditionalParenthesisFunction( "current_timestamp", Hibernate.TIMESTAMP )
- );
- registerFunction( "curtime", new StandardJDBCEscapeFunction( "curtime", Hibernate.TIME ) );
- registerFunction( "database", new StandardJDBCEscapeFunction( "database", Hibernate.STRING ) );
- registerFunction( "dateadd", new VarArgsSQLFunction( Hibernate.TIMESTAMP, "dateadd(", ",", ")" ) );
- registerFunction( "datediff", new VarArgsSQLFunction( Hibernate.INTEGER, "datediff(", ",", ")" ) );
- registerFunction( "datename", new VarArgsSQLFunction( Hibernate.STRING, "datename(", ",", ")" ) );
- registerFunction( "datepart", new VarArgsSQLFunction( Hibernate.INTEGER, "datepart(", ",", ")" ) );
- registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
- registerFunction( "dayname", new StandardJDBCEscapeFunction( "dayname", Hibernate.STRING ) );
- registerFunction( "dayofmonth", new StandardJDBCEscapeFunction( "dayofmonth", Hibernate.INTEGER ) );
- registerFunction( "dayofweek", new StandardJDBCEscapeFunction( "dayofweek", Hibernate.INTEGER ) );
- registerFunction( "dayofyear", new StandardJDBCEscapeFunction( "dayofyear", Hibernate.INTEGER ) );
- // is it necessary to register %exact since it can only appear in a where clause?
- registerFunction( "%exact", new StandardSQLFunction( "%exact", Hibernate.STRING ) );
- registerFunction( "exp", new StandardJDBCEscapeFunction( "exp", Hibernate.DOUBLE ) );
- registerFunction( "%external", new StandardSQLFunction( "%external", Hibernate.STRING ) );
- registerFunction( "$extract", new VarArgsSQLFunction( Hibernate.INTEGER, "$extract(", ",", ")" ) );
- registerFunction( "$find", new VarArgsSQLFunction( Hibernate.INTEGER, "$find(", ",", ")" ) );
- registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.INTEGER ) );
- registerFunction( "getdate", new StandardSQLFunction( "getdate", Hibernate.TIMESTAMP ) );
- registerFunction( "hour", new StandardJDBCEscapeFunction( "hour", Hibernate.INTEGER ) );
- registerFunction( "ifnull", new VarArgsSQLFunction( "ifnull(", ",", ")" ) );
- registerFunction( "%internal", new StandardSQLFunction( "%internal" ) );
- registerFunction( "isnull", new VarArgsSQLFunction( "isnull(", ",", ")" ) );
- registerFunction( "isnumeric", new StandardSQLFunction( "isnumeric", Hibernate.INTEGER ) );
- registerFunction( "lcase", new StandardJDBCEscapeFunction( "lcase", Hibernate.STRING ) );
- registerFunction( "left", new StandardJDBCEscapeFunction( "left", Hibernate.STRING ) );
- registerFunction( "len", new StandardSQLFunction( "len", Hibernate.INTEGER ) );
- registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
- registerFunction( "$length", new VarArgsSQLFunction( "$length(", ",", ")" ) );
- // aggregate functions shouldn't be registered, right?
- //registerFunction( "list", new StandardSQLFunction("list",Hibernate.STRING) );
- // stopped on $list
- registerFunction( "$list", new VarArgsSQLFunction( "$list(", ",", ")" ) );
- registerFunction( "$listdata", new VarArgsSQLFunction( "$listdata(", ",", ")" ) );
- registerFunction( "$listfind", new VarArgsSQLFunction( "$listfind(", ",", ")" ) );
- registerFunction( "$listget", new VarArgsSQLFunction( "$listget(", ",", ")" ) );
- registerFunction( "$listlength", new StandardSQLFunction( "$listlength", Hibernate.INTEGER ) );
- registerFunction( "locate", new StandardSQLFunction( "$FIND", Hibernate.INTEGER ) );
- registerFunction( "log", new StandardJDBCEscapeFunction( "log", Hibernate.DOUBLE ) );
- registerFunction( "log10", new StandardJDBCEscapeFunction( "log", Hibernate.DOUBLE ) );
- registerFunction( "lower", new StandardSQLFunction( "lower" ) );
- registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
- registerFunction( "minute", new StandardJDBCEscapeFunction( "minute", Hibernate.INTEGER ) );
- registerFunction( "mod", new StandardJDBCEscapeFunction( "mod", Hibernate.DOUBLE ) );
- registerFunction( "month", new StandardJDBCEscapeFunction( "month", Hibernate.INTEGER ) );
- registerFunction( "monthname", new StandardJDBCEscapeFunction( "monthname", Hibernate.STRING ) );
- registerFunction( "now", new StandardJDBCEscapeFunction( "monthname", Hibernate.TIMESTAMP ) );
- registerFunction( "nullif", new VarArgsSQLFunction( "nullif(", ",", ")" ) );
- registerFunction( "nvl", new NvlFunction() );
- registerFunction( "%odbcin", new StandardSQLFunction( "%odbcin" ) );
- registerFunction( "%odbcout", new StandardSQLFunction( "%odbcin" ) );
- registerFunction( "%pattern", new VarArgsSQLFunction( Hibernate.STRING, "", "%pattern", "" ) );
- registerFunction( "pi", new StandardJDBCEscapeFunction( "pi", Hibernate.DOUBLE ) );
- registerFunction( "$piece", new VarArgsSQLFunction( Hibernate.STRING, "$piece(", ",", ")" ) );
- registerFunction( "position", new VarArgsSQLFunction( Hibernate.INTEGER, "position(", " in ", ")" ) );
- registerFunction( "power", new VarArgsSQLFunction( Hibernate.STRING, "power(", ",", ")" ) );
- registerFunction( "quarter", new StandardJDBCEscapeFunction( "quarter", Hibernate.INTEGER ) );
- registerFunction( "repeat", new VarArgsSQLFunction( Hibernate.STRING, "repeat(", ",", ")" ) );
- registerFunction( "replicate", new VarArgsSQLFunction( Hibernate.STRING, "replicate(", ",", ")" ) );
- registerFunction( "right", new StandardJDBCEscapeFunction( "right", Hibernate.STRING ) );
- registerFunction( "round", new VarArgsSQLFunction( Hibernate.FLOAT, "round(", ",", ")" ) );
- registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
- registerFunction( "second", new StandardJDBCEscapeFunction( "second", Hibernate.INTEGER ) );
- registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
- registerFunction( "sin", new StandardJDBCEscapeFunction( "sin", Hibernate.DOUBLE ) );
- registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
- registerFunction( "%sqlstring", new VarArgsSQLFunction( Hibernate.STRING, "%sqlstring(", ",", ")" ) );
- registerFunction( "%sqlupper", new VarArgsSQLFunction( Hibernate.STRING, "%sqlupper(", ",", ")" ) );
- registerFunction( "sqrt", new StandardJDBCEscapeFunction( "SQRT", Hibernate.DOUBLE ) );
- registerFunction( "%startswith", new VarArgsSQLFunction( Hibernate.STRING, "", "%startswith", "" ) );
- // below is for Cache' that don't have str in 2007.1 there is str and we register str directly
- registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "cast(?1 as char varying)" ) );
- registerFunction( "string", new VarArgsSQLFunction( Hibernate.STRING, "string(", ",", ")" ) );
- // note that %string is deprecated
- registerFunction( "%string", new VarArgsSQLFunction( Hibernate.STRING, "%string(", ",", ")" ) );
- registerFunction( "substr", new VarArgsSQLFunction( Hibernate.STRING, "substr(", ",", ")" ) );
- registerFunction( "substring", new VarArgsSQLFunction( Hibernate.STRING, "substring(", ",", ")" ) );
- registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", Hibernate.TIMESTAMP, false ) );
- registerFunction( "tan", new StandardJDBCEscapeFunction( "tan", Hibernate.DOUBLE ) );
- registerFunction( "timestampadd", new StandardJDBCEscapeFunction( "timestampadd", Hibernate.DOUBLE ) );
- registerFunction( "timestampdiff", new StandardJDBCEscapeFunction( "timestampdiff", Hibernate.DOUBLE ) );
- registerFunction( "tochar", new VarArgsSQLFunction( Hibernate.STRING, "tochar(", ",", ")" ) );
- registerFunction( "to_char", new VarArgsSQLFunction( Hibernate.STRING, "to_char(", ",", ")" ) );
- registerFunction( "todate", new VarArgsSQLFunction( Hibernate.STRING, "todate(", ",", ")" ) );
- registerFunction( "to_date", new VarArgsSQLFunction( Hibernate.STRING, "todate(", ",", ")" ) );
- registerFunction( "tonumber", new StandardSQLFunction( "tonumber" ) );
- registerFunction( "to_number", new StandardSQLFunction( "tonumber" ) );
- // TRIM(end_keyword string-expression-1 FROM string-expression-2)
- // use Hibernate implementation "From" is one of the parameters they pass in position ?3
- //registerFunction( "trim", new SQLFunctionTemplate(Hibernate.STRING, "trim(?1 ?2 from ?3)") );
- registerFunction( "truncate", new StandardJDBCEscapeFunction( "truncate", Hibernate.STRING ) );
- registerFunction( "ucase", new StandardJDBCEscapeFunction( "ucase", Hibernate.STRING ) );
- registerFunction( "upper", new StandardSQLFunction( "upper" ) );
- // %upper is deprecated
- registerFunction( "%upper", new StandardSQLFunction( "%upper" ) );
- registerFunction( "user", new StandardJDBCEscapeFunction( "user", Hibernate.STRING ) );
- registerFunction( "week", new StandardJDBCEscapeFunction( "user", Hibernate.INTEGER ) );
- registerFunction( "xmlconcat", new VarArgsSQLFunction( Hibernate.STRING, "xmlconcat(", ",", ")" ) );
- registerFunction( "xmlelement", new VarArgsSQLFunction( Hibernate.STRING, "xmlelement(", ",", ")" ) );
- // xmlforest requires a new kind of function constructor
- registerFunction( "year", new StandardJDBCEscapeFunction( "year", Hibernate.INTEGER ) );
- }
-
- protected final void register71Functions() {
- this.registerFunction( "str", new VarArgsSQLFunction( Hibernate.STRING, "str(", ",", ")" ) );
- }
-
- // DDL support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean hasAlterTable() {
- // Does this dialect support the ALTER TABLE syntax?
- return true;
- }
-
- public boolean qualifyIndexName() {
- // Do we need to qualify index names with the schema name?
- return false;
- }
-
- public boolean supportsUnique() {
- // Does this dialect support the UNIQUE column syntax?
- return true;
- }
-
- /**
- * The syntax used to add a foreign key constraint to a table.
- *
- * @return String
- */
- public String getAddForeignKeyConstraintString(
- String constraintName,
- String[] foreignKey,
- String referencedTable,
- String[] primaryKey,
- boolean referencesPrimaryKey) {
- // The syntax used to add a foreign key constraint to a table.
- return new StringBuffer( 300 )
- .append( " ADD CONSTRAINT " )
- .append( constraintName )
- .append( " FOREIGN KEY " )
- .append( constraintName )
- .append( " (" )
- .append( StringHelper.join( ", ", foreignKey ) ) // identifier-commalist
- .append( ") REFERENCES " )
- .append( referencedTable )
- .append( " (" )
- .append( StringHelper.join( ", ", primaryKey ) ) // identifier-commalist
- .append( ") " )
- .toString();
- }
-
- public boolean supportsCheck() {
- // Does this dialect support check constraints?
- return false;
- }
-
- public String getAddColumnString() {
- // The syntax used to add a column to a table
- return " add column";
- }
-
- public String getCascadeConstraintsString() {
- // Completely optional cascading drop clause.
- return "";
- }
-
- public boolean dropConstraints() {
- // Do we need to drop constraints before dropping tables in this dialect?
- return true;
- }
-
- public boolean supportsCascadeDelete() {
- return true;
- }
-
- public boolean hasSelfReferentialForeignKeyBug() {
- return true;
- }
-
- // temporary table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- String name = super.generateTemporaryTableName( baseTableName );
- return name.length() > 25 ? name.substring( 1, 25 ) : name;
- }
-
- public String getCreateTemporaryTableString() {
- return "create global temporary table";
- }
-
- public Boolean performTemporaryTableDDLInIsolation() {
- return Boolean.FALSE;
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "";
- }
-
- public boolean dropTemporaryTableAfterUse() {
- return true;
- }
-
- // IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public Class getNativeIdentifierGeneratorClass() {
- return IdentityGenerator.class;
- }
-
- public boolean hasDataTypeInIdentityColumn() {
- // Whether this dialect has an Identity clause added to the data type or a completely seperate identity
- // data type
- return true;
- }
-
- public String getIdentityColumnString() throws MappingException {
- // The keyword used to specify an identity column, if identity column key generation is supported.
- return "identity";
- }
-
- public String getIdentitySelectString() {
- return "SELECT LAST_IDENTITY() FROM %TSQL_sys.snf";
- }
-
- // SEQUENCE support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsSequences() {
- return false;
- }
-
-// It really does support sequences, but InterSystems elects to suggest usage of IDENTITY instead :/
-// Anyway, below are the actual support overrides for users wanting to use this combo...
-//
-// public String getSequenceNextValString(String sequenceName) {
-// return "select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "')";
-// }
-//
-// public String getSelectSequenceNextValString(String sequenceName) {
-// return "(select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "'))";
-// }
-//
-// public String getCreateSequenceString(String sequenceName) {
-// return "insert into InterSystems.Sequences(Name) values (ucase('" + sequenceName + "'))";
-// }
-//
-// public String getDropSequenceString(String sequenceName) {
-// return "delete from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "')";
-// }
-//
-// public String getQuerySequencesString() {
-// return "select name from InterSystems.Sequences";
-// }
-
- // lock acquisition support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsForUpdate() {
- // Does this dialect support the FOR UPDATE syntax?
- return false;
- }
-
- public boolean supportsForUpdateOf() {
- // Does this dialect support FOR UPDATE OF, allowing particular rows to be locked?
- return false;
- }
-
- public boolean supportsForUpdateNowait() {
- // Does this dialect support the Oracle-style FOR UPDATE NOWAIT syntax?
- return false;
- }
-
- public boolean supportsOuterJoinForUpdate() {
- return false;
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax...
- // Set your transaction mode to READ_COMMITTED before using
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- return new UpdateLockingStrategy( lockable, lockMode );
- }
- else {
- return new SelectLockingStrategy( lockable, lockMode );
- }
- }
-
- // LIMIT support (ala TOP) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public boolean supportsVariableLimit() {
- return true;
- }
-
- public boolean bindLimitParametersFirst() {
- // Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?
- return true;
- }
-
- public boolean useMaxForLimit() {
- // Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?
- return true;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- if ( hasOffset ) {
- throw new UnsupportedOperationException( "An offset may not be specified to <TOP n> in Cache SQL" );
- }
-
- // This does not support the Cache SQL 'DISTINCT BY (comma-list)' extensions,
- // but this extension is not supported through Hibernate anyway.
- int insertionPoint = sql.startsWith( "select distinct" ) ? 15 : 6;
-
- return new StringBuffer( sql.length() + 8 )
- .append( sql )
- .insert( insertionPoint, " TOP ? " )
- .toString();
- }
-
- // callable statement support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
- return col;
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- ps.execute();
- return ( ResultSet ) ps.getObject( 1 );
- }
-
- // miscellaneous support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public String getLowercaseFunction() {
- // The name of the SQL function that transforms a string to lowercase
- return "lower";
- }
-
- public String getNullColumnString() {
- // The keyword used to specify a nullable column.
- return " null";
- }
-
- public JoinFragment createOuterJoinFragment() {
- // Create an OuterJoinGenerator for this dialect.
- return new CacheJoinFragment();
- }
-
- public String getNoColumnsInsertString() {
- // The keyword used to insert a row without specifying
- // any column values
- return " default values";
- }
-
- public SQLExceptionConverter buildSQLExceptionConverter() {
- return new CacheSQLStateConverter( EXTRACTER );
- }
-
- public static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
- }
- };
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean areStringComparisonsCaseInsensitive() {
- return true;
- }
-
- public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Cache71Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,678 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.NvlFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.function.StandardJDBCEscapeFunction;
+import org.hibernate.dialect.function.ConvertFunction;
+import org.hibernate.dialect.function.ConditionalParenthesisFunction;
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.dialect.lock.UpdateLockingStrategy;
+import org.hibernate.exception.CacheSQLStateConverter;
+import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.id.IdentityGenerator;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.sql.CacheJoinFragment;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Caché 2007.1 dialect. This class is required in order to use Hibernate with Intersystems Cach� SQL.<br>
+ * <br>
+ * Compatible with Cach� 2007.1.
+ * <br>
+ * <head>
+ * <title>Caché and Hibernate</title>
+ * </head>
+ * <body>
+ * <h1>Caché and Hibernate</h1>
+ * <h2>PREREQUISITES</h2>
+ * These setup instructions assume that both Caché and Hibernate are installed and operational.
+ * <br>
+ * <h2>HIBERNATE DIRECTORIES AND FILES</h2>
+ * JBoss distributes the InterSystems Cache' dialect for Hibernate 3.2.1
+ * For earlier versions of Hibernate please contact
+ * <a href="http://www.intersystems.com/support/cache-support.html">InterSystems Worldwide Response Center</A> (WRC)
+ * for the appropriate source files.
+ * <br>
+ * <h2>CACHÉ DOCUMENTATION</h2>
+ * Documentation for Caché is available online when Caché is running.
+ * It can also be obtained from the
+ * <a href="http://www.intersystems.com/cache/downloads/documentation.html">InterSystems</A> website.
+ * The book, "Object-oriented Application Development Using the Caché Post-relational Database:
+ * is also available from Springer-Verlag.
+ * <br>
+ * <h2>HIBERNATE DOCUMENTATION</h2>
+ * Hibernate comes with extensive electronic documentation.
+ * In addition, several books on Hibernate are available from
+ * <a href="http://www.manning.com">Manning Publications Co</a>.
+ * Three available titles are "Hibernate Quickly", "Hibernate in Action", and "Java Persistence with Hibernate".
+ * <br>
+ * <h2>TO SET UP HIBERNATE FOR USE WITH CACHÉ</h2>
+ * The following steps assume that the directory where Caché was installed is C:\CacheSys.
+ * This is the default installation directory for Caché.
+ * The default installation directory for Hibernate is assumed to be C:\Hibernate.
+ * <p/>
+ * If either product is installed in a different location, the pathnames that follow should be modified appropriately.
+ * <p/>
+ * Caché version 2007.1 and above is recommended for use with
+ * Hibernate. The next step depends on the location of your
+ * CacheDB.jar depending on your version of Caché.
+ * <ol>
+ * <li>Copy C:\CacheSys\dev\java\lib\JDK15\CacheDB.jar to C:\Hibernate\lib\CacheDB.jar.</li>
+ * <p/>
+ * <li>Insert the following files into your Java classpath:
+ * <p/>
+ * <ul>
+ * <li>All jar files in the directory C:\Hibernate\lib</li>
+ * <li>The directory (or directories) where hibernate.properties and/or hibernate.cfg.xml are kept.</li>
+ * </ul>
+ * </li>
+ * <p/>
+ * <li>In the file, hibernate.properties (or hibernate.cfg.xml),
+ * specify the Caché dialect and the Caché version URL settings.</li>
+ * </ol>
+ * <p/>
+ * For example, in Hibernate 3.2, typical entries in hibernate.properties would have the following
+ * "name=value" pairs:
+ * <p/>
+ * <table cols=3 border cellpadding=5 cellspacing=0>
+ * <tr>
+ * <th>Property Name</th>
+ * <th>Property Value</th>
+ * </tr>
+ * <tr>
+ * <td>hibernate.dialect</td>
+ * <td>org.hibernate.dialect.Cache71Dialect</td>
+ * </tr>
+ * <tr>
+ * <td>hibernate.connection.driver_class</td>
+ * <td>com.intersys.jdbc.CacheDriver</td>
+ * </tr>
+ * <tr>
+ * <td>hibernate.connection.username</td>
+ * <td>(see note 1)</td>
+ * </tr>
+ * <tr>
+ * <td>hibernate.connection.password</td>
+ * <td>(see note 1)</td>
+ * </tr>
+ * <tr>
+ * <td>hibernate.connection.url</td>
+ * <td>jdbc:Cache://127.0.0.1:1972/USER</td>
+ * </tr>
+ * </table>
+ * <p/>
+ * <dl>
+ * <dt><b>Note 1</b></dt>
+ * <dd>Please contact your administrator for the userid and password you should use when attempting access via JDBC.
+ * By default, these are chosen to be "_SYSTEM" and "SYS" respectively as noted in the SQL standard.</dd>
+ * </dl>
+ * <br>
+ * <h2>CACHÉ VERSION URL</h2>
+ * This is the standard URL for the JDBC driver.
+ * For a JDBC driver on the machine hosting Caché, use the IP "loopback" address, 127.0.0.1.
+ * For 1972, the default port, specify the super server port of your Caché instance.
+ * For USER, substitute the NAMESPACE which contains your Caché database data.
+ * <br>
+ * <h2>CACHÉ DIALECTS</h2>
+ * Choices for Dialect are:
+ * <br>
+ * <p/>
+ * <ol>
+ * <li>org.hibernate.dialect.Cache71Dialect (requires Caché
+ * 2007.1 or above)</li>
+ * <p/>
+ * </ol>
+ * <br>
+ * <h2>SUPPORT FOR IDENTITY COLUMNS</h2>
+ * Caché 2007.1 or later supports identity columns. For
+ * Hibernate to use identity columns, specify "native" as the
+ * generator.
+ * <br>
+ * <h2>SEQUENCE DIALECTS SUPPORT SEQUENCES</h2>
+ * <p/>
+ * To use Hibernate sequence support with Caché in a namespace, you must FIRST load the following file into that namespace:
+ * <pre>
+ * etc\CacheSequences.xml
+ * </pre>
+ * For example, at the COS terminal prompt in the namespace, run the
+ * following command:
+ * <p>
+ * d LoadFile^%apiOBJ("c:\hibernate\etc\CacheSequences.xml","ck")
+ * <p>
+ * In your Hibernate mapping you can specify sequence use.
+ * <p>
+ * For example, the following shows the use of a sequence generator in a Hibernate mapping:
+ * <pre>
+ * <id name="id" column="uid" type="long" unsaved-value="null">
+ * <generator class="sequence"/>
+ * </id>
+ * </pre>
+ * <br>
+ * <p/>
+ * Some versions of Hibernate under some circumstances call
+ * getSelectSequenceNextValString() in the dialect. If this happens
+ * you will receive the error message: new MappingException( "Dialect
+ * does not support sequences" ).
+ * <br>
+ * <h2>HIBERNATE FILES ASSOCIATED WITH CACHÉ DIALECT</h2>
+ * The following files are associated with Caché dialect:
+ * <p/>
+ * <ol>
+ * <li>src\org\hibernate\dialect\Cache71Dialect.java</li>
+ * <li>src\org\hibernate\dialect\function\ConditionalParenthesisFunction.java</li>
+ * <li>src\org\hibernate\dialect\function\ConvertFunction.java</li>
+ * <li>src\org\hibernate\exception\CacheSQLStateConverter.java</li>
+ * <li>src\org\hibernate\sql\CacheJoinFragment.java</li>
+ * </ol>
+ * Cache71Dialect ships with Hibernate 3.2. All other dialects are distributed by InterSystems and subclass Cache71Dialect.
+ *
+ * @author Jonathan Levinson
+ */
+
+public class Cache71Dialect extends Dialect {
+
+ /**
+ * Creates new <code>Cach�71Dialect</code> instance. Sets up the JDBC /
+ * Cach� type mappings.
+ */
+ public Cache71Dialect() {
+ super();
+ commonRegistration();
+ register71Functions();
+ }
+
+ protected final void commonRegistration() {
+ // Note: For object <-> SQL datatype mappings see:
+ // Configuration Manager | Advanced | SQL | System DDL Datatype Mappings
+ //
+ // TBD registerColumnType(Types.BINARY, "binary($1)");
+ // changed 08-11-2005, jsl
+ registerColumnType( Types.BINARY, "varbinary($1)" );
+ registerColumnType( Types.BIGINT, "BigInt" );
+ registerColumnType( Types.BIT, "bit" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.DECIMAL, "decimal" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.LONGVARBINARY, "longvarbinary" ); // binary %Stream
+ registerColumnType( Types.LONGVARCHAR, "longvarchar" ); // character %Stream
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ registerColumnType( Types.REAL, "real" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ // TBD should this be varbinary($1)?
+ // registerColumnType(Types.VARBINARY, "binary($1)");
+ registerColumnType( Types.VARBINARY, "longvarbinary" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.BLOB, "longvarbinary" );
+ registerColumnType( Types.CLOB, "longvarchar" );
+
+ getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
+ //getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
+
+ getDefaultProperties().setProperty( Environment.USE_SQL_COMMENTS, "false" );
+
+ registerFunction( "abs", new StandardSQLFunction( "abs" ) );
+ registerFunction( "acos", new StandardJDBCEscapeFunction( "acos", Hibernate.DOUBLE ) );
+ registerFunction( "%alphaup", new StandardSQLFunction( "%alphaup", Hibernate.STRING ) );
+ registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.STRING ) );
+ registerFunction( "asin", new StandardJDBCEscapeFunction( "asin", Hibernate.DOUBLE ) );
+ registerFunction( "atan", new StandardJDBCEscapeFunction( "atan", Hibernate.DOUBLE ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "($length(?1)*8)" ) );
+ // hibernate impelemnts cast in Dialect.java
+ registerFunction( "ceiling", new StandardSQLFunction( "ceiling", Hibernate.INTEGER ) );
+ registerFunction( "char", new StandardJDBCEscapeFunction( "char", Hibernate.CHARACTER ) );
+ registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.INTEGER ) );
+ registerFunction( "char_length", new StandardSQLFunction( "char_length", Hibernate.INTEGER ) );
+ registerFunction( "cos", new StandardJDBCEscapeFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "cot", new StandardJDBCEscapeFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "coalesce", new VarArgsSQLFunction( "coalesce(", ",", ")" ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "", "||", "" ) );
+ registerFunction( "convert", new ConvertFunction() );
+ registerFunction( "curdate", new StandardJDBCEscapeFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE, false ) );
+ registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME, false ) );
+ registerFunction(
+ "current_timestamp", new ConditionalParenthesisFunction( "current_timestamp", Hibernate.TIMESTAMP )
+ );
+ registerFunction( "curtime", new StandardJDBCEscapeFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "database", new StandardJDBCEscapeFunction( "database", Hibernate.STRING ) );
+ registerFunction( "dateadd", new VarArgsSQLFunction( Hibernate.TIMESTAMP, "dateadd(", ",", ")" ) );
+ registerFunction( "datediff", new VarArgsSQLFunction( Hibernate.INTEGER, "datediff(", ",", ")" ) );
+ registerFunction( "datename", new VarArgsSQLFunction( Hibernate.STRING, "datename(", ",", ")" ) );
+ registerFunction( "datepart", new VarArgsSQLFunction( Hibernate.INTEGER, "datepart(", ",", ")" ) );
+ registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
+ registerFunction( "dayname", new StandardJDBCEscapeFunction( "dayname", Hibernate.STRING ) );
+ registerFunction( "dayofmonth", new StandardJDBCEscapeFunction( "dayofmonth", Hibernate.INTEGER ) );
+ registerFunction( "dayofweek", new StandardJDBCEscapeFunction( "dayofweek", Hibernate.INTEGER ) );
+ registerFunction( "dayofyear", new StandardJDBCEscapeFunction( "dayofyear", Hibernate.INTEGER ) );
+ // is it necessary to register %exact since it can only appear in a where clause?
+ registerFunction( "%exact", new StandardSQLFunction( "%exact", Hibernate.STRING ) );
+ registerFunction( "exp", new StandardJDBCEscapeFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "%external", new StandardSQLFunction( "%external", Hibernate.STRING ) );
+ registerFunction( "$extract", new VarArgsSQLFunction( Hibernate.INTEGER, "$extract(", ",", ")" ) );
+ registerFunction( "$find", new VarArgsSQLFunction( Hibernate.INTEGER, "$find(", ",", ")" ) );
+ registerFunction( "floor", new StandardSQLFunction( "floor", Hibernate.INTEGER ) );
+ registerFunction( "getdate", new StandardSQLFunction( "getdate", Hibernate.TIMESTAMP ) );
+ registerFunction( "hour", new StandardJDBCEscapeFunction( "hour", Hibernate.INTEGER ) );
+ registerFunction( "ifnull", new VarArgsSQLFunction( "ifnull(", ",", ")" ) );
+ registerFunction( "%internal", new StandardSQLFunction( "%internal" ) );
+ registerFunction( "isnull", new VarArgsSQLFunction( "isnull(", ",", ")" ) );
+ registerFunction( "isnumeric", new StandardSQLFunction( "isnumeric", Hibernate.INTEGER ) );
+ registerFunction( "lcase", new StandardJDBCEscapeFunction( "lcase", Hibernate.STRING ) );
+ registerFunction( "left", new StandardJDBCEscapeFunction( "left", Hibernate.STRING ) );
+ registerFunction( "len", new StandardSQLFunction( "len", Hibernate.INTEGER ) );
+ registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
+ registerFunction( "$length", new VarArgsSQLFunction( "$length(", ",", ")" ) );
+ // aggregate functions shouldn't be registered, right?
+ //registerFunction( "list", new StandardSQLFunction("list",Hibernate.STRING) );
+ // stopped on $list
+ registerFunction( "$list", new VarArgsSQLFunction( "$list(", ",", ")" ) );
+ registerFunction( "$listdata", new VarArgsSQLFunction( "$listdata(", ",", ")" ) );
+ registerFunction( "$listfind", new VarArgsSQLFunction( "$listfind(", ",", ")" ) );
+ registerFunction( "$listget", new VarArgsSQLFunction( "$listget(", ",", ")" ) );
+ registerFunction( "$listlength", new StandardSQLFunction( "$listlength", Hibernate.INTEGER ) );
+ registerFunction( "locate", new StandardSQLFunction( "$FIND", Hibernate.INTEGER ) );
+ registerFunction( "log", new StandardJDBCEscapeFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "log10", new StandardJDBCEscapeFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "lower", new StandardSQLFunction( "lower" ) );
+ registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
+ registerFunction( "minute", new StandardJDBCEscapeFunction( "minute", Hibernate.INTEGER ) );
+ registerFunction( "mod", new StandardJDBCEscapeFunction( "mod", Hibernate.DOUBLE ) );
+ registerFunction( "month", new StandardJDBCEscapeFunction( "month", Hibernate.INTEGER ) );
+ registerFunction( "monthname", new StandardJDBCEscapeFunction( "monthname", Hibernate.STRING ) );
+ registerFunction( "now", new StandardJDBCEscapeFunction( "monthname", Hibernate.TIMESTAMP ) );
+ registerFunction( "nullif", new VarArgsSQLFunction( "nullif(", ",", ")" ) );
+ registerFunction( "nvl", new NvlFunction() );
+ registerFunction( "%odbcin", new StandardSQLFunction( "%odbcin" ) );
+ registerFunction( "%odbcout", new StandardSQLFunction( "%odbcin" ) );
+ registerFunction( "%pattern", new VarArgsSQLFunction( Hibernate.STRING, "", "%pattern", "" ) );
+ registerFunction( "pi", new StandardJDBCEscapeFunction( "pi", Hibernate.DOUBLE ) );
+ registerFunction( "$piece", new VarArgsSQLFunction( Hibernate.STRING, "$piece(", ",", ")" ) );
+ registerFunction( "position", new VarArgsSQLFunction( Hibernate.INTEGER, "position(", " in ", ")" ) );
+ registerFunction( "power", new VarArgsSQLFunction( Hibernate.STRING, "power(", ",", ")" ) );
+ registerFunction( "quarter", new StandardJDBCEscapeFunction( "quarter", Hibernate.INTEGER ) );
+ registerFunction( "repeat", new VarArgsSQLFunction( Hibernate.STRING, "repeat(", ",", ")" ) );
+ registerFunction( "replicate", new VarArgsSQLFunction( Hibernate.STRING, "replicate(", ",", ")" ) );
+ registerFunction( "right", new StandardJDBCEscapeFunction( "right", Hibernate.STRING ) );
+ registerFunction( "round", new VarArgsSQLFunction( Hibernate.FLOAT, "round(", ",", ")" ) );
+ registerFunction( "rtrim", new StandardSQLFunction( "rtrim", Hibernate.STRING ) );
+ registerFunction( "second", new StandardJDBCEscapeFunction( "second", Hibernate.INTEGER ) );
+ registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
+ registerFunction( "sin", new StandardJDBCEscapeFunction( "sin", Hibernate.DOUBLE ) );
+ registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
+ registerFunction( "%sqlstring", new VarArgsSQLFunction( Hibernate.STRING, "%sqlstring(", ",", ")" ) );
+ registerFunction( "%sqlupper", new VarArgsSQLFunction( Hibernate.STRING, "%sqlupper(", ",", ")" ) );
+ registerFunction( "sqrt", new StandardJDBCEscapeFunction( "SQRT", Hibernate.DOUBLE ) );
+ registerFunction( "%startswith", new VarArgsSQLFunction( Hibernate.STRING, "", "%startswith", "" ) );
+ // below is for Cache' that don't have str in 2007.1 there is str and we register str directly
+ registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "cast(?1 as char varying)" ) );
+ registerFunction( "string", new VarArgsSQLFunction( Hibernate.STRING, "string(", ",", ")" ) );
+ // note that %string is deprecated
+ registerFunction( "%string", new VarArgsSQLFunction( Hibernate.STRING, "%string(", ",", ")" ) );
+ registerFunction( "substr", new VarArgsSQLFunction( Hibernate.STRING, "substr(", ",", ")" ) );
+ registerFunction( "substring", new VarArgsSQLFunction( Hibernate.STRING, "substring(", ",", ")" ) );
+ registerFunction( "sysdate", new NoArgSQLFunction( "sysdate", Hibernate.TIMESTAMP, false ) );
+ registerFunction( "tan", new StandardJDBCEscapeFunction( "tan", Hibernate.DOUBLE ) );
+ registerFunction( "timestampadd", new StandardJDBCEscapeFunction( "timestampadd", Hibernate.DOUBLE ) );
+ registerFunction( "timestampdiff", new StandardJDBCEscapeFunction( "timestampdiff", Hibernate.DOUBLE ) );
+ registerFunction( "tochar", new VarArgsSQLFunction( Hibernate.STRING, "tochar(", ",", ")" ) );
+ registerFunction( "to_char", new VarArgsSQLFunction( Hibernate.STRING, "to_char(", ",", ")" ) );
+ registerFunction( "todate", new VarArgsSQLFunction( Hibernate.STRING, "todate(", ",", ")" ) );
+ registerFunction( "to_date", new VarArgsSQLFunction( Hibernate.STRING, "todate(", ",", ")" ) );
+ registerFunction( "tonumber", new StandardSQLFunction( "tonumber" ) );
+ registerFunction( "to_number", new StandardSQLFunction( "tonumber" ) );
+ // TRIM(end_keyword string-expression-1 FROM string-expression-2)
+ // use Hibernate implementation "From" is one of the parameters they pass in position ?3
+ //registerFunction( "trim", new SQLFunctionTemplate(Hibernate.STRING, "trim(?1 ?2 from ?3)") );
+ registerFunction( "truncate", new StandardJDBCEscapeFunction( "truncate", Hibernate.STRING ) );
+ registerFunction( "ucase", new StandardJDBCEscapeFunction( "ucase", Hibernate.STRING ) );
+ registerFunction( "upper", new StandardSQLFunction( "upper" ) );
+ // %upper is deprecated
+ registerFunction( "%upper", new StandardSQLFunction( "%upper" ) );
+ registerFunction( "user", new StandardJDBCEscapeFunction( "user", Hibernate.STRING ) );
+ registerFunction( "week", new StandardJDBCEscapeFunction( "user", Hibernate.INTEGER ) );
+ registerFunction( "xmlconcat", new VarArgsSQLFunction( Hibernate.STRING, "xmlconcat(", ",", ")" ) );
+ registerFunction( "xmlelement", new VarArgsSQLFunction( Hibernate.STRING, "xmlelement(", ",", ")" ) );
+ // xmlforest requires a new kind of function constructor
+ registerFunction( "year", new StandardJDBCEscapeFunction( "year", Hibernate.INTEGER ) );
+ }
+
+ protected final void register71Functions() {
+ this.registerFunction( "str", new VarArgsSQLFunction( Hibernate.STRING, "str(", ",", ")" ) );
+ }
+
+ // DDL support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean hasAlterTable() {
+ // Does this dialect support the ALTER TABLE syntax?
+ return true;
+ }
+
+ public boolean qualifyIndexName() {
+ // Do we need to qualify index names with the schema name?
+ return false;
+ }
+
+ public boolean supportsUnique() {
+ // Does this dialect support the UNIQUE column syntax?
+ return true;
+ }
+
+ /**
+ * The syntax used to add a foreign key constraint to a table.
+ *
+ * @return String
+ */
+ public String getAddForeignKeyConstraintString(
+ String constraintName,
+ String[] foreignKey,
+ String referencedTable,
+ String[] primaryKey,
+ boolean referencesPrimaryKey) {
+ // The syntax used to add a foreign key constraint to a table.
+ return new StringBuffer( 300 )
+ .append( " ADD CONSTRAINT " )
+ .append( constraintName )
+ .append( " FOREIGN KEY " )
+ .append( constraintName )
+ .append( " (" )
+ .append( StringHelper.join( ", ", foreignKey ) ) // identifier-commalist
+ .append( ") REFERENCES " )
+ .append( referencedTable )
+ .append( " (" )
+ .append( StringHelper.join( ", ", primaryKey ) ) // identifier-commalist
+ .append( ") " )
+ .toString();
+ }
+
+ public boolean supportsCheck() {
+ // Does this dialect support check constraints?
+ return false;
+ }
+
+ public String getAddColumnString() {
+ // The syntax used to add a column to a table
+ return " add column";
+ }
+
+ public String getCascadeConstraintsString() {
+ // Completely optional cascading drop clause.
+ return "";
+ }
+
+ public boolean dropConstraints() {
+ // Do we need to drop constraints before dropping tables in this dialect?
+ return true;
+ }
+
+ public boolean supportsCascadeDelete() {
+ return true;
+ }
+
+ public boolean hasSelfReferentialForeignKeyBug() {
+ return true;
+ }
+
+ // temporary table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ String name = super.generateTemporaryTableName( baseTableName );
+ return name.length() > 25 ? name.substring( 1, 25 ) : name;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create global temporary table";
+ }
+
+ public Boolean performTemporaryTableDDLInIsolation() {
+ return Boolean.FALSE;
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "";
+ }
+
+ public boolean dropTemporaryTableAfterUse() {
+ return true;
+ }
+
+ // IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public Class getNativeIdentifierGeneratorClass() {
+ return IdentityGenerator.class;
+ }
+
+ public boolean hasDataTypeInIdentityColumn() {
+ // Whether this dialect has an Identity clause added to the data type or a completely seperate identity
+ // data type
+ return true;
+ }
+
+ public String getIdentityColumnString() throws MappingException {
+ // The keyword used to specify an identity column, if identity column key generation is supported.
+ return "identity";
+ }
+
+ public String getIdentitySelectString() {
+ return "SELECT LAST_IDENTITY() FROM %TSQL_sys.snf";
+ }
+
+ // SEQUENCE support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsSequences() {
+ return false;
+ }
+
+// It really does support sequences, but InterSystems elects to suggest usage of IDENTITY instead :/
+// Anyway, below are the actual support overrides for users wanting to use this combo...
+//
+// public String getSequenceNextValString(String sequenceName) {
+// return "select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "')";
+// }
+//
+// public String getSelectSequenceNextValString(String sequenceName) {
+// return "(select InterSystems.Sequences_GetNext('" + sequenceName + "') from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "'))";
+// }
+//
+// public String getCreateSequenceString(String sequenceName) {
+// return "insert into InterSystems.Sequences(Name) values (ucase('" + sequenceName + "'))";
+// }
+//
+// public String getDropSequenceString(String sequenceName) {
+// return "delete from InterSystems.Sequences where ucase(name)=ucase('" + sequenceName + "')";
+// }
+//
+// public String getQuerySequencesString() {
+// return "select name from InterSystems.Sequences";
+// }
+
+ // lock acquisition support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsForUpdate() {
+ // Does this dialect support the FOR UPDATE syntax?
+ return false;
+ }
+
+ public boolean supportsForUpdateOf() {
+ // Does this dialect support FOR UPDATE OF, allowing particular rows to be locked?
+ return false;
+ }
+
+ public boolean supportsForUpdateNowait() {
+ // Does this dialect support the Oracle-style FOR UPDATE NOWAIT syntax?
+ return false;
+ }
+
+ public boolean supportsOuterJoinForUpdate() {
+ return false;
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // InterSystems Cache' does not current support "SELECT ... FOR UPDATE" syntax...
+ // Set your transaction mode to READ_COMMITTED before using
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ return new UpdateLockingStrategy( lockable, lockMode );
+ }
+ else {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+ }
+
+ // LIMIT support (ala TOP) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public boolean supportsVariableLimit() {
+ return true;
+ }
+
+ public boolean bindLimitParametersFirst() {
+ // Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?
+ return true;
+ }
+
+ public boolean useMaxForLimit() {
+ // Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?
+ return true;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ if ( hasOffset ) {
+ throw new UnsupportedOperationException( "An offset may not be specified to <TOP n> in Cache SQL" );
+ }
+
+ // This does not support the Cache SQL 'DISTINCT BY (comma-list)' extensions,
+ // but this extension is not supported through Hibernate anyway.
+ int insertionPoint = sql.startsWith( "select distinct" ) ? 15 : 6;
+
+ return new StringBuffer( sql.length() + 8 )
+ .append( sql )
+ .insert( insertionPoint, " TOP ? " )
+ .toString();
+ }
+
+ // callable statement support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
+ return col;
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ ps.execute();
+ return ( ResultSet ) ps.getObject( 1 );
+ }
+
+ // miscellaneous support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public String getLowercaseFunction() {
+ // The name of the SQL function that transforms a string to lowercase
+ return "lower";
+ }
+
+ public String getNullColumnString() {
+ // The keyword used to specify a nullable column.
+ return " null";
+ }
+
+ public JoinFragment createOuterJoinFragment() {
+ // Create an OuterJoinGenerator for this dialect.
+ return new CacheJoinFragment();
+ }
+
+ public String getNoColumnsInsertString() {
+ // The keyword used to insert a row without specifying
+ // any column values
+ return " default values";
+ }
+
+ public SQLExceptionConverter buildSQLExceptionConverter() {
+ return new CacheSQLStateConverter( EXTRACTER );
+ }
+
+ public static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
+ }
+ };
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean areStringComparisonsCaseInsensitive() {
+ return true;
+ }
+
+ public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: DB2390Dialect.java 5712 2005-02-13 13:48:39Z oneovthafew $
-package org.hibernate.dialect;
-
-/**
- * An SQL dialect for DB2/390. This class provides support for
- * DB2 Universal Database for OS/390, also known as DB2/390.
- *
- * @author Kristoffer Dyrkorn
- */
-public class DB2390Dialect extends DB2Dialect {
-
- public boolean supportsSequences() {
- return false;
- }
-
- public String getIdentitySelectString() {
- return "select identity_val_local() from sysibm.sysdummy1";
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public String getLimitString(String sql, int offset, int limit) {
- return new StringBuffer(sql.length() + 40)
- .append(sql)
- .append(" fetch first ")
- .append(limit)
- .append(" rows only ")
- .toString();
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+ * An SQL dialect for DB2/390. This class provides support for
+ * DB2 Universal Database for OS/390, also known as DB2/390.
+ *
+ * @author Kristoffer Dyrkorn
+ */
+public class DB2390Dialect extends DB2Dialect {
+
+ public boolean supportsSequences() {
+ return false;
+ }
+
+ public String getIdentitySelectString() {
+ return "select identity_val_local() from sysibm.sysdummy1";
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public String getLimitString(String sql, int offset, int limit) {
+ return new StringBuffer(sql.length() + 40)
+ .append(sql)
+ .append(" fetch first ")
+ .append(limit)
+ .append(" rows only ")
+ .toString();
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,44 +0,0 @@
-package org.hibernate.dialect;
-
-/**
-* An SQL dialect for DB2/400
-* @author Peter DeGregorio (pdegregorio)
-* This class provides support for DB2 Universal Database for iSeries,
-* also known as DB2/400.
-*/
-public class DB2400Dialect extends DB2Dialect {
-
- public boolean supportsSequences() {
- return false;
- }
-
- public String getIdentitySelectString() {
- return "select identity_val_local() from sysibm.sysdummy1";
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public String getLimitString(String sql, int offset, int limit) {
- return new StringBuffer(sql.length() + 40)
- .append(sql)
- .append(" fetch first ")
- .append(limit)
- .append(" rows only ")
- .toString();
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+* An SQL dialect for DB2/400
+* @author Peter DeGregorio (pdegregorio)
+* This class provides support for DB2 Universal Database for iSeries,
+* also known as DB2/400.
+*/
+public class DB2400Dialect extends DB2Dialect {
+
+ public boolean supportsSequences() {
+ return false;
+ }
+
+ public String getIdentitySelectString() {
+ return "select identity_val_local() from sysibm.sysdummy1";
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public String getLimitString(String sql, int offset, int limit) {
+ return new StringBuffer(sql.length() + 40)
+ .append(sql)
+ .append(" fetch first ")
+ .append(limit)
+ .append(" rows only ")
+ .toString();
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DB2Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,369 +0,0 @@
-//$Id: DB2Dialect.java 10963 2006-12-08 16:06:14Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.dialect.function.AnsiTrimEmulationFunction;
-
-/**
- * An SQL dialect for DB2.
- * @author Gavin King
- */
-public class DB2Dialect extends Dialect {
-
- public DB2Dialect() {
- super();
- registerColumnType( Types.BIT, "smallint" );
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "smallint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "varchar($l) for bit data" );
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- registerColumnType( Types.BLOB, "blob($l)" );
- registerColumnType( Types.CLOB, "clob($l)" );
-
- registerFunction("abs", new StandardSQLFunction("abs") );
- registerFunction("absval", new StandardSQLFunction("absval") );
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction("ceiling", new StandardSQLFunction("ceiling") );
- registerFunction("ceil", new StandardSQLFunction("ceil") );
- registerFunction("floor", new StandardSQLFunction("floor") );
- registerFunction("round", new StandardSQLFunction("round") );
-
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction("float", new StandardSQLFunction("float", Hibernate.DOUBLE) );
- registerFunction("hex", new StandardSQLFunction("hex", Hibernate.STRING) );
- registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING) );
- registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction("stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction("variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
-
- registerFunction("julian_day", new StandardSQLFunction("julian_day", Hibernate.INTEGER) );
- registerFunction("microsecond", new StandardSQLFunction("microsecond", Hibernate.INTEGER) );
- registerFunction("midnight_seconds", new StandardSQLFunction("midnight_seconds", Hibernate.INTEGER) );
- registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER) );
- registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER) );
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
- registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER) );
- registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER) );
- registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER) );
- registerFunction("current_date", new NoArgSQLFunction("current date", Hibernate.DATE, false) );
- registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
- registerFunction("day", new StandardSQLFunction("day", Hibernate.INTEGER) );
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
- registerFunction("dayofweek_iso", new StandardSQLFunction("dayofweek_iso", Hibernate.INTEGER) );
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
- registerFunction("days", new StandardSQLFunction("days", Hibernate.LONG) );
- registerFunction("current_time", new NoArgSQLFunction("current time", Hibernate.TIME, false) );
- registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
- registerFunction("current_timestamp", new NoArgSQLFunction("current timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
- registerFunction("timestamp_iso", new StandardSQLFunction("timestamp_iso", Hibernate.TIMESTAMP) );
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER) );
- registerFunction("week_iso", new StandardSQLFunction("week_iso", Hibernate.INTEGER) );
- registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER) );
-
- registerFunction("double", new StandardSQLFunction("double", Hibernate.DOUBLE) );
- registerFunction("varchar", new StandardSQLFunction("varchar", Hibernate.STRING) );
- registerFunction("real", new StandardSQLFunction("real", Hibernate.FLOAT) );
- registerFunction("bigint", new StandardSQLFunction("bigint", Hibernate.LONG) );
- registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
- registerFunction("integer", new StandardSQLFunction("integer", Hibernate.INTEGER) );
- registerFunction("smallint", new StandardSQLFunction("smallint", Hibernate.SHORT) );
-
- registerFunction("digits", new StandardSQLFunction("digits", Hibernate.STRING) );
- registerFunction("chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
- registerFunction("upper", new StandardSQLFunction("upper") );
- registerFunction("lower", new StandardSQLFunction("lower") );
- registerFunction("ucase", new StandardSQLFunction("ucase") );
- registerFunction("lcase", new StandardSQLFunction("lcase") );
- registerFunction("length", new StandardSQLFunction("length", Hibernate.LONG) );
- registerFunction("ltrim", new StandardSQLFunction("ltrim") );
- registerFunction("rtrim", new StandardSQLFunction("rtrim") );
- registerFunction( "substr", new StandardSQLFunction( "substr", Hibernate.STRING ) );
- registerFunction( "posstr", new StandardSQLFunction( "posstr", Hibernate.INTEGER ) );
-
- registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
- registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "length(?1)*8" ) );
- registerFunction( "trim", new AnsiTrimEmulationFunction() );
-
- registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
-
- registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "rtrim(char(?1))" ) );
-
- registerKeyword("current");
- registerKeyword("date");
- registerKeyword("time");
- registerKeyword("timestamp");
- registerKeyword("fetch");
- registerKeyword("first");
- registerKeyword("rows");
- registerKeyword("only");
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
- }
-
- public String getLowercaseFunction() {
- return "lcase";
- }
-
- public String getAddColumnString() {
- return "add column";
- }
- public boolean dropConstraints() {
- return false;
- }
- public boolean supportsIdentityColumns() {
- return true;
- }
- public String getIdentitySelectString() {
- return "values identity_val_local()";
- }
- public String getIdentityColumnString() {
- return "generated by default as identity"; //not null ... (start with 1) is implicit
- }
- public String getIdentityInsertString() {
- return "default";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "values nextval for " + sequenceName;
- }
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName + " restrict";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public String getQuerySequencesString() {
- return "select seqname from sysibm.syssequences";
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- /*public String getLimitString(String sql, boolean hasOffset) {
- StringBuffer rownumber = new StringBuffer(50)
- .append(" rownumber() over(");
- int orderByIndex = sql.toLowerCase().indexOf("order by");
- if (orderByIndex>0) rownumber.append( sql.substring(orderByIndex) );
- rownumber.append(") as row_,");
- StringBuffer pagingSelect = new StringBuffer( sql.length()+100 )
- .append("select * from ( ")
- .append(sql)
- .insert( getAfterSelectInsertPoint(sql)+16, rownumber.toString() )
- .append(" ) as temp_ where row_ ");
- if (hasOffset) {
- pagingSelect.append("between ?+1 and ?");
- }
- else {
- pagingSelect.append("<= ?");
- }
- return pagingSelect.toString();
- }*/
-
- /**
- * Render the <tt>rownumber() over ( .... ) as rownumber_,</tt>
- * bit, that goes in the select list
- */
- private String getRowNumber(String sql) {
- StringBuffer rownumber = new StringBuffer(50)
- .append("rownumber() over(");
-
- int orderByIndex = sql.toLowerCase().indexOf("order by");
-
- if ( orderByIndex>0 && !hasDistinct(sql) ) {
- rownumber.append( sql.substring(orderByIndex) );
- }
-
- rownumber.append(") as rownumber_,");
-
- return rownumber.toString();
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
-
- int startOfSelect = sql.toLowerCase().indexOf("select");
-
- StringBuffer pagingSelect = new StringBuffer( sql.length()+100 )
- .append( sql.substring(0, startOfSelect) ) //add the comment
- .append("select * from ( select ") //nest the main query in an outer select
- .append( getRowNumber(sql) ); //add the rownnumber bit into the outer query select list
-
- if ( hasDistinct(sql) ) {
- pagingSelect.append(" row_.* from ( ") //add another (inner) nested select
- .append( sql.substring(startOfSelect) ) //add the main query
- .append(" ) as row_"); //close off the inner nested select
- }
- else {
- pagingSelect.append( sql.substring( startOfSelect + 6 ) ); //add the main query
- }
-
- pagingSelect.append(" ) as temp_ where rownumber_ ");
-
- //add the restriction to the outer select
- if (hasOffset) {
- pagingSelect.append("between ?+1 and ?");
- }
- else {
- pagingSelect.append("<= ?");
- }
-
- return pagingSelect.toString();
- }
-
- private static boolean hasDistinct(String sql) {
- return sql.toLowerCase().indexOf("select distinct")>=0;
- }
-
- public String getForUpdateString() {
- return " for read only with rs";
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean supportsOuterJoinForUpdate() {
- return false;
- }
-
- public boolean supportsNotNullUnique() {
- return false;
- }
-
- public String getSelectClauseNullString(int sqlType) {
- String literal;
- switch(sqlType) {
- case Types.VARCHAR:
- case Types.CHAR:
- literal = "'x'";
- break;
- case Types.DATE:
- literal = "'2000-1-1'";
- break;
- case Types.TIMESTAMP:
- literal = "'2000-1-1 00:00:00'";
- break;
- case Types.TIME:
- literal = "'00:00:00'";
- break;
- default:
- literal = "0";
- }
- return "nullif(" + literal + ',' + literal + ')';
- }
-
- public static void main(String[] args) {
- System.out.println( new DB2Dialect().getLimitString("/*foo*/ select * from foos", true) );
- System.out.println( new DB2Dialect().getLimitString("/*foo*/ select distinct * from foos", true) );
- System.out.println( new DB2Dialect().getLimitString("/*foo*/ select * from foos foo order by foo.bar, foo.baz", true) );
- System.out.println( new DB2Dialect().getLimitString("/*foo*/ select distinct * from foos foo order by foo.bar, foo.baz", true) );
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
-
- public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
- return col;
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- boolean isResultSet = ps.execute();
- // This assumes you will want to ignore any update counts
- while (!isResultSet && ps.getUpdateCount() != -1) {
- isResultSet = ps.getMoreResults();
- }
- ResultSet rs = ps.getResultSet();
- // You may still have other ResultSets or update counts left to process here
- // but you can't do it now or the ResultSet you just got will be closed
- return rs;
- }
-
- public boolean supportsCommentOn() {
- return true;
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "declare global temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "not logged";
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- return "session." + super.generateTemporaryTableName(baseTableName);
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public String getCurrentTimestampSelectString() {
- return "values current timestamp";
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public boolean supportsParametersInInsertSelect() {
- // DB2 known to not support parameters within the select
- // clause of an SQL INSERT ... SELECT ... statement
- return false;
- }
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsLobValueChangePropogation() {
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/DB2Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DB2Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,392 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.function.AnsiTrimEmulationFunction;
+
+/**
+ * An SQL dialect for DB2.
+ * @author Gavin King
+ */
+public class DB2Dialect extends Dialect {
+
+ public DB2Dialect() {
+ super();
+ registerColumnType( Types.BIT, "smallint" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "smallint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "varchar($l) for bit data" );
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ registerColumnType( Types.BLOB, "blob($l)" );
+ registerColumnType( Types.CLOB, "clob($l)" );
+
+ registerFunction("abs", new StandardSQLFunction("abs") );
+ registerFunction("absval", new StandardSQLFunction("absval") );
+ registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction("ceiling", new StandardSQLFunction("ceiling") );
+ registerFunction("ceil", new StandardSQLFunction("ceil") );
+ registerFunction("floor", new StandardSQLFunction("floor") );
+ registerFunction("round", new StandardSQLFunction("round") );
+
+ registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
+ registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
+ registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction("float", new StandardSQLFunction("float", Hibernate.DOUBLE) );
+ registerFunction("hex", new StandardSQLFunction("hex", Hibernate.STRING) );
+ registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
+ registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
+ registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
+ registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
+ registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING) );
+ registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction("stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
+ registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction("variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
+
+ registerFunction("julian_day", new StandardSQLFunction("julian_day", Hibernate.INTEGER) );
+ registerFunction("microsecond", new StandardSQLFunction("microsecond", Hibernate.INTEGER) );
+ registerFunction("midnight_seconds", new StandardSQLFunction("midnight_seconds", Hibernate.INTEGER) );
+ registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER) );
+ registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER) );
+ registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
+ registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER) );
+ registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER) );
+ registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER) );
+ registerFunction("current_date", new NoArgSQLFunction("current date", Hibernate.DATE, false) );
+ registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
+ registerFunction("day", new StandardSQLFunction("day", Hibernate.INTEGER) );
+ registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
+ registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
+ registerFunction("dayofweek_iso", new StandardSQLFunction("dayofweek_iso", Hibernate.INTEGER) );
+ registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
+ registerFunction("days", new StandardSQLFunction("days", Hibernate.LONG) );
+ registerFunction("current_time", new NoArgSQLFunction("current time", Hibernate.TIME, false) );
+ registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
+ registerFunction("current_timestamp", new NoArgSQLFunction("current timestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
+ registerFunction("timestamp_iso", new StandardSQLFunction("timestamp_iso", Hibernate.TIMESTAMP) );
+ registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER) );
+ registerFunction("week_iso", new StandardSQLFunction("week_iso", Hibernate.INTEGER) );
+ registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER) );
+
+ registerFunction("double", new StandardSQLFunction("double", Hibernate.DOUBLE) );
+ registerFunction("varchar", new StandardSQLFunction("varchar", Hibernate.STRING) );
+ registerFunction("real", new StandardSQLFunction("real", Hibernate.FLOAT) );
+ registerFunction("bigint", new StandardSQLFunction("bigint", Hibernate.LONG) );
+ registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
+ registerFunction("integer", new StandardSQLFunction("integer", Hibernate.INTEGER) );
+ registerFunction("smallint", new StandardSQLFunction("smallint", Hibernate.SHORT) );
+
+ registerFunction("digits", new StandardSQLFunction("digits", Hibernate.STRING) );
+ registerFunction("chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
+ registerFunction("upper", new StandardSQLFunction("upper") );
+ registerFunction("lower", new StandardSQLFunction("lower") );
+ registerFunction("ucase", new StandardSQLFunction("ucase") );
+ registerFunction("lcase", new StandardSQLFunction("lcase") );
+ registerFunction("length", new StandardSQLFunction("length", Hibernate.LONG) );
+ registerFunction("ltrim", new StandardSQLFunction("ltrim") );
+ registerFunction("rtrim", new StandardSQLFunction("rtrim") );
+ registerFunction( "substr", new StandardSQLFunction( "substr", Hibernate.STRING ) );
+ registerFunction( "posstr", new StandardSQLFunction( "posstr", Hibernate.INTEGER ) );
+
+ registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "length(?1)*8" ) );
+ registerFunction( "trim", new AnsiTrimEmulationFunction() );
+
+ registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
+
+ registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "rtrim(char(?1))" ) );
+
+ registerKeyword("current");
+ registerKeyword("date");
+ registerKeyword("time");
+ registerKeyword("timestamp");
+ registerKeyword("fetch");
+ registerKeyword("first");
+ registerKeyword("rows");
+ registerKeyword("only");
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
+ }
+
+ public String getLowercaseFunction() {
+ return "lcase";
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+ public boolean dropConstraints() {
+ return false;
+ }
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+ public String getIdentitySelectString() {
+ return "values identity_val_local()";
+ }
+ public String getIdentityColumnString() {
+ return "generated by default as identity"; //not null ... (start with 1) is implicit
+ }
+ public String getIdentityInsertString() {
+ return "default";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "values nextval for " + sequenceName;
+ }
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName + " restrict";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public String getQuerySequencesString() {
+ return "select seqname from sysibm.syssequences";
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ /*public String getLimitString(String sql, boolean hasOffset) {
+ StringBuffer rownumber = new StringBuffer(50)
+ .append(" rownumber() over(");
+ int orderByIndex = sql.toLowerCase().indexOf("order by");
+ if (orderByIndex>0) rownumber.append( sql.substring(orderByIndex) );
+ rownumber.append(") as row_,");
+ StringBuffer pagingSelect = new StringBuffer( sql.length()+100 )
+ .append("select * from ( ")
+ .append(sql)
+ .insert( getAfterSelectInsertPoint(sql)+16, rownumber.toString() )
+ .append(" ) as temp_ where row_ ");
+ if (hasOffset) {
+ pagingSelect.append("between ?+1 and ?");
+ }
+ else {
+ pagingSelect.append("<= ?");
+ }
+ return pagingSelect.toString();
+ }*/
+
+ /**
+ * Render the <tt>rownumber() over ( .... ) as rownumber_,</tt>
+ * bit, that goes in the select list
+ */
+ private String getRowNumber(String sql) {
+ StringBuffer rownumber = new StringBuffer(50)
+ .append("rownumber() over(");
+
+ int orderByIndex = sql.toLowerCase().indexOf("order by");
+
+ if ( orderByIndex>0 && !hasDistinct(sql) ) {
+ rownumber.append( sql.substring(orderByIndex) );
+ }
+
+ rownumber.append(") as rownumber_,");
+
+ return rownumber.toString();
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+
+ int startOfSelect = sql.toLowerCase().indexOf("select");
+
+ StringBuffer pagingSelect = new StringBuffer( sql.length()+100 )
+ .append( sql.substring(0, startOfSelect) ) //add the comment
+ .append("select * from ( select ") //nest the main query in an outer select
+ .append( getRowNumber(sql) ); //add the rownnumber bit into the outer query select list
+
+ if ( hasDistinct(sql) ) {
+ pagingSelect.append(" row_.* from ( ") //add another (inner) nested select
+ .append( sql.substring(startOfSelect) ) //add the main query
+ .append(" ) as row_"); //close off the inner nested select
+ }
+ else {
+ pagingSelect.append( sql.substring( startOfSelect + 6 ) ); //add the main query
+ }
+
+ pagingSelect.append(" ) as temp_ where rownumber_ ");
+
+ //add the restriction to the outer select
+ if (hasOffset) {
+ pagingSelect.append("between ?+1 and ?");
+ }
+ else {
+ pagingSelect.append("<= ?");
+ }
+
+ return pagingSelect.toString();
+ }
+
+ private static boolean hasDistinct(String sql) {
+ return sql.toLowerCase().indexOf("select distinct")>=0;
+ }
+
+ public String getForUpdateString() {
+ return " for read only with rs";
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean supportsOuterJoinForUpdate() {
+ return false;
+ }
+
+ public boolean supportsNotNullUnique() {
+ return false;
+ }
+
+ public String getSelectClauseNullString(int sqlType) {
+ String literal;
+ switch(sqlType) {
+ case Types.VARCHAR:
+ case Types.CHAR:
+ literal = "'x'";
+ break;
+ case Types.DATE:
+ literal = "'2000-1-1'";
+ break;
+ case Types.TIMESTAMP:
+ literal = "'2000-1-1 00:00:00'";
+ break;
+ case Types.TIME:
+ literal = "'00:00:00'";
+ break;
+ default:
+ literal = "0";
+ }
+ return "nullif(" + literal + ',' + literal + ')';
+ }
+
+ public static void main(String[] args) {
+ System.out.println( new DB2Dialect().getLimitString("/*foo*/ select * from foos", true) );
+ System.out.println( new DB2Dialect().getLimitString("/*foo*/ select distinct * from foos", true) );
+ System.out.println( new DB2Dialect().getLimitString("/*foo*/ select * from foos foo order by foo.bar, foo.baz", true) );
+ System.out.println( new DB2Dialect().getLimitString("/*foo*/ select distinct * from foos foo order by foo.bar, foo.baz", true) );
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
+ return col;
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ boolean isResultSet = ps.execute();
+ // This assumes you will want to ignore any update counts
+ while (!isResultSet && ps.getUpdateCount() != -1) {
+ isResultSet = ps.getMoreResults();
+ }
+ ResultSet rs = ps.getResultSet();
+ // You may still have other ResultSets or update counts left to process here
+ // but you can't do it now or the ResultSet you just got will be closed
+ return rs;
+ }
+
+ public boolean supportsCommentOn() {
+ return true;
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "declare global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "not logged";
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ return "session." + super.generateTemporaryTableName(baseTableName);
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "values current timestamp";
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public boolean supportsParametersInInsertSelect() {
+ // DB2 known to not support parameters within the select
+ // clause of an SQL INSERT ... SELECT ... statement
+ return false;
+ }
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsLobValueChangePropogation() {
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,25 +0,0 @@
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class DataDirectOracle9Dialect extends Oracle9Dialect {
-
- public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
- return col; // sql server just returns automatically
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- boolean isResultSet = ps.execute();
-// This assumes you will want to ignore any update counts
- while (!isResultSet && ps.getUpdateCount() != -1) {
- isResultSet = ps.getMoreResults();
- }
- ResultSet rs = ps.getResultSet();
-// You may still have other ResultSets or update counts left to process here
-// but you can't do it now or the ResultSet you just got will be closed
- return rs;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DataDirectOracle9Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class DataDirectOracle9Dialect extends Oracle9Dialect {
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
+ return col; // sql server just returns automatically
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ boolean isResultSet = ps.execute();
+// This assumes you will want to ignore any update counts
+ while (!isResultSet && ps.getUpdateCount() != -1) {
+ isResultSet = ps.getMoreResults();
+ }
+ ResultSet rs = ps.getResultSet();
+// You may still have other ResultSets or update counts left to process here
+// but you can't do it now or the ResultSet you just got will be closed
+ return rs;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,198 +0,0 @@
-//$Id: DerbyDialect.java 10988 2006-12-13 18:37:01Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import org.hibernate.Hibernate;
-import org.hibernate.QueryException;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.id.TableHiLoGenerator;
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.DerbyCaseFragment;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author Simon Johnston
- *
- * Hibernate Dialect for Cloudscape 10 - aka Derby. This implements both an
- * override for the identity column generator as well as for the case statement
- * issue documented at:
- * http://www.jroller.com/comments/kenlars99/Weblog/cloudscape_soon_to_be_derby
- */
-public class DerbyDialect extends DB2Dialect {
-
- public DerbyDialect() {
- super();
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
- registerFunction( "trim", new DerbyTrimFunctionEmulation() );
- }
-
- /**
- * This is different in Cloudscape to DB2.
- */
- public String getIdentityColumnString() {
- return "not null generated always as identity"; //$NON-NLS-1
- }
-
- /**
- * Return the case statement modified for Cloudscape.
- */
- public CaseFragment createCaseFragment() {
- return new DerbyCaseFragment();
- }
-
- public boolean dropConstraints() {
- return true;
- }
-
- public Class getNativeIdentifierGeneratorClass() {
- return TableHiLoGenerator.class;
- }
-
- public boolean supportsSequences() {
- return false;
- }
-
- public boolean supportsLimit() {
- return false;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public String getQuerySequencesString() {
- return null ;
- }
-
- /**
- * A specialized function template to emulate the ANSI trim function on Derby DB
- * since it does not support the full trim specification. However, we cannot even
- * fully emulate it because there is not standard 'replace' function either. :(
- */
- public static class DerbyTrimFunctionEmulation implements SQLFunction {
- private static final SQLFunction LEADING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( ?1 )");
- private static final SQLFunction TRAILING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "rtrim( ?1 )");
- private static final SQLFunction BOTH_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?1 ) )");
- private static final SQLFunction BOTH_SPACE_TRIM_FROM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?2 ) )");
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return Hibernate.STRING;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return false;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- // according to both the ANSI-SQL and EJB3 specs, trim can either take
- // exactly one parameter or a variable number of parameters between 1 and 4.
- // from the SQL spec:
- //
- // <trim function> ::=
- // TRIM <left paren> <trim operands> <right paren>
- //
- // <trim operands> ::=
- // [ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
- //
- // <trim specification> ::=
- // LEADING
- // | TRAILING
- // | BOTH
- //
- // If only <trim specification> is omitted, BOTH is assumed;
- // if <trim character> is omitted, space is assumed
- if ( args.size() == 1 ) {
- // we have the form: trim(trimSource)
- // so we trim leading and trailing spaces
- return BOTH_SPACE_TRIM.render( args, factory );
- }
- else if ( "from".equalsIgnoreCase( ( String ) args.get( 0 ) ) ) {
- // we have the form: trim(from trimSource).
- // This is functionally equivalent to trim(trimSource)
- return BOTH_SPACE_TRIM_FROM.render( args, factory );
- }
- else {
- // otherwise, a trim-specification and/or a trim-character
- // have been specified; we need to decide which options
- // are present and "do the right thing"
- boolean leading = true; // should leading trim-characters be trimmed?
- boolean trailing = true; // should trailing trim-characters be trimmed?
- String trimCharacter; // the trim-character
- String trimSource; // the trim-source
-
- // potentialTrimCharacterArgIndex = 1 assumes that a
- // trim-specification has been specified. we handle the
- // exception to that explicitly
- int potentialTrimCharacterArgIndex = 1;
- String firstArg = ( String ) args.get( 0 );
- if ( "leading".equalsIgnoreCase( firstArg ) ) {
- trailing = false;
- }
- else if ( "trailing".equalsIgnoreCase( firstArg ) ) {
- leading = false;
- }
- else if ( "both".equalsIgnoreCase( firstArg ) ) {
- }
- else {
- potentialTrimCharacterArgIndex = 0;
- }
-
- String potentialTrimCharacter = ( String ) args.get( potentialTrimCharacterArgIndex );
- if ( "from".equalsIgnoreCase( potentialTrimCharacter ) ) {
- trimCharacter = "' '";
- trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
- }
- else if ( potentialTrimCharacterArgIndex + 1 >= args.size() ) {
- trimCharacter = "' '";
- trimSource = potentialTrimCharacter;
- }
- else {
- trimCharacter = potentialTrimCharacter;
- if ( "from".equalsIgnoreCase( ( String ) args.get( potentialTrimCharacterArgIndex + 1 ) ) ) {
- trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 2 );
- }
- else {
- trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
- }
- }
-
- List argsToUse = new ArrayList();
- argsToUse.add( trimSource );
- argsToUse.add( trimCharacter );
-
- if ( trimCharacter.equals( "' '" ) ) {
- if ( leading && trailing ) {
- return BOTH_SPACE_TRIM.render( argsToUse, factory );
- }
- else if ( leading ) {
- return LEADING_SPACE_TRIM.render( argsToUse, factory );
- }
- else {
- return TRAILING_SPACE_TRIM.render( argsToUse, factory );
- }
- }
- else {
- throw new HibernateException( "cannot specify trim character when using Derby as Derby does not support the ANSI trim function, not does it support a replace function to properly emmulate it" );
- }
- }
- }
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsLobValueChangePropogation() {
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/DerbyDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DerbyDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,221 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import org.hibernate.Hibernate;
+import org.hibernate.QueryException;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.id.TableHiLoGenerator;
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.DerbyCaseFragment;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Simon Johnston
+ *
+ * Hibernate Dialect for Cloudscape 10 - aka Derby. This implements both an
+ * override for the identity column generator as well as for the case statement
+ * issue documented at:
+ * http://www.jroller.com/comments/kenlars99/Weblog/cloudscape_soon_to_be_derby
+ */
+public class DerbyDialect extends DB2Dialect {
+
+ public DerbyDialect() {
+ super();
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
+ registerFunction( "trim", new DerbyTrimFunctionEmulation() );
+ }
+
+ /**
+ * This is different in Cloudscape to DB2.
+ */
+ public String getIdentityColumnString() {
+ return "not null generated always as identity"; //$NON-NLS-1
+ }
+
+ /**
+ * Return the case statement modified for Cloudscape.
+ */
+ public CaseFragment createCaseFragment() {
+ return new DerbyCaseFragment();
+ }
+
+ public boolean dropConstraints() {
+ return true;
+ }
+
+ public Class getNativeIdentifierGeneratorClass() {
+ return TableHiLoGenerator.class;
+ }
+
+ public boolean supportsSequences() {
+ return false;
+ }
+
+ public boolean supportsLimit() {
+ return false;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public String getQuerySequencesString() {
+ return null ;
+ }
+
+ /**
+ * A specialized function template to emulate the ANSI trim function on Derby DB
+ * since it does not support the full trim specification. However, we cannot even
+ * fully emulate it because there is not standard 'replace' function either. :(
+ */
+ public static class DerbyTrimFunctionEmulation implements SQLFunction {
+ private static final SQLFunction LEADING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( ?1 )");
+ private static final SQLFunction TRAILING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "rtrim( ?1 )");
+ private static final SQLFunction BOTH_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?1 ) )");
+ private static final SQLFunction BOTH_SPACE_TRIM_FROM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?2 ) )");
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return Hibernate.STRING;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return false;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ // according to both the ANSI-SQL and EJB3 specs, trim can either take
+ // exactly one parameter or a variable number of parameters between 1 and 4.
+ // from the SQL spec:
+ //
+ // <trim function> ::=
+ // TRIM <left paren> <trim operands> <right paren>
+ //
+ // <trim operands> ::=
+ // [ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
+ //
+ // <trim specification> ::=
+ // LEADING
+ // | TRAILING
+ // | BOTH
+ //
+ // If only <trim specification> is omitted, BOTH is assumed;
+ // if <trim character> is omitted, space is assumed
+ if ( args.size() == 1 ) {
+ // we have the form: trim(trimSource)
+ // so we trim leading and trailing spaces
+ return BOTH_SPACE_TRIM.render( args, factory );
+ }
+ else if ( "from".equalsIgnoreCase( ( String ) args.get( 0 ) ) ) {
+ // we have the form: trim(from trimSource).
+ // This is functionally equivalent to trim(trimSource)
+ return BOTH_SPACE_TRIM_FROM.render( args, factory );
+ }
+ else {
+ // otherwise, a trim-specification and/or a trim-character
+ // have been specified; we need to decide which options
+ // are present and "do the right thing"
+ boolean leading = true; // should leading trim-characters be trimmed?
+ boolean trailing = true; // should trailing trim-characters be trimmed?
+ String trimCharacter; // the trim-character
+ String trimSource; // the trim-source
+
+ // potentialTrimCharacterArgIndex = 1 assumes that a
+ // trim-specification has been specified. we handle the
+ // exception to that explicitly
+ int potentialTrimCharacterArgIndex = 1;
+ String firstArg = ( String ) args.get( 0 );
+ if ( "leading".equalsIgnoreCase( firstArg ) ) {
+ trailing = false;
+ }
+ else if ( "trailing".equalsIgnoreCase( firstArg ) ) {
+ leading = false;
+ }
+ else if ( "both".equalsIgnoreCase( firstArg ) ) {
+ }
+ else {
+ potentialTrimCharacterArgIndex = 0;
+ }
+
+ String potentialTrimCharacter = ( String ) args.get( potentialTrimCharacterArgIndex );
+ if ( "from".equalsIgnoreCase( potentialTrimCharacter ) ) {
+ trimCharacter = "' '";
+ trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
+ }
+ else if ( potentialTrimCharacterArgIndex + 1 >= args.size() ) {
+ trimCharacter = "' '";
+ trimSource = potentialTrimCharacter;
+ }
+ else {
+ trimCharacter = potentialTrimCharacter;
+ if ( "from".equalsIgnoreCase( ( String ) args.get( potentialTrimCharacterArgIndex + 1 ) ) ) {
+ trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 2 );
+ }
+ else {
+ trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
+ }
+ }
+
+ List argsToUse = new ArrayList();
+ argsToUse.add( trimSource );
+ argsToUse.add( trimCharacter );
+
+ if ( trimCharacter.equals( "' '" ) ) {
+ if ( leading && trailing ) {
+ return BOTH_SPACE_TRIM.render( argsToUse, factory );
+ }
+ else if ( leading ) {
+ return LEADING_SPACE_TRIM.render( argsToUse, factory );
+ }
+ else {
+ return TRAILING_SPACE_TRIM.render( argsToUse, factory );
+ }
+ }
+ else {
+ throw new HibernateException( "cannot specify trim character when using Derby as Derby does not support the ANSI trim function, not does it support a replace function to properly emmulate it" );
+ }
+ }
+ }
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsLobValueChangePropogation() {
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,1764 +0,0 @@
-//$Id: Dialect.java 11303 2007-03-19 22:06:14Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.MappingException;
-import org.hibernate.QueryException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.CastFunction;
-import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.engine.Mapping;
-import org.hibernate.exception.SQLExceptionConverter;
-import org.hibernate.exception.SQLStateConverter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.id.IdentityGenerator;
-import org.hibernate.id.SequenceGenerator;
-import org.hibernate.id.TableHiLoGenerator;
-import org.hibernate.mapping.Column;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.sql.ANSICaseFragment;
-import org.hibernate.sql.ANSIJoinFragment;
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.ForUpdateFragment;
-import org.hibernate.type.Type;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * Represents a dialect of SQL implemented by a particular RDBMS.
- * Subclasses implement Hibernate compatibility with different systems.<br>
- * <br>
- * Subclasses should provide a public default constructor that <tt>register()</tt>
- * a set of type mappings and default Hibernate properties.<br>
- * <br>
- * Subclasses should be immutable.
- *
- * @author Gavin King, David Channon
- */
-public abstract class Dialect {
-
- private static final Logger log = LoggerFactory.getLogger( Dialect.class );
-
- public static final String DEFAULT_BATCH_SIZE = "15";
- public static final String NO_BATCH = "0";
-
- /**
- * Characters used for quoting SQL identifiers
- */
- public static final String QUOTE = "`\"[";
- public static final String CLOSED_QUOTE = "`\"]";
-
-
- // build the map of standard ANSI SQL aggregation functions ~~~~~~~~~~~~~~~
-
- private static final Map STANDARD_AGGREGATE_FUNCTIONS = new HashMap();
- static {
- STANDARD_AGGREGATE_FUNCTIONS.put( "count", new StandardSQLFunction("count") {
- public Type getReturnType(Type columnType, Mapping mapping) {
- return Hibernate.LONG;
- }
- } );
-
- STANDARD_AGGREGATE_FUNCTIONS.put( "avg", new StandardSQLFunction("avg") {
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- int[] sqlTypes;
- try {
- sqlTypes = columnType.sqlTypes( mapping );
- }
- catch ( MappingException me ) {
- throw new QueryException( me );
- }
- if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in avg()" );
- return Hibernate.DOUBLE;
- }
- } );
-
- STANDARD_AGGREGATE_FUNCTIONS.put( "max", new StandardSQLFunction("max") );
- STANDARD_AGGREGATE_FUNCTIONS.put( "min", new StandardSQLFunction("min") );
- STANDARD_AGGREGATE_FUNCTIONS.put( "sum", new StandardSQLFunction("sum") {
- public Type getReturnType(Type columnType, Mapping mapping) {
- //pre H3.2 behavior: super.getReturnType(ct, m);
- int[] sqlTypes;
- try {
- sqlTypes = columnType.sqlTypes( mapping );
- }
- catch ( MappingException me ) {
- throw new QueryException( me );
- }
- if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in sum()" );
- int sqlType = sqlTypes[0];
-
- // First allow the actual type to control the return value. (the actual underlying sqltype could actually be different)
- if ( columnType == Hibernate.BIG_INTEGER ) {
- return Hibernate.BIG_INTEGER;
- }
- else if ( columnType == Hibernate.BIG_DECIMAL ) {
- return Hibernate.BIG_DECIMAL;
- }
- else if ( columnType == Hibernate.LONG || columnType == Hibernate.SHORT || columnType == Hibernate.INTEGER) {
- return Hibernate.LONG;
- }
- else if ( columnType == Hibernate.FLOAT || columnType == Hibernate.DOUBLE) {
- return Hibernate.DOUBLE;
- }
-
- // finally use the sqltype if == on Hibernate types did not find a match.
- if ( sqlType == Types.NUMERIC ) {
- return columnType; //because numeric can be anything
- }
- else if ( sqlType == Types.FLOAT || sqlType == Types.DOUBLE || sqlType == Types.DECIMAL || sqlType == Types.REAL) {
- return Hibernate.DOUBLE;
- }
- else if ( sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.SMALLINT || sqlType == Types.TINYINT ) {
- return Hibernate.LONG;
- }
- else {
- return columnType;
- }
- }
- });
- }
-
- private final TypeNames typeNames = new TypeNames();
- private final TypeNames hibernateTypeNames = new TypeNames();
-
- private final Properties properties = new Properties();
- private final Map sqlFunctions = new HashMap();
- private final Set sqlKeywords = new HashSet();
-
-
- // constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected Dialect() {
- log.info( "Using dialect: " + this );
- sqlFunctions.putAll( STANDARD_AGGREGATE_FUNCTIONS );
-
- // standard sql92 functions (can be overridden by subclasses)
- registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1, ?2, ?3)" ) );
- registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "locate(?1, ?2, ?3)" ) );
- registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "trim(?1 ?2 ?3 ?4)" ) );
- registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
- registerFunction( "bit_length", new StandardSQLFunction( "bit_length", Hibernate.INTEGER ) );
- registerFunction( "coalesce", new StandardSQLFunction( "coalesce" ) );
- registerFunction( "nullif", new StandardSQLFunction( "nullif" ) );
- registerFunction( "abs", new StandardSQLFunction( "abs" ) );
- registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER) );
- registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE) );
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "cast", new CastFunction() );
- registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(?1 ?2 ?3)") );
-
- //map second/minute/hour/day/month/year to ANSI extract(), override on subclasses
- registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(second from ?1)") );
- registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(minute from ?1)") );
- registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(hour from ?1)") );
- registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(day from ?1)") );
- registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(month from ?1)") );
- registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(year from ?1)") );
-
- registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as char)") );
-
- // register hibernate types for default use in scalar sqlquery type auto detection
- registerHibernateType( Types.BIGINT, Hibernate.BIG_INTEGER.getName() );
- registerHibernateType( Types.BINARY, Hibernate.BINARY.getName() );
- registerHibernateType( Types.BIT, Hibernate.BOOLEAN.getName() );
- registerHibernateType( Types.CHAR, Hibernate.CHARACTER.getName() );
- registerHibernateType( Types.DATE, Hibernate.DATE.getName() );
- registerHibernateType( Types.DOUBLE, Hibernate.DOUBLE.getName() );
- registerHibernateType( Types.FLOAT, Hibernate.FLOAT.getName() );
- registerHibernateType( Types.INTEGER, Hibernate.INTEGER.getName() );
- registerHibernateType( Types.SMALLINT, Hibernate.SHORT.getName() );
- registerHibernateType( Types.TINYINT, Hibernate.BYTE.getName() );
- registerHibernateType( Types.TIME, Hibernate.TIME.getName() );
- registerHibernateType( Types.TIMESTAMP, Hibernate.TIMESTAMP.getName() );
- registerHibernateType( Types.VARCHAR, Hibernate.STRING.getName() );
- registerHibernateType( Types.VARBINARY, Hibernate.BINARY.getName() );
- registerHibernateType( Types.NUMERIC, Hibernate.BIG_DECIMAL.getName() );
- registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
- registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
- registerHibernateType( Types.CLOB, Hibernate.CLOB.getName() );
- registerHibernateType( Types.REAL, Hibernate.FLOAT.getName() );
- }
-
- /**
- * Get an instance of the dialect specified by the current <tt>System</tt> properties.
- *
- * @return The specified Dialect
- * @throws HibernateException If no dialect was specified, or if it could not be instantiated.
- */
- public static Dialect getDialect() throws HibernateException {
- String dialectName = Environment.getProperties().getProperty( Environment.DIALECT );
- return instantiateDialect( dialectName );
- }
-
-
- /**
- * Get an instance of the dialect specified by the given properties or by
- * the current <tt>System</tt> properties.
- *
- * @param props The properties to use for finding the dialect class to use.
- * @return The specified Dialect
- * @throws HibernateException If no dialect was specified, or if it could not be instantiated.
- */
- public static Dialect getDialect(Properties props) throws HibernateException {
- String dialectName = props.getProperty( Environment.DIALECT );
- if ( dialectName == null ) {
- return getDialect();
- }
- return instantiateDialect( dialectName );
- }
-
- private static Dialect instantiateDialect(String dialectName) throws HibernateException {
- if ( dialectName == null ) {
- throw new HibernateException( "The dialect was not set. Set the property hibernate.dialect." );
- }
- try {
- return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
- }
- catch ( ClassNotFoundException cnfe ) {
- throw new HibernateException( "Dialect class not found: " + dialectName );
- }
- catch ( Exception e ) {
- throw new HibernateException( "Could not instantiate dialect class", e );
- }
- }
-
- /**
- * Retrieve a set of default Hibernate properties for this database.
- *
- * @return a set of Hibernate properties
- */
- public final Properties getDefaultProperties() {
- return properties;
- }
-
- public String toString() {
- return getClass().getName();
- }
-
-
- // database type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the name of the database type associated with the given
- * {@link java.sql.Types} typecode.
- *
- * @param code The {@link java.sql.Types} typecode
- * @return the database type name
- * @throws HibernateException If no mapping was specified for that type.
- */
- public String getTypeName(int code) throws HibernateException {
- String result = typeNames.get( code );
- if ( result == null ) {
- throw new HibernateException( "No default type mapping for (java.sql.Types) " + code );
- }
- return result;
- }
-
- /**
- * Get the name of the database type associated with the given
- * {@link java.sql.Types} typecode with the given storage specification
- * parameters.
- *
- * @param code The {@link java.sql.Types} typecode
- * @param length The datatype length
- * @param precision The datatype precision
- * @param scale The datatype scale
- * @return the database type name
- * @throws HibernateException If no mapping was specified for that type.
- */
- public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
- String result = typeNames.get( code, length, precision, scale );
- if ( result == null ) {
- throw new HibernateException(
- "No type mapping for java.sql.Types code: " +
- code +
- ", length: " +
- length
- );
- }
- return result;
- }
-
- /**
- * Get the name of the database type appropriate for casting operations
- * (via the CAST() SQL function) for the given {@link java.sql.Types} typecode.
- *
- * @param code The {@link java.sql.Types} typecode
- * @return The database type name
- */
- public String getCastTypeName(int code) {
- return getTypeName( code, Column.DEFAULT_LENGTH, Column.DEFAULT_PRECISION, Column.DEFAULT_SCALE );
- }
-
- /**
- * Subclasses register a type name for the given type code and maximum
- * column length. <tt>$l</tt> in the type name with be replaced by the
- * column length (if appropriate).
- *
- * @param code The {@link java.sql.Types} typecode
- * @param capacity The maximum length of database type
- * @param name The database type name
- */
- protected void registerColumnType(int code, int capacity, String name) {
- typeNames.put( code, capacity, name );
- }
-
- /**
- * Subclasses register a type name for the given type code. <tt>$l</tt> in
- * the type name with be replaced by the column length (if appropriate).
- *
- * @param code The {@link java.sql.Types} typecode
- * @param name The database type name
- */
- protected void registerColumnType(int code, String name) {
- typeNames.put( code, name );
- }
-
-
- // hibernate type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the name of the Hibernate {@link org.hibernate.type.Type} associated with th given
- * {@link java.sql.Types} typecode.
- *
- * @param code The {@link java.sql.Types} typecode
- * @return The Hibernate {@link org.hibernate.type.Type} name.
- * @throws HibernateException If no mapping was specified for that type.
- */
- public String getHibernateTypeName(int code) throws HibernateException {
- String result = hibernateTypeNames.get( code );
- if ( result == null ) {
- throw new HibernateException( "No Hibernate type mapping for java.sql.Types code: " + code );
- }
- return result;
- }
-
- /**
- * Get the name of the Hibernate {@link org.hibernate.type.Type} associated
- * with the given {@link java.sql.Types} typecode with the given storage
- * specification parameters.
- *
- * @param code The {@link java.sql.Types} typecode
- * @param length The datatype length
- * @param precision The datatype precision
- * @param scale The datatype scale
- * @return The Hibernate {@link org.hibernate.type.Type} name.
- * @throws HibernateException If no mapping was specified for that type.
- */
- public String getHibernateTypeName(int code, int length, int precision, int scale) throws HibernateException {
- String result = hibernateTypeNames.get( code, length, precision, scale );
- if ( result == null ) {
- throw new HibernateException(
- "No Hibernate type mapping for java.sql.Types code: " +
- code +
- ", length: " +
- length
- );
- }
- return result;
- }
-
- /**
- * Registers a Hibernate {@link org.hibernate.type.Type} name for the given
- * {@link java.sql.Types} type code and maximum column length.
- *
- * @param code The {@link java.sql.Types} typecode
- * @param capacity The maximum length of database type
- * @param name The Hibernate {@link org.hibernate.type.Type} name
- */
- protected void registerHibernateType(int code, int capacity, String name) {
- hibernateTypeNames.put( code, capacity, name);
- }
-
- /**
- * Registers a Hibernate {@link org.hibernate.type.Type} name for the given
- * {@link java.sql.Types} type code.
- *
- * @param code The {@link java.sql.Types} typecode
- * @param name The Hibernate {@link org.hibernate.type.Type} name
- */
- protected void registerHibernateType(int code, String name) {
- hibernateTypeNames.put( code, name);
- }
-
-
- // function support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected void registerFunction(String name, SQLFunction function) {
- sqlFunctions.put( name, function );
- }
-
- /**
- * Retrieves a map of the dialect's registered fucntions
- * (functionName => {@link org.hibernate.dialect.function.SQLFunction}).
- *
- * @return The map of registered functions.
- */
- public final Map getFunctions() {
- return sqlFunctions;
- }
-
-
- // keyword support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected void registerKeyword(String word) {
- sqlKeywords.add(word);
- }
-
- public Set getKeywords() {
- return sqlKeywords;
- }
-
-
- // native identifier generatiion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * The class (which implements {@link org.hibernate.id.IdentifierGenerator})
- * which acts as this dialects native generation strategy.
- * <p/>
- * Comes into play whenever the user specifies the native generator.
- *
- * @return The native generator class.
- */
- public Class getNativeIdentifierGeneratorClass() {
- if ( supportsIdentityColumns() ) {
- return IdentityGenerator.class;
- }
- else if ( supportsSequences() ) {
- return SequenceGenerator.class;
- }
- else {
- return TableHiLoGenerator.class;
- }
- }
-
-
- // IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support identity column key generation?
- *
- * @return True if IDENTITY columns are supported; false otherwise.
- */
- public boolean supportsIdentityColumns() {
- return false;
- }
-
- /**
- * Does the dialect support some form of inserting and selecting
- * the generated IDENTITY value all in the same statement.
- *
- * @return True if the dialect supports selecting the just
- * generated IDENTITY in the insert statement.
- */
- public boolean supportsInsertSelectIdentity() {
- return false;
- }
-
- /**
- * Whether this dialect have an Identity clause added to the data type or a
- * completely seperate identity data type
- *
- * @return boolean
- */
- public boolean hasDataTypeInIdentityColumn() {
- return true;
- }
-
- /**
- * Provided we {@link #supportsInsertSelectIdentity}, then attch the
- * "select identity" clause to the insert statement.
- * <p/>
- * Note, if {@link #supportsInsertSelectIdentity} == false then
- * the insert-string should be returned without modification.
- *
- * @param insertString The insert command
- * @return The insert command with any necessary identity select
- * clause attached.
- */
- public String appendIdentitySelectToInsert(String insertString) {
- return insertString;
- }
-
- /**
- * Get the select command to use to retrieve the last generated IDENTITY
- * value for a particuar table
- *
- * @param table The table into which the insert was done
- * @param column The PK column.
- * @param type The {@link java.sql.Types} type code.
- * @return The appropriate select command
- * @throws MappingException If IDENTITY generation is not supported.
- */
- public String getIdentitySelectString(String table, String column, int type) throws MappingException {
- return getIdentitySelectString();
- }
-
- /**
- * Get the select command to use to retrieve the last generated IDENTITY
- * value.
- *
- * @return The appropriate select command
- * @throws MappingException If IDENTITY generation is not supported.
- */
- protected String getIdentitySelectString() throws MappingException {
- throw new MappingException( "Dialect does not support identity key generation" );
- }
-
- /**
- * The syntax used during DDL to define a column as being an IDENTITY of
- * a particular type.
- *
- * @param type The {@link java.sql.Types} type code.
- * @return The appropriate DDL fragment.
- * @throws MappingException If IDENTITY generation is not supported.
- */
- public String getIdentityColumnString(int type) throws MappingException {
- return getIdentityColumnString();
- }
-
- /**
- * The syntax used during DDL to define a column as being an IDENTITY.
- *
- * @return The appropriate DDL fragment.
- * @throws MappingException If IDENTITY generation is not supported.
- */
- protected String getIdentityColumnString() throws MappingException {
- throw new MappingException( "Dialect does not support identity key generation" );
- }
-
- /**
- * The keyword used to insert a generated value into an identity column (or null).
- * Need if the dialect does not support inserts that specify no column values.
- *
- * @return The appropriate keyword.
- */
- public String getIdentityInsertString() {
- return null;
- }
-
-
- // SEQUENCE support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support sequences?
- *
- * @return True if sequences supported; false otherwise.
- */
- public boolean supportsSequences() {
- return false;
- }
-
- /**
- * Does this dialect support "pooled" sequences. Not aware of a better
- * name for this. Essentially can we specify the initial and increment values?
- *
- * @return True if such "pooled" sequences are supported; false otherwise.
- * @see #getCreateSequenceStrings(String, int, int)
- * @see #getCreateSequenceString(String, int, int)
- */
- public boolean supportsPooledSequences() {
- return false;
- }
-
- /**
- * Generate the appropriate select statement to to retreive the next value
- * of a sequence.
- * <p/>
- * This should be a "stand alone" select statement.
- *
- * @param sequenceName the name of the sequence
- * @return String The "nextval" select string.
- * @throws MappingException If sequences are not supported.
- */
- public String getSequenceNextValString(String sequenceName) throws MappingException {
- throw new MappingException( "Dialect does not support sequences" );
- }
-
- /**
- * Generate the select expression fragment that will retreive the next
- * value of a sequence as part of another (typically DML) statement.
- * <p/>
- * This differs from {@link #getSequenceNextValString(String)} in that this
- * should return an expression usable within another statement.
- *
- * @param sequenceName the name of the sequence
- * @return The "nextval" fragment.
- * @throws MappingException If sequences are not supported.
- */
- public String getSelectSequenceNextValString(String sequenceName) throws MappingException {
- throw new MappingException( "Dialect does not support sequences" );
- }
-
- /**
- * The multiline script used to create a sequence.
- *
- * @param sequenceName The name of the sequence
- * @return The sequence creation commands
- * @throws MappingException If sequences are not supported.
- * @deprecated Use {@link #getCreateSequenceString(String, int, int)} instead
- */
- public String[] getCreateSequenceStrings(String sequenceName) throws MappingException {
- return new String[] { getCreateSequenceString( sequenceName ) };
- }
-
- /**
- * An optional multi-line form for databases which {@link #supportsPooledSequences()}.
- *
- * @param sequenceName The name of the sequence
- * @param initialValue The initial value to apply to 'create sequence' statement
- * @param incrementSize The increment value to apply to 'create sequence' statement
- * @return The sequence creation commands
- * @throws MappingException If sequences are not supported.
- */
- public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) throws MappingException {
- return new String[] { getCreateSequenceString( sequenceName, initialValue, incrementSize ) };
- }
-
- /**
- * Typically dialects which support sequences can create a sequence
- * with a single command. This is convenience form of
- * {@link #getCreateSequenceStrings} to help facilitate that.
- * <p/>
- * Dialects which support sequences and can create a sequence in a
- * single command need *only* override this method. Dialects
- * which support sequences but require multiple commands to create
- * a sequence should instead override {@link #getCreateSequenceStrings}.
- *
- * @param sequenceName The name of the sequence
- * @return The sequence creation command
- * @throws MappingException If sequences are not supported.
- */
- protected String getCreateSequenceString(String sequenceName) throws MappingException {
- throw new MappingException( "Dialect does not support sequences" );
- }
-
- /**
- * Overloaded form of {@link #getCreateSequenceString(String)}, additionally
- * taking the initial value and increment size to be applied to the sequence
- * definition.
- * </p>
- * The default definition is to suffix {@link #getCreateSequenceString(String)}
- * with the string: " start with {initialValue} increment by {incrementSize}" where
- * {initialValue} and {incrementSize} are replacement placeholders. Generally
- * dialects should only need to override this method if different key phrases
- * are used to apply the allocation information.
- *
- * @param sequenceName The name of the sequence
- * @param initialValue The initial value to apply to 'create sequence' statement
- * @param incrementSize The increment value to apply to 'create sequence' statement
- * @return The sequence creation command
- * @throws MappingException If sequences are not supported.
- */
- protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException {
- if ( supportsPooledSequences() ) {
- return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize;
- }
- throw new MappingException( "Dialect does not support pooled sequences" );
- }
-
- /**
- * The multiline script used to drop a sequence.
- *
- * @param sequenceName The name of the sequence
- * @return The sequence drop commands
- * @throws MappingException If sequences are not supported.
- */
- public String[] getDropSequenceStrings(String sequenceName) throws MappingException {
- return new String[]{getDropSequenceString( sequenceName )};
- }
-
- /**
- * Typically dialects which support sequences can drop a sequence
- * with a single command. This is convenience form of
- * {@link #getDropSequenceStrings} to help facilitate that.
- * <p/>
- * Dialects which support sequences and can drop a sequence in a
- * single command need *only* override this method. Dialects
- * which support sequences but require multiple commands to drop
- * a sequence should instead override {@link #getDropSequenceStrings}.
- *
- * @param sequenceName The name of the sequence
- * @return The sequence drop commands
- * @throws MappingException If sequences are not supported.
- */
- protected String getDropSequenceString(String sequenceName) throws MappingException {
- throw new MappingException( "Dialect does not support sequences" );
- }
-
- /**
- * Get the select command used retrieve the names of all sequences.
- *
- * @return The select command; or null if sequences are not supported.
- * @see org.hibernate.tool.hbm2ddl.SchemaUpdate
- */
- public String getQuerySequencesString() {
- return null;
- }
-
-
- // GUID support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get the command used to select a GUID from the underlying database.
- * <p/>
- * Optional operation.
- *
- * @return The appropriate command.
- */
- public String getSelectGUIDString() {
- throw new UnsupportedOperationException( "dialect does not support GUIDs" );
- }
-
-
- // limit/offset support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support some form of limiting query results
- * via a SQL clause?
- *
- * @return True if this dialect supports some form of LIMIT.
- */
- public boolean supportsLimit() {
- return false;
- }
-
- /**
- * Does this dialect's LIMIT support (if any) additionally
- * support specifying an offset?
- *
- * @return True if the dialect supports an offset within the limit support.
- */
- public boolean supportsLimitOffset() {
- return supportsLimit();
- }
-
- /**
- * Does this dialect support bind variables (i.e., prepared statememnt
- * parameters) for its limit/offset?
- *
- * @return True if bind variables can be used; false otherwise.
- */
- public boolean supportsVariableLimit() {
- return supportsLimit();
- }
-
- /**
- * ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit.
- * Does this dialect require us to bind the parameters in reverse order?
- *
- * @return true if the correct order is limit, offset
- */
- public boolean bindLimitParametersInReverseOrder() {
- return false;
- }
-
- /**
- * Does the <tt>LIMIT</tt> clause come at the start of the
- * <tt>SELECT</tt> statement, rather than at the end?
- *
- * @return true if limit parameters should come before other parameters
- */
- public boolean bindLimitParametersFirst() {
- return false;
- }
-
- /**
- * Does the <tt>LIMIT</tt> clause take a "maximum" row number instead
- * of a total number of returned rows?
- * <p/>
- * This is easiest understood via an example. Consider you have a table
- * with 20 rows, but you only want to retrieve rows number 11 through 20.
- * Generally, a limit with offset would say that the offset = 11 and the
- * limit = 10 (we only want 10 rows at a time); this is specifying the
- * total number of returned rows. Some dialects require that we instead
- * specify offset = 11 and limit = 20, where 20 is the "last" row we want
- * relative to offset (i.e. total number of rows = 20 - 11 = 9)
- * <p/>
- * So essentially, is limit relative from offset? Or is limit absolute?
- *
- * @return True if limit is relative from offset; false otherwise.
- */
- public boolean useMaxForLimit() {
- return false;
- }
-
- /**
- * Given a limit and an offset, apply the limit clause to the query.
- *
- * @param query The query to which to apply the limit.
- * @param offset The offset of the limit
- * @param limit The limit of the limit ;)
- * @return The modified query statement with the limit applied.
- */
- public String getLimitString(String query, int offset, int limit) {
- return getLimitString( query, offset > 0 );
- }
-
- /**
- * Apply s limit clause to the query.
- * <p/>
- * Typically dialects utilize {@link #supportsVariableLimit() variable}
- * limit caluses when they support limits. Thus, when building the
- * select command we do not actually need to know the limit or the offest
- * since we will just be using placeholders.
- * <p/>
- * Here we do still pass along whether or not an offset was specified
- * so that dialects not supporting offsets can generate proper exceptions.
- * In general, dialects will override one or the other of this method and
- * {@link #getLimitString(String, int, int)}.
- *
- * @param query The query to which to apply the limit.
- * @param hasOffset Is the query requesting an offset?
- * @return the modified SQL
- */
- protected String getLimitString(String query, boolean hasOffset) {
- throw new UnsupportedOperationException( "paged queries not supported" );
- }
-
-
- // lock acquisition support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Get a strategy instance which knows how to acquire a database-level lock
- * of the specified mode for this dialect.
- *
- * @param lockable The persister for the entity to be locked.
- * @param lockMode The type of lock to be acquired.
- * @return The appropriate locking strategy.
- * @since 3.2
- */
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- return new SelectLockingStrategy( lockable, lockMode );
- }
-
- /**
- * Given a lock mode, determine the appropriate for update fragment to use.
- *
- * @param lockMode The lock mode to apply.
- * @return The appropriate for update fragment.
- */
- public String getForUpdateString(LockMode lockMode) {
- if ( lockMode==LockMode.UPGRADE ) {
- return getForUpdateString();
- }
- else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
- return getForUpdateNowaitString();
- }
- else if ( lockMode==LockMode.FORCE ) {
- return getForUpdateNowaitString();
- }
- else {
- return "";
- }
- }
-
- /**
- * Get the string to append to SELECT statements to acquire locks
- * for this dialect.
- *
- * @return The appropriate <tt>FOR UPDATE</tt> clause string.
- */
- public String getForUpdateString() {
- return " for update";
- }
-
- /**
- * Is <tt>FOR UPDATE OF</tt> syntax supported?
- *
- * @return True if the database supports <tt>FOR UPDATE OF</tt> syntax;
- * false otherwise.
- */
- public boolean forUpdateOfColumns() {
- // by default we report no support
- return false;
- }
-
- /**
- * Does this dialect support <tt>FOR UPDATE</tt> in conjunction with
- * outer joined rows?
- *
- * @return True if outer joined rows can be locked via <tt>FOR UPDATE</tt>.
- */
- public boolean supportsOuterJoinForUpdate() {
- return true;
- }
-
- /**
- * Get the <tt>FOR UPDATE OF column_list</tt> fragment appropriate for this
- * dialect given the aliases of the columns to be write locked.
- *
- * @param aliases The columns to be write locked.
- * @return The appropriate <tt>FOR UPDATE OF column_list</tt> clause string.
- */
- public String getForUpdateString(String aliases) {
- // by default we simply return the getForUpdateString() result since
- // the default is to say no support for "FOR UPDATE OF ..."
- return getForUpdateString();
- }
-
- /**
- * Retrieves the <tt>FOR UPDATE NOWAIT</tt> syntax specific to this dialect.
- *
- * @return The appropriate <tt>FOR UPDATE NOWAIT</tt> clause string.
- */
- public String getForUpdateNowaitString() {
- // by default we report no support for NOWAIT lock semantics
- return getForUpdateString();
- }
-
- /**
- * Get the <tt>FOR UPDATE OF column_list NOWAIT</tt> fragment appropriate
- * for this dialect given the aliases of the columns to be write locked.
- *
- * @param aliases The columns to be write locked.
- * @return The appropriate <tt>FOR UPDATE colunm_list NOWAIT</tt> clause string.
- */
- public String getForUpdateNowaitString(String aliases) {
- return getForUpdateString( aliases );
- }
-
- /**
- * Some dialects support an alternative means to <tt>SELECT FOR UPDATE</tt>,
- * whereby a "lock hint" is appends to the table name in the from clause.
- * <p/>
- * contributed by <a href="http://sourceforge.net/users/heschulz">Helge Schulz</a>
- *
- * @param mode The lock mode to apply
- * @param tableName The name of the table to which to apply the lock hint.
- * @return The table with any required lock hints.
- */
- public String appendLockHint(LockMode mode, String tableName) {
- return tableName;
- }
-
- /**
- * Modifies the given SQL by applying the appropriate updates for the specified
- * lock modes and key columns.
- * <p/>
- * The behavior here is that of an ANSI SQL <tt>SELECT FOR UPDATE</tt>. This
- * method is really intended to allow dialects which do not support
- * <tt>SELECT FOR UPDATE</tt> to achieve this in their own fashion.
- *
- * @param sql the SQL string to modify
- * @param aliasedLockModes a map of lock modes indexed by aliased table names.
- * @param keyColumnNames a map of key columns indexed by aliased table names.
- * @return the modified SQL string.
- */
- public String applyLocksToSql(String sql, Map aliasedLockModes, Map keyColumnNames) {
- return sql + new ForUpdateFragment( this, aliasedLockModes, keyColumnNames ).toFragmentString();
- }
-
-
- // table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Command used to create a table.
- *
- * @return The command used to create a table.
- */
- public String getCreateTableString() {
- return "create table";
- }
-
- /**
- * Slight variation on {@link #getCreateTableString}. Here, we have the
- * command used to create a table when there is no primary key and
- * duplicate rows are expected.
- * <p/>
- * Most databases do not care about the distinction; originally added for
- * Teradata support which does care.
- *
- * @return The command used to create a multiset table.
- */
- public String getCreateMultisetTableString() {
- return getCreateTableString();
- }
-
-
- // temporary table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support temporary tables?
- *
- * @return True if temp tables are supported; false otherwise.
- */
- public boolean supportsTemporaryTables() {
- return false;
- }
-
- /**
- * Generate a temporary table name given the bas table.
- *
- * @param baseTableName The table name from which to base the temp table name.
- * @return The generated temp table name.
- */
- public String generateTemporaryTableName(String baseTableName) {
- return "HT_" + baseTableName;
- }
-
- /**
- * Command used to create a temporary table.
- *
- * @return The command used to create a temporary table.
- */
- public String getCreateTemporaryTableString() {
- return "create table";
- }
-
- /**
- * Get any fragments needing to be postfixed to the command for
- * temporary table creation.
- *
- * @return Any required postfix.
- */
- public String getCreateTemporaryTablePostfix() {
- return "";
- }
-
- /**
- * Does the dialect require that temporary table DDL statements occur in
- * isolation from other statements? This would be the case if the creation
- * would cause any current transaction to get committed implicitly.
- * <p/>
- * JDBC defines a standard way to query for this information via the
- * {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()}
- * method. However, that does not distinguish between temporary table
- * DDL and other forms of DDL; MySQL, for example, reports DDL causing a
- * transaction commit via its driver, even though that is not the case for
- * temporary table DDL.
- * <p/>
- * Possible return values and their meanings:<ul>
- * <li>{@link Boolean#TRUE} - Unequivocally, perform the temporary table DDL
- * in isolation.</li>
- * <li>{@link Boolean#FALSE} - Unequivocally, do <b>not</b> perform the
- * temporary table DDL in isolation.</li>
- * <li><i>null</i> - defer to the JDBC driver response in regards to
- * {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()}</li>
- * </ul>
- *
- * @return see the result matrix above.
- */
- public Boolean performTemporaryTableDDLInIsolation() {
- return null;
- }
-
- /**
- * Do we need to drop the temporary table after use?
- *
- * @return True if the table should be dropped.
- */
- public boolean dropTemporaryTableAfterUse() {
- return true;
- }
-
-
- // callable statement support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Registers an OUT parameter which will be returing a
- * {@link java.sql.ResultSet}. How this is accomplished varies greatly
- * from DB to DB, hence its inclusion (along with {@link #getResultSet}) here.
- *
- * @param statement The callable statement.
- * @param position The bind position at which to register the OUT param.
- * @return The number of (contiguous) bind positions used.
- * @throws SQLException Indicates problems registering the OUT param.
- */
- public int registerResultSetOutParameter(CallableStatement statement, int position) throws SQLException {
- throw new UnsupportedOperationException(
- getClass().getName() +
- " does not support resultsets via stored procedures"
- );
- }
-
- /**
- * Given a callable statement previously processed by {@link #registerResultSetOutParameter},
- * extract the {@link java.sql.ResultSet} from the OUT parameter.
- *
- * @param statement The callable statement.
- * @return The extracted result set.
- * @throws SQLException Indicates problems extracting the result set.
- */
- public ResultSet getResultSet(CallableStatement statement) throws SQLException {
- throw new UnsupportedOperationException(
- getClass().getName() +
- " does not support resultsets via stored procedures"
- );
- }
-
- // current timestamp support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support a way to retrieve the database's current
- * timestamp value?
- *
- * @return True if the current timestamp can be retrieved; false otherwise.
- */
- public boolean supportsCurrentTimestampSelection() {
- return false;
- }
-
- /**
- * Should the value returned by {@link #getCurrentTimestampSelectString}
- * be treated as callable. Typically this indicates that JDBC escape
- * sytnax is being used...
- *
- * @return True if the {@link #getCurrentTimestampSelectString} return
- * is callable; false otherwise.
- */
- public boolean isCurrentTimestampSelectStringCallable() {
- throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
- }
-
- /**
- * Retrieve the command used to retrieve the current timestammp from the
- * database.
- *
- * @return The command.
- */
- public String getCurrentTimestampSelectString() {
- throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
- }
-
- /**
- * The name of the database-specific SQL function for retrieving the
- * current timestamp.
- *
- * @return The function name.
- */
- public String getCurrentTimestampSQLFunctionName() {
- // the standard SQL function name is current_timestamp...
- return "current_timestamp";
- }
-
-
- // SQLException support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Build an instance of the SQLExceptionConverter preferred by this dialect for
- * converting SQLExceptions into Hibernate's JDBCException hierarchy. The default
- * Dialect implementation simply returns a converter based on X/Open SQLState codes.
- * <p/>
- * It is strongly recommended that specific Dialect implementations override this
- * method, since interpretation of a SQL error is much more accurate when based on
- * the ErrorCode rather than the SQLState. Unfortunately, the ErrorCode is a vendor-
- * specific approach.
- *
- * @return The Dialect's preferred SQLExceptionConverter.
- */
- public SQLExceptionConverter buildSQLExceptionConverter() {
- // The default SQLExceptionConverter for all dialects is based on SQLState
- // since SQLErrorCode is extremely vendor-specific. Specific Dialects
- // may override to return whatever is most appropriate for that vendor.
- return new SQLStateConverter( getViolatedConstraintNameExtracter() );
- }
-
- private static final ViolatedConstraintNameExtracter EXTRACTER = new ViolatedConstraintNameExtracter() {
- public String extractConstraintName(SQLException sqle) {
- return null;
- }
- };
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
-
- // union subclass support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Given a {@link java.sql.Types} type code, determine an appropriate
- * null value to use in a select clause.
- * <p/>
- * One thing to consider here is that certain databases might
- * require proper casting for the nulls here since the select here
- * will be part of a UNION/UNION ALL.
- *
- * @param sqlType The {@link java.sql.Types} type code.
- * @return The appropriate select clause value fragment.
- */
- public String getSelectClauseNullString(int sqlType) {
- return "null";
- }
-
- /**
- * Does this dialect support UNION ALL, which is generally a faster
- * variant of UNION?
- *
- * @return True if UNION ALL is supported; false otherwise.
- */
- public boolean supportsUnionAll() {
- return false;
- }
-
-
- // miscellaneous support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
- /**
- * Create a {@link org.hibernate.sql.JoinFragment} strategy responsible
- * for handling this dialect's variations in how joins are handled.
- *
- * @return This dialect's {@link org.hibernate.sql.JoinFragment} strategy.
- */
- public JoinFragment createOuterJoinFragment() {
- return new ANSIJoinFragment();
- }
-
- /**
- * Create a {@link org.hibernate.sql.CaseFragment} strategy responsible
- * for handling this dialect's variations in how CASE statements are
- * handled.
- *
- * @return This dialect's {@link org.hibernate.sql.CaseFragment} strategy.
- */
- public CaseFragment createCaseFragment() {
- return new ANSICaseFragment();
- }
-
- /**
- * The fragment used to insert a row without specifying any column values.
- * This is not possible on some databases.
- *
- * @return The appropriate empty values clause.
- */
- public String getNoColumnsInsertString() {
- return "values ( )";
- }
-
- /**
- * The name of the SQL function that transforms a string to
- * lowercase
- *
- * @return The dialect-specific lowercase function.
- */
- public String getLowercaseFunction() {
- return "lower";
- }
-
- /**
- * Meant as a means for end users to affect the select strings being sent
- * to the database and perhaps manipulate them in some fashion.
- * <p/>
- * The recommend approach is to instead use
- * {@link org.hibernate.Interceptor#onPrepareStatement(String)}.
- *
- * @param select The select command
- * @return The mutated select command, or the same as was passed in.
- */
- public String transformSelectString(String select) {
- return select;
- }
-
- /**
- * What is the maximum length Hibernate can use for generated aliases?
- *
- * @return The maximum length.
- */
- public int getMaxAliasLength() {
- return 10;
- }
-
- /**
- * The SQL literal value to which this database maps boolean values.
- *
- * @param bool The boolean value
- * @return The appropriate SQL literal.
- */
- public String toBooleanValueString(boolean bool) {
- return bool ? "1" : "0";
- }
-
-
- // identifier quoting support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * The character specific to this dialect used to begin a quoted identifier.
- *
- * @return The dialect's specific open quote character.
- */
- public char openQuote() {
- return '"';
- }
-
- /**
- * The character specific to this dialect used to close a quoted identifier.
- *
- * @return The dialect's specific close quote character.
- */
- public char closeQuote() {
- return '"';
- }
-
- /**
- * Apply dialect-specific quoting.
- * <p/>
- * By default, the incoming value is checked to see if its first character
- * is the back-tick (`). If so, the dialect specific quoting is applied.
- *
- * @param column The value to be quoted.
- * @return The quoted (or unmodified, if not starting with back-tick) value.
- * @see #openQuote()
- * @see #closeQuote()
- */
- public final String quote(String column) {
- if ( column.charAt( 0 ) == '`' ) {
- return openQuote() + column.substring( 1, column.length() - 1 ) + closeQuote();
- }
- else {
- return column;
- }
- }
-
-
- // DDL support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support the <tt>ALTER TABLE</tt> syntax?
- *
- * @return True if we support altering of tables; false otherwise.
- */
- public boolean hasAlterTable() {
- return true;
- }
-
- /**
- * Do we need to drop constraints before dropping tables in this dialect?
- *
- * @return True if constraints must be dropped prior to dropping
- * the table; false otherwise.
- */
- public boolean dropConstraints() {
- return true;
- }
-
- /**
- * Do we need to qualify index names with the schema name?
- *
- * @return boolean
- */
- public boolean qualifyIndexName() {
- return true;
- }
-
- /**
- * Does this dialect support the <tt>UNIQUE</tt> column syntax?
- *
- * @return boolean
- */
- public boolean supportsUnique() {
- return true;
- }
-
- /**
- * Does this dialect support adding Unique constraints via create and alter table ?
- * @return boolean
- */
- public boolean supportsUniqueConstraintInCreateAlterTable() {
- return true;
- }
-
- /**
- * The syntax used to add a column to a table (optional).
- *
- * @return The "add column" fragment.
- */
- public String getAddColumnString() {
- throw new UnsupportedOperationException( "No add column syntax supported by Dialect" );
- }
-
- public String getDropForeignKeyString() {
- return " drop constraint ";
- }
-
- public String getTableTypeString() {
- // grrr... for differentiation of mysql storage engines
- return "";
- }
-
- /**
- * The syntax used to add a foreign key constraint to a table.
- *
- * @param constraintName The FK constraint name.
- * @param foreignKey The names of the columns comprising the FK
- * @param referencedTable The table referenced by the FK
- * @param primaryKey The explicit columns in the referencedTable referenced
- * by this FK.
- * @param referencesPrimaryKey if false, constraint should be
- * explicit about which column names the constraint refers to
- *
- * @return the "add FK" fragment
- */
- public String getAddForeignKeyConstraintString(
- String constraintName,
- String[] foreignKey,
- String referencedTable,
- String[] primaryKey,
- boolean referencesPrimaryKey) {
- StringBuffer res = new StringBuffer( 30 );
-
- res.append( " add constraint " )
- .append( constraintName )
- .append( " foreign key (" )
- .append( StringHelper.join( ", ", foreignKey ) )
- .append( ") references " )
- .append( referencedTable );
-
- if ( !referencesPrimaryKey ) {
- res.append( " (" )
- .append( StringHelper.join( ", ", primaryKey ) )
- .append( ')' );
- }
-
- return res.toString();
- }
-
- /**
- * The syntax used to add a primary key constraint to a table.
- *
- * @param constraintName The name of the PK constraint.
- * @return The "add PK" fragment
- */
- public String getAddPrimaryKeyConstraintString(String constraintName) {
- return " add constraint " + constraintName + " primary key ";
- }
-
- public boolean hasSelfReferentialForeignKeyBug() {
- return false;
- }
-
- /**
- * The keyword used to specify a nullable column.
- *
- * @return String
- */
- public String getNullColumnString() {
- return "";
- }
-
- public boolean supportsCommentOn() {
- return false;
- }
-
- public String getTableComment(String comment) {
- return "";
- }
-
- public String getColumnComment(String comment) {
- return "";
- }
-
- public boolean supportsIfExistsBeforeTableName() {
- return false;
- }
-
- public boolean supportsIfExistsAfterTableName() {
- return false;
- }
-
- /**
- * Does this dialect support column-level check constraints?
- *
- * @return True if column-level CHECK constraints are supported; false
- * otherwise.
- */
- public boolean supportsColumnCheck() {
- return true;
- }
-
- /**
- * Does this dialect support table-level check constraints?
- *
- * @return True if table-level CHECK constraints are supported; false
- * otherwise.
- */
- public boolean supportsTableCheck() {
- return true;
- }
-
- public boolean supportsCascadeDelete() {
- return true;
- }
-
- public boolean supportsNotNullUnique() {
- return true;
- }
-
- /**
- * Completely optional cascading drop clause
- *
- * @return String
- */
- public String getCascadeConstraintsString() {
- return "";
- }
-
-
- // Informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Does this dialect support empty IN lists?
- * <p/>
- * For example, is [where XYZ in ()] a supported construct?
- *
- * @return True if empty in lists are supported; false otherwise.
- * @since 3.2
- */
- public boolean supportsEmptyInList() {
- return true;
- }
-
- /**
- * Are string comparisons implicitly case insensitive.
- * <p/>
- * In other words, does [where 'XYZ' = 'xyz'] resolve to true?
- *
- * @return True if comparisons are case insensitive.
- * @since 3.2
- */
- public boolean areStringComparisonsCaseInsensitive() {
- return false;
- }
-
- /**
- * Is this dialect known to support what ANSI-SQL terms "row value
- * constructor" syntax; sometimes called tuple syntax.
- * <p/>
- * Basically, does it support syntax like
- * "... where (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".
- *
- * @return True if this SQL dialect is known to support "row value
- * constructor" syntax; false otherwise.
- * @since 3.2
- */
- public boolean supportsRowValueConstructorSyntax() {
- // return false here, as most databases do not properly support this construct...
- return false;
- }
-
- /**
- * If the dialect supports {@link #supportsRowValueConstructorSyntax() row values},
- * does it offer such support in IN lists as well?
- * <p/>
- * For example, "... where (FIRST_NAME, LAST_NAME) IN ( (?, ?), (?, ?) ) ..."
- *
- * @return True if this SQL dialect is known to support "row value
- * constructor" syntax in the IN list; false otherwise.
- * @since 3.2
- */
- public boolean supportsRowValueConstructorSyntaxInInList() {
- return false;
- }
-
- /**
- * Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e.
- * {@link java.sql.PreparedStatement#setBinaryStream}).
- *
- * @return True if BLOBs and CLOBs should be bound using stream operations.
- * @since 3.2
- */
- public boolean useInputStreamToInsertBlob() {
- return true;
- }
-
- /**
- * Does this dialect support parameters within the select clause of
- * INSERT ... SELECT ... statements?
- *
- * @return True if this is supported; false otherwise.
- * @since 3.2
- */
- public boolean supportsParametersInInsertSelect() {
- return true;
- }
-
- /**
- * Does this dialect support asking the result set its positioning
- * information on forward only cursors. Specifically, in the case of
- * scrolling fetches, Hibernate needs to use
- * {@link java.sql.ResultSet#isAfterLast} and
- * {@link java.sql.ResultSet#isBeforeFirst}. Certain drivers do not
- * allow access to these methods for forward only cursors.
- * <p/>
- * NOTE : this is highly driver dependent!
- *
- * @return True if methods like {@link java.sql.ResultSet#isAfterLast} and
- * {@link java.sql.ResultSet#isBeforeFirst} are supported for forward
- * only cursors; false otherwise.
- * @since 3.2
- */
- public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
- return true;
- }
-
- /**
- * Does this dialect support definition of cascade delete constraints
- * which can cause circular chains?
- *
- * @return True if circular cascade delete constraints are supported; false
- * otherwise.
- * @since 3.2
- */
- public boolean supportsCircularCascadeDeleteConstraints() {
- return true;
- }
-
- /**
- * Are subselects supported as the left-hand-side (LHS) of
- * IN-predicates.
- * <p/>
- * In other words, is syntax like "... <subquery> IN (1, 2, 3) ..." supported?
- *
- * @return True if subselects can appear as the LHS of an in-predicate;
- * false otherwise.
- * @since 3.2
- */
- public boolean supportsSubselectAsInPredicateLHS() {
- return true;
- }
-
- /**
- * Expected LOB usage pattern is such that I can perform an insert
- * via prepared statement with a parameter binding for a LOB value
- * without crazy casting to JDBC driver implementation-specific classes...
- * <p/>
- * Part of the trickiness here is the fact that this is largely
- * driver dependent. For example, Oracle (which is notoriously bad with
- * LOB support in their drivers historically) actually does a pretty good
- * job with LOB support as of the 10.2.x versions of their drivers...
- *
- * @return True if normal LOB usage patterns can be used with this driver;
- * false if driver-specific hookiness needs to be applied.
- * @since 3.2
- */
- public boolean supportsExpectedLobUsagePattern() {
- return true;
- }
-
- /**
- * Does the dialect support propogating changes to LOB
- * values back to the database? Talking about mutating the
- * internal value of the locator as opposed to supplying a new
- * locator instance...
- * <p/>
- * For BLOBs, the internal value might be changed by:
- * {@link java.sql.Blob#setBinaryStream},
- * {@link java.sql.Blob#setBytes(long, byte[])},
- * {@link java.sql.Blob#setBytes(long, byte[], int, int)},
- * or {@link java.sql.Blob#truncate(long)}.
- * <p/>
- * For CLOBs, the internal value might be changed by:
- * {@link java.sql.Clob#setAsciiStream(long)},
- * {@link java.sql.Clob#setCharacterStream(long)},
- * {@link java.sql.Clob#setString(long, String)},
- * {@link java.sql.Clob#setString(long, String, int, int)},
- * or {@link java.sql.Clob#truncate(long)}.
- * <p/>
- * NOTE : I do not know the correct answer currently for
- * databases which (1) are not part of the cruise control process
- * or (2) do not {@link #supportsExpectedLobUsagePattern}.
- *
- * @return True if the changes are propogated back to the
- * database; false otherwise.
- * @since 3.2
- */
- public boolean supportsLobValueChangePropogation() {
- return true;
- }
-
- /**
- * Is it supported to materialize a LOB locator outside the transaction in
- * which it was created?
- * <p/>
- * Again, part of the trickiness here is the fact that this is largely
- * driver dependent.
- * <p/>
- * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
- * also support the ability to materialize a LOB outside the owning transaction...
- *
- * @return True if unbounded materialization is supported; false otherwise.
- * @since 3.2
- */
- public boolean supportsUnboundedLobLocatorMaterialization() {
- return true;
- }
-
- /**
- * Does this dialect support referencing the table being mutated in
- * a subquery. The "table being mutated" is the table referenced in
- * an UPDATE or a DELETE query. And so can that table then be
- * referenced in a subquery of said UPDATE/DELETE query.
- * <p/>
- * For example, would the following two syntaxes be supported:<ul>
- * <li>delete from TABLE_A where ID not in ( select ID from TABLE_A )</li>
- * <li>update TABLE_A set NON_ID = 'something' where ID in ( select ID from TABLE_A)</li>
- * </ul>
- *
- * @return True if this dialect allows references the mutating table from
- * a subquery.
- */
- public boolean supportsSubqueryOnMutatingTable() {
- return true;
- }
-
- /**
- * Does the dialect support an exists statement in the select clause?
- *
- * @return True if exists checks are allowed in the select clause; false otherwise.
- */
- public boolean supportsExistsInSelect() {
- return true;
- }
-
- /**
- * For the underlying database, is READ_COMMITTED isolation implemented by
- * forcing readers to wait for write locks to be released?
- *
- * @return True if writers block readers to achieve READ_COMMITTED; false otherwise.
- */
- public boolean doesReadCommittedCauseWritersToBlockReaders() {
- return false;
- }
-
- /**
- * For the underlying database, is REPEATABLE_READ isolation implemented by
- * forcing writers to wait for read locks to be released?
- *
- * @return True if readers block writers to achieve REPEATABLE_READ; false otherwise.
- */
- public boolean doesRepeatableReadCauseReadersToBlockWriters() {
- return false;
- }
-
- /**
- * Does this dialect support using a JDBC bind parameter as an argument
- * to a function or procedure call?
- *
- * @return True if the database supports accepting bind params as args; false otherwise.
- */
- public boolean supportsBindAsCallableArgument() {
- return true;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,1787 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.MappingException;
+import org.hibernate.QueryException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.CastFunction;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.engine.Mapping;
+import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.exception.SQLStateConverter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.id.IdentityGenerator;
+import org.hibernate.id.SequenceGenerator;
+import org.hibernate.id.TableHiLoGenerator;
+import org.hibernate.mapping.Column;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.sql.ANSICaseFragment;
+import org.hibernate.sql.ANSIJoinFragment;
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.ForUpdateFragment;
+import org.hibernate.type.Type;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Represents a dialect of SQL implemented by a particular RDBMS.
+ * Subclasses implement Hibernate compatibility with different systems.<br>
+ * <br>
+ * Subclasses should provide a public default constructor that <tt>register()</tt>
+ * a set of type mappings and default Hibernate properties.<br>
+ * <br>
+ * Subclasses should be immutable.
+ *
+ * @author Gavin King, David Channon
+ */
+public abstract class Dialect {
+
+ private static final Logger log = LoggerFactory.getLogger( Dialect.class );
+
+ public static final String DEFAULT_BATCH_SIZE = "15";
+ public static final String NO_BATCH = "0";
+
+ /**
+ * Characters used for quoting SQL identifiers
+ */
+ public static final String QUOTE = "`\"[";
+ public static final String CLOSED_QUOTE = "`\"]";
+
+
+ // build the map of standard ANSI SQL aggregation functions ~~~~~~~~~~~~~~~
+
+ private static final Map STANDARD_AGGREGATE_FUNCTIONS = new HashMap();
+ static {
+ STANDARD_AGGREGATE_FUNCTIONS.put( "count", new StandardSQLFunction("count") {
+ public Type getReturnType(Type columnType, Mapping mapping) {
+ return Hibernate.LONG;
+ }
+ } );
+
+ STANDARD_AGGREGATE_FUNCTIONS.put( "avg", new StandardSQLFunction("avg") {
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ int[] sqlTypes;
+ try {
+ sqlTypes = columnType.sqlTypes( mapping );
+ }
+ catch ( MappingException me ) {
+ throw new QueryException( me );
+ }
+ if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in avg()" );
+ return Hibernate.DOUBLE;
+ }
+ } );
+
+ STANDARD_AGGREGATE_FUNCTIONS.put( "max", new StandardSQLFunction("max") );
+ STANDARD_AGGREGATE_FUNCTIONS.put( "min", new StandardSQLFunction("min") );
+ STANDARD_AGGREGATE_FUNCTIONS.put( "sum", new StandardSQLFunction("sum") {
+ public Type getReturnType(Type columnType, Mapping mapping) {
+ //pre H3.2 behavior: super.getReturnType(ct, m);
+ int[] sqlTypes;
+ try {
+ sqlTypes = columnType.sqlTypes( mapping );
+ }
+ catch ( MappingException me ) {
+ throw new QueryException( me );
+ }
+ if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in sum()" );
+ int sqlType = sqlTypes[0];
+
+ // First allow the actual type to control the return value. (the actual underlying sqltype could actually be different)
+ if ( columnType == Hibernate.BIG_INTEGER ) {
+ return Hibernate.BIG_INTEGER;
+ }
+ else if ( columnType == Hibernate.BIG_DECIMAL ) {
+ return Hibernate.BIG_DECIMAL;
+ }
+ else if ( columnType == Hibernate.LONG || columnType == Hibernate.SHORT || columnType == Hibernate.INTEGER) {
+ return Hibernate.LONG;
+ }
+ else if ( columnType == Hibernate.FLOAT || columnType == Hibernate.DOUBLE) {
+ return Hibernate.DOUBLE;
+ }
+
+ // finally use the sqltype if == on Hibernate types did not find a match.
+ if ( sqlType == Types.NUMERIC ) {
+ return columnType; //because numeric can be anything
+ }
+ else if ( sqlType == Types.FLOAT || sqlType == Types.DOUBLE || sqlType == Types.DECIMAL || sqlType == Types.REAL) {
+ return Hibernate.DOUBLE;
+ }
+ else if ( sqlType == Types.BIGINT || sqlType == Types.INTEGER || sqlType == Types.SMALLINT || sqlType == Types.TINYINT ) {
+ return Hibernate.LONG;
+ }
+ else {
+ return columnType;
+ }
+ }
+ });
+ }
+
+ private final TypeNames typeNames = new TypeNames();
+ private final TypeNames hibernateTypeNames = new TypeNames();
+
+ private final Properties properties = new Properties();
+ private final Map sqlFunctions = new HashMap();
+ private final Set sqlKeywords = new HashSet();
+
+
+ // constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected Dialect() {
+ log.info( "Using dialect: " + this );
+ sqlFunctions.putAll( STANDARD_AGGREGATE_FUNCTIONS );
+
+ // standard sql92 functions (can be overridden by subclasses)
+ registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1, ?2, ?3)" ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "locate(?1, ?2, ?3)" ) );
+ registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "trim(?1 ?2 ?3 ?4)" ) );
+ registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
+ registerFunction( "bit_length", new StandardSQLFunction( "bit_length", Hibernate.INTEGER ) );
+ registerFunction( "coalesce", new StandardSQLFunction( "coalesce" ) );
+ registerFunction( "nullif", new StandardSQLFunction( "nullif" ) );
+ registerFunction( "abs", new StandardSQLFunction( "abs" ) );
+ registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER) );
+ registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE) );
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "cast", new CastFunction() );
+ registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(?1 ?2 ?3)") );
+
+ //map second/minute/hour/day/month/year to ANSI extract(), override on subclasses
+ registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(second from ?1)") );
+ registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(minute from ?1)") );
+ registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(hour from ?1)") );
+ registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(day from ?1)") );
+ registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(month from ?1)") );
+ registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(year from ?1)") );
+
+ registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as char)") );
+
+ // register hibernate types for default use in scalar sqlquery type auto detection
+ registerHibernateType( Types.BIGINT, Hibernate.BIG_INTEGER.getName() );
+ registerHibernateType( Types.BINARY, Hibernate.BINARY.getName() );
+ registerHibernateType( Types.BIT, Hibernate.BOOLEAN.getName() );
+ registerHibernateType( Types.CHAR, Hibernate.CHARACTER.getName() );
+ registerHibernateType( Types.DATE, Hibernate.DATE.getName() );
+ registerHibernateType( Types.DOUBLE, Hibernate.DOUBLE.getName() );
+ registerHibernateType( Types.FLOAT, Hibernate.FLOAT.getName() );
+ registerHibernateType( Types.INTEGER, Hibernate.INTEGER.getName() );
+ registerHibernateType( Types.SMALLINT, Hibernate.SHORT.getName() );
+ registerHibernateType( Types.TINYINT, Hibernate.BYTE.getName() );
+ registerHibernateType( Types.TIME, Hibernate.TIME.getName() );
+ registerHibernateType( Types.TIMESTAMP, Hibernate.TIMESTAMP.getName() );
+ registerHibernateType( Types.VARCHAR, Hibernate.STRING.getName() );
+ registerHibernateType( Types.VARBINARY, Hibernate.BINARY.getName() );
+ registerHibernateType( Types.NUMERIC, Hibernate.BIG_DECIMAL.getName() );
+ registerHibernateType( Types.DECIMAL, Hibernate.BIG_DECIMAL.getName() );
+ registerHibernateType( Types.BLOB, Hibernate.BLOB.getName() );
+ registerHibernateType( Types.CLOB, Hibernate.CLOB.getName() );
+ registerHibernateType( Types.REAL, Hibernate.FLOAT.getName() );
+ }
+
+ /**
+ * Get an instance of the dialect specified by the current <tt>System</tt> properties.
+ *
+ * @return The specified Dialect
+ * @throws HibernateException If no dialect was specified, or if it could not be instantiated.
+ */
+ public static Dialect getDialect() throws HibernateException {
+ String dialectName = Environment.getProperties().getProperty( Environment.DIALECT );
+ return instantiateDialect( dialectName );
+ }
+
+
+ /**
+ * Get an instance of the dialect specified by the given properties or by
+ * the current <tt>System</tt> properties.
+ *
+ * @param props The properties to use for finding the dialect class to use.
+ * @return The specified Dialect
+ * @throws HibernateException If no dialect was specified, or if it could not be instantiated.
+ */
+ public static Dialect getDialect(Properties props) throws HibernateException {
+ String dialectName = props.getProperty( Environment.DIALECT );
+ if ( dialectName == null ) {
+ return getDialect();
+ }
+ return instantiateDialect( dialectName );
+ }
+
+ private static Dialect instantiateDialect(String dialectName) throws HibernateException {
+ if ( dialectName == null ) {
+ throw new HibernateException( "The dialect was not set. Set the property hibernate.dialect." );
+ }
+ try {
+ return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
+ }
+ catch ( ClassNotFoundException cnfe ) {
+ throw new HibernateException( "Dialect class not found: " + dialectName );
+ }
+ catch ( Exception e ) {
+ throw new HibernateException( "Could not instantiate dialect class", e );
+ }
+ }
+
+ /**
+ * Retrieve a set of default Hibernate properties for this database.
+ *
+ * @return a set of Hibernate properties
+ */
+ public final Properties getDefaultProperties() {
+ return properties;
+ }
+
+ public String toString() {
+ return getClass().getName();
+ }
+
+
+ // database type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Get the name of the database type associated with the given
+ * {@link java.sql.Types} typecode.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @return the database type name
+ * @throws HibernateException If no mapping was specified for that type.
+ */
+ public String getTypeName(int code) throws HibernateException {
+ String result = typeNames.get( code );
+ if ( result == null ) {
+ throw new HibernateException( "No default type mapping for (java.sql.Types) " + code );
+ }
+ return result;
+ }
+
+ /**
+ * Get the name of the database type associated with the given
+ * {@link java.sql.Types} typecode with the given storage specification
+ * parameters.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @param length The datatype length
+ * @param precision The datatype precision
+ * @param scale The datatype scale
+ * @return the database type name
+ * @throws HibernateException If no mapping was specified for that type.
+ */
+ public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
+ String result = typeNames.get( code, length, precision, scale );
+ if ( result == null ) {
+ throw new HibernateException(
+ "No type mapping for java.sql.Types code: " +
+ code +
+ ", length: " +
+ length
+ );
+ }
+ return result;
+ }
+
+ /**
+ * Get the name of the database type appropriate for casting operations
+ * (via the CAST() SQL function) for the given {@link java.sql.Types} typecode.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @return The database type name
+ */
+ public String getCastTypeName(int code) {
+ return getTypeName( code, Column.DEFAULT_LENGTH, Column.DEFAULT_PRECISION, Column.DEFAULT_SCALE );
+ }
+
+ /**
+ * Subclasses register a type name for the given type code and maximum
+ * column length. <tt>$l</tt> in the type name with be replaced by the
+ * column length (if appropriate).
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @param capacity The maximum length of database type
+ * @param name The database type name
+ */
+ protected void registerColumnType(int code, int capacity, String name) {
+ typeNames.put( code, capacity, name );
+ }
+
+ /**
+ * Subclasses register a type name for the given type code. <tt>$l</tt> in
+ * the type name with be replaced by the column length (if appropriate).
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @param name The database type name
+ */
+ protected void registerColumnType(int code, String name) {
+ typeNames.put( code, name );
+ }
+
+
+ // hibernate type mapping support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Get the name of the Hibernate {@link org.hibernate.type.Type} associated with th given
+ * {@link java.sql.Types} typecode.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @return The Hibernate {@link org.hibernate.type.Type} name.
+ * @throws HibernateException If no mapping was specified for that type.
+ */
+ public String getHibernateTypeName(int code) throws HibernateException {
+ String result = hibernateTypeNames.get( code );
+ if ( result == null ) {
+ throw new HibernateException( "No Hibernate type mapping for java.sql.Types code: " + code );
+ }
+ return result;
+ }
+
+ /**
+ * Get the name of the Hibernate {@link org.hibernate.type.Type} associated
+ * with the given {@link java.sql.Types} typecode with the given storage
+ * specification parameters.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @param length The datatype length
+ * @param precision The datatype precision
+ * @param scale The datatype scale
+ * @return The Hibernate {@link org.hibernate.type.Type} name.
+ * @throws HibernateException If no mapping was specified for that type.
+ */
+ public String getHibernateTypeName(int code, int length, int precision, int scale) throws HibernateException {
+ String result = hibernateTypeNames.get( code, length, precision, scale );
+ if ( result == null ) {
+ throw new HibernateException(
+ "No Hibernate type mapping for java.sql.Types code: " +
+ code +
+ ", length: " +
+ length
+ );
+ }
+ return result;
+ }
+
+ /**
+ * Registers a Hibernate {@link org.hibernate.type.Type} name for the given
+ * {@link java.sql.Types} type code and maximum column length.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @param capacity The maximum length of database type
+ * @param name The Hibernate {@link org.hibernate.type.Type} name
+ */
+ protected void registerHibernateType(int code, int capacity, String name) {
+ hibernateTypeNames.put( code, capacity, name);
+ }
+
+ /**
+ * Registers a Hibernate {@link org.hibernate.type.Type} name for the given
+ * {@link java.sql.Types} type code.
+ *
+ * @param code The {@link java.sql.Types} typecode
+ * @param name The Hibernate {@link org.hibernate.type.Type} name
+ */
+ protected void registerHibernateType(int code, String name) {
+ hibernateTypeNames.put( code, name);
+ }
+
+
+ // function support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected void registerFunction(String name, SQLFunction function) {
+ sqlFunctions.put( name, function );
+ }
+
+ /**
+ * Retrieves a map of the dialect's registered fucntions
+ * (functionName => {@link org.hibernate.dialect.function.SQLFunction}).
+ *
+ * @return The map of registered functions.
+ */
+ public final Map getFunctions() {
+ return sqlFunctions;
+ }
+
+
+ // keyword support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected void registerKeyword(String word) {
+ sqlKeywords.add(word);
+ }
+
+ public Set getKeywords() {
+ return sqlKeywords;
+ }
+
+
+ // native identifier generatiion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * The class (which implements {@link org.hibernate.id.IdentifierGenerator})
+ * which acts as this dialects native generation strategy.
+ * <p/>
+ * Comes into play whenever the user specifies the native generator.
+ *
+ * @return The native generator class.
+ */
+ public Class getNativeIdentifierGeneratorClass() {
+ if ( supportsIdentityColumns() ) {
+ return IdentityGenerator.class;
+ }
+ else if ( supportsSequences() ) {
+ return SequenceGenerator.class;
+ }
+ else {
+ return TableHiLoGenerator.class;
+ }
+ }
+
+
+ // IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support identity column key generation?
+ *
+ * @return True if IDENTITY columns are supported; false otherwise.
+ */
+ public boolean supportsIdentityColumns() {
+ return false;
+ }
+
+ /**
+ * Does the dialect support some form of inserting and selecting
+ * the generated IDENTITY value all in the same statement.
+ *
+ * @return True if the dialect supports selecting the just
+ * generated IDENTITY in the insert statement.
+ */
+ public boolean supportsInsertSelectIdentity() {
+ return false;
+ }
+
+ /**
+ * Whether this dialect have an Identity clause added to the data type or a
+ * completely seperate identity data type
+ *
+ * @return boolean
+ */
+ public boolean hasDataTypeInIdentityColumn() {
+ return true;
+ }
+
+ /**
+ * Provided we {@link #supportsInsertSelectIdentity}, then attch the
+ * "select identity" clause to the insert statement.
+ * <p/>
+ * Note, if {@link #supportsInsertSelectIdentity} == false then
+ * the insert-string should be returned without modification.
+ *
+ * @param insertString The insert command
+ * @return The insert command with any necessary identity select
+ * clause attached.
+ */
+ public String appendIdentitySelectToInsert(String insertString) {
+ return insertString;
+ }
+
+ /**
+ * Get the select command to use to retrieve the last generated IDENTITY
+ * value for a particuar table
+ *
+ * @param table The table into which the insert was done
+ * @param column The PK column.
+ * @param type The {@link java.sql.Types} type code.
+ * @return The appropriate select command
+ * @throws MappingException If IDENTITY generation is not supported.
+ */
+ public String getIdentitySelectString(String table, String column, int type) throws MappingException {
+ return getIdentitySelectString();
+ }
+
+ /**
+ * Get the select command to use to retrieve the last generated IDENTITY
+ * value.
+ *
+ * @return The appropriate select command
+ * @throws MappingException If IDENTITY generation is not supported.
+ */
+ protected String getIdentitySelectString() throws MappingException {
+ throw new MappingException( "Dialect does not support identity key generation" );
+ }
+
+ /**
+ * The syntax used during DDL to define a column as being an IDENTITY of
+ * a particular type.
+ *
+ * @param type The {@link java.sql.Types} type code.
+ * @return The appropriate DDL fragment.
+ * @throws MappingException If IDENTITY generation is not supported.
+ */
+ public String getIdentityColumnString(int type) throws MappingException {
+ return getIdentityColumnString();
+ }
+
+ /**
+ * The syntax used during DDL to define a column as being an IDENTITY.
+ *
+ * @return The appropriate DDL fragment.
+ * @throws MappingException If IDENTITY generation is not supported.
+ */
+ protected String getIdentityColumnString() throws MappingException {
+ throw new MappingException( "Dialect does not support identity key generation" );
+ }
+
+ /**
+ * The keyword used to insert a generated value into an identity column (or null).
+ * Need if the dialect does not support inserts that specify no column values.
+ *
+ * @return The appropriate keyword.
+ */
+ public String getIdentityInsertString() {
+ return null;
+ }
+
+
+ // SEQUENCE support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support sequences?
+ *
+ * @return True if sequences supported; false otherwise.
+ */
+ public boolean supportsSequences() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support "pooled" sequences. Not aware of a better
+ * name for this. Essentially can we specify the initial and increment values?
+ *
+ * @return True if such "pooled" sequences are supported; false otherwise.
+ * @see #getCreateSequenceStrings(String, int, int)
+ * @see #getCreateSequenceString(String, int, int)
+ */
+ public boolean supportsPooledSequences() {
+ return false;
+ }
+
+ /**
+ * Generate the appropriate select statement to to retreive the next value
+ * of a sequence.
+ * <p/>
+ * This should be a "stand alone" select statement.
+ *
+ * @param sequenceName the name of the sequence
+ * @return String The "nextval" select string.
+ * @throws MappingException If sequences are not supported.
+ */
+ public String getSequenceNextValString(String sequenceName) throws MappingException {
+ throw new MappingException( "Dialect does not support sequences" );
+ }
+
+ /**
+ * Generate the select expression fragment that will retreive the next
+ * value of a sequence as part of another (typically DML) statement.
+ * <p/>
+ * This differs from {@link #getSequenceNextValString(String)} in that this
+ * should return an expression usable within another statement.
+ *
+ * @param sequenceName the name of the sequence
+ * @return The "nextval" fragment.
+ * @throws MappingException If sequences are not supported.
+ */
+ public String getSelectSequenceNextValString(String sequenceName) throws MappingException {
+ throw new MappingException( "Dialect does not support sequences" );
+ }
+
+ /**
+ * The multiline script used to create a sequence.
+ *
+ * @param sequenceName The name of the sequence
+ * @return The sequence creation commands
+ * @throws MappingException If sequences are not supported.
+ * @deprecated Use {@link #getCreateSequenceString(String, int, int)} instead
+ */
+ public String[] getCreateSequenceStrings(String sequenceName) throws MappingException {
+ return new String[] { getCreateSequenceString( sequenceName ) };
+ }
+
+ /**
+ * An optional multi-line form for databases which {@link #supportsPooledSequences()}.
+ *
+ * @param sequenceName The name of the sequence
+ * @param initialValue The initial value to apply to 'create sequence' statement
+ * @param incrementSize The increment value to apply to 'create sequence' statement
+ * @return The sequence creation commands
+ * @throws MappingException If sequences are not supported.
+ */
+ public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) throws MappingException {
+ return new String[] { getCreateSequenceString( sequenceName, initialValue, incrementSize ) };
+ }
+
+ /**
+ * Typically dialects which support sequences can create a sequence
+ * with a single command. This is convenience form of
+ * {@link #getCreateSequenceStrings} to help facilitate that.
+ * <p/>
+ * Dialects which support sequences and can create a sequence in a
+ * single command need *only* override this method. Dialects
+ * which support sequences but require multiple commands to create
+ * a sequence should instead override {@link #getCreateSequenceStrings}.
+ *
+ * @param sequenceName The name of the sequence
+ * @return The sequence creation command
+ * @throws MappingException If sequences are not supported.
+ */
+ protected String getCreateSequenceString(String sequenceName) throws MappingException {
+ throw new MappingException( "Dialect does not support sequences" );
+ }
+
+ /**
+ * Overloaded form of {@link #getCreateSequenceString(String)}, additionally
+ * taking the initial value and increment size to be applied to the sequence
+ * definition.
+ * </p>
+ * The default definition is to suffix {@link #getCreateSequenceString(String)}
+ * with the string: " start with {initialValue} increment by {incrementSize}" where
+ * {initialValue} and {incrementSize} are replacement placeholders. Generally
+ * dialects should only need to override this method if different key phrases
+ * are used to apply the allocation information.
+ *
+ * @param sequenceName The name of the sequence
+ * @param initialValue The initial value to apply to 'create sequence' statement
+ * @param incrementSize The increment value to apply to 'create sequence' statement
+ * @return The sequence creation command
+ * @throws MappingException If sequences are not supported.
+ */
+ protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException {
+ if ( supportsPooledSequences() ) {
+ return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize;
+ }
+ throw new MappingException( "Dialect does not support pooled sequences" );
+ }
+
+ /**
+ * The multiline script used to drop a sequence.
+ *
+ * @param sequenceName The name of the sequence
+ * @return The sequence drop commands
+ * @throws MappingException If sequences are not supported.
+ */
+ public String[] getDropSequenceStrings(String sequenceName) throws MappingException {
+ return new String[]{getDropSequenceString( sequenceName )};
+ }
+
+ /**
+ * Typically dialects which support sequences can drop a sequence
+ * with a single command. This is convenience form of
+ * {@link #getDropSequenceStrings} to help facilitate that.
+ * <p/>
+ * Dialects which support sequences and can drop a sequence in a
+ * single command need *only* override this method. Dialects
+ * which support sequences but require multiple commands to drop
+ * a sequence should instead override {@link #getDropSequenceStrings}.
+ *
+ * @param sequenceName The name of the sequence
+ * @return The sequence drop commands
+ * @throws MappingException If sequences are not supported.
+ */
+ protected String getDropSequenceString(String sequenceName) throws MappingException {
+ throw new MappingException( "Dialect does not support sequences" );
+ }
+
+ /**
+ * Get the select command used retrieve the names of all sequences.
+ *
+ * @return The select command; or null if sequences are not supported.
+ * @see org.hibernate.tool.hbm2ddl.SchemaUpdate
+ */
+ public String getQuerySequencesString() {
+ return null;
+ }
+
+
+ // GUID support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Get the command used to select a GUID from the underlying database.
+ * <p/>
+ * Optional operation.
+ *
+ * @return The appropriate command.
+ */
+ public String getSelectGUIDString() {
+ throw new UnsupportedOperationException( "dialect does not support GUIDs" );
+ }
+
+
+ // limit/offset support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support some form of limiting query results
+ * via a SQL clause?
+ *
+ * @return True if this dialect supports some form of LIMIT.
+ */
+ public boolean supportsLimit() {
+ return false;
+ }
+
+ /**
+ * Does this dialect's LIMIT support (if any) additionally
+ * support specifying an offset?
+ *
+ * @return True if the dialect supports an offset within the limit support.
+ */
+ public boolean supportsLimitOffset() {
+ return supportsLimit();
+ }
+
+ /**
+ * Does this dialect support bind variables (i.e., prepared statememnt
+ * parameters) for its limit/offset?
+ *
+ * @return True if bind variables can be used; false otherwise.
+ */
+ public boolean supportsVariableLimit() {
+ return supportsLimit();
+ }
+
+ /**
+ * ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit.
+ * Does this dialect require us to bind the parameters in reverse order?
+ *
+ * @return true if the correct order is limit, offset
+ */
+ public boolean bindLimitParametersInReverseOrder() {
+ return false;
+ }
+
+ /**
+ * Does the <tt>LIMIT</tt> clause come at the start of the
+ * <tt>SELECT</tt> statement, rather than at the end?
+ *
+ * @return true if limit parameters should come before other parameters
+ */
+ public boolean bindLimitParametersFirst() {
+ return false;
+ }
+
+ /**
+ * Does the <tt>LIMIT</tt> clause take a "maximum" row number instead
+ * of a total number of returned rows?
+ * <p/>
+ * This is easiest understood via an example. Consider you have a table
+ * with 20 rows, but you only want to retrieve rows number 11 through 20.
+ * Generally, a limit with offset would say that the offset = 11 and the
+ * limit = 10 (we only want 10 rows at a time); this is specifying the
+ * total number of returned rows. Some dialects require that we instead
+ * specify offset = 11 and limit = 20, where 20 is the "last" row we want
+ * relative to offset (i.e. total number of rows = 20 - 11 = 9)
+ * <p/>
+ * So essentially, is limit relative from offset? Or is limit absolute?
+ *
+ * @return True if limit is relative from offset; false otherwise.
+ */
+ public boolean useMaxForLimit() {
+ return false;
+ }
+
+ /**
+ * Given a limit and an offset, apply the limit clause to the query.
+ *
+ * @param query The query to which to apply the limit.
+ * @param offset The offset of the limit
+ * @param limit The limit of the limit ;)
+ * @return The modified query statement with the limit applied.
+ */
+ public String getLimitString(String query, int offset, int limit) {
+ return getLimitString( query, offset > 0 );
+ }
+
+ /**
+ * Apply s limit clause to the query.
+ * <p/>
+ * Typically dialects utilize {@link #supportsVariableLimit() variable}
+ * limit caluses when they support limits. Thus, when building the
+ * select command we do not actually need to know the limit or the offest
+ * since we will just be using placeholders.
+ * <p/>
+ * Here we do still pass along whether or not an offset was specified
+ * so that dialects not supporting offsets can generate proper exceptions.
+ * In general, dialects will override one or the other of this method and
+ * {@link #getLimitString(String, int, int)}.
+ *
+ * @param query The query to which to apply the limit.
+ * @param hasOffset Is the query requesting an offset?
+ * @return the modified SQL
+ */
+ protected String getLimitString(String query, boolean hasOffset) {
+ throw new UnsupportedOperationException( "paged queries not supported" );
+ }
+
+
+ // lock acquisition support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Get a strategy instance which knows how to acquire a database-level lock
+ * of the specified mode for this dialect.
+ *
+ * @param lockable The persister for the entity to be locked.
+ * @param lockMode The type of lock to be acquired.
+ * @return The appropriate locking strategy.
+ * @since 3.2
+ */
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+
+ /**
+ * Given a lock mode, determine the appropriate for update fragment to use.
+ *
+ * @param lockMode The lock mode to apply.
+ * @return The appropriate for update fragment.
+ */
+ public String getForUpdateString(LockMode lockMode) {
+ if ( lockMode==LockMode.UPGRADE ) {
+ return getForUpdateString();
+ }
+ else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
+ return getForUpdateNowaitString();
+ }
+ else if ( lockMode==LockMode.FORCE ) {
+ return getForUpdateNowaitString();
+ }
+ else {
+ return "";
+ }
+ }
+
+ /**
+ * Get the string to append to SELECT statements to acquire locks
+ * for this dialect.
+ *
+ * @return The appropriate <tt>FOR UPDATE</tt> clause string.
+ */
+ public String getForUpdateString() {
+ return " for update";
+ }
+
+ /**
+ * Is <tt>FOR UPDATE OF</tt> syntax supported?
+ *
+ * @return True if the database supports <tt>FOR UPDATE OF</tt> syntax;
+ * false otherwise.
+ */
+ public boolean forUpdateOfColumns() {
+ // by default we report no support
+ return false;
+ }
+
+ /**
+ * Does this dialect support <tt>FOR UPDATE</tt> in conjunction with
+ * outer joined rows?
+ *
+ * @return True if outer joined rows can be locked via <tt>FOR UPDATE</tt>.
+ */
+ public boolean supportsOuterJoinForUpdate() {
+ return true;
+ }
+
+ /**
+ * Get the <tt>FOR UPDATE OF column_list</tt> fragment appropriate for this
+ * dialect given the aliases of the columns to be write locked.
+ *
+ * @param aliases The columns to be write locked.
+ * @return The appropriate <tt>FOR UPDATE OF column_list</tt> clause string.
+ */
+ public String getForUpdateString(String aliases) {
+ // by default we simply return the getForUpdateString() result since
+ // the default is to say no support for "FOR UPDATE OF ..."
+ return getForUpdateString();
+ }
+
+ /**
+ * Retrieves the <tt>FOR UPDATE NOWAIT</tt> syntax specific to this dialect.
+ *
+ * @return The appropriate <tt>FOR UPDATE NOWAIT</tt> clause string.
+ */
+ public String getForUpdateNowaitString() {
+ // by default we report no support for NOWAIT lock semantics
+ return getForUpdateString();
+ }
+
+ /**
+ * Get the <tt>FOR UPDATE OF column_list NOWAIT</tt> fragment appropriate
+ * for this dialect given the aliases of the columns to be write locked.
+ *
+ * @param aliases The columns to be write locked.
+ * @return The appropriate <tt>FOR UPDATE colunm_list NOWAIT</tt> clause string.
+ */
+ public String getForUpdateNowaitString(String aliases) {
+ return getForUpdateString( aliases );
+ }
+
+ /**
+ * Some dialects support an alternative means to <tt>SELECT FOR UPDATE</tt>,
+ * whereby a "lock hint" is appends to the table name in the from clause.
+ * <p/>
+ * contributed by <a href="http://sourceforge.net/users/heschulz">Helge Schulz</a>
+ *
+ * @param mode The lock mode to apply
+ * @param tableName The name of the table to which to apply the lock hint.
+ * @return The table with any required lock hints.
+ */
+ public String appendLockHint(LockMode mode, String tableName) {
+ return tableName;
+ }
+
+ /**
+ * Modifies the given SQL by applying the appropriate updates for the specified
+ * lock modes and key columns.
+ * <p/>
+ * The behavior here is that of an ANSI SQL <tt>SELECT FOR UPDATE</tt>. This
+ * method is really intended to allow dialects which do not support
+ * <tt>SELECT FOR UPDATE</tt> to achieve this in their own fashion.
+ *
+ * @param sql the SQL string to modify
+ * @param aliasedLockModes a map of lock modes indexed by aliased table names.
+ * @param keyColumnNames a map of key columns indexed by aliased table names.
+ * @return the modified SQL string.
+ */
+ public String applyLocksToSql(String sql, Map aliasedLockModes, Map keyColumnNames) {
+ return sql + new ForUpdateFragment( this, aliasedLockModes, keyColumnNames ).toFragmentString();
+ }
+
+
+ // table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Command used to create a table.
+ *
+ * @return The command used to create a table.
+ */
+ public String getCreateTableString() {
+ return "create table";
+ }
+
+ /**
+ * Slight variation on {@link #getCreateTableString}. Here, we have the
+ * command used to create a table when there is no primary key and
+ * duplicate rows are expected.
+ * <p/>
+ * Most databases do not care about the distinction; originally added for
+ * Teradata support which does care.
+ *
+ * @return The command used to create a multiset table.
+ */
+ public String getCreateMultisetTableString() {
+ return getCreateTableString();
+ }
+
+
+ // temporary table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support temporary tables?
+ *
+ * @return True if temp tables are supported; false otherwise.
+ */
+ public boolean supportsTemporaryTables() {
+ return false;
+ }
+
+ /**
+ * Generate a temporary table name given the bas table.
+ *
+ * @param baseTableName The table name from which to base the temp table name.
+ * @return The generated temp table name.
+ */
+ public String generateTemporaryTableName(String baseTableName) {
+ return "HT_" + baseTableName;
+ }
+
+ /**
+ * Command used to create a temporary table.
+ *
+ * @return The command used to create a temporary table.
+ */
+ public String getCreateTemporaryTableString() {
+ return "create table";
+ }
+
+ /**
+ * Get any fragments needing to be postfixed to the command for
+ * temporary table creation.
+ *
+ * @return Any required postfix.
+ */
+ public String getCreateTemporaryTablePostfix() {
+ return "";
+ }
+
+ /**
+ * Does the dialect require that temporary table DDL statements occur in
+ * isolation from other statements? This would be the case if the creation
+ * would cause any current transaction to get committed implicitly.
+ * <p/>
+ * JDBC defines a standard way to query for this information via the
+ * {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()}
+ * method. However, that does not distinguish between temporary table
+ * DDL and other forms of DDL; MySQL, for example, reports DDL causing a
+ * transaction commit via its driver, even though that is not the case for
+ * temporary table DDL.
+ * <p/>
+ * Possible return values and their meanings:<ul>
+ * <li>{@link Boolean#TRUE} - Unequivocally, perform the temporary table DDL
+ * in isolation.</li>
+ * <li>{@link Boolean#FALSE} - Unequivocally, do <b>not</b> perform the
+ * temporary table DDL in isolation.</li>
+ * <li><i>null</i> - defer to the JDBC driver response in regards to
+ * {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()}</li>
+ * </ul>
+ *
+ * @return see the result matrix above.
+ */
+ public Boolean performTemporaryTableDDLInIsolation() {
+ return null;
+ }
+
+ /**
+ * Do we need to drop the temporary table after use?
+ *
+ * @return True if the table should be dropped.
+ */
+ public boolean dropTemporaryTableAfterUse() {
+ return true;
+ }
+
+
+ // callable statement support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Registers an OUT parameter which will be returing a
+ * {@link java.sql.ResultSet}. How this is accomplished varies greatly
+ * from DB to DB, hence its inclusion (along with {@link #getResultSet}) here.
+ *
+ * @param statement The callable statement.
+ * @param position The bind position at which to register the OUT param.
+ * @return The number of (contiguous) bind positions used.
+ * @throws SQLException Indicates problems registering the OUT param.
+ */
+ public int registerResultSetOutParameter(CallableStatement statement, int position) throws SQLException {
+ throw new UnsupportedOperationException(
+ getClass().getName() +
+ " does not support resultsets via stored procedures"
+ );
+ }
+
+ /**
+ * Given a callable statement previously processed by {@link #registerResultSetOutParameter},
+ * extract the {@link java.sql.ResultSet} from the OUT parameter.
+ *
+ * @param statement The callable statement.
+ * @return The extracted result set.
+ * @throws SQLException Indicates problems extracting the result set.
+ */
+ public ResultSet getResultSet(CallableStatement statement) throws SQLException {
+ throw new UnsupportedOperationException(
+ getClass().getName() +
+ " does not support resultsets via stored procedures"
+ );
+ }
+
+ // current timestamp support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support a way to retrieve the database's current
+ * timestamp value?
+ *
+ * @return True if the current timestamp can be retrieved; false otherwise.
+ */
+ public boolean supportsCurrentTimestampSelection() {
+ return false;
+ }
+
+ /**
+ * Should the value returned by {@link #getCurrentTimestampSelectString}
+ * be treated as callable. Typically this indicates that JDBC escape
+ * sytnax is being used...
+ *
+ * @return True if the {@link #getCurrentTimestampSelectString} return
+ * is callable; false otherwise.
+ */
+ public boolean isCurrentTimestampSelectStringCallable() {
+ throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
+ }
+
+ /**
+ * Retrieve the command used to retrieve the current timestammp from the
+ * database.
+ *
+ * @return The command.
+ */
+ public String getCurrentTimestampSelectString() {
+ throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
+ }
+
+ /**
+ * The name of the database-specific SQL function for retrieving the
+ * current timestamp.
+ *
+ * @return The function name.
+ */
+ public String getCurrentTimestampSQLFunctionName() {
+ // the standard SQL function name is current_timestamp...
+ return "current_timestamp";
+ }
+
+
+ // SQLException support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Build an instance of the SQLExceptionConverter preferred by this dialect for
+ * converting SQLExceptions into Hibernate's JDBCException hierarchy. The default
+ * Dialect implementation simply returns a converter based on X/Open SQLState codes.
+ * <p/>
+ * It is strongly recommended that specific Dialect implementations override this
+ * method, since interpretation of a SQL error is much more accurate when based on
+ * the ErrorCode rather than the SQLState. Unfortunately, the ErrorCode is a vendor-
+ * specific approach.
+ *
+ * @return The Dialect's preferred SQLExceptionConverter.
+ */
+ public SQLExceptionConverter buildSQLExceptionConverter() {
+ // The default SQLExceptionConverter for all dialects is based on SQLState
+ // since SQLErrorCode is extremely vendor-specific. Specific Dialects
+ // may override to return whatever is most appropriate for that vendor.
+ return new SQLStateConverter( getViolatedConstraintNameExtracter() );
+ }
+
+ private static final ViolatedConstraintNameExtracter EXTRACTER = new ViolatedConstraintNameExtracter() {
+ public String extractConstraintName(SQLException sqle) {
+ return null;
+ }
+ };
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+
+ // union subclass support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Given a {@link java.sql.Types} type code, determine an appropriate
+ * null value to use in a select clause.
+ * <p/>
+ * One thing to consider here is that certain databases might
+ * require proper casting for the nulls here since the select here
+ * will be part of a UNION/UNION ALL.
+ *
+ * @param sqlType The {@link java.sql.Types} type code.
+ * @return The appropriate select clause value fragment.
+ */
+ public String getSelectClauseNullString(int sqlType) {
+ return "null";
+ }
+
+ /**
+ * Does this dialect support UNION ALL, which is generally a faster
+ * variant of UNION?
+ *
+ * @return True if UNION ALL is supported; false otherwise.
+ */
+ public boolean supportsUnionAll() {
+ return false;
+ }
+
+
+ // miscellaneous support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+ /**
+ * Create a {@link org.hibernate.sql.JoinFragment} strategy responsible
+ * for handling this dialect's variations in how joins are handled.
+ *
+ * @return This dialect's {@link org.hibernate.sql.JoinFragment} strategy.
+ */
+ public JoinFragment createOuterJoinFragment() {
+ return new ANSIJoinFragment();
+ }
+
+ /**
+ * Create a {@link org.hibernate.sql.CaseFragment} strategy responsible
+ * for handling this dialect's variations in how CASE statements are
+ * handled.
+ *
+ * @return This dialect's {@link org.hibernate.sql.CaseFragment} strategy.
+ */
+ public CaseFragment createCaseFragment() {
+ return new ANSICaseFragment();
+ }
+
+ /**
+ * The fragment used to insert a row without specifying any column values.
+ * This is not possible on some databases.
+ *
+ * @return The appropriate empty values clause.
+ */
+ public String getNoColumnsInsertString() {
+ return "values ( )";
+ }
+
+ /**
+ * The name of the SQL function that transforms a string to
+ * lowercase
+ *
+ * @return The dialect-specific lowercase function.
+ */
+ public String getLowercaseFunction() {
+ return "lower";
+ }
+
+ /**
+ * Meant as a means for end users to affect the select strings being sent
+ * to the database and perhaps manipulate them in some fashion.
+ * <p/>
+ * The recommend approach is to instead use
+ * {@link org.hibernate.Interceptor#onPrepareStatement(String)}.
+ *
+ * @param select The select command
+ * @return The mutated select command, or the same as was passed in.
+ */
+ public String transformSelectString(String select) {
+ return select;
+ }
+
+ /**
+ * What is the maximum length Hibernate can use for generated aliases?
+ *
+ * @return The maximum length.
+ */
+ public int getMaxAliasLength() {
+ return 10;
+ }
+
+ /**
+ * The SQL literal value to which this database maps boolean values.
+ *
+ * @param bool The boolean value
+ * @return The appropriate SQL literal.
+ */
+ public String toBooleanValueString(boolean bool) {
+ return bool ? "1" : "0";
+ }
+
+
+ // identifier quoting support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * The character specific to this dialect used to begin a quoted identifier.
+ *
+ * @return The dialect's specific open quote character.
+ */
+ public char openQuote() {
+ return '"';
+ }
+
+ /**
+ * The character specific to this dialect used to close a quoted identifier.
+ *
+ * @return The dialect's specific close quote character.
+ */
+ public char closeQuote() {
+ return '"';
+ }
+
+ /**
+ * Apply dialect-specific quoting.
+ * <p/>
+ * By default, the incoming value is checked to see if its first character
+ * is the back-tick (`). If so, the dialect specific quoting is applied.
+ *
+ * @param column The value to be quoted.
+ * @return The quoted (or unmodified, if not starting with back-tick) value.
+ * @see #openQuote()
+ * @see #closeQuote()
+ */
+ public final String quote(String column) {
+ if ( column.charAt( 0 ) == '`' ) {
+ return openQuote() + column.substring( 1, column.length() - 1 ) + closeQuote();
+ }
+ else {
+ return column;
+ }
+ }
+
+
+ // DDL support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support the <tt>ALTER TABLE</tt> syntax?
+ *
+ * @return True if we support altering of tables; false otherwise.
+ */
+ public boolean hasAlterTable() {
+ return true;
+ }
+
+ /**
+ * Do we need to drop constraints before dropping tables in this dialect?
+ *
+ * @return True if constraints must be dropped prior to dropping
+ * the table; false otherwise.
+ */
+ public boolean dropConstraints() {
+ return true;
+ }
+
+ /**
+ * Do we need to qualify index names with the schema name?
+ *
+ * @return boolean
+ */
+ public boolean qualifyIndexName() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support the <tt>UNIQUE</tt> column syntax?
+ *
+ * @return boolean
+ */
+ public boolean supportsUnique() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support adding Unique constraints via create and alter table ?
+ * @return boolean
+ */
+ public boolean supportsUniqueConstraintInCreateAlterTable() {
+ return true;
+ }
+
+ /**
+ * The syntax used to add a column to a table (optional).
+ *
+ * @return The "add column" fragment.
+ */
+ public String getAddColumnString() {
+ throw new UnsupportedOperationException( "No add column syntax supported by Dialect" );
+ }
+
+ public String getDropForeignKeyString() {
+ return " drop constraint ";
+ }
+
+ public String getTableTypeString() {
+ // grrr... for differentiation of mysql storage engines
+ return "";
+ }
+
+ /**
+ * The syntax used to add a foreign key constraint to a table.
+ *
+ * @param constraintName The FK constraint name.
+ * @param foreignKey The names of the columns comprising the FK
+ * @param referencedTable The table referenced by the FK
+ * @param primaryKey The explicit columns in the referencedTable referenced
+ * by this FK.
+ * @param referencesPrimaryKey if false, constraint should be
+ * explicit about which column names the constraint refers to
+ *
+ * @return the "add FK" fragment
+ */
+ public String getAddForeignKeyConstraintString(
+ String constraintName,
+ String[] foreignKey,
+ String referencedTable,
+ String[] primaryKey,
+ boolean referencesPrimaryKey) {
+ StringBuffer res = new StringBuffer( 30 );
+
+ res.append( " add constraint " )
+ .append( constraintName )
+ .append( " foreign key (" )
+ .append( StringHelper.join( ", ", foreignKey ) )
+ .append( ") references " )
+ .append( referencedTable );
+
+ if ( !referencesPrimaryKey ) {
+ res.append( " (" )
+ .append( StringHelper.join( ", ", primaryKey ) )
+ .append( ')' );
+ }
+
+ return res.toString();
+ }
+
+ /**
+ * The syntax used to add a primary key constraint to a table.
+ *
+ * @param constraintName The name of the PK constraint.
+ * @return The "add PK" fragment
+ */
+ public String getAddPrimaryKeyConstraintString(String constraintName) {
+ return " add constraint " + constraintName + " primary key ";
+ }
+
+ public boolean hasSelfReferentialForeignKeyBug() {
+ return false;
+ }
+
+ /**
+ * The keyword used to specify a nullable column.
+ *
+ * @return String
+ */
+ public String getNullColumnString() {
+ return "";
+ }
+
+ public boolean supportsCommentOn() {
+ return false;
+ }
+
+ public String getTableComment(String comment) {
+ return "";
+ }
+
+ public String getColumnComment(String comment) {
+ return "";
+ }
+
+ public boolean supportsIfExistsBeforeTableName() {
+ return false;
+ }
+
+ public boolean supportsIfExistsAfterTableName() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support column-level check constraints?
+ *
+ * @return True if column-level CHECK constraints are supported; false
+ * otherwise.
+ */
+ public boolean supportsColumnCheck() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support table-level check constraints?
+ *
+ * @return True if table-level CHECK constraints are supported; false
+ * otherwise.
+ */
+ public boolean supportsTableCheck() {
+ return true;
+ }
+
+ public boolean supportsCascadeDelete() {
+ return true;
+ }
+
+ public boolean supportsNotNullUnique() {
+ return true;
+ }
+
+ /**
+ * Completely optional cascading drop clause
+ *
+ * @return String
+ */
+ public String getCascadeConstraintsString() {
+ return "";
+ }
+
+
+ // Informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Does this dialect support empty IN lists?
+ * <p/>
+ * For example, is [where XYZ in ()] a supported construct?
+ *
+ * @return True if empty in lists are supported; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsEmptyInList() {
+ return true;
+ }
+
+ /**
+ * Are string comparisons implicitly case insensitive.
+ * <p/>
+ * In other words, does [where 'XYZ' = 'xyz'] resolve to true?
+ *
+ * @return True if comparisons are case insensitive.
+ * @since 3.2
+ */
+ public boolean areStringComparisonsCaseInsensitive() {
+ return false;
+ }
+
+ /**
+ * Is this dialect known to support what ANSI-SQL terms "row value
+ * constructor" syntax; sometimes called tuple syntax.
+ * <p/>
+ * Basically, does it support syntax like
+ * "... where (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".
+ *
+ * @return True if this SQL dialect is known to support "row value
+ * constructor" syntax; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsRowValueConstructorSyntax() {
+ // return false here, as most databases do not properly support this construct...
+ return false;
+ }
+
+ /**
+ * If the dialect supports {@link #supportsRowValueConstructorSyntax() row values},
+ * does it offer such support in IN lists as well?
+ * <p/>
+ * For example, "... where (FIRST_NAME, LAST_NAME) IN ( (?, ?), (?, ?) ) ..."
+ *
+ * @return True if this SQL dialect is known to support "row value
+ * constructor" syntax in the IN list; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsRowValueConstructorSyntaxInInList() {
+ return false;
+ }
+
+ /**
+ * Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e.
+ * {@link java.sql.PreparedStatement#setBinaryStream}).
+ *
+ * @return True if BLOBs and CLOBs should be bound using stream operations.
+ * @since 3.2
+ */
+ public boolean useInputStreamToInsertBlob() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support parameters within the select clause of
+ * INSERT ... SELECT ... statements?
+ *
+ * @return True if this is supported; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsParametersInInsertSelect() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support asking the result set its positioning
+ * information on forward only cursors. Specifically, in the case of
+ * scrolling fetches, Hibernate needs to use
+ * {@link java.sql.ResultSet#isAfterLast} and
+ * {@link java.sql.ResultSet#isBeforeFirst}. Certain drivers do not
+ * allow access to these methods for forward only cursors.
+ * <p/>
+ * NOTE : this is highly driver dependent!
+ *
+ * @return True if methods like {@link java.sql.ResultSet#isAfterLast} and
+ * {@link java.sql.ResultSet#isBeforeFirst} are supported for forward
+ * only cursors; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support definition of cascade delete constraints
+ * which can cause circular chains?
+ *
+ * @return True if circular cascade delete constraints are supported; false
+ * otherwise.
+ * @since 3.2
+ */
+ public boolean supportsCircularCascadeDeleteConstraints() {
+ return true;
+ }
+
+ /**
+ * Are subselects supported as the left-hand-side (LHS) of
+ * IN-predicates.
+ * <p/>
+ * In other words, is syntax like "... <subquery> IN (1, 2, 3) ..." supported?
+ *
+ * @return True if subselects can appear as the LHS of an in-predicate;
+ * false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsSubselectAsInPredicateLHS() {
+ return true;
+ }
+
+ /**
+ * Expected LOB usage pattern is such that I can perform an insert
+ * via prepared statement with a parameter binding for a LOB value
+ * without crazy casting to JDBC driver implementation-specific classes...
+ * <p/>
+ * Part of the trickiness here is the fact that this is largely
+ * driver dependent. For example, Oracle (which is notoriously bad with
+ * LOB support in their drivers historically) actually does a pretty good
+ * job with LOB support as of the 10.2.x versions of their drivers...
+ *
+ * @return True if normal LOB usage patterns can be used with this driver;
+ * false if driver-specific hookiness needs to be applied.
+ * @since 3.2
+ */
+ public boolean supportsExpectedLobUsagePattern() {
+ return true;
+ }
+
+ /**
+ * Does the dialect support propogating changes to LOB
+ * values back to the database? Talking about mutating the
+ * internal value of the locator as opposed to supplying a new
+ * locator instance...
+ * <p/>
+ * For BLOBs, the internal value might be changed by:
+ * {@link java.sql.Blob#setBinaryStream},
+ * {@link java.sql.Blob#setBytes(long, byte[])},
+ * {@link java.sql.Blob#setBytes(long, byte[], int, int)},
+ * or {@link java.sql.Blob#truncate(long)}.
+ * <p/>
+ * For CLOBs, the internal value might be changed by:
+ * {@link java.sql.Clob#setAsciiStream(long)},
+ * {@link java.sql.Clob#setCharacterStream(long)},
+ * {@link java.sql.Clob#setString(long, String)},
+ * {@link java.sql.Clob#setString(long, String, int, int)},
+ * or {@link java.sql.Clob#truncate(long)}.
+ * <p/>
+ * NOTE : I do not know the correct answer currently for
+ * databases which (1) are not part of the cruise control process
+ * or (2) do not {@link #supportsExpectedLobUsagePattern}.
+ *
+ * @return True if the changes are propogated back to the
+ * database; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsLobValueChangePropogation() {
+ return true;
+ }
+
+ /**
+ * Is it supported to materialize a LOB locator outside the transaction in
+ * which it was created?
+ * <p/>
+ * Again, part of the trickiness here is the fact that this is largely
+ * driver dependent.
+ * <p/>
+ * NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
+ * also support the ability to materialize a LOB outside the owning transaction...
+ *
+ * @return True if unbounded materialization is supported; false otherwise.
+ * @since 3.2
+ */
+ public boolean supportsUnboundedLobLocatorMaterialization() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support referencing the table being mutated in
+ * a subquery. The "table being mutated" is the table referenced in
+ * an UPDATE or a DELETE query. And so can that table then be
+ * referenced in a subquery of said UPDATE/DELETE query.
+ * <p/>
+ * For example, would the following two syntaxes be supported:<ul>
+ * <li>delete from TABLE_A where ID not in ( select ID from TABLE_A )</li>
+ * <li>update TABLE_A set NON_ID = 'something' where ID in ( select ID from TABLE_A)</li>
+ * </ul>
+ *
+ * @return True if this dialect allows references the mutating table from
+ * a subquery.
+ */
+ public boolean supportsSubqueryOnMutatingTable() {
+ return true;
+ }
+
+ /**
+ * Does the dialect support an exists statement in the select clause?
+ *
+ * @return True if exists checks are allowed in the select clause; false otherwise.
+ */
+ public boolean supportsExistsInSelect() {
+ return true;
+ }
+
+ /**
+ * For the underlying database, is READ_COMMITTED isolation implemented by
+ * forcing readers to wait for write locks to be released?
+ *
+ * @return True if writers block readers to achieve READ_COMMITTED; false otherwise.
+ */
+ public boolean doesReadCommittedCauseWritersToBlockReaders() {
+ return false;
+ }
+
+ /**
+ * For the underlying database, is REPEATABLE_READ isolation implemented by
+ * forcing writers to wait for read locks to be released?
+ *
+ * @return True if readers block writers to achieve REPEATABLE_READ; false otherwise.
+ */
+ public boolean doesRepeatableReadCauseReadersToBlockWriters() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support using a JDBC bind parameter as an argument
+ * to a function or procedure call?
+ *
+ * @return True if the database supports accepting bind params as args; false otherwise.
+ */
+ public boolean supportsBindAsCallableArgument() {
+ return true;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/DialectFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,156 +0,0 @@
-// $Id: DialectFactory.java 9789 2006-04-25 17:06:55Z epbernard $
-package org.hibernate.dialect;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * A factory for generating Dialect instances.
- *
- * @author Steve Ebersole
- */
-public class DialectFactory {
-
- /**
- * Builds an appropriate Dialect instance.
- * <p/>
- * If a dialect is explicitly named in the incoming properties, it is used. Otherwise, the database name and version
- * (obtained from connection metadata) are used to make the dertemination.
- * <p/>
- * An exception is thrown if a dialect was not explicitly set and the database name is not known.
- *
- * @param props The configuration properties.
- * @param databaseName The name of the database product (obtained from metadata).
- * @param databaseMajorVersion The major version of the database product (obtained from metadata).
- *
- * @return The appropriate dialect.
- *
- * @throws HibernateException No dialect specified and database name not known.
- */
- public static Dialect buildDialect(Properties props, String databaseName, int databaseMajorVersion)
- throws HibernateException {
- String dialectName = props.getProperty( Environment.DIALECT );
- if ( dialectName == null ) {
- return determineDialect( databaseName, databaseMajorVersion );
- }
- else {
- return buildDialect( dialectName );
- }
- }
-
- /**
- * Determine the appropriate Dialect to use given the database product name
- * and major version.
- *
- * @param databaseName The name of the database product (obtained from metadata).
- * @param databaseMajorVersion The major version of the database product (obtained from metadata).
- *
- * @return An appropriate dialect instance.
- */
- public static Dialect determineDialect(String databaseName, int databaseMajorVersion) {
- if ( databaseName == null ) {
- throw new HibernateException( "Hibernate Dialect must be explicitly set" );
- }
-
- DatabaseDialectMapper mapper = ( DatabaseDialectMapper ) MAPPERS.get( databaseName );
- if ( mapper == null ) {
- throw new HibernateException( "Hibernate Dialect must be explicitly set for database: " + databaseName );
- }
-
- String dialectName = mapper.getDialectClass( databaseMajorVersion );
- return buildDialect( dialectName );
- }
-
- /**
- * Returns a dialect instance given the name of the class to use.
- *
- * @param dialectName The name of the dialect class.
- *
- * @return The dialect instance.
- */
- public static Dialect buildDialect(String dialectName) {
- try {
- return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
- }
- catch ( ClassNotFoundException cnfe ) {
- throw new HibernateException( "Dialect class not found: " + dialectName );
- }
- catch ( Exception e ) {
- throw new HibernateException( "Could not instantiate dialect class", e );
- }
- }
-
- /**
- * For a given database product name, instances of
- * DatabaseDialectMapper know which Dialect to use for different versions.
- */
- public static interface DatabaseDialectMapper {
- public String getDialectClass(int majorVersion);
- }
-
- /**
- * A simple DatabaseDialectMapper for dialects which are independent
- * of the underlying database product version.
- */
- public static class VersionInsensitiveMapper implements DatabaseDialectMapper {
- private String dialectClassName;
-
- public VersionInsensitiveMapper(String dialectClassName) {
- this.dialectClassName = dialectClassName;
- }
-
- public String getDialectClass(int majorVersion) {
- return dialectClassName;
- }
- }
-
- // TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
- private static final Map MAPPERS = new HashMap();
- static {
- // detectors...
- MAPPERS.put( "HSQL Database Engine", new VersionInsensitiveMapper( "org.hibernate.dialect.HSQLDialect" ) );
- MAPPERS.put( "H2", new VersionInsensitiveMapper( "org.hibernate.dialect.H2Dialect" ) );
- MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.hibernate.dialect.MySQLDialect" ) );
- MAPPERS.put( "PostgreSQL", new VersionInsensitiveMapper( "org.hibernate.dialect.PostgreSQLDialect" ) );
- MAPPERS.put( "Apache Derby", new VersionInsensitiveMapper( "org.hibernate.dialect.DerbyDialect" ) );
-
- MAPPERS.put( "Ingres", new VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect" ) );
- MAPPERS.put( "ingres", new VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect" ) );
- MAPPERS.put( "INGRES", new VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect" ) );
-
- MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
- MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
- MAPPERS.put( "Sybase SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
- MAPPERS.put( "Adaptive Server Enterprise", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
-
- MAPPERS.put( "Informix Dynamic Server", new VersionInsensitiveMapper( "org.hibernate.dialect.InformixDialect" ) );
-
- // thanks goodness for "universal" databases...
- MAPPERS.put( "DB2/NT", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
- MAPPERS.put( "DB2/LINUX", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
- MAPPERS.put( "DB2/6000", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
- MAPPERS.put( "DB2/HPUX", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
- MAPPERS.put( "DB2/SUN", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
- MAPPERS.put( "DB2/LINUX390", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
- MAPPERS.put( "DB2/AIX64", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
-
- MAPPERS.put(
- "Oracle",
- new DatabaseDialectMapper() {
- public String getDialectClass(int majorVersion) {
- switch ( majorVersion ) {
- case 8: return Oracle8iDialect.class.getName();
- case 9: return Oracle9iDialect.class.getName();
- case 10: return Oracle10gDialect.class.getName();
- default: throw new HibernateException( "unknown Oracle major version [" + majorVersion + "]" );
- }
- }
- }
- );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/DialectFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/DialectFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,179 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * A factory for generating Dialect instances.
+ *
+ * @author Steve Ebersole
+ */
+public class DialectFactory {
+
+ /**
+ * Builds an appropriate Dialect instance.
+ * <p/>
+ * If a dialect is explicitly named in the incoming properties, it is used. Otherwise, the database name and version
+ * (obtained from connection metadata) are used to make the dertemination.
+ * <p/>
+ * An exception is thrown if a dialect was not explicitly set and the database name is not known.
+ *
+ * @param props The configuration properties.
+ * @param databaseName The name of the database product (obtained from metadata).
+ * @param databaseMajorVersion The major version of the database product (obtained from metadata).
+ *
+ * @return The appropriate dialect.
+ *
+ * @throws HibernateException No dialect specified and database name not known.
+ */
+ public static Dialect buildDialect(Properties props, String databaseName, int databaseMajorVersion)
+ throws HibernateException {
+ String dialectName = props.getProperty( Environment.DIALECT );
+ if ( dialectName == null ) {
+ return determineDialect( databaseName, databaseMajorVersion );
+ }
+ else {
+ return buildDialect( dialectName );
+ }
+ }
+
+ /**
+ * Determine the appropriate Dialect to use given the database product name
+ * and major version.
+ *
+ * @param databaseName The name of the database product (obtained from metadata).
+ * @param databaseMajorVersion The major version of the database product (obtained from metadata).
+ *
+ * @return An appropriate dialect instance.
+ */
+ public static Dialect determineDialect(String databaseName, int databaseMajorVersion) {
+ if ( databaseName == null ) {
+ throw new HibernateException( "Hibernate Dialect must be explicitly set" );
+ }
+
+ DatabaseDialectMapper mapper = ( DatabaseDialectMapper ) MAPPERS.get( databaseName );
+ if ( mapper == null ) {
+ throw new HibernateException( "Hibernate Dialect must be explicitly set for database: " + databaseName );
+ }
+
+ String dialectName = mapper.getDialectClass( databaseMajorVersion );
+ return buildDialect( dialectName );
+ }
+
+ /**
+ * Returns a dialect instance given the name of the class to use.
+ *
+ * @param dialectName The name of the dialect class.
+ *
+ * @return The dialect instance.
+ */
+ public static Dialect buildDialect(String dialectName) {
+ try {
+ return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
+ }
+ catch ( ClassNotFoundException cnfe ) {
+ throw new HibernateException( "Dialect class not found: " + dialectName );
+ }
+ catch ( Exception e ) {
+ throw new HibernateException( "Could not instantiate dialect class", e );
+ }
+ }
+
+ /**
+ * For a given database product name, instances of
+ * DatabaseDialectMapper know which Dialect to use for different versions.
+ */
+ public static interface DatabaseDialectMapper {
+ public String getDialectClass(int majorVersion);
+ }
+
+ /**
+ * A simple DatabaseDialectMapper for dialects which are independent
+ * of the underlying database product version.
+ */
+ public static class VersionInsensitiveMapper implements DatabaseDialectMapper {
+ private String dialectClassName;
+
+ public VersionInsensitiveMapper(String dialectClassName) {
+ this.dialectClassName = dialectClassName;
+ }
+
+ public String getDialectClass(int majorVersion) {
+ return dialectClassName;
+ }
+ }
+
+ // TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place
+ private static final Map MAPPERS = new HashMap();
+ static {
+ // detectors...
+ MAPPERS.put( "HSQL Database Engine", new VersionInsensitiveMapper( "org.hibernate.dialect.HSQLDialect" ) );
+ MAPPERS.put( "H2", new VersionInsensitiveMapper( "org.hibernate.dialect.H2Dialect" ) );
+ MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.hibernate.dialect.MySQLDialect" ) );
+ MAPPERS.put( "PostgreSQL", new VersionInsensitiveMapper( "org.hibernate.dialect.PostgreSQLDialect" ) );
+ MAPPERS.put( "Apache Derby", new VersionInsensitiveMapper( "org.hibernate.dialect.DerbyDialect" ) );
+
+ MAPPERS.put( "Ingres", new VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect" ) );
+ MAPPERS.put( "ingres", new VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect" ) );
+ MAPPERS.put( "INGRES", new VersionInsensitiveMapper( "org.hibernate.dialect.IngresDialect" ) );
+
+ MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
+ MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SQLServerDialect" ) );
+ MAPPERS.put( "Sybase SQL Server", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
+ MAPPERS.put( "Adaptive Server Enterprise", new VersionInsensitiveMapper( "org.hibernate.dialect.SybaseDialect" ) );
+
+ MAPPERS.put( "Informix Dynamic Server", new VersionInsensitiveMapper( "org.hibernate.dialect.InformixDialect" ) );
+
+ // thanks goodness for "universal" databases...
+ MAPPERS.put( "DB2/NT", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/LINUX", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/6000", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/HPUX", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/SUN", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/LINUX390", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+ MAPPERS.put( "DB2/AIX64", new VersionInsensitiveMapper( "org.hibernate.dialect.DB2Dialect" ) );
+
+ MAPPERS.put(
+ "Oracle",
+ new DatabaseDialectMapper() {
+ public String getDialectClass(int majorVersion) {
+ switch ( majorVersion ) {
+ case 8: return Oracle8iDialect.class.getName();
+ case 9: return Oracle9iDialect.class.getName();
+ case 10: return Oracle10gDialect.class.getName();
+ default: throw new HibernateException( "unknown Oracle major version [" + majorVersion + "]" );
+ }
+ }
+ }
+ );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,29 +0,0 @@
-//$Id: FirebirdDialect.java 4202 2004-08-09 06:38:52Z oneovthafew $
-package org.hibernate.dialect;
-
-/**
- * An SQL dialect for Firebird.
- * @author Reha CENANI
- */
-public class FirebirdDialect extends InterbaseDialect {
-
- public String getDropSequenceString(String sequenceName) {
- return "drop generator " + sequenceName;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer( sql.length()+20 )
- .append(sql)
- .insert(6, hasOffset ? " first ? skip ?" : " first ?")
- .toString();
- }
-
- public boolean bindLimitParametersFirst() {
- return true;
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FirebirdDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,52 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+ * An SQL dialect for Firebird.
+ * @author Reha CENANI
+ */
+public class FirebirdDialect extends InterbaseDialect {
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop generator " + sequenceName;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length()+20 )
+ .append(sql)
+ .insert(6, hasOffset ? " first ? skip ?" : " first ?")
+ .toString();
+ }
+
+ public boolean bindLimitParametersFirst() {
+ return true;
+ }
+
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,91 +0,0 @@
-//$Id: FrontBaseDialect.java 9328 2006-02-23 17:32:47Z steveebersole $
-package org.hibernate.dialect;
-
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.UpdateLockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.LockMode;
-
-import java.sql.Types;
-
-/**
- * An SQL Dialect for Frontbase. Assumes you're using the latest version
- * of the FrontBase JDBC driver, available from <tt>http://frontbase.com/</tt>
- * <p>
- * <b>NOTE</b>: The latest JDBC driver is not always included with the
- * latest release of FrontBase. Download the driver separately, and enjoy
- * the informative release notes.
- * <p>
- * This dialect was tested with JDBC driver version 2.3.1. This driver
- * contains a bug that causes batches of updates to fail. (The bug should be
- * fixed in the next release of the JDBC driver.) If you are using JDBC driver
- * 2.3.1, you can work-around this problem by setting the following in your
- * <tt>hibernate.properties</tt> file: <tt>hibernate.jdbc.batch_size=15</tt>
- *
- * @author Ron Lussier <tt>rlussier(a)lenscraft.com</tt>
- */
-public class FrontBaseDialect extends Dialect {
-
- public FrontBaseDialect() {
- super();
-
- registerColumnType( Types.BIT, "bit" );
- registerColumnType( Types.BIGINT, "longint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "bit varying($l)" );
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- registerColumnType( Types.BLOB, "blob" );
- registerColumnType( Types.CLOB, "clob" );
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public String getCascadeConstraintsString() {
- return " cascade";
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
- /**
- * Does this dialect support the <tt>FOR UPDATE</tt> syntax. No!
- *
- * @return false always. FrontBase doesn't support this syntax,
- * which was dropped with SQL92
- */
- public String getForUpdateString() {
- return "";
- }
-
- public String getCurrentTimestampCallString() {
- // TODO : not sure this is correct, could not find docs on how to do this.
- return "{?= call current_timestamp}";
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return true;
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- return new UpdateLockingStrategy( lockable, lockMode );
- }
- else {
- return new SelectLockingStrategy( lockable, lockMode );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/FrontBaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,114 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.UpdateLockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.LockMode;
+
+import java.sql.Types;
+
+/**
+ * An SQL Dialect for Frontbase. Assumes you're using the latest version
+ * of the FrontBase JDBC driver, available from <tt>http://frontbase.com/</tt>
+ * <p>
+ * <b>NOTE</b>: The latest JDBC driver is not always included with the
+ * latest release of FrontBase. Download the driver separately, and enjoy
+ * the informative release notes.
+ * <p>
+ * This dialect was tested with JDBC driver version 2.3.1. This driver
+ * contains a bug that causes batches of updates to fail. (The bug should be
+ * fixed in the next release of the JDBC driver.) If you are using JDBC driver
+ * 2.3.1, you can work-around this problem by setting the following in your
+ * <tt>hibernate.properties</tt> file: <tt>hibernate.jdbc.batch_size=15</tt>
+ *
+ * @author Ron Lussier <tt>rlussier(a)lenscraft.com</tt>
+ */
+public class FrontBaseDialect extends Dialect {
+
+ public FrontBaseDialect() {
+ super();
+
+ registerColumnType( Types.BIT, "bit" );
+ registerColumnType( Types.BIGINT, "longint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "bit varying($l)" );
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public String getCascadeConstraintsString() {
+ return " cascade";
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support the <tt>FOR UPDATE</tt> syntax. No!
+ *
+ * @return false always. FrontBase doesn't support this syntax,
+ * which was dropped with SQL92
+ */
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public String getCurrentTimestampCallString() {
+ // TODO : not sure this is correct, could not find docs on how to do this.
+ return "{?= call current_timestamp}";
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return true;
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ return new UpdateLockingStrategy( lockable, lockMode );
+ }
+ else {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,298 +0,0 @@
-package org.hibernate.dialect;
-
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * A dialect compatible with the H2 database.
- *
- * @author Thomas Mueller
- *
- */
-public class H2Dialect extends Dialect {
-
- private String querySequenceString;
- public H2Dialect() {
- super();
-
- querySequenceString = "select sequence_name from information_schema.sequences";
- try {
- // HHH-2300
- Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
- Integer build = (Integer)constants.getDeclaredField("BUILD_ID" ).get(null);
- int buildid = build.intValue();
- if(buildid < 32) {
- querySequenceString = "select name from information_schema.sequences";
- }
- } catch(Throwable e) {
- // ignore (probably H2 not in the classpath)
- }
- registerColumnType(Types.BOOLEAN, "boolean");
- registerColumnType(Types.BIGINT, "bigint");
- registerColumnType(Types.BINARY, "binary");
- registerColumnType(Types.BIT, "bit");
- registerColumnType(Types.CHAR, "char($l)");
- registerColumnType(Types.DATE, "date");
- registerColumnType(Types.DECIMAL, "decimal($p,$s)");
- registerColumnType(Types.DOUBLE, "double");
- registerColumnType(Types.FLOAT, "float");
- registerColumnType(Types.INTEGER, "integer");
- registerColumnType(Types.LONGVARBINARY, "longvarbinary");
- registerColumnType(Types.LONGVARCHAR, "longvarchar");
- registerColumnType(Types.REAL, "real");
- registerColumnType(Types.SMALLINT, "smallint");
- registerColumnType(Types.TINYINT, "tinyint");
- registerColumnType(Types.TIME, "time");
- registerColumnType(Types.TIMESTAMP, "timestamp");
- registerColumnType(Types.VARCHAR, "varchar($l)");
- registerColumnType(Types.VARBINARY, "binary($l)");
- registerColumnType(Types.NUMERIC, "numeric");
- registerColumnType(Types.BLOB, "blob");
- registerColumnType(Types.CLOB, "clob");
-
- // select topic, syntax from information_schema.help
- // where section like 'Function%' order by section, topic
-
-// registerFunction("abs", new StandardSQLFunction("abs"));
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE));
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE));
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE));
- registerFunction("atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE));
- registerFunction("bitand", new StandardSQLFunction("bitand", Hibernate.INTEGER));
- registerFunction("bitor", new StandardSQLFunction("bitor", Hibernate.INTEGER));
- registerFunction("bitxor", new StandardSQLFunction("bitxor", Hibernate.INTEGER));
- registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.DOUBLE));
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE));
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE));
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE));
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE));
- registerFunction("floor", new StandardSQLFunction("floor", Hibernate.DOUBLE));
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE));
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE));
-// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
- registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE));
- registerFunction("power", new StandardSQLFunction("power", Hibernate.DOUBLE));
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE));
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE));
- registerFunction("round", new StandardSQLFunction("round", Hibernate.DOUBLE));
- registerFunction("roundmagic", new StandardSQLFunction("roundmagic", Hibernate.DOUBLE));
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER));
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE));
-// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE));
- registerFunction("truncate", new StandardSQLFunction("truncate", Hibernate.DOUBLE));
-
- registerFunction("compress", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("expand", new StandardSQLFunction("compress", Hibernate.BINARY));
- registerFunction("decrypt", new StandardSQLFunction("decrypt", Hibernate.BINARY));
- registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.BINARY));
- registerFunction("hash", new StandardSQLFunction("hash", Hibernate.BINARY));
-
- registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER));
-// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
- registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER));
- registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "(", "||", ")"));
- registerFunction("difference", new StandardSQLFunction("difference", Hibernate.INTEGER));
- registerFunction("hextoraw", new StandardSQLFunction("hextoraw", Hibernate.STRING));
- registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("insert", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("left", new StandardSQLFunction("left", Hibernate.STRING));
-// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
-// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
-// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
- registerFunction("lcase", new StandardSQLFunction("lcase", Hibernate.STRING));
- registerFunction("ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING));
- registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.INTEGER));
- registerFunction("position", new StandardSQLFunction("position", Hibernate.INTEGER));
- registerFunction("rawtohex", new StandardSQLFunction("rawtohex", Hibernate.STRING));
- registerFunction("repeat", new StandardSQLFunction("repeat", Hibernate.STRING));
- registerFunction("replace", new StandardSQLFunction("replace", Hibernate.STRING));
- registerFunction("right", new StandardSQLFunction("right", Hibernate.STRING));
- registerFunction("rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING));
- registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING));
- registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING));
- registerFunction("stringencode", new StandardSQLFunction("stringencode", Hibernate.STRING));
- registerFunction("stringdecode", new StandardSQLFunction("stringdecode", Hibernate.STRING));
-// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
-// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
- registerFunction("ucase", new StandardSQLFunction("ucase", Hibernate.STRING));
-
- registerFunction("stringtoutf8", new StandardSQLFunction("stringtoutf8", Hibernate.BINARY));
- registerFunction("utf8tostring", new StandardSQLFunction("utf8tostring", Hibernate.STRING));
-
- registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
- registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
- registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
- registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER));
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER));
-// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
-// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
-// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
- registerFunction("quater", new StandardSQLFunction("quater", Hibernate.INTEGER));
-// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
-// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
-
- registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE));
- registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME));
- registerFunction("curtimestamp", new NoArgSQLFunction("curtimestamp", Hibernate.TIME));
- registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP));
-
- registerFunction("database", new NoArgSQLFunction("database", Hibernate.STRING));
- registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
-
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public String getIdentityColumnString() {
- return "generated by default as identity"; // not null is implicit
- }
-
- public String getIdentitySelectString() {
- return "call identity()";
- }
-
- public String getIdentityInsertString() {
- return "null";
- }
-
- public String getForUpdateString() {
- return " for update";
- }
-
- public boolean supportsUnique() {
- return true;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer(sql.length() + 20).
- append(sql).
- append(hasOffset ? " limit ? offset ?" : " limit ?").
- toString();
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
-
- public boolean bindLimitParametersFirst() {
- return false;
- }
-
- public boolean supportsIfExistsAfterTableName() {
- return true;
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public boolean supportsPooledSequences() {
- return true;
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return "next value for " + sequenceName;
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "call next value for " + sequenceName;
- }
-
- public String getQuerySequencesString() {
- return querySequenceString;
- }
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
-
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- String constraintName = null;
- // 23000: Check constraint violation: {0}
- // 23001: Unique index or primary key violation: {0}
- if(sqle.getSQLState().startsWith("23")) {
- String message = sqle.getMessage();
- int idx = message.indexOf("violation: ");
- if(idx > 0) {
- constraintName = message.substring(idx + "violation: ".length());
- }
- }
- return constraintName;
- }
-
- };
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "create temporary table if not exists";
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "call current_timestamp()";
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsLobValueChangePropogation() {
- return false;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/H2Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/H2Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,322 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * A dialect compatible with the H2 database.
+ *
+ * @author Thomas Mueller
+ *
+ */
+public class H2Dialect extends Dialect {
+
+ private String querySequenceString;
+ public H2Dialect() {
+ super();
+
+ querySequenceString = "select sequence_name from information_schema.sequences";
+ try {
+ // HHH-2300
+ Class constants = ReflectHelper.classForName( "org.h2.engine.Constants" );
+ Integer build = (Integer)constants.getDeclaredField("BUILD_ID" ).get(null);
+ int buildid = build.intValue();
+ if(buildid < 32) {
+ querySequenceString = "select name from information_schema.sequences";
+ }
+ } catch(Throwable e) {
+ // ignore (probably H2 not in the classpath)
+ }
+ registerColumnType(Types.BOOLEAN, "boolean");
+ registerColumnType(Types.BIGINT, "bigint");
+ registerColumnType(Types.BINARY, "binary");
+ registerColumnType(Types.BIT, "bit");
+ registerColumnType(Types.CHAR, "char($l)");
+ registerColumnType(Types.DATE, "date");
+ registerColumnType(Types.DECIMAL, "decimal($p,$s)");
+ registerColumnType(Types.DOUBLE, "double");
+ registerColumnType(Types.FLOAT, "float");
+ registerColumnType(Types.INTEGER, "integer");
+ registerColumnType(Types.LONGVARBINARY, "longvarbinary");
+ registerColumnType(Types.LONGVARCHAR, "longvarchar");
+ registerColumnType(Types.REAL, "real");
+ registerColumnType(Types.SMALLINT, "smallint");
+ registerColumnType(Types.TINYINT, "tinyint");
+ registerColumnType(Types.TIME, "time");
+ registerColumnType(Types.TIMESTAMP, "timestamp");
+ registerColumnType(Types.VARCHAR, "varchar($l)");
+ registerColumnType(Types.VARBINARY, "binary($l)");
+ registerColumnType(Types.NUMERIC, "numeric");
+ registerColumnType(Types.BLOB, "blob");
+ registerColumnType(Types.CLOB, "clob");
+
+ // select topic, syntax from information_schema.help
+ // where section like 'Function%' order by section, topic
+
+// registerFunction("abs", new StandardSQLFunction("abs"));
+ registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE));
+ registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE));
+ registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE));
+ registerFunction("atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE));
+ registerFunction("bitand", new StandardSQLFunction("bitand", Hibernate.INTEGER));
+ registerFunction("bitor", new StandardSQLFunction("bitor", Hibernate.INTEGER));
+ registerFunction("bitxor", new StandardSQLFunction("bitxor", Hibernate.INTEGER));
+ registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.DOUBLE));
+ registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE));
+ registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE));
+ registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE));
+ registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE));
+ registerFunction("floor", new StandardSQLFunction("floor", Hibernate.DOUBLE));
+ registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE));
+ registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE));
+// registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER));
+ registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE));
+ registerFunction("power", new StandardSQLFunction("power", Hibernate.DOUBLE));
+ registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE));
+ registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE));
+ registerFunction("round", new StandardSQLFunction("round", Hibernate.DOUBLE));
+ registerFunction("roundmagic", new StandardSQLFunction("roundmagic", Hibernate.DOUBLE));
+ registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER));
+ registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE));
+// registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE));
+ registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE));
+ registerFunction("truncate", new StandardSQLFunction("truncate", Hibernate.DOUBLE));
+
+ registerFunction("compress", new StandardSQLFunction("compress", Hibernate.BINARY));
+ registerFunction("expand", new StandardSQLFunction("compress", Hibernate.BINARY));
+ registerFunction("decrypt", new StandardSQLFunction("decrypt", Hibernate.BINARY));
+ registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.BINARY));
+ registerFunction("hash", new StandardSQLFunction("hash", Hibernate.BINARY));
+
+ registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER));
+// registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER));
+ registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER));
+ registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "(", "||", ")"));
+ registerFunction("difference", new StandardSQLFunction("difference", Hibernate.INTEGER));
+ registerFunction("hextoraw", new StandardSQLFunction("hextoraw", Hibernate.STRING));
+ registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
+ registerFunction("insert", new StandardSQLFunction("lower", Hibernate.STRING));
+ registerFunction("left", new StandardSQLFunction("left", Hibernate.STRING));
+// registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER));
+// registerFunction("locate", new StandardSQLFunction("locate", Hibernate.INTEGER));
+// registerFunction("lower", new StandardSQLFunction("lower", Hibernate.STRING));
+ registerFunction("lcase", new StandardSQLFunction("lcase", Hibernate.STRING));
+ registerFunction("ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING));
+ registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.INTEGER));
+ registerFunction("position", new StandardSQLFunction("position", Hibernate.INTEGER));
+ registerFunction("rawtohex", new StandardSQLFunction("rawtohex", Hibernate.STRING));
+ registerFunction("repeat", new StandardSQLFunction("repeat", Hibernate.STRING));
+ registerFunction("replace", new StandardSQLFunction("replace", Hibernate.STRING));
+ registerFunction("right", new StandardSQLFunction("right", Hibernate.STRING));
+ registerFunction("rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING));
+ registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING));
+ registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING));
+ registerFunction("stringencode", new StandardSQLFunction("stringencode", Hibernate.STRING));
+ registerFunction("stringdecode", new StandardSQLFunction("stringdecode", Hibernate.STRING));
+// registerFunction("substring", new StandardSQLFunction("substring", Hibernate.STRING));
+// registerFunction("upper", new StandardSQLFunction("upper", Hibernate.STRING));
+ registerFunction("ucase", new StandardSQLFunction("ucase", Hibernate.STRING));
+
+ registerFunction("stringtoutf8", new StandardSQLFunction("stringtoutf8", Hibernate.BINARY));
+ registerFunction("utf8tostring", new StandardSQLFunction("utf8tostring", Hibernate.STRING));
+
+ registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE));
+ registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME));
+ registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP));
+ registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER));
+ registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING));
+ registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER));
+ registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER));
+ registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER));
+// registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER));
+// registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER));
+// registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER));
+ registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING));
+ registerFunction("quater", new StandardSQLFunction("quater", Hibernate.INTEGER));
+// registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER));
+ registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER));
+// registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER));
+
+ registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE));
+ registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME));
+ registerFunction("curtimestamp", new NoArgSQLFunction("curtimestamp", Hibernate.TIME));
+ registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP));
+
+ registerFunction("database", new NoArgSQLFunction("database", Hibernate.STRING));
+ registerFunction("user", new NoArgSQLFunction("user", Hibernate.STRING));
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public String getIdentityColumnString() {
+ return "generated by default as identity"; // not null is implicit
+ }
+
+ public String getIdentitySelectString() {
+ return "call identity()";
+ }
+
+ public String getIdentityInsertString() {
+ return "null";
+ }
+
+ public String getForUpdateString() {
+ return " for update";
+ }
+
+ public boolean supportsUnique() {
+ return true;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer(sql.length() + 20).
+ append(sql).
+ append(hasOffset ? " limit ? offset ?" : " limit ?").
+ toString();
+ }
+
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
+
+ public boolean bindLimitParametersFirst() {
+ return false;
+ }
+
+ public boolean supportsIfExistsAfterTableName() {
+ return true;
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public boolean supportsPooledSequences() {
+ return true;
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "next value for " + sequenceName;
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "call next value for " + sequenceName;
+ }
+
+ public String getQuerySequencesString() {
+ return querySequenceString;
+ }
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ String constraintName = null;
+ // 23000: Check constraint violation: {0}
+ // 23001: Unique index or primary key violation: {0}
+ if(sqle.getSQLState().startsWith("23")) {
+ String message = sqle.getMessage();
+ int idx = message.indexOf("violation: ");
+ if(idx > 0) {
+ constraintName = message.substring(idx + "violation: ".length());
+ }
+ }
+ return constraintName;
+ }
+
+ };
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create temporary table if not exists";
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "call current_timestamp()";
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsLobValueChangePropogation() {
+ return false;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,297 +0,0 @@
-//$Id: HSQLDialect.java 11259 2007-03-07 22:55:12Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.SQLException;
-import java.sql.Types;
-import java.io.Serializable;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.StaleObjectStateException;
-import org.hibernate.JDBCException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An SQL dialect compatible with HSQLDB (Hypersonic SQL).
- * <p/>
- * Note this version supports HSQLDB version 1.8 and higher, only.
- *
- * @author Christoph Sturm
- * @author Phillip Baird
- */
-public class HSQLDialect extends Dialect {
-
- private static final Logger log = LoggerFactory.getLogger( HSQLDialect.class );
-
- public HSQLDialect() {
- super();
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.BINARY, "binary" );
- registerColumnType( Types.BIT, "bit" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.DECIMAL, "decimal" );
- registerColumnType( Types.DOUBLE, "double" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.LONGVARBINARY, "longvarbinary" );
- registerColumnType( Types.LONGVARCHAR, "longvarchar" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.VARBINARY, "varbinary($l)" );
- registerColumnType( Types.NUMERIC, "numeric" );
- //HSQL has no Blob/Clob support .... but just put these here for now!
- registerColumnType( Types.BLOB, "longvarbinary" );
- registerColumnType( Types.CLOB, "longvarchar" );
-
- registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
- registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
- registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
- registerFunction( "lower", new StandardSQLFunction( "lower" ) );
- registerFunction( "upper", new StandardSQLFunction( "upper" ) );
- registerFunction( "lcase", new StandardSQLFunction( "lcase" ) );
- registerFunction( "ucase", new StandardSQLFunction( "ucase" ) );
- registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
- registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
- registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) );
- registerFunction( "reverse", new StandardSQLFunction( "reverse" ) );
- registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
- registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex" ) );
- registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw" ) );
-
- registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
- registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
-
- registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE, false ) );
- registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
- registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP, false ) );
- registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
- registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME, false ) );
- registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
- registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
- registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
- registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
- registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
- registerFunction( "month", new StandardSQLFunction( "month", Hibernate.INTEGER ) );
- registerFunction( "year", new StandardSQLFunction( "year", Hibernate.INTEGER ) );
- registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
- registerFunction( "quater", new StandardSQLFunction( "quater", Hibernate.INTEGER ) );
- registerFunction( "hour", new StandardSQLFunction( "hour", Hibernate.INTEGER ) );
- registerFunction( "minute", new StandardSQLFunction( "minute", Hibernate.INTEGER ) );
- registerFunction( "second", new StandardSQLFunction( "second", Hibernate.INTEGER ) );
- registerFunction( "dayname", new StandardSQLFunction( "dayname", Hibernate.STRING ) );
- registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
-
- registerFunction( "abs", new StandardSQLFunction( "abs" ) );
- registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
-
- registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
- registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
- registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
- registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
- registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
- registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
- registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
- registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
- registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
- registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
- registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
- registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
- registerFunction( "rand", new StandardSQLFunction( "rand", Hibernate.FLOAT ) );
-
- registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
- registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
- registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic" ) );
-
- registerFunction( "ceiling", new StandardSQLFunction( "ceiling" ) );
- registerFunction( "floor", new StandardSQLFunction( "floor" ) );
-
- // Multi-param dialect functions...
- registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER ) );
-
- // function templates
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
-
- getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public String getIdentityColumnString() {
- return "generated by default as identity (start with 1)"; //not null is implicit
- }
-
- public String getIdentitySelectString() {
- return "call identity()";
- }
-
- public String getIdentityInsertString() {
- return "null";
- }
-
- public String getForUpdateString() {
- return "";
- }
-
- public boolean supportsUnique() {
- return false;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer( sql.length() + 10 )
- .append( sql )
- .insert( sql.toLowerCase().indexOf( "select" ) + 6, hasOffset ? " limit ? ?" : " top ?" )
- .toString();
- }
-
- public boolean bindLimitParametersFirst() {
- return true;
- }
-
- public boolean supportsIfExistsAfterTableName() {
- return true;
- }
-
- public boolean supportsColumnCheck() {
- return false;
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public boolean supportsPooledSequences() {
- return true;
- }
-
- protected String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
-
- protected String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return "next value for " + sequenceName;
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "call next value for " + sequenceName;
- }
-
- public String getQuerySequencesString() {
- // this assumes schema support, which is present in 1.8.0 and later...
- return "select sequence_name from information_schema.system_sequences";
- }
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
-
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- String constraintName = null;
-
- int errorCode = JDBCExceptionHelper.extractErrorCode( sqle );
-
- if ( errorCode == -8 ) {
- constraintName = extractUsingTemplate(
- "Integrity constraint violation ", " table:", sqle.getMessage()
- );
- }
- else if ( errorCode == -9 ) {
- constraintName = extractUsingTemplate(
- "Violation of unique index: ", " in statement [", sqle.getMessage()
- );
- }
- else if ( errorCode == -104 ) {
- constraintName = extractUsingTemplate(
- "Unique constraint violation: ", " in statement [", sqle.getMessage()
- );
- }
- else if ( errorCode == -177 ) {
- constraintName = extractUsingTemplate(
- "Integrity constraint violation - no parent ", " table:", sqle.getMessage()
- );
- }
-
- return constraintName;
- }
-
- };
-
- /**
- * HSQL does not really support temp tables; just take advantage of the
- * fact that it is a single user db...
- */
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return false;
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // HSQLDB only supports READ_UNCOMMITTED transaction isolation
- return new ReadUncommittedLockingStrategy( lockable, lockMode );
- }
-
- public static class ReadUncommittedLockingStrategy extends SelectLockingStrategy {
- public ReadUncommittedLockingStrategy(Lockable lockable, LockMode lockMode) {
- super( lockable, lockMode );
- }
-
- public void lock(Serializable id, Object version, Object object, SessionImplementor session)
- throws StaleObjectStateException, JDBCException {
- if ( getLockMode().greaterThan( LockMode.READ ) ) {
- log.warn( "HSQLDB supports only READ_UNCOMMITTED isolation" );
- }
- super.lock( id, version, object, session );
- }
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsLobValueChangePropogation() {
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/HSQLDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/HSQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,320 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import java.io.Serializable;
+
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.StaleObjectStateException;
+import org.hibernate.JDBCException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.exception.JDBCExceptionHelper;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An SQL dialect compatible with HSQLDB (Hypersonic SQL).
+ * <p/>
+ * Note this version supports HSQLDB version 1.8 and higher, only.
+ *
+ * @author Christoph Sturm
+ * @author Phillip Baird
+ */
+public class HSQLDialect extends Dialect {
+
+ private static final Logger log = LoggerFactory.getLogger( HSQLDialect.class );
+
+ public HSQLDialect() {
+ super();
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.BINARY, "binary" );
+ registerColumnType( Types.BIT, "bit" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.DECIMAL, "decimal" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.LONGVARBINARY, "longvarbinary" );
+ registerColumnType( Types.LONGVARCHAR, "longvarchar" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.VARBINARY, "varbinary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric" );
+ //HSQL has no Blob/Clob support .... but just put these here for now!
+ registerColumnType( Types.BLOB, "longvarbinary" );
+ registerColumnType( Types.CLOB, "longvarchar" );
+
+ registerFunction( "ascii", new StandardSQLFunction( "ascii", Hibernate.INTEGER ) );
+ registerFunction( "char", new StandardSQLFunction( "char", Hibernate.CHARACTER ) );
+ registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
+ registerFunction( "lower", new StandardSQLFunction( "lower" ) );
+ registerFunction( "upper", new StandardSQLFunction( "upper" ) );
+ registerFunction( "lcase", new StandardSQLFunction( "lcase" ) );
+ registerFunction( "ucase", new StandardSQLFunction( "ucase" ) );
+ registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
+ registerFunction( "ltrim", new StandardSQLFunction( "ltrim" ) );
+ registerFunction( "rtrim", new StandardSQLFunction( "rtrim" ) );
+ registerFunction( "reverse", new StandardSQLFunction( "reverse" ) );
+ registerFunction( "space", new StandardSQLFunction( "space", Hibernate.STRING ) );
+ registerFunction( "rawtohex", new StandardSQLFunction( "rawtohex" ) );
+ registerFunction( "hextoraw", new StandardSQLFunction( "hextoraw" ) );
+
+ registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING ) );
+ registerFunction( "database", new NoArgSQLFunction( "database", Hibernate.STRING ) );
+
+ registerFunction( "current_date", new NoArgSQLFunction( "current_date", Hibernate.DATE, false ) );
+ registerFunction( "curdate", new NoArgSQLFunction( "curdate", Hibernate.DATE ) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction( "current_timestamp", Hibernate.TIMESTAMP, false ) );
+ registerFunction( "now", new NoArgSQLFunction( "now", Hibernate.TIMESTAMP ) );
+ registerFunction( "current_time", new NoArgSQLFunction( "current_time", Hibernate.TIME, false ) );
+ registerFunction( "curtime", new NoArgSQLFunction( "curtime", Hibernate.TIME ) );
+ registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
+ registerFunction( "dayofweek", new StandardSQLFunction( "dayofweek", Hibernate.INTEGER ) );
+ registerFunction( "dayofyear", new StandardSQLFunction( "dayofyear", Hibernate.INTEGER ) );
+ registerFunction( "dayofmonth", new StandardSQLFunction( "dayofmonth", Hibernate.INTEGER ) );
+ registerFunction( "month", new StandardSQLFunction( "month", Hibernate.INTEGER ) );
+ registerFunction( "year", new StandardSQLFunction( "year", Hibernate.INTEGER ) );
+ registerFunction( "week", new StandardSQLFunction( "week", Hibernate.INTEGER ) );
+ registerFunction( "quater", new StandardSQLFunction( "quater", Hibernate.INTEGER ) );
+ registerFunction( "hour", new StandardSQLFunction( "hour", Hibernate.INTEGER ) );
+ registerFunction( "minute", new StandardSQLFunction( "minute", Hibernate.INTEGER ) );
+ registerFunction( "second", new StandardSQLFunction( "second", Hibernate.INTEGER ) );
+ registerFunction( "dayname", new StandardSQLFunction( "dayname", Hibernate.STRING ) );
+ registerFunction( "monthname", new StandardSQLFunction( "monthname", Hibernate.STRING ) );
+
+ registerFunction( "abs", new StandardSQLFunction( "abs" ) );
+ registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
+
+ registerFunction( "acos", new StandardSQLFunction( "acos", Hibernate.DOUBLE ) );
+ registerFunction( "asin", new StandardSQLFunction( "asin", Hibernate.DOUBLE ) );
+ registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
+ registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "cot", new StandardSQLFunction( "cot", Hibernate.DOUBLE ) );
+ registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "log10", new StandardSQLFunction( "log10", Hibernate.DOUBLE ) );
+ registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
+ registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
+ registerFunction( "tan", new StandardSQLFunction( "tan", Hibernate.DOUBLE ) );
+ registerFunction( "pi", new NoArgSQLFunction( "pi", Hibernate.DOUBLE ) );
+ registerFunction( "rand", new StandardSQLFunction( "rand", Hibernate.FLOAT ) );
+
+ registerFunction( "radians", new StandardSQLFunction( "radians", Hibernate.DOUBLE ) );
+ registerFunction( "degrees", new StandardSQLFunction( "degrees", Hibernate.DOUBLE ) );
+ registerFunction( "roundmagic", new StandardSQLFunction( "roundmagic" ) );
+
+ registerFunction( "ceiling", new StandardSQLFunction( "ceiling" ) );
+ registerFunction( "floor", new StandardSQLFunction( "floor" ) );
+
+ // Multi-param dialect functions...
+ registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER ) );
+
+ // function templates
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public String getIdentityColumnString() {
+ return "generated by default as identity (start with 1)"; //not null is implicit
+ }
+
+ public String getIdentitySelectString() {
+ return "call identity()";
+ }
+
+ public String getIdentityInsertString() {
+ return "null";
+ }
+
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public boolean supportsUnique() {
+ return false;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length() + 10 )
+ .append( sql )
+ .insert( sql.toLowerCase().indexOf( "select" ) + 6, hasOffset ? " limit ? ?" : " top ?" )
+ .toString();
+ }
+
+ public boolean bindLimitParametersFirst() {
+ return true;
+ }
+
+ public boolean supportsIfExistsAfterTableName() {
+ return true;
+ }
+
+ public boolean supportsColumnCheck() {
+ return false;
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public boolean supportsPooledSequences() {
+ return true;
+ }
+
+ protected String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+
+ protected String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "next value for " + sequenceName;
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "call next value for " + sequenceName;
+ }
+
+ public String getQuerySequencesString() {
+ // this assumes schema support, which is present in 1.8.0 and later...
+ return "select sequence_name from information_schema.system_sequences";
+ }
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ String constraintName = null;
+
+ int errorCode = JDBCExceptionHelper.extractErrorCode( sqle );
+
+ if ( errorCode == -8 ) {
+ constraintName = extractUsingTemplate(
+ "Integrity constraint violation ", " table:", sqle.getMessage()
+ );
+ }
+ else if ( errorCode == -9 ) {
+ constraintName = extractUsingTemplate(
+ "Violation of unique index: ", " in statement [", sqle.getMessage()
+ );
+ }
+ else if ( errorCode == -104 ) {
+ constraintName = extractUsingTemplate(
+ "Unique constraint violation: ", " in statement [", sqle.getMessage()
+ );
+ }
+ else if ( errorCode == -177 ) {
+ constraintName = extractUsingTemplate(
+ "Integrity constraint violation - no parent ", " table:", sqle.getMessage()
+ );
+ }
+
+ return constraintName;
+ }
+
+ };
+
+ /**
+ * HSQL does not really support temp tables; just take advantage of the
+ * fact that it is a single user db...
+ */
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return false;
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // HSQLDB only supports READ_UNCOMMITTED transaction isolation
+ return new ReadUncommittedLockingStrategy( lockable, lockMode );
+ }
+
+ public static class ReadUncommittedLockingStrategy extends SelectLockingStrategy {
+ public ReadUncommittedLockingStrategy(Lockable lockable, LockMode lockMode) {
+ super( lockable, lockMode );
+ }
+
+ public void lock(Serializable id, Object version, Object object, SessionImplementor session)
+ throws StaleObjectStateException, JDBCException {
+ if ( getLockMode().greaterThan( LockMode.READ ) ) {
+ log.warn( "HSQLDB supports only READ_UNCOMMITTED isolation" );
+ }
+ super.lock( id, version, object, session );
+ }
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsLobValueChangePropogation() {
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/InformixDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,213 +0,0 @@
-//$Id: InformixDialect.java 11177 2007-02-09 15:43:04Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.hibernate.MappingException;
-import org.hibernate.Hibernate;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.util.StringHelper;
-
-/**
- * Informix dialect.<br>
- * <br>
- * Seems to work with Informix Dynamic Server Version 7.31.UD3,
- * Informix JDBC driver version 2.21JC3.
- * @author Steve Molitor
- */
-public class InformixDialect extends Dialect {
-
- /**
- * Creates new <code>InformixDialect</code> instance. Sets up the JDBC /
- * Informix type mappings.
- */
- public InformixDialect() {
- super();
-
- registerColumnType(Types.BIGINT, "int8");
- registerColumnType(Types.BINARY, "byte");
- registerColumnType(Types.BIT, "smallint"); // Informix doesn't have a bit type
- registerColumnType(Types.CHAR, "char($l)");
- registerColumnType(Types.DATE, "date");
- registerColumnType(Types.DECIMAL, "decimal");
- registerColumnType(Types.DOUBLE, "float");
- registerColumnType(Types.FLOAT, "smallfloat");
- registerColumnType(Types.INTEGER, "integer");
- registerColumnType(Types.LONGVARBINARY, "blob"); // or BYTE
- registerColumnType(Types.LONGVARCHAR, "clob"); // or TEXT?
- registerColumnType(Types.NUMERIC, "decimal"); // or MONEY
- registerColumnType(Types.REAL, "smallfloat");
- registerColumnType(Types.SMALLINT, "smallint");
- registerColumnType(Types.TIMESTAMP, "datetime year to fraction(5)");
- registerColumnType(Types.TIME, "datetime hour to second");
- registerColumnType(Types.TINYINT, "smallint");
- registerColumnType(Types.VARBINARY, "byte");
- registerColumnType(Types.VARCHAR, "varchar($l)");
- registerColumnType(Types.VARCHAR, 255, "varchar($l)");
- registerColumnType(Types.VARCHAR, 32739, "lvarchar($l)");
-
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public String getIdentitySelectString(String table, String column, int type)
- throws MappingException {
- return type==Types.BIGINT ?
- "select dbinfo('serial8') from systables where tabid=1" :
- "select dbinfo('sqlca.sqlerrd1') from systables where tabid=1";
- }
-
- public String getIdentityColumnString(int type) throws MappingException {
- return type==Types.BIGINT ?
- "serial8 not null" :
- "serial not null";
- }
-
- public boolean hasDataTypeInIdentityColumn() {
- return false;
- }
-
- /**
- * The syntax used to add a foreign key constraint to a table.
- * Informix constraint name must be at the end.
- * @return String
- */
- public String getAddForeignKeyConstraintString(
- String constraintName,
- String[] foreignKey,
- String referencedTable,
- String[] primaryKey, boolean referencesPrimaryKey
- ) {
- StringBuffer result = new StringBuffer(30);
-
- result.append(" add constraint ")
- .append(" foreign key (")
- .append( StringHelper.join(", ", foreignKey) )
- .append(") references ")
- .append(referencedTable);
-
- if(!referencesPrimaryKey) {
- result.append(" (")
- .append( StringHelper.join(", ", primaryKey) )
- .append(')');
- }
-
- result.append(" constraint ").append(constraintName);
-
- return result.toString();
- }
-
- /**
- * The syntax used to add a primary key constraint to a table.
- * Informix constraint name must be at the end.
- * @return String
- */
- public String getAddPrimaryKeyConstraintString(String constraintName) {
- return " add constraint primary key constraint " + constraintName + " ";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName + " restrict";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName ) + " from systables where tabid=1";
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return sequenceName + ".nextval";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public String getLimitString(String querySelect, int offset, int limit) {
- if (offset>0) throw new UnsupportedOperationException("informix has no offset");
- return new StringBuffer( querySelect.length()+8 )
- .append(querySelect)
- .insert( querySelect.toLowerCase().indexOf( "select" ) + 6, " first " + limit )
- .toString();
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
-
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- String constraintName = null;
-
- int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
- if ( errorCode == -268 ) {
- constraintName = extractUsingTemplate( "Unique constraint (", ") violated.", sqle.getMessage() );
- }
- else if ( errorCode == -691 ) {
- constraintName = extractUsingTemplate( "Missing key in referenced table for referential constraint (", ").", sqle.getMessage() );
- }
- else if ( errorCode == -692 ) {
- constraintName = extractUsingTemplate( "Key value for constraint (", ") is still being referenced.", sqle.getMessage() );
- }
-
- if (constraintName != null) {
- // strip table-owner because Informix always returns constraint names as "<table-owner>.<constraint-name>"
- int i = constraintName.indexOf('.');
- if (i != -1) {
- constraintName = constraintName.substring(i + 1);
- }
- }
-
- return constraintName;
- }
-
- };
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "select distinct current timestamp from informix.systables";
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/InformixDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InformixDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,236 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.MappingException;
+import org.hibernate.Hibernate;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.JDBCExceptionHelper;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Informix dialect.<br>
+ * <br>
+ * Seems to work with Informix Dynamic Server Version 7.31.UD3,
+ * Informix JDBC driver version 2.21JC3.
+ * @author Steve Molitor
+ */
+public class InformixDialect extends Dialect {
+
+ /**
+ * Creates new <code>InformixDialect</code> instance. Sets up the JDBC /
+ * Informix type mappings.
+ */
+ public InformixDialect() {
+ super();
+
+ registerColumnType(Types.BIGINT, "int8");
+ registerColumnType(Types.BINARY, "byte");
+ registerColumnType(Types.BIT, "smallint"); // Informix doesn't have a bit type
+ registerColumnType(Types.CHAR, "char($l)");
+ registerColumnType(Types.DATE, "date");
+ registerColumnType(Types.DECIMAL, "decimal");
+ registerColumnType(Types.DOUBLE, "float");
+ registerColumnType(Types.FLOAT, "smallfloat");
+ registerColumnType(Types.INTEGER, "integer");
+ registerColumnType(Types.LONGVARBINARY, "blob"); // or BYTE
+ registerColumnType(Types.LONGVARCHAR, "clob"); // or TEXT?
+ registerColumnType(Types.NUMERIC, "decimal"); // or MONEY
+ registerColumnType(Types.REAL, "smallfloat");
+ registerColumnType(Types.SMALLINT, "smallint");
+ registerColumnType(Types.TIMESTAMP, "datetime year to fraction(5)");
+ registerColumnType(Types.TIME, "datetime hour to second");
+ registerColumnType(Types.TINYINT, "smallint");
+ registerColumnType(Types.VARBINARY, "byte");
+ registerColumnType(Types.VARCHAR, "varchar($l)");
+ registerColumnType(Types.VARCHAR, 255, "varchar($l)");
+ registerColumnType(Types.VARCHAR, 32739, "lvarchar($l)");
+
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public String getIdentitySelectString(String table, String column, int type)
+ throws MappingException {
+ return type==Types.BIGINT ?
+ "select dbinfo('serial8') from systables where tabid=1" :
+ "select dbinfo('sqlca.sqlerrd1') from systables where tabid=1";
+ }
+
+ public String getIdentityColumnString(int type) throws MappingException {
+ return type==Types.BIGINT ?
+ "serial8 not null" :
+ "serial not null";
+ }
+
+ public boolean hasDataTypeInIdentityColumn() {
+ return false;
+ }
+
+ /**
+ * The syntax used to add a foreign key constraint to a table.
+ * Informix constraint name must be at the end.
+ * @return String
+ */
+ public String getAddForeignKeyConstraintString(
+ String constraintName,
+ String[] foreignKey,
+ String referencedTable,
+ String[] primaryKey, boolean referencesPrimaryKey
+ ) {
+ StringBuffer result = new StringBuffer(30);
+
+ result.append(" add constraint ")
+ .append(" foreign key (")
+ .append( StringHelper.join(", ", foreignKey) )
+ .append(") references ")
+ .append(referencedTable);
+
+ if(!referencesPrimaryKey) {
+ result.append(" (")
+ .append( StringHelper.join(", ", primaryKey) )
+ .append(')');
+ }
+
+ result.append(" constraint ").append(constraintName);
+
+ return result.toString();
+ }
+
+ /**
+ * The syntax used to add a primary key constraint to a table.
+ * Informix constraint name must be at the end.
+ * @return String
+ */
+ public String getAddPrimaryKeyConstraintString(String constraintName) {
+ return " add constraint primary key constraint " + constraintName + " ";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName + " restrict";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName ) + " from systables where tabid=1";
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public String getLimitString(String querySelect, int offset, int limit) {
+ if (offset>0) throw new UnsupportedOperationException("informix has no offset");
+ return new StringBuffer( querySelect.length()+8 )
+ .append(querySelect)
+ .insert( querySelect.toLowerCase().indexOf( "select" ) + 6, " first " + limit )
+ .toString();
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ String constraintName = null;
+
+ int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
+ if ( errorCode == -268 ) {
+ constraintName = extractUsingTemplate( "Unique constraint (", ") violated.", sqle.getMessage() );
+ }
+ else if ( errorCode == -691 ) {
+ constraintName = extractUsingTemplate( "Missing key in referenced table for referential constraint (", ").", sqle.getMessage() );
+ }
+ else if ( errorCode == -692 ) {
+ constraintName = extractUsingTemplate( "Key value for constraint (", ") is still being referenced.", sqle.getMessage() );
+ }
+
+ if (constraintName != null) {
+ // strip table-owner because Informix always returns constraint names as "<table-owner>.<constraint-name>"
+ int i = constraintName.indexOf('.');
+ if (i != -1) {
+ constraintName = constraintName.substring(i + 1);
+ }
+ }
+
+ return constraintName;
+ }
+
+ };
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select distinct current timestamp from informix.systables";
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,305 +0,0 @@
-//$Id: IngresDialect.java 10963 2006-12-08 16:06:14Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-
-
-/**
- * An Ingres SQL dialect.
- * <p/>
- * Known limitations:
- * - only supports simple constants or columns on the left side of an IN, making (1,2,3) in (...) or (<subselect) in (...) non-supported
- * - supports only 31 digits in decimal
- *
- * @author Ian Booth, Bruce Lunsford, Max Rydahl Andersen
- */
-public class IngresDialect extends Dialect {
-
- public IngresDialect() {
- super();
- registerColumnType( Types.BIT, "tinyint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.REAL, "real" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "float" );
- registerColumnType( Types.NUMERIC, "decimal($p, $s)" );
- registerColumnType( Types.DECIMAL, "decimal($p, $s)" );
- registerColumnType( Types.BINARY, 32000, "byte($l)" );
- registerColumnType( Types.BINARY, "long byte" );
- registerColumnType( Types.VARBINARY, 32000, "varbyte($l)" );
- registerColumnType( Types.VARBINARY, "long byte" );
- registerColumnType( Types.LONGVARBINARY, "long byte" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, 32000, "varchar($l)" );
- registerColumnType( Types.VARCHAR, "long varchar" );
- registerColumnType( Types.LONGVARCHAR, "long varchar" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time with time zone" );
- registerColumnType( Types.TIMESTAMP, "timestamp with time zone" );
- registerColumnType( Types.BLOB, "blob" );
- registerColumnType( Types.CLOB, "clob" );
-
- registerFunction( "abs", new StandardSQLFunction( "abs" ) );
- registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
- registerFunction( "bit_add", new StandardSQLFunction( "bit_add" ) );
- registerFunction( "bit_and", new StandardSQLFunction( "bit_and" ) );
- registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(hex(?1))*4" ) );
- registerFunction( "bit_not", new StandardSQLFunction( "bit_not" ) );
- registerFunction( "bit_or", new StandardSQLFunction( "bit_or" ) );
- registerFunction( "bit_xor", new StandardSQLFunction( "bit_xor" ) );
- registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.LONG ) );
- registerFunction( "charextract", new StandardSQLFunction( "charextract", Hibernate.STRING ) );
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "+", ")" ) );
- registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
- registerFunction( "current_user", new NoArgSQLFunction( "current_user", Hibernate.STRING, false ) );
- registerFunction( "current_time", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
- registerFunction( "current_timestamp", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
- registerFunction( "current_date", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
- registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
- registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
- registerFunction( "dba", new NoArgSQLFunction( "dba", Hibernate.STRING, true ) );
- registerFunction( "dow", new StandardSQLFunction( "dow", Hibernate.STRING ) );
- registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "date_part('?1', ?3)" ) );
- registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
- registerFunction( "gmt_timestamp", new StandardSQLFunction( "gmt_timestamp", Hibernate.STRING ) );
- registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.INTEGER ) );
- registerFunction( "hex", new StandardSQLFunction( "hex", Hibernate.STRING ) );
- registerFunction( "hour", new StandardSQLFunction( "hour", Hibernate.INTEGER ) );
- registerFunction( "initial_user", new NoArgSQLFunction( "initial_user", Hibernate.STRING, false ) );
- registerFunction( "intextract", new StandardSQLFunction( "intextract", Hibernate.INTEGER ) );
- registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
- registerFunction( "locate", new SQLFunctionTemplate( Hibernate.LONG, "locate(?1, ?2)" ) );
- registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
- registerFunction( "ln", new StandardSQLFunction( "ln", Hibernate.DOUBLE ) );
- registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
- registerFunction( "lower", new StandardSQLFunction( "lower" ) );
- registerFunction( "lowercase", new StandardSQLFunction( "lowercase" ) );
- registerFunction( "minute", new StandardSQLFunction( "minute", Hibernate.INTEGER ) );
- registerFunction( "month", new StandardSQLFunction( "month", Hibernate.INTEGER ) );
- registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.LONG ) );
- registerFunction( "pad", new StandardSQLFunction( "pad", Hibernate.STRING ) );
- registerFunction( "position", new StandardSQLFunction( "position", Hibernate.LONG ) );
- registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
- registerFunction( "random", new NoArgSQLFunction( "random", Hibernate.LONG, true ) );
- registerFunction( "randomf", new NoArgSQLFunction( "randomf", Hibernate.DOUBLE, true ) );
- registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
- registerFunction( "session_user", new NoArgSQLFunction( "session_user", Hibernate.STRING, false ) );
- registerFunction( "second", new StandardSQLFunction( "second", Hibernate.INTEGER ) );
- registerFunction( "size", new NoArgSQLFunction( "size", Hibernate.LONG, true ) );
- registerFunction( "squeeze", new StandardSQLFunction( "squeeze" ) );
- registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
- registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
- registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
- registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
- registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
- //registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
- registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
- registerFunction( "upper", new StandardSQLFunction( "upper" ) );
- registerFunction( "uppercase", new StandardSQLFunction( "uppercase" ) );
- registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING, false ) );
- registerFunction( "usercode", new NoArgSQLFunction( "usercode", Hibernate.STRING, true ) );
- registerFunction( "username", new NoArgSQLFunction( "username", Hibernate.STRING, true ) );
- registerFunction( "uuid_create", new StandardSQLFunction( "uuid_create", Hibernate.BYTE ) );
- registerFunction( "uuid_compare", new StandardSQLFunction( "uuid_compare", Hibernate.INTEGER ) );
- registerFunction( "uuid_from_char", new StandardSQLFunction( "uuid_from_char", Hibernate.BYTE ) );
- registerFunction( "uuid_to_char", new StandardSQLFunction( "uuid_to_char", Hibernate.STRING ) );
- registerFunction( "year", new StandardSQLFunction( "year", Hibernate.INTEGER ) );
- }
-
- /**
- * Do we need to drop constraints before dropping tables in this dialect?
- *
- * @return boolean
- */
- public boolean dropConstraints() {
- return false;
- }
-
- /**
- * Does this dialect support <tt>FOR UPDATE OF</tt>, allowing
- * particular rows to be locked?
- *
- * @return True (Ingres does support "for update of" syntax...)
- */
- public boolean supportsForUpdateOf() {
- return true;
- }
-
- /**
- * The syntax used to add a column to a table (optional).
- */
- public String getAddColumnString() {
- return "add column";
- }
-
- /**
- * The keyword used to specify a nullable column.
- *
- * @return String
- */
- public String getNullColumnString() {
- return " with null";
- }
-
- /**
- * Does this dialect support sequences?
- *
- * @return boolean
- */
- public boolean supportsSequences() {
- return true;
- }
-
- /**
- * The syntax that fetches the next value of a sequence, if sequences are supported.
- *
- * @param sequenceName the name of the sequence
- *
- * @return String
- */
- public String getSequenceNextValString(String sequenceName) {
- return "select nextval for " + sequenceName;
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return sequenceName + ".nextval";
- }
-
- /**
- * The syntax used to create a sequence, if sequences are supported.
- *
- * @param sequenceName the name of the sequence
- *
- * @return String
- */
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
-
- /**
- * The syntax used to drop a sequence, if sequences are supported.
- *
- * @param sequenceName the name of the sequence
- *
- * @return String
- */
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName + " restrict";
- }
-
- /**
- * A query used to find all sequences
- */
- public String getQuerySequencesString() {
- return "select seq_name from iisequence";
- }
-
- /**
- * The name of the SQL function that transforms a string to
- * lowercase
- *
- * @return String
- */
- public String getLowercaseFunction() {
- return "lowercase";
- }
-
- /**
- * Does this <tt>Dialect</tt> have some kind of <tt>LIMIT</tt> syntax?
- */
- public boolean supportsLimit() {
- return true;
- }
-
- /**
- * Does this dialect support an offset?
- */
- public boolean supportsLimitOffset() {
- return false;
- }
-
- /**
- * Add a <tt>LIMIT</tt> clause to the given SQL <tt>SELECT</tt>
- *
- * @return the modified SQL
- */
- public String getLimitString(String querySelect, int offset, int limit) {
- if ( offset > 0 ) {
- throw new UnsupportedOperationException( "offset not supported" );
- }
- return new StringBuffer( querySelect.length() + 16 )
- .append( querySelect )
- .insert( 6, " first " + limit )
- .toString();
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
- /**
- * Does the <tt>LIMIT</tt> clause take a "maximum" row number instead
- * of a total number of returned rows?
- */
- public boolean useMaxForLimit() {
- return true;
- }
-
- /**
- * Ingres explicitly needs "unique not null", because "with null" is default
- */
- public boolean supportsNotNullUnique() {
- return false;
- }
-
- /**
- * Does this dialect support temporary tables?
- */
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "declare global temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "on commit preserve rows with norecovery";
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- return "session." + super.generateTemporaryTableName( baseTableName );
- }
-
-
- /**
- * Expression for current_timestamp
- */
- public String getCurrentTimestampSQLFunctionName() {
- return "date(now)";
- }
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsSubselectAsInPredicateLHS() {
- return false;
- }
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsExpectedLobUsagePattern () {
- return false;
- }
-}
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/IngresDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/IngresDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,327 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+
+/**
+ * An Ingres SQL dialect.
+ * <p/>
+ * Known limitations:
+ * - only supports simple constants or columns on the left side of an IN, making (1,2,3) in (...) or (<subselect) in (...) non-supported
+ * - supports only 31 digits in decimal
+ *
+ * @author Ian Booth, Bruce Lunsford, Max Rydahl Andersen
+ */
+public class IngresDialect extends Dialect {
+
+ public IngresDialect() {
+ super();
+ registerColumnType( Types.BIT, "tinyint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.REAL, "real" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "float" );
+ registerColumnType( Types.NUMERIC, "decimal($p, $s)" );
+ registerColumnType( Types.DECIMAL, "decimal($p, $s)" );
+ registerColumnType( Types.BINARY, 32000, "byte($l)" );
+ registerColumnType( Types.BINARY, "long byte" );
+ registerColumnType( Types.VARBINARY, 32000, "varbyte($l)" );
+ registerColumnType( Types.VARBINARY, "long byte" );
+ registerColumnType( Types.LONGVARBINARY, "long byte" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, 32000, "varchar($l)" );
+ registerColumnType( Types.VARCHAR, "long varchar" );
+ registerColumnType( Types.LONGVARCHAR, "long varchar" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time with time zone" );
+ registerColumnType( Types.TIMESTAMP, "timestamp with time zone" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+
+ registerFunction( "abs", new StandardSQLFunction( "abs" ) );
+ registerFunction( "atan", new StandardSQLFunction( "atan", Hibernate.DOUBLE ) );
+ registerFunction( "bit_add", new StandardSQLFunction( "bit_add" ) );
+ registerFunction( "bit_and", new StandardSQLFunction( "bit_and" ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(hex(?1))*4" ) );
+ registerFunction( "bit_not", new StandardSQLFunction( "bit_not" ) );
+ registerFunction( "bit_or", new StandardSQLFunction( "bit_or" ) );
+ registerFunction( "bit_xor", new StandardSQLFunction( "bit_xor" ) );
+ registerFunction( "character_length", new StandardSQLFunction( "character_length", Hibernate.LONG ) );
+ registerFunction( "charextract", new StandardSQLFunction( "charextract", Hibernate.STRING ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "+", ")" ) );
+ registerFunction( "cos", new StandardSQLFunction( "cos", Hibernate.DOUBLE ) );
+ registerFunction( "current_user", new NoArgSQLFunction( "current_user", Hibernate.STRING, false ) );
+ registerFunction( "current_time", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
+ registerFunction( "current_date", new NoArgSQLFunction( "date('now')", Hibernate.TIMESTAMP, false ) );
+ registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
+ registerFunction( "day", new StandardSQLFunction( "day", Hibernate.INTEGER ) );
+ registerFunction( "dba", new NoArgSQLFunction( "dba", Hibernate.STRING, true ) );
+ registerFunction( "dow", new StandardSQLFunction( "dow", Hibernate.STRING ) );
+ registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "date_part('?1', ?3)" ) );
+ registerFunction( "exp", new StandardSQLFunction( "exp", Hibernate.DOUBLE ) );
+ registerFunction( "gmt_timestamp", new StandardSQLFunction( "gmt_timestamp", Hibernate.STRING ) );
+ registerFunction( "hash", new StandardSQLFunction( "hash", Hibernate.INTEGER ) );
+ registerFunction( "hex", new StandardSQLFunction( "hex", Hibernate.STRING ) );
+ registerFunction( "hour", new StandardSQLFunction( "hour", Hibernate.INTEGER ) );
+ registerFunction( "initial_user", new NoArgSQLFunction( "initial_user", Hibernate.STRING, false ) );
+ registerFunction( "intextract", new StandardSQLFunction( "intextract", Hibernate.INTEGER ) );
+ registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.LONG, "locate(?1, ?2)" ) );
+ registerFunction( "length", new StandardSQLFunction( "length", Hibernate.LONG ) );
+ registerFunction( "ln", new StandardSQLFunction( "ln", Hibernate.DOUBLE ) );
+ registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE ) );
+ registerFunction( "lower", new StandardSQLFunction( "lower" ) );
+ registerFunction( "lowercase", new StandardSQLFunction( "lowercase" ) );
+ registerFunction( "minute", new StandardSQLFunction( "minute", Hibernate.INTEGER ) );
+ registerFunction( "month", new StandardSQLFunction( "month", Hibernate.INTEGER ) );
+ registerFunction( "octet_length", new StandardSQLFunction( "octet_length", Hibernate.LONG ) );
+ registerFunction( "pad", new StandardSQLFunction( "pad", Hibernate.STRING ) );
+ registerFunction( "position", new StandardSQLFunction( "position", Hibernate.LONG ) );
+ registerFunction( "power", new StandardSQLFunction( "power", Hibernate.DOUBLE ) );
+ registerFunction( "random", new NoArgSQLFunction( "random", Hibernate.LONG, true ) );
+ registerFunction( "randomf", new NoArgSQLFunction( "randomf", Hibernate.DOUBLE, true ) );
+ registerFunction( "right", new StandardSQLFunction( "right", Hibernate.STRING ) );
+ registerFunction( "session_user", new NoArgSQLFunction( "session_user", Hibernate.STRING, false ) );
+ registerFunction( "second", new StandardSQLFunction( "second", Hibernate.INTEGER ) );
+ registerFunction( "size", new NoArgSQLFunction( "size", Hibernate.LONG, true ) );
+ registerFunction( "squeeze", new StandardSQLFunction( "squeeze" ) );
+ registerFunction( "sin", new StandardSQLFunction( "sin", Hibernate.DOUBLE ) );
+ registerFunction( "soundex", new StandardSQLFunction( "soundex", Hibernate.STRING ) );
+ registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE ) );
+ registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 FROM ?2 FOR ?3)" ) );
+ registerFunction( "system_user", new NoArgSQLFunction( "system_user", Hibernate.STRING, false ) );
+ //registerFunction( "trim", new StandardSQLFunction( "trim", Hibernate.STRING ) );
+ registerFunction( "unhex", new StandardSQLFunction( "unhex", Hibernate.STRING ) );
+ registerFunction( "upper", new StandardSQLFunction( "upper" ) );
+ registerFunction( "uppercase", new StandardSQLFunction( "uppercase" ) );
+ registerFunction( "user", new NoArgSQLFunction( "user", Hibernate.STRING, false ) );
+ registerFunction( "usercode", new NoArgSQLFunction( "usercode", Hibernate.STRING, true ) );
+ registerFunction( "username", new NoArgSQLFunction( "username", Hibernate.STRING, true ) );
+ registerFunction( "uuid_create", new StandardSQLFunction( "uuid_create", Hibernate.BYTE ) );
+ registerFunction( "uuid_compare", new StandardSQLFunction( "uuid_compare", Hibernate.INTEGER ) );
+ registerFunction( "uuid_from_char", new StandardSQLFunction( "uuid_from_char", Hibernate.BYTE ) );
+ registerFunction( "uuid_to_char", new StandardSQLFunction( "uuid_to_char", Hibernate.STRING ) );
+ registerFunction( "year", new StandardSQLFunction( "year", Hibernate.INTEGER ) );
+ }
+
+ /**
+ * Do we need to drop constraints before dropping tables in this dialect?
+ *
+ * @return boolean
+ */
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support <tt>FOR UPDATE OF</tt>, allowing
+ * particular rows to be locked?
+ *
+ * @return True (Ingres does support "for update of" syntax...)
+ */
+ public boolean supportsForUpdateOf() {
+ return true;
+ }
+
+ /**
+ * The syntax used to add a column to a table (optional).
+ */
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ /**
+ * The keyword used to specify a nullable column.
+ *
+ * @return String
+ */
+ public String getNullColumnString() {
+ return " with null";
+ }
+
+ /**
+ * Does this dialect support sequences?
+ *
+ * @return boolean
+ */
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ /**
+ * The syntax that fetches the next value of a sequence, if sequences are supported.
+ *
+ * @param sequenceName the name of the sequence
+ *
+ * @return String
+ */
+ public String getSequenceNextValString(String sequenceName) {
+ return "select nextval for " + sequenceName;
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
+ /**
+ * The syntax used to create a sequence, if sequences are supported.
+ *
+ * @param sequenceName the name of the sequence
+ *
+ * @return String
+ */
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+
+ /**
+ * The syntax used to drop a sequence, if sequences are supported.
+ *
+ * @param sequenceName the name of the sequence
+ *
+ * @return String
+ */
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName + " restrict";
+ }
+
+ /**
+ * A query used to find all sequences
+ */
+ public String getQuerySequencesString() {
+ return "select seq_name from iisequence";
+ }
+
+ /**
+ * The name of the SQL function that transforms a string to
+ * lowercase
+ *
+ * @return String
+ */
+ public String getLowercaseFunction() {
+ return "lowercase";
+ }
+
+ /**
+ * Does this <tt>Dialect</tt> have some kind of <tt>LIMIT</tt> syntax?
+ */
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ /**
+ * Does this dialect support an offset?
+ */
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ /**
+ * Add a <tt>LIMIT</tt> clause to the given SQL <tt>SELECT</tt>
+ *
+ * @return the modified SQL
+ */
+ public String getLimitString(String querySelect, int offset, int limit) {
+ if ( offset > 0 ) {
+ throw new UnsupportedOperationException( "offset not supported" );
+ }
+ return new StringBuffer( querySelect.length() + 16 )
+ .append( querySelect )
+ .insert( 6, " first " + limit )
+ .toString();
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+ /**
+ * Does the <tt>LIMIT</tt> clause take a "maximum" row number instead
+ * of a total number of returned rows?
+ */
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ /**
+ * Ingres explicitly needs "unique not null", because "with null" is default
+ */
+ public boolean supportsNotNullUnique() {
+ return false;
+ }
+
+ /**
+ * Does this dialect support temporary tables?
+ */
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "declare global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit preserve rows with norecovery";
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ return "session." + super.generateTemporaryTableName( baseTableName );
+ }
+
+
+ /**
+ * Expression for current_timestamp
+ */
+ public String getCurrentTimestampSQLFunctionName() {
+ return "date(now)";
+ }
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsSubselectAsInPredicateLHS() {
+ return false;
+ }
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExpectedLobUsagePattern () {
+ return false;
+ }
+}
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,105 +0,0 @@
-//$Id: InterbaseDialect.java 7746 2005-08-03 23:29:32Z oneovthafew $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-
-/**
- * An SQL dialect for Interbase.
- * @author Gavin King
- */
-public class InterbaseDialect extends Dialect {
-
- public InterbaseDialect() {
- super();
- registerColumnType( Types.BIT, "smallint" );
- registerColumnType( Types.BIGINT, "numeric(18,0)" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "smallint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "blob" );
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- registerColumnType( Types.BLOB, "blob" );
- registerColumnType( Types.CLOB, "blob sub_type 1" );
-
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName ) + " from RDB$DATABASE";
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return "gen_id( " + sequenceName + ", 1 )";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create generator " + sequenceName;
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "delete from RDB$GENERATORS where RDB$GENERATOR_NAME = '" + sequenceName.toUpperCase() + "'";
- }
-
- public String getQuerySequencesString() {
- return "select RDB$GENERATOR_NAME from RDB$GENERATORS";
- }
-
- public String getForUpdateString() {
- return " with lock";
- }
- public String getForUpdateString(String aliases) {
- return " for update of " + aliases + " with lock";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer( sql.length()+15 )
- .append(sql)
- .append(hasOffset ? " rows ? to ?" : " rows ?")
- .toString();
- }
-
- public boolean bindLimitParametersFirst() {
- return false;
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return false;
- }
-
- public String getCurrentTimestampCallString() {
- // TODO : not sure which (either?) is correct, could not find docs on how to do this.
- // did find various blogs and forums mentioning that select CURRENT_TIMESTAMP
- // does not work...
- return "{?= call CURRENT_TIMESTAMP }";
-// return "select CURRENT_TIMESTAMP from RDB$DATABASE";
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return true;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/InterbaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,128 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+
+/**
+ * An SQL dialect for Interbase.
+ * @author Gavin King
+ */
+public class InterbaseDialect extends Dialect {
+
+ public InterbaseDialect() {
+ super();
+ registerColumnType( Types.BIT, "smallint" );
+ registerColumnType( Types.BIGINT, "numeric(18,0)" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "smallint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "blob" );
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "blob sub_type 1" );
+
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName ) + " from RDB$DATABASE";
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "gen_id( " + sequenceName + ", 1 )";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create generator " + sequenceName;
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "delete from RDB$GENERATORS where RDB$GENERATOR_NAME = '" + sequenceName.toUpperCase() + "'";
+ }
+
+ public String getQuerySequencesString() {
+ return "select RDB$GENERATOR_NAME from RDB$GENERATORS";
+ }
+
+ public String getForUpdateString() {
+ return " with lock";
+ }
+ public String getForUpdateString(String aliases) {
+ return " for update of " + aliases + " with lock";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length()+15 )
+ .append(sql)
+ .append(hasOffset ? " rows ? to ?" : " rows ?")
+ .toString();
+ }
+
+ public boolean bindLimitParametersFirst() {
+ return false;
+ }
+
+ public boolean bindLimitParametersInReverseOrder() {
+ return false;
+ }
+
+ public String getCurrentTimestampCallString() {
+ // TODO : not sure which (either?) is correct, could not find docs on how to do this.
+ // did find various blogs and forums mentioning that select CURRENT_TIMESTAMP
+ // does not work...
+ return "{?= call CURRENT_TIMESTAMP }";
+// return "select CURRENT_TIMESTAMP from RDB$DATABASE";
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return true;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,78 +0,0 @@
-// $Id: JDataStoreDialect.java 7075 2005-06-08 07:06:50Z oneovthafew $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.cfg.Environment;
-
-/**
- * A <tt>Dialect</tt> for JDataStore.
- *
- * @author Vishy Kasar
- */
-public class JDataStoreDialect extends Dialect {
-
- /**
- * Creates new JDataStoreDialect
- */
- public JDataStoreDialect() {
- super();
-
- registerColumnType( Types.BIT, "tinyint" );
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "varbinary($l)" );
- registerColumnType( Types.NUMERIC, "numeric($p, $s)" );
-
- registerColumnType( Types.BLOB, "varbinary" );
- registerColumnType( Types.CLOB, "varchar" );
-
- getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
- public String getCascadeConstraintsString() {
- return " cascade";
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public String getIdentitySelectString() {
- return null; // NOT_SUPPORTED_SHOULD_USE_JDBC3_PreparedStatement.getGeneratedKeys_method
- }
-
- public String getIdentityColumnString() {
- return "autoincrement";
- }
-
- public String getNoColumnsInsertString() {
- return "default values";
- }
-
- public boolean supportsColumnCheck() {
- return false;
- }
-
- public boolean supportsTableCheck() {
- return false;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/JDataStoreDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.cfg.Environment;
+
+/**
+ * A <tt>Dialect</tt> for JDataStore.
+ *
+ * @author Vishy Kasar
+ */
+public class JDataStoreDialect extends Dialect {
+
+ /**
+ * Creates new JDataStoreDialect
+ */
+ public JDataStoreDialect() {
+ super();
+
+ registerColumnType( Types.BIT, "tinyint" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "varbinary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric($p, $s)" );
+
+ registerColumnType( Types.BLOB, "varbinary" );
+ registerColumnType( Types.CLOB, "varchar" );
+
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ public String getCascadeConstraintsString() {
+ return " cascade";
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public String getIdentitySelectString() {
+ return null; // NOT_SUPPORTED_SHOULD_USE_JDBC3_PreparedStatement.getGeneratedKeys_method
+ }
+
+ public String getIdentityColumnString() {
+ return "autoincrement";
+ }
+
+ public String getNoColumnsInsertString() {
+ return "default values";
+ }
+
+ public boolean supportsColumnCheck() {
+ return false;
+ }
+
+ public boolean supportsTableCheck() {
+ return false;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MckoiDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,98 +0,0 @@
-//$Id: MckoiDialect.java 9328 2006-02-23 17:32:47Z steveebersole $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.UpdateLockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.MckoiCaseFragment;
-
-/**
- * An SQL dialect compatible with McKoi SQL
- * @author Doug Currie, Gabe Hicks
- */
-public class MckoiDialect extends Dialect {
- public MckoiDialect() {
- super();
- registerColumnType( Types.BIT, "bit" );
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "varbinary" );
- registerColumnType( Types.NUMERIC, "numeric" );
- registerColumnType( Types.BLOB, "blob" );
- registerColumnType( Types.CLOB, "clob" );
-
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
- registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
- registerFunction( "round", new StandardSQLFunction( "round", Hibernate.INTEGER ) );
- registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER ) );
- registerFunction( "least", new StandardSQLFunction("least") );
- registerFunction( "greatest", new StandardSQLFunction("greatest") );
- registerFunction( "user", new StandardSQLFunction( "user", Hibernate.STRING ) );
- registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName );
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return "nextval('" + sequenceName + "')";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getForUpdateString() {
- return "";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public CaseFragment createCaseFragment() {
- return new MckoiCaseFragment();
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax...
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- return new UpdateLockingStrategy( lockable, lockMode );
- }
- else {
- return new SelectLockingStrategy( lockable, lockMode );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MckoiDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MckoiDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,121 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.UpdateLockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.MckoiCaseFragment;
+
+/**
+ * An SQL dialect compatible with McKoi SQL
+ * @author Doug Currie, Gabe Hicks
+ */
+public class MckoiDialect extends Dialect {
+ public MckoiDialect() {
+ super();
+ registerColumnType( Types.BIT, "bit" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "varbinary" );
+ registerColumnType( Types.NUMERIC, "numeric" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
+ registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
+ registerFunction( "round", new StandardSQLFunction( "round", Hibernate.INTEGER ) );
+ registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER ) );
+ registerFunction( "least", new StandardSQLFunction("least") );
+ registerFunction( "greatest", new StandardSQLFunction("greatest") );
+ registerFunction( "user", new StandardSQLFunction( "user", Hibernate.STRING ) );
+ registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName );
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "nextval('" + sequenceName + "')";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public CaseFragment createCaseFragment() {
+ return new MckoiCaseFragment();
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // Mckoi has no known variation of a "SELECT ... FOR UPDATE" syntax...
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ return new UpdateLockingStrategy( lockable, lockMode );
+ }
+ else {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,221 +0,0 @@
-//$Id: MimerSQLDialect.java 7822 2005-08-10 19:49:36Z oneovthafew $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.*;
-
-/**
- * An Hibernate 3 SQL dialect for Mimer SQL. This dialect requires Mimer SQL 9.2.1 or later
- * because of the mappings to NCLOB, BINARY, and BINARY VARYING.
- * @author Fredrik �lund <fredrik.alund(a)mimer.se>
- */
-public class MimerSQLDialect extends Dialect {
-
- private static final int NATIONAL_CHAR_LENGTH = 2000;
- private static final int BINARY_MAX_LENGTH = 2000;
-
- /**
- * Even thoug Mimer SQL supports character and binary columns up to 15 000 in lenght,
- * this is also the maximum width of the table (exluding LOBs). To avoid breaking the limit all the
- * time we limit the length of the character columns to CHAR_MAX_LENTH, NATIONAL_CHAR_LENGTH for national
- * characters, and BINARY_MAX_LENGTH for binary types.
- *
- */
- public MimerSQLDialect() {
- super();
- registerColumnType( Types.BIT, "ODBC.BIT" );
- registerColumnType( Types.BIGINT, "BIGINT" );
- registerColumnType( Types.SMALLINT, "SMALLINT" );
- registerColumnType( Types.TINYINT, "ODBC.TINYINT" );
- registerColumnType( Types.INTEGER, "INTEGER" );
- registerColumnType( Types.CHAR, "NCHAR(1)" );
- registerColumnType( Types.VARCHAR, NATIONAL_CHAR_LENGTH, "NATIONAL CHARACTER VARYING($l)" );
- registerColumnType( Types.VARCHAR, "NCLOB($l)" );
- registerColumnType( Types.LONGVARCHAR, "CLOB($1)");
- registerColumnType( Types.FLOAT, "FLOAT" );
- registerColumnType( Types.DOUBLE, "DOUBLE PRECISION" );
- registerColumnType( Types.DATE, "DATE" );
- registerColumnType( Types.TIME, "TIME" );
- registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
- registerColumnType( Types.VARBINARY, BINARY_MAX_LENGTH, "BINARY VARYING($l)" );
- registerColumnType( Types.VARBINARY, "BLOB($1)" );
- registerColumnType( Types.LONGVARBINARY, "BLOB($1)");
- registerColumnType( Types.BINARY, BINARY_MAX_LENGTH, "BINARY" );
- registerColumnType( Types.BINARY, "BLOB($1)" );
- registerColumnType( Types.NUMERIC, "NUMERIC(19, $l)" );
- registerColumnType( Types.BLOB, "BLOB($l)" );
- registerColumnType( Types.CLOB, "NCLOB($l)" );
-
- registerFunction("abs", new StandardSQLFunction("abs") );
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
- registerFunction("ceiling", new StandardSQLFunction("ceiling") );
- registerFunction("floor", new StandardSQLFunction("floor") );
- registerFunction("round", new StandardSQLFunction("round") );
-
- registerFunction("dacos", new StandardSQLFunction("dacos", Hibernate.DOUBLE) );
- registerFunction("acos", new StandardSQLFunction("dacos", Hibernate.DOUBLE) );
- registerFunction("dasin", new StandardSQLFunction("dasin", Hibernate.DOUBLE) );
- registerFunction("asin", new StandardSQLFunction("dasin", Hibernate.DOUBLE) );
- registerFunction("datan", new StandardSQLFunction("datan", Hibernate.DOUBLE) );
- registerFunction("atan", new StandardSQLFunction("datan", Hibernate.DOUBLE) );
- registerFunction("datan2", new StandardSQLFunction("datan2", Hibernate.DOUBLE) );
- registerFunction("atan2", new StandardSQLFunction("datan2", Hibernate.DOUBLE) );
- registerFunction("dcos", new StandardSQLFunction("dcos", Hibernate.DOUBLE) );
- registerFunction("cos", new StandardSQLFunction("dcos", Hibernate.DOUBLE) );
- registerFunction("dcot", new StandardSQLFunction("dcot", Hibernate.DOUBLE) );
- registerFunction("cot", new StandardSQLFunction("dcot", Hibernate.DOUBLE) );
- registerFunction("ddegrees", new StandardSQLFunction("ddegrees", Hibernate.DOUBLE) );
- registerFunction("degrees", new StandardSQLFunction("ddegrees", Hibernate.DOUBLE) );
- registerFunction("dexp", new StandardSQLFunction("dexp", Hibernate.DOUBLE) );
- registerFunction("exp", new StandardSQLFunction("dexp", Hibernate.DOUBLE) );
- registerFunction("dlog", new StandardSQLFunction("dlog", Hibernate.DOUBLE) );
- registerFunction("log", new StandardSQLFunction("dlog", Hibernate.DOUBLE) );
- registerFunction("dlog10", new StandardSQLFunction("dlog10", Hibernate.DOUBLE) );
- registerFunction("log10", new StandardSQLFunction("dlog10", Hibernate.DOUBLE) );
- registerFunction("dradian", new StandardSQLFunction("dradian", Hibernate.DOUBLE) );
- registerFunction("radian", new StandardSQLFunction("dradian", Hibernate.DOUBLE) );
- registerFunction("dsin", new StandardSQLFunction("dsin", Hibernate.DOUBLE) );
- registerFunction("sin", new StandardSQLFunction("dsin", Hibernate.DOUBLE) );
- registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING) );
- registerFunction("dsqrt", new StandardSQLFunction("dsqrt", Hibernate.DOUBLE) );
- registerFunction("sqrt", new StandardSQLFunction("dsqrt", Hibernate.DOUBLE) );
- registerFunction("dtan", new StandardSQLFunction("dtan", Hibernate.DOUBLE) );
- registerFunction("tan", new StandardSQLFunction("dtan", Hibernate.DOUBLE) );
- registerFunction("dpower", new StandardSQLFunction("dpower") );
- registerFunction("power", new StandardSQLFunction("dpower") );
-
- registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
- registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
- registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER) );
-
-
- registerFunction("varchar", new StandardSQLFunction("varchar", Hibernate.STRING) );
- registerFunction("real", new StandardSQLFunction("real", Hibernate.FLOAT) );
- registerFunction("bigint", new StandardSQLFunction("bigint", Hibernate.LONG) );
- registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
- registerFunction("integer", new StandardSQLFunction("integer", Hibernate.INTEGER) );
- registerFunction("smallint", new StandardSQLFunction("smallint", Hibernate.SHORT) );
-
- registerFunction("ascii_char", new StandardSQLFunction("ascii_char", Hibernate.CHARACTER) );
- registerFunction("ascii_code", new StandardSQLFunction("ascii_code", Hibernate.STRING));
- registerFunction("unicode_char", new StandardSQLFunction("unicode_char", Hibernate.LONG));
- registerFunction("unicode_code", new StandardSQLFunction("unicode_code", Hibernate.STRING));
- registerFunction("upper", new StandardSQLFunction("upper") );
- registerFunction("lower", new StandardSQLFunction("lower") );
- registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
- registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.STRING));
-
- getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, "50");
- }
-
- /**
- * The syntax used to add a column to a table
- */
- public String getAddColumnString() {
- return "add column";
- }
-
- /**
- * We do not have to drop constraints before we drop the table
- */
- public boolean dropConstraints() {
- return false;
- }
-
- /**
- * TODO: Check if Mimer SQL cannot handle the way DB2 does
- */
- public boolean supportsIdentityColumns() {
- return false;
- }
-
- /**
- * Mimer SQL supports sequences
- * @return boolean
- */
- public boolean supportsSequences() {
- return true;
- }
-
- /**
- * The syntax used to get the next value of a sequence in Mimer SQL
- */
- public String getSequenceNextValString(String sequenceName) {
- return "select next_value of " + sequenceName + " from system.onerow";
- }
-
- /**
- * The syntax used to create a sequence. Since we presume the sequences will be used as keys,
- * we make them unique.
- */
- public String getCreateSequenceString(String sequenceName) {
- return "create unique sequence " + sequenceName;
- }
-
- /**
- * The syntax used to drop sequences
- */
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName + " restrict";
- }
-
- /**
- * Mimer SQL does not support limit
- */
- public boolean supportsLimit() {
- return false;
- }
-
- /**
- * The syntax for using cascade on constraints
- */
- public String getCascadeConstraintsString() {
- return " cascade";
- }
-
- /**
- * The syntax for fetching all sequnces avialable in the current schema.
- */
- public String getQuerySequencesString() {
- return "select sequence_schema || '.' || sequence_name from information_schema.ext_sequences";
- }
-
- /**
- * Does the <tt>FOR UPDATE OF</tt> syntax specify particular
- * columns?
- */
- public boolean forUpdateOfColumns() {
- return false;
- }
-
- /**
- * Support the FOR UPDATE syntax? For now, returns false since
- * the current version of the Mimer SQL JDBC Driver does not support
- * updatable resultsets. Otherwise, Mimer SQL actually supports the for update syntax.
- * @return boolean
- */
- public boolean supportsForUpdate() {
- return false;
- }
-
-
- /**
- * For now, simply return false since we don't updatable result sets.
- */
- public boolean supportsOuterJoinForUpdate() {
- return false;
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MimerSQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,244 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.*;
+
+/**
+ * An Hibernate 3 SQL dialect for Mimer SQL. This dialect requires Mimer SQL 9.2.1 or later
+ * because of the mappings to NCLOB, BINARY, and BINARY VARYING.
+ * @author Fredrik �lund <fredrik.alund(a)mimer.se>
+ */
+public class MimerSQLDialect extends Dialect {
+
+ private static final int NATIONAL_CHAR_LENGTH = 2000;
+ private static final int BINARY_MAX_LENGTH = 2000;
+
+ /**
+ * Even thoug Mimer SQL supports character and binary columns up to 15 000 in lenght,
+ * this is also the maximum width of the table (exluding LOBs). To avoid breaking the limit all the
+ * time we limit the length of the character columns to CHAR_MAX_LENTH, NATIONAL_CHAR_LENGTH for national
+ * characters, and BINARY_MAX_LENGTH for binary types.
+ *
+ */
+ public MimerSQLDialect() {
+ super();
+ registerColumnType( Types.BIT, "ODBC.BIT" );
+ registerColumnType( Types.BIGINT, "BIGINT" );
+ registerColumnType( Types.SMALLINT, "SMALLINT" );
+ registerColumnType( Types.TINYINT, "ODBC.TINYINT" );
+ registerColumnType( Types.INTEGER, "INTEGER" );
+ registerColumnType( Types.CHAR, "NCHAR(1)" );
+ registerColumnType( Types.VARCHAR, NATIONAL_CHAR_LENGTH, "NATIONAL CHARACTER VARYING($l)" );
+ registerColumnType( Types.VARCHAR, "NCLOB($l)" );
+ registerColumnType( Types.LONGVARCHAR, "CLOB($1)");
+ registerColumnType( Types.FLOAT, "FLOAT" );
+ registerColumnType( Types.DOUBLE, "DOUBLE PRECISION" );
+ registerColumnType( Types.DATE, "DATE" );
+ registerColumnType( Types.TIME, "TIME" );
+ registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
+ registerColumnType( Types.VARBINARY, BINARY_MAX_LENGTH, "BINARY VARYING($l)" );
+ registerColumnType( Types.VARBINARY, "BLOB($1)" );
+ registerColumnType( Types.LONGVARBINARY, "BLOB($1)");
+ registerColumnType( Types.BINARY, BINARY_MAX_LENGTH, "BINARY" );
+ registerColumnType( Types.BINARY, "BLOB($1)" );
+ registerColumnType( Types.NUMERIC, "NUMERIC(19, $l)" );
+ registerColumnType( Types.BLOB, "BLOB($l)" );
+ registerColumnType( Types.CLOB, "NCLOB($l)" );
+
+ registerFunction("abs", new StandardSQLFunction("abs") );
+ registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+ registerFunction("ceiling", new StandardSQLFunction("ceiling") );
+ registerFunction("floor", new StandardSQLFunction("floor") );
+ registerFunction("round", new StandardSQLFunction("round") );
+
+ registerFunction("dacos", new StandardSQLFunction("dacos", Hibernate.DOUBLE) );
+ registerFunction("acos", new StandardSQLFunction("dacos", Hibernate.DOUBLE) );
+ registerFunction("dasin", new StandardSQLFunction("dasin", Hibernate.DOUBLE) );
+ registerFunction("asin", new StandardSQLFunction("dasin", Hibernate.DOUBLE) );
+ registerFunction("datan", new StandardSQLFunction("datan", Hibernate.DOUBLE) );
+ registerFunction("atan", new StandardSQLFunction("datan", Hibernate.DOUBLE) );
+ registerFunction("datan2", new StandardSQLFunction("datan2", Hibernate.DOUBLE) );
+ registerFunction("atan2", new StandardSQLFunction("datan2", Hibernate.DOUBLE) );
+ registerFunction("dcos", new StandardSQLFunction("dcos", Hibernate.DOUBLE) );
+ registerFunction("cos", new StandardSQLFunction("dcos", Hibernate.DOUBLE) );
+ registerFunction("dcot", new StandardSQLFunction("dcot", Hibernate.DOUBLE) );
+ registerFunction("cot", new StandardSQLFunction("dcot", Hibernate.DOUBLE) );
+ registerFunction("ddegrees", new StandardSQLFunction("ddegrees", Hibernate.DOUBLE) );
+ registerFunction("degrees", new StandardSQLFunction("ddegrees", Hibernate.DOUBLE) );
+ registerFunction("dexp", new StandardSQLFunction("dexp", Hibernate.DOUBLE) );
+ registerFunction("exp", new StandardSQLFunction("dexp", Hibernate.DOUBLE) );
+ registerFunction("dlog", new StandardSQLFunction("dlog", Hibernate.DOUBLE) );
+ registerFunction("log", new StandardSQLFunction("dlog", Hibernate.DOUBLE) );
+ registerFunction("dlog10", new StandardSQLFunction("dlog10", Hibernate.DOUBLE) );
+ registerFunction("log10", new StandardSQLFunction("dlog10", Hibernate.DOUBLE) );
+ registerFunction("dradian", new StandardSQLFunction("dradian", Hibernate.DOUBLE) );
+ registerFunction("radian", new StandardSQLFunction("dradian", Hibernate.DOUBLE) );
+ registerFunction("dsin", new StandardSQLFunction("dsin", Hibernate.DOUBLE) );
+ registerFunction("sin", new StandardSQLFunction("dsin", Hibernate.DOUBLE) );
+ registerFunction("soundex", new StandardSQLFunction("soundex", Hibernate.STRING) );
+ registerFunction("dsqrt", new StandardSQLFunction("dsqrt", Hibernate.DOUBLE) );
+ registerFunction("sqrt", new StandardSQLFunction("dsqrt", Hibernate.DOUBLE) );
+ registerFunction("dtan", new StandardSQLFunction("dtan", Hibernate.DOUBLE) );
+ registerFunction("tan", new StandardSQLFunction("dtan", Hibernate.DOUBLE) );
+ registerFunction("dpower", new StandardSQLFunction("dpower") );
+ registerFunction("power", new StandardSQLFunction("dpower") );
+
+ registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
+ registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
+ registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
+ registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
+ registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
+ registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER) );
+
+
+ registerFunction("varchar", new StandardSQLFunction("varchar", Hibernate.STRING) );
+ registerFunction("real", new StandardSQLFunction("real", Hibernate.FLOAT) );
+ registerFunction("bigint", new StandardSQLFunction("bigint", Hibernate.LONG) );
+ registerFunction("char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
+ registerFunction("integer", new StandardSQLFunction("integer", Hibernate.INTEGER) );
+ registerFunction("smallint", new StandardSQLFunction("smallint", Hibernate.SHORT) );
+
+ registerFunction("ascii_char", new StandardSQLFunction("ascii_char", Hibernate.CHARACTER) );
+ registerFunction("ascii_code", new StandardSQLFunction("ascii_code", Hibernate.STRING));
+ registerFunction("unicode_char", new StandardSQLFunction("unicode_char", Hibernate.LONG));
+ registerFunction("unicode_code", new StandardSQLFunction("unicode_code", Hibernate.STRING));
+ registerFunction("upper", new StandardSQLFunction("upper") );
+ registerFunction("lower", new StandardSQLFunction("lower") );
+ registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
+ registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.STRING));
+
+ getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, "50");
+ }
+
+ /**
+ * The syntax used to add a column to a table
+ */
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ /**
+ * We do not have to drop constraints before we drop the table
+ */
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ /**
+ * TODO: Check if Mimer SQL cannot handle the way DB2 does
+ */
+ public boolean supportsIdentityColumns() {
+ return false;
+ }
+
+ /**
+ * Mimer SQL supports sequences
+ * @return boolean
+ */
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ /**
+ * The syntax used to get the next value of a sequence in Mimer SQL
+ */
+ public String getSequenceNextValString(String sequenceName) {
+ return "select next_value of " + sequenceName + " from system.onerow";
+ }
+
+ /**
+ * The syntax used to create a sequence. Since we presume the sequences will be used as keys,
+ * we make them unique.
+ */
+ public String getCreateSequenceString(String sequenceName) {
+ return "create unique sequence " + sequenceName;
+ }
+
+ /**
+ * The syntax used to drop sequences
+ */
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName + " restrict";
+ }
+
+ /**
+ * Mimer SQL does not support limit
+ */
+ public boolean supportsLimit() {
+ return false;
+ }
+
+ /**
+ * The syntax for using cascade on constraints
+ */
+ public String getCascadeConstraintsString() {
+ return " cascade";
+ }
+
+ /**
+ * The syntax for fetching all sequnces avialable in the current schema.
+ */
+ public String getQuerySequencesString() {
+ return "select sequence_schema || '.' || sequence_name from information_schema.ext_sequences";
+ }
+
+ /**
+ * Does the <tt>FOR UPDATE OF</tt> syntax specify particular
+ * columns?
+ */
+ public boolean forUpdateOfColumns() {
+ return false;
+ }
+
+ /**
+ * Support the FOR UPDATE syntax? For now, returns false since
+ * the current version of the Mimer SQL JDBC Driver does not support
+ * updatable resultsets. Otherwise, Mimer SQL actually supports the for update syntax.
+ * @return boolean
+ */
+ public boolean supportsForUpdate() {
+ return false;
+ }
+
+
+ /**
+ * For now, simply return false since we don't updatable result sets.
+ */
+ public boolean supportsOuterJoinForUpdate() {
+ return false;
+ }
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,16 +0,0 @@
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-/**
- * An SQL dialect for MySQL 5.x specific features.
- *
- * @author Steve Ebersole
- */
-public class MySQL5Dialect extends MySQLDialect {
- protected void registerVarcharTypes() {
- registerColumnType( Types.VARCHAR, "longtext" );
-// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
- registerColumnType( Types.VARCHAR, 65535, "varchar($l)" );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+/**
+ * An SQL dialect for MySQL 5.x specific features.
+ *
+ * @author Steve Ebersole
+ */
+public class MySQL5Dialect extends MySQLDialect {
+ protected void registerVarcharTypes() {
+ registerColumnType( Types.VARCHAR, "longtext" );
+// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
+ registerColumnType( Types.VARCHAR, 65535, "varchar($l)" );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: $
-package org.hibernate.dialect;
-
-/**
- * @author Gavin King, Scott Marlow
- */
-public class MySQL5InnoDBDialect extends MySQL5Dialect {
-
- public boolean supportsCascadeDelete() {
- return true;
- }
-
- public String getTableTypeString() {
- return " ENGINE=InnoDB";
- }
-
- public boolean hasSelfReferentialForeignKeyBug() {
- return true;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQL5InnoDBDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+ * @author Gavin King, Scott Marlow
+ */
+public class MySQL5InnoDBDialect extends MySQL5Dialect {
+
+ public boolean supportsCascadeDelete() {
+ return true;
+ }
+
+ public String getTableTypeString() {
+ return " ENGINE=InnoDB";
+ }
+
+ public boolean hasSelfReferentialForeignKeyBug() {
+ return true;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,350 +0,0 @@
-//$Id: MySQLDialect.java 10963 2006-12-08 16:06:14Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.util.StringHelper;
-
-/**
- * An SQL dialect for MySQL (prior to 5.x).
- *
- * @author Gavin King
- */
-public class MySQLDialect extends Dialect {
-
- public MySQLDialect() {
- super();
- registerColumnType( Types.BIT, "bit" );
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "datetime" );
- registerColumnType( Types.VARBINARY, "longblob" );
- registerColumnType( Types.VARBINARY, 16777215, "mediumblob" );
- registerColumnType( Types.VARBINARY, 65535, "blob" );
- registerColumnType( Types.VARBINARY, 255, "tinyblob" );
- registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
- registerColumnType( Types.BLOB, "longblob" );
-// registerColumnType( Types.BLOB, 16777215, "mediumblob" );
-// registerColumnType( Types.BLOB, 65535, "blob" );
- registerColumnType( Types.CLOB, "longtext" );
-// registerColumnType( Types.CLOB, 16777215, "mediumtext" );
-// registerColumnType( Types.CLOB, 65535, "text" );
- registerVarcharTypes();
-
- registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
- registerFunction("bin", new StandardSQLFunction("bin", Hibernate.STRING) );
- registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
- registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.LONG) );
- registerFunction("lcase", new StandardSQLFunction("lcase") );
- registerFunction("lower", new StandardSQLFunction("lower") );
- registerFunction("length", new StandardSQLFunction("length", Hibernate.LONG) );
- registerFunction("ltrim", new StandardSQLFunction("ltrim") );
- registerFunction("ord", new StandardSQLFunction("ord", Hibernate.INTEGER) );
- registerFunction("quote", new StandardSQLFunction("quote") );
- registerFunction("reverse", new StandardSQLFunction("reverse") );
- registerFunction("rtrim", new StandardSQLFunction("rtrim") );
- registerFunction("soundex", new StandardSQLFunction("soundex") );
- registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) );
- registerFunction("ucase", new StandardSQLFunction("ucase") );
- registerFunction("upper", new StandardSQLFunction("upper") );
- registerFunction("unhex", new StandardSQLFunction("unhex", Hibernate.STRING) );
-
- registerFunction("abs", new StandardSQLFunction("abs") );
- registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
- registerFunction("crc32", new StandardSQLFunction("crc32", Hibernate.LONG) );
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
- registerFunction("log2", new StandardSQLFunction("log2", Hibernate.DOUBLE) );
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
- registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
-
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
-
- registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.INTEGER) );
- registerFunction("ceil", new StandardSQLFunction("ceil", Hibernate.INTEGER) );
- registerFunction("floor", new StandardSQLFunction("floor", Hibernate.INTEGER) );
- registerFunction("round", new StandardSQLFunction("round", Hibernate.INTEGER) );
-
- registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER) );
- registerFunction("timediff", new StandardSQLFunction("timediff", Hibernate.TIME) );
- registerFunction("date_format", new StandardSQLFunction("date_format", Hibernate.STRING) );
-
- registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE) );
- registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME) );
- registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
- registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME, false) );
- registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
- registerFunction("day", new StandardSQLFunction("day", Hibernate.INTEGER) );
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER) );
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
- registerFunction("from_days", new StandardSQLFunction("from_days", Hibernate.DATE) );
- registerFunction("from_unixtime", new StandardSQLFunction("from_unixtime", Hibernate.TIMESTAMP) );
- registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER) );
- registerFunction("last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
- registerFunction("localtime", new NoArgSQLFunction("localtime", Hibernate.TIMESTAMP) );
- registerFunction("localtimestamp", new NoArgSQLFunction("localtimestamp", Hibernate.TIMESTAMP) );
- registerFunction("microseconds", new StandardSQLFunction("microseconds", Hibernate.INTEGER) );
- registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER) );
- registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER) );
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
- registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP) );
- registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER) );
- registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER) );
- registerFunction("sec_to_time", new StandardSQLFunction("sec_to_time", Hibernate.TIME) );
- registerFunction("sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP) );
- registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
- registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
- registerFunction("time_to_sec", new StandardSQLFunction("time_to_sec", Hibernate.INTEGER) );
- registerFunction("to_days", new StandardSQLFunction("to_days", Hibernate.LONG) );
- registerFunction("unix_timestamp", new StandardSQLFunction("unix_timestamp", Hibernate.LONG) );
- registerFunction("utc_date", new NoArgSQLFunction("utc_date", Hibernate.STRING) );
- registerFunction("utc_time", new NoArgSQLFunction("utc_time", Hibernate.STRING) );
- registerFunction("utc_timestamp", new NoArgSQLFunction("utc_timestamp", Hibernate.STRING) );
- registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER) );
- registerFunction("weekday", new StandardSQLFunction("weekday", Hibernate.INTEGER) );
- registerFunction("weekofyear", new StandardSQLFunction("weekofyear", Hibernate.INTEGER) );
- registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER) );
- registerFunction("yearweek", new StandardSQLFunction("yearweek", Hibernate.INTEGER) );
-
- registerFunction("hex", new StandardSQLFunction("hex", Hibernate.STRING) );
- registerFunction("oct", new StandardSQLFunction("oct", Hibernate.STRING) );
-
- registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.LONG) );
- registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.LONG) );
-
- registerFunction("bit_count", new StandardSQLFunction("bit_count", Hibernate.LONG) );
- registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.STRING) );
- registerFunction("md5", new StandardSQLFunction("md5", Hibernate.STRING) );
- registerFunction("sha1", new StandardSQLFunction("sha1", Hibernate.STRING) );
- registerFunction("sha", new StandardSQLFunction("sha", Hibernate.STRING) );
-
- registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
-
- getDefaultProperties().setProperty(Environment.MAX_FETCH_DEPTH, "2");
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
- }
-
- protected void registerVarcharTypes() {
- registerColumnType( Types.VARCHAR, "longtext" );
-// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
-// registerColumnType( Types.VARCHAR, 65535, "text" );
- registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public boolean qualifyIndexName() {
- return false;
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public String getIdentitySelectString() {
- return "select last_insert_id()";
- }
-
- public String getIdentityColumnString() {
- return "not null auto_increment"; //starts with 1, implicitly
- }
-
- public String getAddForeignKeyConstraintString(
- String constraintName,
- String[] foreignKey,
- String referencedTable,
- String[] primaryKey, boolean referencesPrimaryKey
- ) {
- String cols = StringHelper.join(", ", foreignKey);
- return new StringBuffer(30)
- .append(" add index ")
- .append(constraintName)
- .append(" (")
- .append(cols)
- .append("), add constraint ")
- .append(constraintName)
- .append(" foreign key (")
- .append(cols)
- .append(") references ")
- .append(referencedTable)
- .append(" (")
- .append( StringHelper.join(", ", primaryKey) )
- .append(')')
- .toString();
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getDropForeignKeyString() {
- return " drop foreign key ";
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer( sql.length()+20 )
- .append(sql)
- .append( hasOffset ? " limit ?, ?" : " limit ?")
- .toString();
- }
-
- /*
- * Temporary, until MySQL fix Connector/J bug
- */
- /*public String getLimitString(String sql, int offset, int limit) {
- StringBuffer buf = new StringBuffer( sql.length()+20 )
- .append(sql);
- if (offset>0) {
- buf.append(" limit ")
- .append(offset)
- .append(", ")
- .append(limit);
- }
- else {
- buf.append(" limit ")
- .append(limit);
- }
- return buf.toString();
- }*/
-
- /*
- * Temporary, until MySQL fix Connector/J bug
- */
- /*public boolean supportsVariableLimit() {
- return false;
- }*/
-
- public char closeQuote() {
- return '`';
- }
-
- public char openQuote() {
- return '`';
- }
-
- public boolean supportsIfExistsBeforeTableName() {
- return true;
- }
-
- public String getSelectGUIDString() {
- return "select uuid()";
- }
-
- public boolean supportsCascadeDelete() {
- return false;
- }
-
- public String getTableComment(String comment) {
- return " comment='" + comment + "'";
- }
-
- public String getColumnComment(String comment) {
- return " comment '" + comment + "'";
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "create temporary table if not exists";
- }
-
- public String getCastTypeName(int code) {
- if ( code==Types.INTEGER ) {
- return "signed";
- }
- else if ( code==Types.VARCHAR ) {
- return "char";
- }
- else if ( code==Types.VARBINARY ) {
- return "binary";
- }
- else {
- return super.getCastTypeName( code );
- }
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "select now()";
- }
-
- public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
- return col;
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- boolean isResultSet = ps.execute();
- while (!isResultSet && ps.getUpdateCount() != -1) {
- isResultSet = ps.getMoreResults();
- }
- return ps.getResultSet();
- }
-
- public boolean supportsRowValueConstructorSyntax() {
- return true;
- }
-
- public Boolean performTemporaryTableDDLInIsolation() {
- return Boolean.FALSE;
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean areStringComparisonsCaseInsensitive() {
- return true;
- }
-
- public boolean supportsLobValueChangePropogation() {
- // note: at least my local MySQL 5.1 install shows this not working...
- return false;
- }
-
- public boolean supportsSubqueryOnMutatingTable() {
- return false;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MySQLDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,373 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.util.StringHelper;
+
+/**
+ * An SQL dialect for MySQL (prior to 5.x).
+ *
+ * @author Gavin King
+ */
+public class MySQLDialect extends Dialect {
+
+ public MySQLDialect() {
+ super();
+ registerColumnType( Types.BIT, "bit" );
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "datetime" );
+ registerColumnType( Types.VARBINARY, "longblob" );
+ registerColumnType( Types.VARBINARY, 16777215, "mediumblob" );
+ registerColumnType( Types.VARBINARY, 65535, "blob" );
+ registerColumnType( Types.VARBINARY, 255, "tinyblob" );
+ registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
+ registerColumnType( Types.BLOB, "longblob" );
+// registerColumnType( Types.BLOB, 16777215, "mediumblob" );
+// registerColumnType( Types.BLOB, 65535, "blob" );
+ registerColumnType( Types.CLOB, "longtext" );
+// registerColumnType( Types.CLOB, 16777215, "mediumtext" );
+// registerColumnType( Types.CLOB, 65535, "text" );
+ registerVarcharTypes();
+
+ registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+ registerFunction("bin", new StandardSQLFunction("bin", Hibernate.STRING) );
+ registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
+ registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.LONG) );
+ registerFunction("lcase", new StandardSQLFunction("lcase") );
+ registerFunction("lower", new StandardSQLFunction("lower") );
+ registerFunction("length", new StandardSQLFunction("length", Hibernate.LONG) );
+ registerFunction("ltrim", new StandardSQLFunction("ltrim") );
+ registerFunction("ord", new StandardSQLFunction("ord", Hibernate.INTEGER) );
+ registerFunction("quote", new StandardSQLFunction("quote") );
+ registerFunction("reverse", new StandardSQLFunction("reverse") );
+ registerFunction("rtrim", new StandardSQLFunction("rtrim") );
+ registerFunction("soundex", new StandardSQLFunction("soundex") );
+ registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) );
+ registerFunction("ucase", new StandardSQLFunction("ucase") );
+ registerFunction("upper", new StandardSQLFunction("upper") );
+ registerFunction("unhex", new StandardSQLFunction("unhex", Hibernate.STRING) );
+
+ registerFunction("abs", new StandardSQLFunction("abs") );
+ registerFunction("sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
+ registerFunction("crc32", new StandardSQLFunction("crc32", Hibernate.LONG) );
+ registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
+ registerFunction("log2", new StandardSQLFunction("log2", Hibernate.DOUBLE) );
+ registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
+ registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
+ registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
+ registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+
+ registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
+ registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
+
+ registerFunction("ceiling", new StandardSQLFunction("ceiling", Hibernate.INTEGER) );
+ registerFunction("ceil", new StandardSQLFunction("ceil", Hibernate.INTEGER) );
+ registerFunction("floor", new StandardSQLFunction("floor", Hibernate.INTEGER) );
+ registerFunction("round", new StandardSQLFunction("round", Hibernate.INTEGER) );
+
+ registerFunction("datediff", new StandardSQLFunction("datediff", Hibernate.INTEGER) );
+ registerFunction("timediff", new StandardSQLFunction("timediff", Hibernate.TIME) );
+ registerFunction("date_format", new StandardSQLFunction("date_format", Hibernate.STRING) );
+
+ registerFunction("curdate", new NoArgSQLFunction("curdate", Hibernate.DATE) );
+ registerFunction("curtime", new NoArgSQLFunction("curtime", Hibernate.TIME) );
+ registerFunction("current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
+ registerFunction("current_time", new NoArgSQLFunction("current_time", Hibernate.TIME, false) );
+ registerFunction("current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
+ registerFunction("day", new StandardSQLFunction("day", Hibernate.INTEGER) );
+ registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER) );
+ registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
+ registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
+ registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
+ registerFunction("from_days", new StandardSQLFunction("from_days", Hibernate.DATE) );
+ registerFunction("from_unixtime", new StandardSQLFunction("from_unixtime", Hibernate.TIMESTAMP) );
+ registerFunction("hour", new StandardSQLFunction("hour", Hibernate.INTEGER) );
+ registerFunction("last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
+ registerFunction("localtime", new NoArgSQLFunction("localtime", Hibernate.TIMESTAMP) );
+ registerFunction("localtimestamp", new NoArgSQLFunction("localtimestamp", Hibernate.TIMESTAMP) );
+ registerFunction("microseconds", new StandardSQLFunction("microseconds", Hibernate.INTEGER) );
+ registerFunction("minute", new StandardSQLFunction("minute", Hibernate.INTEGER) );
+ registerFunction("month", new StandardSQLFunction("month", Hibernate.INTEGER) );
+ registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
+ registerFunction("now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP) );
+ registerFunction("quarter", new StandardSQLFunction("quarter", Hibernate.INTEGER) );
+ registerFunction("second", new StandardSQLFunction("second", Hibernate.INTEGER) );
+ registerFunction("sec_to_time", new StandardSQLFunction("sec_to_time", Hibernate.TIME) );
+ registerFunction("sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP) );
+ registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
+ registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
+ registerFunction("time_to_sec", new StandardSQLFunction("time_to_sec", Hibernate.INTEGER) );
+ registerFunction("to_days", new StandardSQLFunction("to_days", Hibernate.LONG) );
+ registerFunction("unix_timestamp", new StandardSQLFunction("unix_timestamp", Hibernate.LONG) );
+ registerFunction("utc_date", new NoArgSQLFunction("utc_date", Hibernate.STRING) );
+ registerFunction("utc_time", new NoArgSQLFunction("utc_time", Hibernate.STRING) );
+ registerFunction("utc_timestamp", new NoArgSQLFunction("utc_timestamp", Hibernate.STRING) );
+ registerFunction("week", new StandardSQLFunction("week", Hibernate.INTEGER) );
+ registerFunction("weekday", new StandardSQLFunction("weekday", Hibernate.INTEGER) );
+ registerFunction("weekofyear", new StandardSQLFunction("weekofyear", Hibernate.INTEGER) );
+ registerFunction("year", new StandardSQLFunction("year", Hibernate.INTEGER) );
+ registerFunction("yearweek", new StandardSQLFunction("yearweek", Hibernate.INTEGER) );
+
+ registerFunction("hex", new StandardSQLFunction("hex", Hibernate.STRING) );
+ registerFunction("oct", new StandardSQLFunction("oct", Hibernate.STRING) );
+
+ registerFunction("octet_length", new StandardSQLFunction("octet_length", Hibernate.LONG) );
+ registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.LONG) );
+
+ registerFunction("bit_count", new StandardSQLFunction("bit_count", Hibernate.LONG) );
+ registerFunction("encrypt", new StandardSQLFunction("encrypt", Hibernate.STRING) );
+ registerFunction("md5", new StandardSQLFunction("md5", Hibernate.STRING) );
+ registerFunction("sha1", new StandardSQLFunction("sha1", Hibernate.STRING) );
+ registerFunction("sha", new StandardSQLFunction("sha", Hibernate.STRING) );
+
+ registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
+
+ getDefaultProperties().setProperty(Environment.MAX_FETCH_DEPTH, "2");
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+ }
+
+ protected void registerVarcharTypes() {
+ registerColumnType( Types.VARCHAR, "longtext" );
+// registerColumnType( Types.VARCHAR, 16777215, "mediumtext" );
+// registerColumnType( Types.VARCHAR, 65535, "text" );
+ registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public boolean qualifyIndexName() {
+ return false;
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public String getIdentitySelectString() {
+ return "select last_insert_id()";
+ }
+
+ public String getIdentityColumnString() {
+ return "not null auto_increment"; //starts with 1, implicitly
+ }
+
+ public String getAddForeignKeyConstraintString(
+ String constraintName,
+ String[] foreignKey,
+ String referencedTable,
+ String[] primaryKey, boolean referencesPrimaryKey
+ ) {
+ String cols = StringHelper.join(", ", foreignKey);
+ return new StringBuffer(30)
+ .append(" add index ")
+ .append(constraintName)
+ .append(" (")
+ .append(cols)
+ .append("), add constraint ")
+ .append(constraintName)
+ .append(" foreign key (")
+ .append(cols)
+ .append(") references ")
+ .append(referencedTable)
+ .append(" (")
+ .append( StringHelper.join(", ", primaryKey) )
+ .append(')')
+ .toString();
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getDropForeignKeyString() {
+ return " drop foreign key ";
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length()+20 )
+ .append(sql)
+ .append( hasOffset ? " limit ?, ?" : " limit ?")
+ .toString();
+ }
+
+ /*
+ * Temporary, until MySQL fix Connector/J bug
+ */
+ /*public String getLimitString(String sql, int offset, int limit) {
+ StringBuffer buf = new StringBuffer( sql.length()+20 )
+ .append(sql);
+ if (offset>0) {
+ buf.append(" limit ")
+ .append(offset)
+ .append(", ")
+ .append(limit);
+ }
+ else {
+ buf.append(" limit ")
+ .append(limit);
+ }
+ return buf.toString();
+ }*/
+
+ /*
+ * Temporary, until MySQL fix Connector/J bug
+ */
+ /*public boolean supportsVariableLimit() {
+ return false;
+ }*/
+
+ public char closeQuote() {
+ return '`';
+ }
+
+ public char openQuote() {
+ return '`';
+ }
+
+ public boolean supportsIfExistsBeforeTableName() {
+ return true;
+ }
+
+ public String getSelectGUIDString() {
+ return "select uuid()";
+ }
+
+ public boolean supportsCascadeDelete() {
+ return false;
+ }
+
+ public String getTableComment(String comment) {
+ return " comment='" + comment + "'";
+ }
+
+ public String getColumnComment(String comment) {
+ return " comment '" + comment + "'";
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create temporary table if not exists";
+ }
+
+ public String getCastTypeName(int code) {
+ if ( code==Types.INTEGER ) {
+ return "signed";
+ }
+ else if ( code==Types.VARCHAR ) {
+ return "char";
+ }
+ else if ( code==Types.VARBINARY ) {
+ return "binary";
+ }
+ else {
+ return super.getCastTypeName( code );
+ }
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select now()";
+ }
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
+ return col;
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ boolean isResultSet = ps.execute();
+ while (!isResultSet && ps.getUpdateCount() != -1) {
+ isResultSet = ps.getMoreResults();
+ }
+ return ps.getResultSet();
+ }
+
+ public boolean supportsRowValueConstructorSyntax() {
+ return true;
+ }
+
+ public Boolean performTemporaryTableDDLInIsolation() {
+ return Boolean.FALSE;
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean areStringComparisonsCaseInsensitive() {
+ return true;
+ }
+
+ public boolean supportsLobValueChangePropogation() {
+ // note: at least my local MySQL 5.1 install shows this not working...
+ return false;
+ }
+
+ public boolean supportsSubqueryOnMutatingTable() {
+ return false;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: MySQLInnoDBDialect.java 7118 2005-06-12 21:55:12Z oneovthafew $
-package org.hibernate.dialect;
-
-/**
- * @author Gavin King
- */
-public class MySQLInnoDBDialect extends MySQLDialect {
-
- public boolean supportsCascadeDelete() {
- return true;
- }
-
- public String getTableTypeString() {
- return " type=InnoDB";
- }
-
- public boolean hasSelfReferentialForeignKeyBug() {
- return true;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLInnoDBDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+ * @author Gavin King
+ */
+public class MySQLInnoDBDialect extends MySQLDialect {
+
+ public boolean supportsCascadeDelete() {
+ return true;
+ }
+
+ public String getTableTypeString() {
+ return " type=InnoDB";
+ }
+
+ public boolean hasSelfReferentialForeignKeyBug() {
+ return true;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,17 +0,0 @@
-//$Id: MySQLMyISAMDialect.java 5685 2005-02-12 07:19:50Z steveebersole $
-package org.hibernate.dialect;
-
-/**
- * @author Gavin King
- */
-public class MySQLMyISAMDialect extends MySQLDialect {
-
- public String getTableTypeString() {
- return " type=MyISAM";
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/MySQLMyISAMDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+ * @author Gavin King
+ */
+public class MySQLMyISAMDialect extends MySQLDialect {
+
+ public String getTableTypeString() {
+ return " type=MyISAM";
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,26 +0,0 @@
-//$Id: Oracle9Dialect.java 11286 2007-03-15 10:33:16Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.ANSIJoinFragment;
-
-
-/**
- * A dialect specifically for use with Oracle 10g.
- * <p/>
- * The main difference between this dialect and {@link Oracle9iDialect}
- * is the use of "ANSI join syntax" here...
- *
- * @author Steve Ebersole
- */
-public class Oracle10gDialect extends Oracle9iDialect {
-
- public Oracle10gDialect() {
- super();
- }
-
- public JoinFragment createOuterJoinFragment() {
- return new ANSIJoinFragment();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle10gDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.ANSIJoinFragment;
+
+
+/**
+ * A dialect specifically for use with Oracle 10g.
+ * <p/>
+ * The main difference between this dialect and {@link Oracle9iDialect}
+ * is the use of "ANSI join syntax" here...
+ *
+ * @author Steve Ebersole
+ */
+public class Oracle10gDialect extends Oracle9iDialect {
+
+ public Oracle10gDialect() {
+ super();
+ }
+
+ public JoinFragment createOuterJoinFragment() {
+ return new ANSIJoinFragment();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,438 +0,0 @@
-//$Id: OracleDialect.java 8610 2005-11-18 18:30:27Z steveebersole $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-import java.sql.SQLException;
-import java.sql.ResultSet;
-import java.sql.CallableStatement;
-
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.DecodeCaseFragment;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.OracleJoinFragment;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.NvlFunction;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.util.ReflectHelper;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.JDBCExceptionHelper;
-
-/**
- * A dialect for Oracle 8i.
- *
- * @author Steve Ebersole
- */
-public class Oracle8iDialect extends Dialect {
-
- public Oracle8iDialect() {
- super();
- registerCharacterTypeMappings();
- registerNumericTypeMappings();
- registerDateTimeTypeMappings();
- registerLargeObjectTypeMappings();
-
- registerReverseHibernateTypeMappings();
-
- registerFunctions();
-
- registerDefaultProperties();
- }
-
- protected void registerCharacterTypeMappings() {
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
- registerColumnType( Types.VARCHAR, "long" );
- }
-
- protected void registerNumericTypeMappings() {
- registerColumnType( Types.BIT, "number(1,0)" );
- registerColumnType( Types.BIGINT, "number(19,0)" );
- registerColumnType( Types.SMALLINT, "number(5,0)" );
- registerColumnType( Types.TINYINT, "number(3,0)" );
- registerColumnType( Types.INTEGER, "number(10,0)" );
-
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.NUMERIC, "number($p,$s)" );
- registerColumnType( Types.DECIMAL, "number($p,$s)" );
- }
-
- protected void registerDateTimeTypeMappings() {
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "date" );
- registerColumnType( Types.TIMESTAMP, "date" );
- }
-
- protected void registerLargeObjectTypeMappings() {
- registerColumnType( Types.VARBINARY, 2000, "raw($l)" );
- registerColumnType( Types.VARBINARY, "long raw" );
-
- registerColumnType( Types.BLOB, "blob" );
- registerColumnType( Types.CLOB, "clob" );
- }
-
- protected void registerReverseHibernateTypeMappings() {
- }
-
- protected void registerFunctions() {
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
- registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
- registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
- registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
- registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
-
- registerFunction( "round", new StandardSQLFunction("round") );
- registerFunction( "trunc", new StandardSQLFunction("trunc") );
- registerFunction( "ceil", new StandardSQLFunction("ceil") );
- registerFunction( "floor", new StandardSQLFunction("floor") );
-
- registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
- registerFunction( "initcap", new StandardSQLFunction("initcap") );
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
- registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
- registerFunction( "soundex", new StandardSQLFunction("soundex") );
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
- registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
-
- registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
- registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.TIMESTAMP) );
-
- registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
- registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
- registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
-
- registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
- registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
- registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
- registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
-
- registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
- registerFunction( "rownum", new NoArgSQLFunction("rownum", Hibernate.LONG, false) );
-
- // Multi-param string dialect functions...
- registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
- registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.INTEGER) );
- registerFunction( "instrb", new StandardSQLFunction("instrb", Hibernate.INTEGER) );
- registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
- registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
- registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
- registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
- registerFunction( "substrb", new StandardSQLFunction("substrb", Hibernate.STRING) );
- registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
-
- registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
- registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
- registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "vsize(?1)*8" ) );
- registerFunction( "coalesce", new NvlFunction() );
-
- // Multi-param numeric dialect functions...
- registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.FLOAT) );
- registerFunction( "log", new StandardSQLFunction("log", Hibernate.INTEGER) );
- registerFunction( "mod", new StandardSQLFunction("mod", Hibernate.INTEGER) );
- registerFunction( "nvl", new StandardSQLFunction("nvl") );
- registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
- registerFunction( "power", new StandardSQLFunction("power", Hibernate.FLOAT) );
-
- // Multi-param date dialect functions...
- registerFunction( "add_months", new StandardSQLFunction("add_months", Hibernate.DATE) );
- registerFunction( "months_between", new StandardSQLFunction("months_between", Hibernate.FLOAT) );
- registerFunction( "next_day", new StandardSQLFunction("next_day", Hibernate.DATE) );
-
- registerFunction( "str", new StandardSQLFunction("to_char", Hibernate.STRING) );
- }
-
- protected void registerDefaultProperties() {
- getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
- getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
- // Oracle driver reports to support getGeneratedKeys(), but they only
- // support the version taking an array of the names of the columns to
- // be returned (via its RETURNING clause). No other driver seems to
- // support this overloaded version.
- getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" );
- }
-
-
- // features which change between 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Support for the oracle proprietary join syntax...
- *
- * @return The orqacle join fragment
- */
- public JoinFragment createOuterJoinFragment() {
- return new OracleJoinFragment();
- }
-
- /**
- * Map case support to the Oracle DECODE function. Oracle did not
- * add support for CASE until 9i.
- *
- * @return The oracle CASE -> DECODE fragment
- */
- public CaseFragment createCaseFragment() {
- return new DecodeCaseFragment();
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- sql = sql.trim();
- boolean isForUpdate = false;
- if ( sql.toLowerCase().endsWith(" for update") ) {
- sql = sql.substring( 0, sql.length()-11 );
- isForUpdate = true;
- }
-
- StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
- if (hasOffset) {
- pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
- }
- else {
- pagingSelect.append("select * from ( ");
- }
- pagingSelect.append(sql);
- if (hasOffset) {
- pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
- }
- else {
- pagingSelect.append(" ) where rownum <= ?");
- }
-
- if ( isForUpdate ) {
- pagingSelect.append( " for update" );
- }
-
- return pagingSelect.toString();
- }
-
- /**
- * Allows access to the basic {@link Dialect#getSelectClauseNullString}
- * implementation...
- *
- * @param sqlType The {@link java.sql.Types} mapping type code
- * @return The appropriate select cluse fragment
- */
- public String getBasicSelectClauseNullString(int sqlType) {
- return super.getSelectClauseNullString( sqlType );
- }
-
- public String getSelectClauseNullString(int sqlType) {
- switch(sqlType) {
- case Types.VARCHAR:
- case Types.CHAR:
- return "to_char(null)";
- case Types.DATE:
- case Types.TIMESTAMP:
- case Types.TIME:
- return "to_date(null)";
- default:
- return "to_number(null)";
- }
- }
-
- public String getCurrentTimestampSelectString() {
- return "select sysdate from dual";
- }
-
- public String getCurrentTimestampSQLFunctionName() {
- return "sysdate";
- }
-
-
- // features which remain constant across 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~
-
- public String getAddColumnString() {
- return "add";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return sequenceName + ".nextval";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName; //starts with 1, implicitly
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getCascadeConstraintsString() {
- return " cascade constraints";
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
- public String getForUpdateNowaitString() {
- return " for update nowait";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public boolean supportsPooledSequences() {
- return true;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getForUpdateString(String aliases) {
- return getForUpdateString() + " of " + aliases;
- }
-
- public String getForUpdateNowaitString(String aliases) {
- return getForUpdateString() + " of " + aliases + " nowait";
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean forUpdateOfColumns() {
- return true;
- }
-
- public String getQuerySequencesString() {
- return " select sequence_name from all_sequences"
- + " union"
- + " select synonym_name"
- + " from all_synonyms us, all_sequences asq"
- + " where asq.sequence_name = us.table_name"
- + " and asq.sequence_owner = us.table_owner";
- }
-
- public String getSelectGUIDString() {
- return "select rawtohex(sys_guid()) from dual";
- }
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
-
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
- if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
- return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
- }
- else if ( errorCode == 1400 ) {
- // simple nullability constraint
- return null;
- }
- else {
- return null;
- }
- }
-
- };
-
- // not final-static to avoid possible classcast exceptions if using different oracle drivers.
- int oracletypes_cursor_value = 0;
- public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col) throws SQLException {
- if(oracletypes_cursor_value==0) {
- try {
- Class types = ReflectHelper.classForName("oracle.jdbc.driver.OracleTypes");
- oracletypes_cursor_value = types.getField("CURSOR").getInt(types.newInstance());
- } catch (Exception se) {
- throw new HibernateException("Problem while trying to load or access OracleTypes.CURSOR value",se);
- }
- }
- // register the type of the out param - an Oracle specific type
- statement.registerOutParameter(col, oracletypes_cursor_value);
- col++;
- return col;
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- ps.execute();
- return ( ResultSet ) ps.getObject( 1 );
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
-
- public boolean supportsCommentOn() {
- return true;
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- String name = super.generateTemporaryTableName(baseTableName);
- return name.length() > 30 ? name.substring( 1, 30 ) : name;
- }
-
- public String getCreateTemporaryTableString() {
- return "create global temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "on commit delete rows";
- }
-
- public boolean dropTemporaryTableAfterUse() {
- return false;
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsExistsInSelect() {
- return false;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,461 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.sql.CallableStatement;
+
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.DecodeCaseFragment;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.OracleJoinFragment;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.NvlFunction;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.util.ReflectHelper;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.JDBCExceptionHelper;
+
+/**
+ * A dialect for Oracle 8i.
+ *
+ * @author Steve Ebersole
+ */
+public class Oracle8iDialect extends Dialect {
+
+ public Oracle8iDialect() {
+ super();
+ registerCharacterTypeMappings();
+ registerNumericTypeMappings();
+ registerDateTimeTypeMappings();
+ registerLargeObjectTypeMappings();
+
+ registerReverseHibernateTypeMappings();
+
+ registerFunctions();
+
+ registerDefaultProperties();
+ }
+
+ protected void registerCharacterTypeMappings() {
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
+ registerColumnType( Types.VARCHAR, "long" );
+ }
+
+ protected void registerNumericTypeMappings() {
+ registerColumnType( Types.BIT, "number(1,0)" );
+ registerColumnType( Types.BIGINT, "number(19,0)" );
+ registerColumnType( Types.SMALLINT, "number(5,0)" );
+ registerColumnType( Types.TINYINT, "number(3,0)" );
+ registerColumnType( Types.INTEGER, "number(10,0)" );
+
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.NUMERIC, "number($p,$s)" );
+ registerColumnType( Types.DECIMAL, "number($p,$s)" );
+ }
+
+ protected void registerDateTimeTypeMappings() {
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "date" );
+ registerColumnType( Types.TIMESTAMP, "date" );
+ }
+
+ protected void registerLargeObjectTypeMappings() {
+ registerColumnType( Types.VARBINARY, 2000, "raw($l)" );
+ registerColumnType( Types.VARBINARY, "long raw" );
+
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+ }
+
+ protected void registerReverseHibernateTypeMappings() {
+ }
+
+ protected void registerFunctions() {
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
+ registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
+ registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
+ registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
+ registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
+
+ registerFunction( "round", new StandardSQLFunction("round") );
+ registerFunction( "trunc", new StandardSQLFunction("trunc") );
+ registerFunction( "ceil", new StandardSQLFunction("ceil") );
+ registerFunction( "floor", new StandardSQLFunction("floor") );
+
+ registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
+ registerFunction( "initcap", new StandardSQLFunction("initcap") );
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
+ registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
+ registerFunction( "soundex", new StandardSQLFunction("soundex") );
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+ registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
+
+ registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
+ registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.TIMESTAMP) );
+
+ registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
+ registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
+
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
+ registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
+ registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
+ registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
+
+ registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
+ registerFunction( "rownum", new NoArgSQLFunction("rownum", Hibernate.LONG, false) );
+
+ // Multi-param string dialect functions...
+ registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
+ registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.INTEGER) );
+ registerFunction( "instrb", new StandardSQLFunction("instrb", Hibernate.INTEGER) );
+ registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
+ registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
+ registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
+ registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
+ registerFunction( "substrb", new StandardSQLFunction("substrb", Hibernate.STRING) );
+ registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
+
+ registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "vsize(?1)*8" ) );
+ registerFunction( "coalesce", new NvlFunction() );
+
+ // Multi-param numeric dialect functions...
+ registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.FLOAT) );
+ registerFunction( "log", new StandardSQLFunction("log", Hibernate.INTEGER) );
+ registerFunction( "mod", new StandardSQLFunction("mod", Hibernate.INTEGER) );
+ registerFunction( "nvl", new StandardSQLFunction("nvl") );
+ registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
+ registerFunction( "power", new StandardSQLFunction("power", Hibernate.FLOAT) );
+
+ // Multi-param date dialect functions...
+ registerFunction( "add_months", new StandardSQLFunction("add_months", Hibernate.DATE) );
+ registerFunction( "months_between", new StandardSQLFunction("months_between", Hibernate.FLOAT) );
+ registerFunction( "next_day", new StandardSQLFunction("next_day", Hibernate.DATE) );
+
+ registerFunction( "str", new StandardSQLFunction("to_char", Hibernate.STRING) );
+ }
+
+ protected void registerDefaultProperties() {
+ getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
+ // Oracle driver reports to support getGeneratedKeys(), but they only
+ // support the version taking an array of the names of the columns to
+ // be returned (via its RETURNING clause). No other driver seems to
+ // support this overloaded version.
+ getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" );
+ }
+
+
+ // features which change between 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Support for the oracle proprietary join syntax...
+ *
+ * @return The orqacle join fragment
+ */
+ public JoinFragment createOuterJoinFragment() {
+ return new OracleJoinFragment();
+ }
+
+ /**
+ * Map case support to the Oracle DECODE function. Oracle did not
+ * add support for CASE until 9i.
+ *
+ * @return The oracle CASE -> DECODE fragment
+ */
+ public CaseFragment createCaseFragment() {
+ return new DecodeCaseFragment();
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ sql = sql.trim();
+ boolean isForUpdate = false;
+ if ( sql.toLowerCase().endsWith(" for update") ) {
+ sql = sql.substring( 0, sql.length()-11 );
+ isForUpdate = true;
+ }
+
+ StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
+ if (hasOffset) {
+ pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
+ }
+ else {
+ pagingSelect.append("select * from ( ");
+ }
+ pagingSelect.append(sql);
+ if (hasOffset) {
+ pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
+ }
+ else {
+ pagingSelect.append(" ) where rownum <= ?");
+ }
+
+ if ( isForUpdate ) {
+ pagingSelect.append( " for update" );
+ }
+
+ return pagingSelect.toString();
+ }
+
+ /**
+ * Allows access to the basic {@link Dialect#getSelectClauseNullString}
+ * implementation...
+ *
+ * @param sqlType The {@link java.sql.Types} mapping type code
+ * @return The appropriate select cluse fragment
+ */
+ public String getBasicSelectClauseNullString(int sqlType) {
+ return super.getSelectClauseNullString( sqlType );
+ }
+
+ public String getSelectClauseNullString(int sqlType) {
+ switch(sqlType) {
+ case Types.VARCHAR:
+ case Types.CHAR:
+ return "to_char(null)";
+ case Types.DATE:
+ case Types.TIMESTAMP:
+ case Types.TIME:
+ return "to_date(null)";
+ default:
+ return "to_number(null)";
+ }
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select sysdate from dual";
+ }
+
+ public String getCurrentTimestampSQLFunctionName() {
+ return "sysdate";
+ }
+
+
+ // features which remain constant across 8i, 9i, and 10g ~~~~~~~~~~~~~~~~~~
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName; //starts with 1, implicitly
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getCascadeConstraintsString() {
+ return " cascade constraints";
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ public String getForUpdateNowaitString() {
+ return " for update nowait";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public boolean supportsPooledSequences() {
+ return true;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getForUpdateString(String aliases) {
+ return getForUpdateString() + " of " + aliases;
+ }
+
+ public String getForUpdateNowaitString(String aliases) {
+ return getForUpdateString() + " of " + aliases + " nowait";
+ }
+
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean forUpdateOfColumns() {
+ return true;
+ }
+
+ public String getQuerySequencesString() {
+ return " select sequence_name from all_sequences"
+ + " union"
+ + " select synonym_name"
+ + " from all_synonyms us, all_sequences asq"
+ + " where asq.sequence_name = us.table_name"
+ + " and asq.sequence_owner = us.table_owner";
+ }
+
+ public String getSelectGUIDString() {
+ return "select rawtohex(sys_guid()) from dual";
+ }
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
+ if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
+ return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
+ }
+ else if ( errorCode == 1400 ) {
+ // simple nullability constraint
+ return null;
+ }
+ else {
+ return null;
+ }
+ }
+
+ };
+
+ // not final-static to avoid possible classcast exceptions if using different oracle drivers.
+ int oracletypes_cursor_value = 0;
+ public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col) throws SQLException {
+ if(oracletypes_cursor_value==0) {
+ try {
+ Class types = ReflectHelper.classForName("oracle.jdbc.driver.OracleTypes");
+ oracletypes_cursor_value = types.getField("CURSOR").getInt(types.newInstance());
+ } catch (Exception se) {
+ throw new HibernateException("Problem while trying to load or access OracleTypes.CURSOR value",se);
+ }
+ }
+ // register the type of the out param - an Oracle specific type
+ statement.registerOutParameter(col, oracletypes_cursor_value);
+ col++;
+ return col;
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ ps.execute();
+ return ( ResultSet ) ps.getObject( 1 );
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+ public boolean supportsCommentOn() {
+ return true;
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ String name = super.generateTemporaryTableName(baseTableName);
+ return name.length() > 30 ? name.substring( 1, 30 ) : name;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit delete rows";
+ }
+
+ public boolean dropTemporaryTableAfterUse() {
+ return false;
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,351 +0,0 @@
-//$Id: Oracle9Dialect.java 11259 2007-03-07 22:55:12Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.NvlFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * An SQL dialect for Oracle 9 (uses ANSI-style syntax where possible).
- *
- * @deprecated Use either Oracle9iDialect or Oracle10gDialect instead
- * @author Gavin King, David Channon
- */
-public class Oracle9Dialect extends Dialect {
-
- private static final Logger log = LoggerFactory.getLogger( Oracle9Dialect.class );
-
- public Oracle9Dialect() {
- super();
- log.warn( "The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead" );
- registerColumnType( Types.BIT, "number(1,0)" );
- registerColumnType( Types.BIGINT, "number(19,0)" );
- registerColumnType( Types.SMALLINT, "number(5,0)" );
- registerColumnType( Types.TINYINT, "number(3,0)" );
- registerColumnType( Types.INTEGER, "number(10,0)" );
- registerColumnType( Types.CHAR, "char(1 char)" );
- registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" );
- registerColumnType( Types.VARCHAR, "long" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "date" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, 2000, "raw($l)" );
- registerColumnType( Types.VARBINARY, "long raw" );
- registerColumnType( Types.NUMERIC, "number($p,$s)" );
- registerColumnType( Types.DECIMAL, "number($p,$s)" );
- registerColumnType( Types.BLOB, "blob" );
- registerColumnType( Types.CLOB, "clob" );
-
- // Oracle driver reports to support getGeneratedKeys(), but they only
- // support the version taking an array of the names of the columns to
- // be returned (via its RETURNING clause). No other driver seems to
- // support this overloaded version.
- getDefaultProperties().setProperty(Environment.USE_GET_GENERATED_KEYS, "false");
- getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
-
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
- registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
- registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
- registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
- registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
-
- registerFunction( "round", new StandardSQLFunction("round") );
- registerFunction( "trunc", new StandardSQLFunction("trunc") );
- registerFunction( "ceil", new StandardSQLFunction("ceil") );
- registerFunction( "floor", new StandardSQLFunction("floor") );
-
- registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
- registerFunction( "initcap", new StandardSQLFunction("initcap") );
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
- registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
- registerFunction( "soundex", new StandardSQLFunction("soundex") );
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
- registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
-
- registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
- registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.TIMESTAMP) );
-
- registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
- registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
- registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
-
- registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
- registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
- registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
- registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
-
- registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
- registerFunction( "rownum", new NoArgSQLFunction("rownum", Hibernate.LONG, false) );
-
- // Multi-param string dialect functions...
- registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
- registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.INTEGER) );
- registerFunction( "instrb", new StandardSQLFunction("instrb", Hibernate.INTEGER) );
- registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
- registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
- registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
- registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
- registerFunction( "substrb", new StandardSQLFunction("substrb", Hibernate.STRING) );
- registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
-
- registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
- registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
- registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "vsize(?1)*8" ) );
- registerFunction( "coalesce", new NvlFunction() );
-
- // Multi-param numeric dialect functions...
- registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.FLOAT) );
- registerFunction( "log", new StandardSQLFunction("log", Hibernate.INTEGER) );
- registerFunction( "mod", new StandardSQLFunction("mod", Hibernate.INTEGER) );
- registerFunction( "nvl", new StandardSQLFunction("nvl") );
- registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
- registerFunction( "power", new StandardSQLFunction("power", Hibernate.FLOAT) );
-
- // Multi-param date dialect functions...
- registerFunction( "add_months", new StandardSQLFunction("add_months", Hibernate.DATE) );
- registerFunction( "months_between", new StandardSQLFunction("months_between", Hibernate.FLOAT) );
- registerFunction( "next_day", new StandardSQLFunction("next_day", Hibernate.DATE) );
-
- registerFunction( "str", new StandardSQLFunction("to_char", Hibernate.STRING) );
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return sequenceName + ".nextval";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName; //starts with 1, implicitly
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getCascadeConstraintsString() {
- return " cascade constraints";
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
- public String getForUpdateNowaitString() {
- return " for update nowait";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public boolean supportsPooledSequences() {
- return true;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
-
- sql = sql.trim();
- boolean isForUpdate = false;
- if ( sql.toLowerCase().endsWith(" for update") ) {
- sql = sql.substring( 0, sql.length()-11 );
- isForUpdate = true;
- }
-
- StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
- if (hasOffset) {
- pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
- }
- else {
- pagingSelect.append("select * from ( ");
- }
- pagingSelect.append(sql);
- if (hasOffset) {
- pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
- }
- else {
- pagingSelect.append(" ) where rownum <= ?");
- }
-
- if ( isForUpdate ) {
- pagingSelect.append( " for update" );
- }
-
- return pagingSelect.toString();
- }
-
- public String getForUpdateString(String aliases) {
- return getForUpdateString() + " of " + aliases;
- }
-
- public String getForUpdateNowaitString(String aliases) {
- return getForUpdateString() + " of " + aliases + " nowait";
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean forUpdateOfColumns() {
- return true;
- }
-
- public String getQuerySequencesString() {
- return "select sequence_name from user_sequences";
- }
-
- public String getSelectGUIDString() {
- return "select rawtohex(sys_guid()) from dual";
- }
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
-
- /**
- * Extract the name of the violated constraint from the given SQLException.
- *
- * @param sqle The exception that was the result of the constraint violation.
- * @return The extracted constraint name.
- */
- public String extractConstraintName(SQLException sqle) {
- int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
- if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
- return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
- }
- else if ( errorCode == 1400 ) {
- // simple nullability constraint
- return null;
- }
- else {
- return null;
- }
- }
-
- };
-
- // not final-static to avoid possible classcast exceptions if using different oracle drivers.
- int oracletypes_cursor_value = 0;
- public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col) throws SQLException {
- if(oracletypes_cursor_value==0) {
- try {
- Class types = ReflectHelper.classForName("oracle.jdbc.driver.OracleTypes");
- oracletypes_cursor_value = types.getField("CURSOR").getInt(types.newInstance());
- } catch (Exception se) {
- throw new HibernateException("Problem while trying to load or access OracleTypes.CURSOR value",se);
- }
- }
- // register the type of the out param - an Oracle specific type
- statement.registerOutParameter(col, oracletypes_cursor_value);
- col++;
- return col;
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- ps.execute();
- return ( ResultSet ) ps.getObject( 1 );
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
-
- public boolean supportsCommentOn() {
- return true;
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- String name = super.generateTemporaryTableName(baseTableName);
- return name.length() > 30 ? name.substring( 1, 30 ) : name;
- }
-
- public String getCreateTemporaryTableString() {
- return "create global temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "on commit delete rows";
- }
-
- public boolean dropTemporaryTableAfterUse() {
- return false;
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public String getCurrentTimestampSelectString() {
- return "select systimestamp from dual";
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsExistsInSelect() {
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,374 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.NvlFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.JDBCExceptionHelper;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * An SQL dialect for Oracle 9 (uses ANSI-style syntax where possible).
+ *
+ * @deprecated Use either Oracle9iDialect or Oracle10gDialect instead
+ * @author Gavin King, David Channon
+ */
+public class Oracle9Dialect extends Dialect {
+
+ private static final Logger log = LoggerFactory.getLogger( Oracle9Dialect.class );
+
+ public Oracle9Dialect() {
+ super();
+ log.warn( "The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead" );
+ registerColumnType( Types.BIT, "number(1,0)" );
+ registerColumnType( Types.BIGINT, "number(19,0)" );
+ registerColumnType( Types.SMALLINT, "number(5,0)" );
+ registerColumnType( Types.TINYINT, "number(3,0)" );
+ registerColumnType( Types.INTEGER, "number(10,0)" );
+ registerColumnType( Types.CHAR, "char(1 char)" );
+ registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" );
+ registerColumnType( Types.VARCHAR, "long" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "date" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, 2000, "raw($l)" );
+ registerColumnType( Types.VARBINARY, "long raw" );
+ registerColumnType( Types.NUMERIC, "number($p,$s)" );
+ registerColumnType( Types.DECIMAL, "number($p,$s)" );
+ registerColumnType( Types.BLOB, "blob" );
+ registerColumnType( Types.CLOB, "clob" );
+
+ // Oracle driver reports to support getGeneratedKeys(), but they only
+ // support the version taking an array of the names of the columns to
+ // be returned (via its RETURNING clause). No other driver seems to
+ // support this overloaded version.
+ getDefaultProperties().setProperty(Environment.USE_GET_GENERATED_KEYS, "false");
+ getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
+ registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
+ registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
+ registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
+ registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
+
+ registerFunction( "round", new StandardSQLFunction("round") );
+ registerFunction( "trunc", new StandardSQLFunction("trunc") );
+ registerFunction( "ceil", new StandardSQLFunction("ceil") );
+ registerFunction( "floor", new StandardSQLFunction("floor") );
+
+ registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
+ registerFunction( "initcap", new StandardSQLFunction("initcap") );
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
+ registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
+ registerFunction( "soundex", new StandardSQLFunction("soundex") );
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+ registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
+
+ registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
+ registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.TIMESTAMP) );
+
+ registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
+ registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
+
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
+ registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.DATE, false) );
+ registerFunction( "systimestamp", new NoArgSQLFunction("systimestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction( "uid", new NoArgSQLFunction("uid", Hibernate.INTEGER, false) );
+ registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
+
+ registerFunction( "rowid", new NoArgSQLFunction("rowid", Hibernate.LONG, false) );
+ registerFunction( "rownum", new NoArgSQLFunction("rownum", Hibernate.LONG, false) );
+
+ // Multi-param string dialect functions...
+ registerFunction( "concat", new VarArgsSQLFunction(Hibernate.STRING, "", "||", "") );
+ registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.INTEGER) );
+ registerFunction( "instrb", new StandardSQLFunction("instrb", Hibernate.INTEGER) );
+ registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
+ registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
+ registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
+ registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
+ registerFunction( "substrb", new StandardSQLFunction("substrb", Hibernate.STRING) );
+ registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
+
+ registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "instr(?2,?1)" ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "vsize(?1)*8" ) );
+ registerFunction( "coalesce", new NvlFunction() );
+
+ // Multi-param numeric dialect functions...
+ registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.FLOAT) );
+ registerFunction( "log", new StandardSQLFunction("log", Hibernate.INTEGER) );
+ registerFunction( "mod", new StandardSQLFunction("mod", Hibernate.INTEGER) );
+ registerFunction( "nvl", new StandardSQLFunction("nvl") );
+ registerFunction( "nvl2", new StandardSQLFunction("nvl2") );
+ registerFunction( "power", new StandardSQLFunction("power", Hibernate.FLOAT) );
+
+ // Multi-param date dialect functions...
+ registerFunction( "add_months", new StandardSQLFunction("add_months", Hibernate.DATE) );
+ registerFunction( "months_between", new StandardSQLFunction("months_between", Hibernate.FLOAT) );
+ registerFunction( "next_day", new StandardSQLFunction("next_day", Hibernate.DATE) );
+
+ registerFunction( "str", new StandardSQLFunction("to_char", Hibernate.STRING) );
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName; //starts with 1, implicitly
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getCascadeConstraintsString() {
+ return " cascade constraints";
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ public String getForUpdateNowaitString() {
+ return " for update nowait";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public boolean supportsPooledSequences() {
+ return true;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+
+ sql = sql.trim();
+ boolean isForUpdate = false;
+ if ( sql.toLowerCase().endsWith(" for update") ) {
+ sql = sql.substring( 0, sql.length()-11 );
+ isForUpdate = true;
+ }
+
+ StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
+ if (hasOffset) {
+ pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
+ }
+ else {
+ pagingSelect.append("select * from ( ");
+ }
+ pagingSelect.append(sql);
+ if (hasOffset) {
+ pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
+ }
+ else {
+ pagingSelect.append(" ) where rownum <= ?");
+ }
+
+ if ( isForUpdate ) {
+ pagingSelect.append( " for update" );
+ }
+
+ return pagingSelect.toString();
+ }
+
+ public String getForUpdateString(String aliases) {
+ return getForUpdateString() + " of " + aliases;
+ }
+
+ public String getForUpdateNowaitString(String aliases) {
+ return getForUpdateString() + " of " + aliases + " nowait";
+ }
+
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean forUpdateOfColumns() {
+ return true;
+ }
+
+ public String getQuerySequencesString() {
+ return "select sequence_name from user_sequences";
+ }
+
+ public String getSelectGUIDString() {
+ return "select rawtohex(sys_guid()) from dual";
+ }
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+
+ /**
+ * Extract the name of the violated constraint from the given SQLException.
+ *
+ * @param sqle The exception that was the result of the constraint violation.
+ * @return The extracted constraint name.
+ */
+ public String extractConstraintName(SQLException sqle) {
+ int errorCode = JDBCExceptionHelper.extractErrorCode(sqle);
+ if ( errorCode == 1 || errorCode == 2291 || errorCode == 2292 ) {
+ return extractUsingTemplate( "constraint (", ") violated", sqle.getMessage() );
+ }
+ else if ( errorCode == 1400 ) {
+ // simple nullability constraint
+ return null;
+ }
+ else {
+ return null;
+ }
+ }
+
+ };
+
+ // not final-static to avoid possible classcast exceptions if using different oracle drivers.
+ int oracletypes_cursor_value = 0;
+ public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col) throws SQLException {
+ if(oracletypes_cursor_value==0) {
+ try {
+ Class types = ReflectHelper.classForName("oracle.jdbc.driver.OracleTypes");
+ oracletypes_cursor_value = types.getField("CURSOR").getInt(types.newInstance());
+ } catch (Exception se) {
+ throw new HibernateException("Problem while trying to load or access OracleTypes.CURSOR value",se);
+ }
+ }
+ // register the type of the out param - an Oracle specific type
+ statement.registerOutParameter(col, oracletypes_cursor_value);
+ col++;
+ return col;
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ ps.execute();
+ return ( ResultSet ) ps.getObject( 1 );
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+ public boolean supportsCommentOn() {
+ return true;
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ String name = super.generateTemporaryTableName(baseTableName);
+ return name.length() > 30 ? name.substring( 1, 30 ) : name;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit delete rows";
+ }
+
+ public boolean dropTemporaryTableAfterUse() {
+ return false;
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select systimestamp from dual";
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,77 +0,0 @@
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.ANSICaseFragment;
-
-/**
- * A dialect for Oracle 9i databases.
- * <p/>
- * Unlike the older (deprecated) {@Link Oracl9Dialect), this version specifies
- * to not use "ANSI join syntax" because 9i does not seem to properly
- * handle it in all cases.
- *
- * @author Steve Ebersole
- */
-public class Oracle9iDialect extends Oracle8iDialect {
- protected void registerCharacterTypeMappings() {
- registerColumnType( Types.CHAR, "char(1 char)" );
- registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" );
- registerColumnType( Types.VARCHAR, "long" );
- }
-
- protected void registerDateTimeTypeMappings() {
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "date" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- }
-
- public CaseFragment createCaseFragment() {
- // Oracle did add support for ANSI CASE statements in 9i
- return new ANSICaseFragment();
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- sql = sql.trim();
- boolean isForUpdate = false;
- if ( sql.toLowerCase().endsWith(" for update") ) {
- sql = sql.substring( 0, sql.length()-11 );
- isForUpdate = true;
- }
-
- StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
- if (hasOffset) {
- pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
- }
- else {
- pagingSelect.append("select * from ( ");
- }
- pagingSelect.append(sql);
- if (hasOffset) {
- pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
- }
- else {
- pagingSelect.append(" ) where rownum <= ?");
- }
-
- if ( isForUpdate ) {
- pagingSelect.append( " for update" );
- }
-
- return pagingSelect.toString();
- }
-
- public String getSelectClauseNullString(int sqlType) {
- return getBasicSelectClauseNullString( sqlType );
- }
-
- public String getCurrentTimestampSelectString() {
- return "select systimestamp from dual";
- }
-
- public String getCurrentTimestampSQLFunctionName() {
- // the standard SQL function name is current_timestamp...
- return "current_timestamp";
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.ANSICaseFragment;
+
+/**
+ * A dialect for Oracle 9i databases.
+ * <p/>
+ * Unlike the older (deprecated) {@Link Oracl9Dialect), this version specifies
+ * to not use "ANSI join syntax" because 9i does not seem to properly
+ * handle it in all cases.
+ *
+ * @author Steve Ebersole
+ */
+public class Oracle9iDialect extends Oracle8iDialect {
+ protected void registerCharacterTypeMappings() {
+ registerColumnType( Types.CHAR, "char(1 char)" );
+ registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" );
+ registerColumnType( Types.VARCHAR, "long" );
+ }
+
+ protected void registerDateTimeTypeMappings() {
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "date" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ }
+
+ public CaseFragment createCaseFragment() {
+ // Oracle did add support for ANSI CASE statements in 9i
+ return new ANSICaseFragment();
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ sql = sql.trim();
+ boolean isForUpdate = false;
+ if ( sql.toLowerCase().endsWith(" for update") ) {
+ sql = sql.substring( 0, sql.length()-11 );
+ isForUpdate = true;
+ }
+
+ StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
+ if (hasOffset) {
+ pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
+ }
+ else {
+ pagingSelect.append("select * from ( ");
+ }
+ pagingSelect.append(sql);
+ if (hasOffset) {
+ pagingSelect.append(" ) row_ where rownum <= ?) where rownum_ > ?");
+ }
+ else {
+ pagingSelect.append(" ) where rownum <= ?");
+ }
+
+ if ( isForUpdate ) {
+ pagingSelect.append( " for update" );
+ }
+
+ return pagingSelect.toString();
+ }
+
+ public String getSelectClauseNullString(int sqlType) {
+ return getBasicSelectClauseNullString( sqlType );
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select systimestamp from dual";
+ }
+
+ public String getCurrentTimestampSQLFunctionName() {
+ // the standard SQL function name is current_timestamp...
+ return "current_timestamp";
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/OracleDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,93 +0,0 @@
-//$Id: OracleDialect.java 8610 2005-11-18 18:30:27Z steveebersole $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.DecodeCaseFragment;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.OracleJoinFragment;
-
-/**
- * An SQL dialect for Oracle, compatible with Oracle 8.
- *
- * @deprecated Use Oracle8iDialect instead.
- * @author Gavin King
- */
-public class OracleDialect extends Oracle9Dialect {
-
- private static final Logger log = LoggerFactory.getLogger( OracleDialect.class );
-
- public OracleDialect() {
- super();
- log.warn( "The OracleDialect dialect has been deprecated; use Oracle8iDialect instead" );
- // Oracle8 and previous define only a "DATE" type which
- // is used to represent all aspects of date/time
- registerColumnType( Types.TIMESTAMP, "date" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
- }
-
- public JoinFragment createOuterJoinFragment() {
- return new OracleJoinFragment();
- }
- public CaseFragment createCaseFragment() {
- return new DecodeCaseFragment();
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
-
- sql = sql.trim();
- boolean isForUpdate = false;
- if ( sql.toLowerCase().endsWith(" for update") ) {
- sql = sql.substring( 0, sql.length()-11 );
- isForUpdate = true;
- }
-
- StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
- if (hasOffset) {
- pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
- }
- else {
- pagingSelect.append("select * from ( ");
- }
- pagingSelect.append(sql);
- if (hasOffset) {
- pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
- }
- else {
- pagingSelect.append(" ) where rownum <= ?");
- }
-
- if ( isForUpdate ) {
- pagingSelect.append( " for update" );
- }
-
- return pagingSelect.toString();
- }
-
- public String getSelectClauseNullString(int sqlType) {
- switch(sqlType) {
- case Types.VARCHAR:
- case Types.CHAR:
- return "to_char(null)";
- case Types.DATE:
- case Types.TIMESTAMP:
- case Types.TIME:
- return "to_date(null)";
- default:
- return "to_number(null)";
- }
- }
-
- public String getCurrentTimestampSelectString() {
- return "select sysdate from dual";
- }
-
- public String getCurrentTimestampSQLFunctionName() {
- return "sysdate";
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/OracleDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/OracleDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,116 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.DecodeCaseFragment;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.OracleJoinFragment;
+
+/**
+ * An SQL dialect for Oracle, compatible with Oracle 8.
+ *
+ * @deprecated Use Oracle8iDialect instead.
+ * @author Gavin King
+ */
+public class OracleDialect extends Oracle9Dialect {
+
+ private static final Logger log = LoggerFactory.getLogger( OracleDialect.class );
+
+ public OracleDialect() {
+ super();
+ log.warn( "The OracleDialect dialect has been deprecated; use Oracle8iDialect instead" );
+ // Oracle8 and previous define only a "DATE" type which
+ // is used to represent all aspects of date/time
+ registerColumnType( Types.TIMESTAMP, "date" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
+ }
+
+ public JoinFragment createOuterJoinFragment() {
+ return new OracleJoinFragment();
+ }
+ public CaseFragment createCaseFragment() {
+ return new DecodeCaseFragment();
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+
+ sql = sql.trim();
+ boolean isForUpdate = false;
+ if ( sql.toLowerCase().endsWith(" for update") ) {
+ sql = sql.substring( 0, sql.length()-11 );
+ isForUpdate = true;
+ }
+
+ StringBuffer pagingSelect = new StringBuffer( sql.length()+100 );
+ if (hasOffset) {
+ pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
+ }
+ else {
+ pagingSelect.append("select * from ( ");
+ }
+ pagingSelect.append(sql);
+ if (hasOffset) {
+ pagingSelect.append(" ) row_ ) where rownum_ <= ? and rownum_ > ?");
+ }
+ else {
+ pagingSelect.append(" ) where rownum <= ?");
+ }
+
+ if ( isForUpdate ) {
+ pagingSelect.append( " for update" );
+ }
+
+ return pagingSelect.toString();
+ }
+
+ public String getSelectClauseNullString(int sqlType) {
+ switch(sqlType) {
+ case Types.VARCHAR:
+ case Types.CHAR:
+ return "to_char(null)";
+ case Types.DATE:
+ case Types.TIMESTAMP:
+ case Types.TIME:
+ return "to_date(null)";
+ default:
+ return "to_number(null)";
+ }
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select sysdate from dual";
+ }
+
+ public String getCurrentTimestampSQLFunctionName() {
+ return "sysdate";
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,69 +0,0 @@
-//$Id: PointbaseDialect.java 9328 2006-02-23 17:32:47Z steveebersole $
-//Created on 04 February 2002, 17:35
-package org.hibernate.dialect;
-
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.UpdateLockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.LockMode;
-
-import java.sql.Types;
-
-/**
- * A <tt>Dialect</tt> for Pointbase.
- * @author Ed Mackenzie
- */
-public class PointbaseDialect extends org.hibernate.dialect.Dialect {
-
- /**
- * Creates new PointbaseDialect
- */
- public PointbaseDialect() {
- super();
- registerColumnType( Types.BIT, "smallint" ); //no pointbase BIT
- registerColumnType( Types.BIGINT, "bigint" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "smallint" ); //no pointbase TINYINT
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- //the BLOB type requires a size arguement - this defaults to
- //bytes - no arg defaults to 1 whole byte!
- //other argument mods include K - kilobyte, M - megabyte, G - gigabyte.
- //refer to the PBdevelopers guide for more info.
- registerColumnType( Types.VARBINARY, "blob($l)" );
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
- public String getCascadeConstraintsString() {
- return " cascade";
- }
-
- public String getForUpdateString() {
- return "";
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- return new UpdateLockingStrategy( lockable, lockMode );
- }
- else {
- return new SelectLockingStrategy( lockable, lockMode );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PointbaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,91 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.UpdateLockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.LockMode;
+
+import java.sql.Types;
+
+/**
+ * A <tt>Dialect</tt> for Pointbase.
+ * @author Ed Mackenzie
+ */
+public class PointbaseDialect extends org.hibernate.dialect.Dialect {
+
+ /**
+ * Creates new PointbaseDialect
+ */
+ public PointbaseDialect() {
+ super();
+ registerColumnType( Types.BIT, "smallint" ); //no pointbase BIT
+ registerColumnType( Types.BIGINT, "bigint" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "smallint" ); //no pointbase TINYINT
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ //the BLOB type requires a size arguement - this defaults to
+ //bytes - no arg defaults to 1 whole byte!
+ //other argument mods include K - kilobyte, M - megabyte, G - gigabyte.
+ //refer to the PBdevelopers guide for more info.
+ registerColumnType( Types.VARBINARY, "blob($l)" );
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ public String getCascadeConstraintsString() {
+ return " cascade";
+ }
+
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // Pointbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ return new UpdateLockingStrategy( lockable, lockMode );
+ }
+ else {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,337 +0,0 @@
-//$Id: PostgreSQLDialect.java 11367 2007-03-29 13:26:40Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.PositionSubstringFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
-import org.hibernate.exception.ViolatedConstraintNameExtracter;
-import org.hibernate.id.SequenceGenerator;
-
-/**
- * An SQL dialect for Postgres
- * @author Gavin King
- */
-public class PostgreSQLDialect extends Dialect {
-
- public PostgreSQLDialect() {
- super();
- registerColumnType( Types.BIT, "bool" );
- registerColumnType( Types.BIGINT, "int8" );
- registerColumnType( Types.SMALLINT, "int2" );
- registerColumnType( Types.TINYINT, "int2" );
- registerColumnType( Types.INTEGER, "int4" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float4" );
- registerColumnType( Types.DOUBLE, "float8" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "bytea" );
- registerColumnType( Types.CLOB, "text" );
- registerColumnType( Types.BLOB, "oid" );
- registerColumnType( Types.NUMERIC, "numeric($p, $s)" );
-
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction( "cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
- registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction( "log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
- registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction( "cbrt", new StandardSQLFunction("cbrt", Hibernate.DOUBLE) );
- registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction( "radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
- registerFunction( "degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
-
- registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
- registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
-
- registerFunction( "random", new NoArgSQLFunction("random", Hibernate.DOUBLE) );
-
- registerFunction( "round", new StandardSQLFunction("round") );
- registerFunction( "trunc", new StandardSQLFunction("trunc") );
- registerFunction( "ceil", new StandardSQLFunction("ceil") );
- registerFunction( "floor", new StandardSQLFunction("floor") );
-
- registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
- registerFunction( "initcap", new StandardSQLFunction("initcap") );
- registerFunction( "to_ascii", new StandardSQLFunction("to_ascii") );
- registerFunction( "quote_ident", new StandardSQLFunction("quote_ident", Hibernate.STRING) );
- registerFunction( "quote_literal", new StandardSQLFunction("quote_literal", Hibernate.STRING) );
- registerFunction( "md5", new StandardSQLFunction("md5") );
- registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
- registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
- registerFunction( "char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
- registerFunction( "bit_length", new StandardSQLFunction("bit_length", Hibernate.LONG) );
- registerFunction( "octet_length", new StandardSQLFunction("octet_length", Hibernate.LONG) );
-
- registerFunction( "age", new StandardSQLFunction("age") );
- registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
- registerFunction( "current_time", new NoArgSQLFunction("current_time", Hibernate.TIME, false) );
- registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
- registerFunction( "localtime", new NoArgSQLFunction("localtime", Hibernate.TIME, false) );
- registerFunction( "localtimestamp", new NoArgSQLFunction("localtimestamp", Hibernate.TIMESTAMP, false) );
- registerFunction( "now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP) );
- registerFunction( "timeofday", new NoArgSQLFunction("timeofday", Hibernate.STRING) );
-
- registerFunction( "current_user", new NoArgSQLFunction("current_user", Hibernate.STRING, false) );
- registerFunction( "session_user", new NoArgSQLFunction("session_user", Hibernate.STRING, false) );
- registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
- registerFunction( "current_database", new NoArgSQLFunction("current_database", Hibernate.STRING, true) );
- registerFunction( "current_schema", new NoArgSQLFunction("current_schema", Hibernate.STRING, true) );
-
- registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
- registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.DATE) );
- registerFunction( "to_timestamp", new StandardSQLFunction("to_timestamp", Hibernate.TIMESTAMP) );
- registerFunction( "to_number", new StandardSQLFunction("to_number", Hibernate.BIG_DECIMAL) );
-
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
-
- registerFunction( "locate", new PositionSubstringFunction() );
-
- registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") );
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName );
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return "nextval ('" + sequenceName + "')";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName; //starts with 1, implicitly
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getCascadeConstraintsString() {
- return "";//" cascade";
- }
- public boolean dropConstraints() {
- return true;
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public String getQuerySequencesString() {
- return "select relname from pg_class where relkind='S'";
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public String getLimitString(String sql, boolean hasOffset) {
- return new StringBuffer( sql.length()+20 )
- .append(sql)
- .append(hasOffset ? " limit ? offset ?" : " limit ?")
- .toString();
- }
-
- public boolean bindLimitParametersInReverseOrder() {
- return true;
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
-
- public String getForUpdateString(String aliases) {
- return getForUpdateString() + " of " + aliases;
- }
-
- public String getIdentitySelectString(String table, String column, int type) {
- return new StringBuffer().append("select currval('")
- .append(table)
- .append('_')
- .append(column)
- .append("_seq')")
- .toString();
- }
-
- public String getIdentityColumnString(int type) {
- return type==Types.BIGINT ?
- "bigserial not null" :
- "serial not null";
- }
-
- public boolean hasDataTypeInIdentityColumn() {
- return false;
- }
-
- public String getNoColumnsInsertString() {
- return "default values";
- }
-
- public Class getNativeIdentifierGeneratorClass() {
- return SequenceGenerator.class;
- }
-
- public boolean supportsOuterJoinForUpdate() {
- return false;
- }
-
- public boolean useInputStreamToInsertBlob() {
- return false;
- }
-
- public boolean supportsUnionAll() {
- return true;
- }
-
- /**
- * Workaround for postgres bug #1453
- */
- public String getSelectClauseNullString(int sqlType) {
- String typeName = getTypeName(sqlType, 1, 1, 0);
- //trim off the length/precision/scale
- int loc = typeName.indexOf('(');
- if (loc>-1) {
- typeName = typeName.substring(0, loc);
- }
- return "null::" + typeName;
- }
-
- public boolean supportsCommentOn() {
- return true;
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "create temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "on commit drop";
- }
-
- /*public boolean dropTemporaryTableAfterUse() {
- //we have to, because postgres sets current tx
- //to rollback only after a failed create table
- return true;
- }*/
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "select now()";
- }
-
- public String toBooleanValueString(boolean bool) {
- return bool ? "true" : "false";
- }
-
- public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
- return EXTRACTER;
- }
-
- /**
- * Constraint-name extractor for Postgres contraint violation exceptions.
- * Orginally contributed by Denny Bartelt.
- */
- private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
- public String extractConstraintName(SQLException sqle) {
- try {
- int sqlState = Integer.valueOf( JDBCExceptionHelper.extractSqlState(sqle)).intValue();
- switch (sqlState) {
- // CHECK VIOLATION
- case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage());
- // UNIQUE VIOLATION
- case 23505: return extractUsingTemplate("violates unique constraint \"","\"", sqle.getMessage());
- // FOREIGN KEY VIOLATION
- case 23503: return extractUsingTemplate("violates foreign key constraint \"","\"", sqle.getMessage());
- // NOT NULL VIOLATION
- case 23502: return extractUsingTemplate("null value in column \"","\" violates not-null constraint", sqle.getMessage());
- // TODO: RESTRICT VIOLATION
- case 23001: return null;
- // ALL OTHER
- default: return null;
- }
- } catch (NumberFormatException nfe) {
- return null;
- }
- }
- };
-
- public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
- // Register the type of the out param - PostgreSQL uses Types.OTHER
- statement.registerOutParameter(col, Types.OTHER);
- col++;
- return col;
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- ps.execute();
- ResultSet rs = (ResultSet) ps.getObject(1);
- return rs;
- }
-
- public boolean supportsPooledSequences() {
- return true;
- }
-
- //only necessary for postgre < 7.4
- //http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/create_sequence.sgml
- protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) {
- return getCreateSequenceString( sequenceName ) + " start " + initialValue + " increment " + incrementSize;
- }
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-// seems to not really...
-// public boolean supportsRowValueConstructorSyntax() {
-// return true;
-// }
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsExpectedLobUsagePattern() {
- // seems to have spotty LOB suppport
- return false;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,360 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.PositionSubstringFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.exception.JDBCExceptionHelper;
+import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
+import org.hibernate.exception.ViolatedConstraintNameExtracter;
+import org.hibernate.id.SequenceGenerator;
+
+/**
+ * An SQL dialect for Postgres
+ * @author Gavin King
+ */
+public class PostgreSQLDialect extends Dialect {
+
+ public PostgreSQLDialect() {
+ super();
+ registerColumnType( Types.BIT, "bool" );
+ registerColumnType( Types.BIGINT, "int8" );
+ registerColumnType( Types.SMALLINT, "int2" );
+ registerColumnType( Types.TINYINT, "int2" );
+ registerColumnType( Types.INTEGER, "int4" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float4" );
+ registerColumnType( Types.DOUBLE, "float8" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "bytea" );
+ registerColumnType( Types.CLOB, "text" );
+ registerColumnType( Types.BLOB, "oid" );
+ registerColumnType( Types.NUMERIC, "numeric($p, $s)" );
+
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction( "cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
+ registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction( "log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
+ registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction( "cbrt", new StandardSQLFunction("cbrt", Hibernate.DOUBLE) );
+ registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction( "radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
+ registerFunction( "degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
+
+ registerFunction( "stddev", new StandardSQLFunction("stddev", Hibernate.DOUBLE) );
+ registerFunction( "variance", new StandardSQLFunction("variance", Hibernate.DOUBLE) );
+
+ registerFunction( "random", new NoArgSQLFunction("random", Hibernate.DOUBLE) );
+
+ registerFunction( "round", new StandardSQLFunction("round") );
+ registerFunction( "trunc", new StandardSQLFunction("trunc") );
+ registerFunction( "ceil", new StandardSQLFunction("ceil") );
+ registerFunction( "floor", new StandardSQLFunction("floor") );
+
+ registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
+ registerFunction( "initcap", new StandardSQLFunction("initcap") );
+ registerFunction( "to_ascii", new StandardSQLFunction("to_ascii") );
+ registerFunction( "quote_ident", new StandardSQLFunction("quote_ident", Hibernate.STRING) );
+ registerFunction( "quote_literal", new StandardSQLFunction("quote_literal", Hibernate.STRING) );
+ registerFunction( "md5", new StandardSQLFunction("md5") );
+ registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+ registerFunction( "length", new StandardSQLFunction("length", Hibernate.LONG) );
+ registerFunction( "char_length", new StandardSQLFunction("char_length", Hibernate.LONG) );
+ registerFunction( "bit_length", new StandardSQLFunction("bit_length", Hibernate.LONG) );
+ registerFunction( "octet_length", new StandardSQLFunction("octet_length", Hibernate.LONG) );
+
+ registerFunction( "age", new StandardSQLFunction("age") );
+ registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
+ registerFunction( "current_time", new NoArgSQLFunction("current_time", Hibernate.TIME, false) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", Hibernate.TIMESTAMP ) );
+ registerFunction( "localtime", new NoArgSQLFunction("localtime", Hibernate.TIME, false) );
+ registerFunction( "localtimestamp", new NoArgSQLFunction("localtimestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction( "now", new NoArgSQLFunction("now", Hibernate.TIMESTAMP) );
+ registerFunction( "timeofday", new NoArgSQLFunction("timeofday", Hibernate.STRING) );
+
+ registerFunction( "current_user", new NoArgSQLFunction("current_user", Hibernate.STRING, false) );
+ registerFunction( "session_user", new NoArgSQLFunction("session_user", Hibernate.STRING, false) );
+ registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
+ registerFunction( "current_database", new NoArgSQLFunction("current_database", Hibernate.STRING, true) );
+ registerFunction( "current_schema", new NoArgSQLFunction("current_schema", Hibernate.STRING, true) );
+
+ registerFunction( "to_char", new StandardSQLFunction("to_char", Hibernate.STRING) );
+ registerFunction( "to_date", new StandardSQLFunction("to_date", Hibernate.DATE) );
+ registerFunction( "to_timestamp", new StandardSQLFunction("to_timestamp", Hibernate.TIMESTAMP) );
+ registerFunction( "to_number", new StandardSQLFunction("to_number", Hibernate.BIG_DECIMAL) );
+
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","||",")" ) );
+
+ registerFunction( "locate", new PositionSubstringFunction() );
+
+ registerFunction( "str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as varchar)") );
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName );
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return "nextval ('" + sequenceName + "')";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName; //starts with 1, implicitly
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getCascadeConstraintsString() {
+ return "";//" cascade";
+ }
+ public boolean dropConstraints() {
+ return true;
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public String getQuerySequencesString() {
+ return "select relname from pg_class where relkind='S'";
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public String getLimitString(String sql, boolean hasOffset) {
+ return new StringBuffer( sql.length()+20 )
+ .append(sql)
+ .append(hasOffset ? " limit ? offset ?" : " limit ?")
+ .toString();
+ }
+
+ public boolean bindLimitParametersInReverseOrder() {
+ return true;
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+
+ public String getForUpdateString(String aliases) {
+ return getForUpdateString() + " of " + aliases;
+ }
+
+ public String getIdentitySelectString(String table, String column, int type) {
+ return new StringBuffer().append("select currval('")
+ .append(table)
+ .append('_')
+ .append(column)
+ .append("_seq')")
+ .toString();
+ }
+
+ public String getIdentityColumnString(int type) {
+ return type==Types.BIGINT ?
+ "bigserial not null" :
+ "serial not null";
+ }
+
+ public boolean hasDataTypeInIdentityColumn() {
+ return false;
+ }
+
+ public String getNoColumnsInsertString() {
+ return "default values";
+ }
+
+ public Class getNativeIdentifierGeneratorClass() {
+ return SequenceGenerator.class;
+ }
+
+ public boolean supportsOuterJoinForUpdate() {
+ return false;
+ }
+
+ public boolean useInputStreamToInsertBlob() {
+ return false;
+ }
+
+ public boolean supportsUnionAll() {
+ return true;
+ }
+
+ /**
+ * Workaround for postgres bug #1453
+ */
+ public String getSelectClauseNullString(int sqlType) {
+ String typeName = getTypeName(sqlType, 1, 1, 0);
+ //trim off the length/precision/scale
+ int loc = typeName.indexOf('(');
+ if (loc>-1) {
+ typeName = typeName.substring(0, loc);
+ }
+ return "null::" + typeName;
+ }
+
+ public boolean supportsCommentOn() {
+ return true;
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit drop";
+ }
+
+ /*public boolean dropTemporaryTableAfterUse() {
+ //we have to, because postgres sets current tx
+ //to rollback only after a failed create table
+ return true;
+ }*/
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select now()";
+ }
+
+ public String toBooleanValueString(boolean bool) {
+ return bool ? "true" : "false";
+ }
+
+ public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
+ return EXTRACTER;
+ }
+
+ /**
+ * Constraint-name extractor for Postgres contraint violation exceptions.
+ * Orginally contributed by Denny Bartelt.
+ */
+ private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
+ public String extractConstraintName(SQLException sqle) {
+ try {
+ int sqlState = Integer.valueOf( JDBCExceptionHelper.extractSqlState(sqle)).intValue();
+ switch (sqlState) {
+ // CHECK VIOLATION
+ case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage());
+ // UNIQUE VIOLATION
+ case 23505: return extractUsingTemplate("violates unique constraint \"","\"", sqle.getMessage());
+ // FOREIGN KEY VIOLATION
+ case 23503: return extractUsingTemplate("violates foreign key constraint \"","\"", sqle.getMessage());
+ // NOT NULL VIOLATION
+ case 23502: return extractUsingTemplate("null value in column \"","\" violates not-null constraint", sqle.getMessage());
+ // TODO: RESTRICT VIOLATION
+ case 23001: return null;
+ // ALL OTHER
+ default: return null;
+ }
+ } catch (NumberFormatException nfe) {
+ return null;
+ }
+ }
+ };
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
+ // Register the type of the out param - PostgreSQL uses Types.OTHER
+ statement.registerOutParameter(col, Types.OTHER);
+ col++;
+ return col;
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ ps.execute();
+ ResultSet rs = (ResultSet) ps.getObject(1);
+ return rs;
+ }
+
+ public boolean supportsPooledSequences() {
+ return true;
+ }
+
+ //only necessary for postgre < 7.4
+ //http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/create_sequence.sgml
+ protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) {
+ return getCreateSequenceString( sequenceName ) + " start " + initialValue + " increment " + incrementSize;
+ }
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+// seems to not really...
+// public boolean supportsRowValueConstructorSyntax() {
+// return true;
+// }
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExpectedLobUsagePattern() {
+ // seems to have spotty LOB suppport
+ return false;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/ProgressDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,60 +0,0 @@
-//$Id: ProgressDialect.java 4609 2004-09-27 03:17:46Z oneovthafew $
-// contributed by Phillip Baird
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-/**
- * An SQL dialect compatible with Progress 9.1C<br>
- *<br>
- * Connection Parameters required:
- *<ul>
- * <li>hibernate.dialect org.hibernate.sql.ProgressDialect
- * <li>hibernate.driver com.progress.sql.jdbc.JdbcProgressDriver
- * <li>hibernate.url jdbc:JdbcProgress:T:host:port:dbname;WorkArounds=536870912
- * <li>hibernate.username username
- * <li>hibernate.password password
- *</ul>
- * The WorkArounds parameter in the URL is required to avoid an error
- * in the Progress 9.1C JDBC driver related to PreparedStatements.
- * @author Phillip Baird
- *
- */
-public class ProgressDialect extends Dialect {
- public ProgressDialect() {
- super();
- registerColumnType( Types.BIT, "bit" );
- registerColumnType( Types.BIGINT, "numeric" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.INTEGER, "integer" );
- registerColumnType( Types.CHAR, "character(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "real" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "varbinary($l)" );
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- }
-
- public boolean hasAlterTable(){
- return false;
- }
-
- public String getAddColumnString() {
- return "add column";
- }
-
- public boolean qualifyIndexName() {
- return false;
- }
-}
-
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/ProgressDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ProgressDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,82 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+/**
+ * An SQL dialect compatible with Progress 9.1C<br>
+ *<br>
+ * Connection Parameters required:
+ *<ul>
+ * <li>hibernate.dialect org.hibernate.sql.ProgressDialect
+ * <li>hibernate.driver com.progress.sql.jdbc.JdbcProgressDriver
+ * <li>hibernate.url jdbc:JdbcProgress:T:host:port:dbname;WorkArounds=536870912
+ * <li>hibernate.username username
+ * <li>hibernate.password password
+ *</ul>
+ * The WorkArounds parameter in the URL is required to avoid an error
+ * in the Progress 9.1C JDBC driver related to PreparedStatements.
+ * @author Phillip Baird
+ *
+ */
+public class ProgressDialect extends Dialect {
+ public ProgressDialect() {
+ super();
+ registerColumnType( Types.BIT, "bit" );
+ registerColumnType( Types.BIGINT, "numeric" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.INTEGER, "integer" );
+ registerColumnType( Types.CHAR, "character(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "real" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "varbinary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ }
+
+ public boolean hasAlterTable(){
+ return false;
+ }
+
+ public String getAddColumnString() {
+ return "add column";
+ }
+
+ public boolean qualifyIndexName() {
+ return false;
+ }
+}
+
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,322 +0,0 @@
-/*
- * Created on Aug 24, 2005
- * This is the Hibernate dialect for the Unisys 2200 Relational Database (RDMS).
- * This dialect was developed for use with Hibernate 3.0.5. Other versions may
- * require modifications to the dialect.
- *
- * Version History:
- * Also change the version displayed below in the constructor
- * 1.1
- * 1.0 2005-10-24 CDH - First dated version for use with CP 11
- */
-package org.hibernate.dialect;
-
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.UpdateLockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-
-import java.sql.Types;
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.DecodeCaseFragment;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Ploski and Hanson
- */
-public class RDMSOS2200Dialect extends Dialect {
- private static Logger log = LoggerFactory.getLogger(RDMSOS2200Dialect.class);
-
- public RDMSOS2200Dialect() {
- super();
- // Display the dialect version.
- log.info("RDMSOS2200Dialect version: 1.0");
-
- /**
- * This section registers RDMS Biult-in Functions (BIFs) with Hibernate.
- * The first parameter is the 'register' function name with Hibernate.
- * The second parameter is the defined RDMS SQL Function and it's
- * characteristics. If StandardSQLFunction(...) is used, the RDMS BIF
- * name and the return type (if any) is specified. If
- * SQLFunctionTemplate(...) is used, the return type and a template
- * string is provided, plus an optional hasParenthesesIfNoArgs flag.
- */
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
- registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.INTEGER) );
- registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.INTEGER) );
- registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER) );
-
- // The RDMS concat() function only supports 2 parameters
- registerFunction( "concat", new SQLFunctionTemplate(Hibernate.STRING, "concat(?1, ?2)") );
- registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.STRING) );
- registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
- registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
- registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
- registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
-
- registerFunction("lcase", new StandardSQLFunction("lcase") );
- registerFunction("lower", new StandardSQLFunction("lower") );
- registerFunction("ltrim", new StandardSQLFunction("ltrim") );
- registerFunction("reverse", new StandardSQLFunction("reverse") );
- registerFunction("rtrim", new StandardSQLFunction("rtrim") );
-
- // RDMS does not directly support the trim() function, we use rtrim() and ltrim()
- registerFunction("trim", new SQLFunctionTemplate(Hibernate.INTEGER, "ltrim(rtrim(?1))" ) );
- registerFunction("soundex", new StandardSQLFunction("soundex") );
- registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) );
- registerFunction("ucase", new StandardSQLFunction("ucase") );
- registerFunction("upper", new StandardSQLFunction("upper") );
-
- registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction("cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
- registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
- registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
- registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
- registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
- registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
- registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction("sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
- registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction("tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
-
- registerFunction( "round", new StandardSQLFunction("round") );
- registerFunction( "trunc", new StandardSQLFunction("trunc") );
- registerFunction( "ceil", new StandardSQLFunction("ceil") );
- registerFunction( "floor", new StandardSQLFunction("floor") );
-
- registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
- registerFunction( "initcap", new StandardSQLFunction("initcap") );
-
- registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
-
- registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
- registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
- registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
- registerFunction("curdate", new NoArgSQLFunction("curdate",Hibernate.DATE) );
- registerFunction("curtime", new NoArgSQLFunction("curtime",Hibernate.TIME) );
- registerFunction("days", new StandardSQLFunction("days",Hibernate.INTEGER) );
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth",Hibernate.INTEGER) );
- registerFunction("dayname", new StandardSQLFunction("dayname",Hibernate.STRING) );
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek",Hibernate.INTEGER) );
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear",Hibernate.INTEGER) );
- registerFunction("hour", new StandardSQLFunction("hour",Hibernate.INTEGER) );
- registerFunction("last_day", new StandardSQLFunction("last_day",Hibernate.DATE) );
- registerFunction("microsecond", new StandardSQLFunction("microsecond",Hibernate.INTEGER) );
- registerFunction("minute", new StandardSQLFunction("minute",Hibernate.INTEGER) );
- registerFunction("month", new StandardSQLFunction("month",Hibernate.INTEGER) );
- registerFunction("monthname", new StandardSQLFunction("monthname",Hibernate.STRING) );
- registerFunction("now", new NoArgSQLFunction("now",Hibernate.TIMESTAMP) );
- registerFunction("quarter", new StandardSQLFunction("quarter",Hibernate.INTEGER) );
- registerFunction("second", new StandardSQLFunction("second",Hibernate.INTEGER) );
- registerFunction("time", new StandardSQLFunction("time",Hibernate.TIME) );
- registerFunction("timestamp", new StandardSQLFunction("timestamp",Hibernate.TIMESTAMP) );
- registerFunction("week", new StandardSQLFunction("week",Hibernate.INTEGER) );
- registerFunction("year", new StandardSQLFunction("year",Hibernate.INTEGER) );
-
- registerFunction("atan2", new StandardSQLFunction("atan2",Hibernate.DOUBLE) );
- registerFunction( "mod", new StandardSQLFunction("mod",Hibernate.INTEGER) );
- registerFunction( "nvl", new StandardSQLFunction("nvl") );
- registerFunction( "power", new StandardSQLFunction("power", Hibernate.DOUBLE) );
-
- /**
- * For a list of column types to register, see section A-1
- * in 7862 7395, the Unisys JDBC manual.
- *
- * Here are column sizes as documented in Table A-1 of
- * 7831 0760, "Enterprise Relational Database Server
- * for ClearPath OS2200 Administration Guide"
- * Numeric - 21
- * Decimal - 22 (21 digits plus one for sign)
- * Float - 60 bits
- * Char - 28000
- * NChar - 14000
- * BLOB+ - 4294967296 (4 Gb)
- * + RDMS JDBC driver does not support BLOBs
- *
- * DATE, TIME and TIMESTAMP literal formats are
- * are all described in section 2.3.4 DATE Literal Format
- * in 7830 8160.
- * The DATE literal format is: YYYY-MM-DD
- * The TIME literal format is: HH:MM:SS[.[FFFFFF]]
- * The TIMESTAMP literal format is: YYYY-MM-DD HH:MM:SS[.[FFFFFF]]
- *
- * Note that $l (dollar-L) will use the length value if provided.
- * Also new for Hibernate3 is the $p percision and $s (scale) parameters
- */
- registerColumnType(Types.BIT, "SMALLINT");
- registerColumnType(Types.TINYINT, "SMALLINT");
- registerColumnType(Types.BIGINT, "NUMERIC(21,0)");
- registerColumnType(Types.SMALLINT, "SMALLINT");
- registerColumnType(Types.CHAR, "CHARACTER(1)");
- registerColumnType(Types.DOUBLE, "DOUBLE PRECISION");
- registerColumnType(Types.FLOAT, "FLOAT");
- registerColumnType(Types.REAL, "REAL");
- registerColumnType(Types.INTEGER, "INTEGER");
- registerColumnType(Types.NUMERIC, "NUMERIC(21,$l)");
- registerColumnType(Types.DECIMAL, "NUMERIC(21,$l)");
- registerColumnType(Types.DATE, "DATE");
- registerColumnType(Types.TIME, "TIME");
- registerColumnType(Types.TIMESTAMP, "TIMESTAMP");
- registerColumnType(Types.VARCHAR, "CHARACTER($l)");
- registerColumnType(Types.BLOB, "BLOB($l)" );
- /*
- * The following types are not supported in RDMS/JDBC and therefore commented out.
- * However, in some cases, mapping them to CHARACTER columns works
- * for many applications, but does not work for all cases.
- */
- // registerColumnType(Types.VARBINARY, "CHARACTER($l)");
- // registerColumnType(Types.BLOB, "CHARACTER($l)" ); // For use prior to CP 11.0
- // registerColumnType(Types.CLOB, "CHARACTER($l)" );
- }
-
-
- // Dialect method overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * RDMS does not support qualifing index names with the schema name.
- */
- public boolean qualifyIndexName() {
- return false;
- }
-
- /**
- * The RDMS DB supports the 'FOR UPDATE OF' clause. However, the RDMS-JDBC
- * driver does not support this feature, so a false is return.
- * The base dialect also returns a false, but we will leave this over-ride
- * in to make sure it stays false.
- */
- public boolean forUpdateOfColumns() {
- return false;
- }
-
- /**
- * Since the RDMS-JDBC driver does not support for updates, this string is
- * set to an empty string. Whenever, the driver does support this feature,
- * the returned string should be " FOR UPDATE OF". Note that RDMS does not
- * support the string 'FOR UPDATE' string.
- */
- public String getForUpdateString() {
- return ""; // Original Dialect.java returns " for update";
- }
-
- /**
- * RDMS does not support adding Unique constraints via create and alter table.
- */
- public boolean supportsUniqueConstraintInCreateAlterTable() {
- return true;
- }
-
- // Verify the state of this new method in Hibernate 3.0 Dialect.java
- /**
- * RDMS does not support Cascade Deletes.
- * Need to review this in the future when support is provided.
- */
- public boolean supportsCascadeDelete() {
- return false; // Origial Dialect.java returns true;
- }
-
- /**
- * Currently, RDMS-JDBC does not support ForUpdate.
- * Need to review this in the future when support is provided.
- */
- public boolean supportsOuterJoinForUpdate() {
- return false;
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public String getNullColumnString() {
- // The keyword used to specify a nullable column.
- return " null";
- }
-
- // *** Sequence methods - start. The RDMS dialect needs these
-
- // methods to make it possible to use the Native Id generator
-
- public boolean supportsSequences() {
- return true;
- }
-
- public String getSequenceNextValString(String sequenceName) {
- // The where clause was added to eliminate this statement from Brute Force Searches.
- return "select permuted_id('NEXT',31) from rdms.rdms_dummy where key_col = 1 ";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- // We must return a valid RDMS/RSA command from this method to
- // prevent RDMS/RSA from issuing *ERROR 400
- return "";
- }
-
- public String getDropSequenceString(String sequenceName) {
- // We must return a valid RDMS/RSA command from this method to
- // prevent RDMS/RSA from issuing *ERROR 400
- return "";
- }
-
- // *** Sequence methods - end
-
- public String getCascadeConstraintsString() {
- // Used with DROP TABLE to delete all records in the table.
- return " including contents";
- }
-
- public CaseFragment createCaseFragment() {
- return new DecodeCaseFragment();
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public String getLimitString(String sql, int offset, int limit) {
- if (offset>0) throw new UnsupportedOperationException("RDMS does not support paged queries");
- return new StringBuffer(sql.length() + 40)
- .append(sql)
- .append(" fetch first ")
- .append(limit)
- .append(" rows only ")
- .toString();
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
- public boolean supportsUnionAll() {
- // RDMS supports the UNION ALL clause.
- return true;
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- return new UpdateLockingStrategy( lockable, lockMode );
- }
- else {
- return new SelectLockingStrategy( lockable, lockMode );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/RDMSOS2200Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,344 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.UpdateLockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+
+import java.sql.Types;
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.DecodeCaseFragment;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is the Hibernate dialect for the Unisys 2200 Relational Database (RDMS).
+ * This dialect was developed for use with Hibernate 3.0.5. Other versions may
+ * require modifications to the dialect.
+ *
+ * Version History:
+ * Also change the version displayed below in the constructor
+ * 1.1
+ * 1.0 2005-10-24 CDH - First dated version for use with CP 11
+ *
+ * @author Ploski and Hanson
+ */
+public class RDMSOS2200Dialect extends Dialect {
+ private static Logger log = LoggerFactory.getLogger(RDMSOS2200Dialect.class);
+
+ public RDMSOS2200Dialect() {
+ super();
+ // Display the dialect version.
+ log.info("RDMSOS2200Dialect version: 1.0");
+
+ /**
+ * This section registers RDMS Biult-in Functions (BIFs) with Hibernate.
+ * The first parameter is the 'register' function name with Hibernate.
+ * The second parameter is the defined RDMS SQL Function and it's
+ * characteristics. If StandardSQLFunction(...) is used, the RDMS BIF
+ * name and the return type (if any) is specified. If
+ * SQLFunctionTemplate(...) is used, the return type and a template
+ * string is provided, plus an optional hasParenthesesIfNoArgs flag.
+ */
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction("ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+ registerFunction("char_length", new StandardSQLFunction("char_length", Hibernate.INTEGER) );
+ registerFunction("character_length", new StandardSQLFunction("character_length", Hibernate.INTEGER) );
+ registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER) );
+
+ // The RDMS concat() function only supports 2 parameters
+ registerFunction( "concat", new SQLFunctionTemplate(Hibernate.STRING, "concat(?1, ?2)") );
+ registerFunction( "instr", new StandardSQLFunction("instr", Hibernate.STRING) );
+ registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
+ registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
+ registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
+ registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
+
+ registerFunction("lcase", new StandardSQLFunction("lcase") );
+ registerFunction("lower", new StandardSQLFunction("lower") );
+ registerFunction("ltrim", new StandardSQLFunction("ltrim") );
+ registerFunction("reverse", new StandardSQLFunction("reverse") );
+ registerFunction("rtrim", new StandardSQLFunction("rtrim") );
+
+ // RDMS does not directly support the trim() function, we use rtrim() and ltrim()
+ registerFunction("trim", new SQLFunctionTemplate(Hibernate.INTEGER, "ltrim(rtrim(?1))" ) );
+ registerFunction("soundex", new StandardSQLFunction("soundex") );
+ registerFunction("space", new StandardSQLFunction("space", Hibernate.STRING) );
+ registerFunction("ucase", new StandardSQLFunction("ucase") );
+ registerFunction("upper", new StandardSQLFunction("upper") );
+
+ registerFunction("acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction("asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction("atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction("cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction("cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
+ registerFunction("cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
+ registerFunction("exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction("ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction("log", new StandardSQLFunction("log", Hibernate.DOUBLE) );
+ registerFunction("log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
+ registerFunction("pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
+ registerFunction("rand", new NoArgSQLFunction("rand", Hibernate.DOUBLE) );
+ registerFunction("sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction("sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
+ registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction("tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction("tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
+
+ registerFunction( "round", new StandardSQLFunction("round") );
+ registerFunction( "trunc", new StandardSQLFunction("trunc") );
+ registerFunction( "ceil", new StandardSQLFunction("ceil") );
+ registerFunction( "floor", new StandardSQLFunction("floor") );
+
+ registerFunction( "chr", new StandardSQLFunction("chr", Hibernate.CHARACTER) );
+ registerFunction( "initcap", new StandardSQLFunction("initcap") );
+
+ registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING, false) );
+
+ registerFunction( "current_date", new NoArgSQLFunction("current_date", Hibernate.DATE, false) );
+ registerFunction( "current_time", new NoArgSQLFunction("current_timestamp", Hibernate.TIME, false) );
+ registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", Hibernate.TIMESTAMP, false) );
+ registerFunction("curdate", new NoArgSQLFunction("curdate",Hibernate.DATE) );
+ registerFunction("curtime", new NoArgSQLFunction("curtime",Hibernate.TIME) );
+ registerFunction("days", new StandardSQLFunction("days",Hibernate.INTEGER) );
+ registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth",Hibernate.INTEGER) );
+ registerFunction("dayname", new StandardSQLFunction("dayname",Hibernate.STRING) );
+ registerFunction("dayofweek", new StandardSQLFunction("dayofweek",Hibernate.INTEGER) );
+ registerFunction("dayofyear", new StandardSQLFunction("dayofyear",Hibernate.INTEGER) );
+ registerFunction("hour", new StandardSQLFunction("hour",Hibernate.INTEGER) );
+ registerFunction("last_day", new StandardSQLFunction("last_day",Hibernate.DATE) );
+ registerFunction("microsecond", new StandardSQLFunction("microsecond",Hibernate.INTEGER) );
+ registerFunction("minute", new StandardSQLFunction("minute",Hibernate.INTEGER) );
+ registerFunction("month", new StandardSQLFunction("month",Hibernate.INTEGER) );
+ registerFunction("monthname", new StandardSQLFunction("monthname",Hibernate.STRING) );
+ registerFunction("now", new NoArgSQLFunction("now",Hibernate.TIMESTAMP) );
+ registerFunction("quarter", new StandardSQLFunction("quarter",Hibernate.INTEGER) );
+ registerFunction("second", new StandardSQLFunction("second",Hibernate.INTEGER) );
+ registerFunction("time", new StandardSQLFunction("time",Hibernate.TIME) );
+ registerFunction("timestamp", new StandardSQLFunction("timestamp",Hibernate.TIMESTAMP) );
+ registerFunction("week", new StandardSQLFunction("week",Hibernate.INTEGER) );
+ registerFunction("year", new StandardSQLFunction("year",Hibernate.INTEGER) );
+
+ registerFunction("atan2", new StandardSQLFunction("atan2",Hibernate.DOUBLE) );
+ registerFunction( "mod", new StandardSQLFunction("mod",Hibernate.INTEGER) );
+ registerFunction( "nvl", new StandardSQLFunction("nvl") );
+ registerFunction( "power", new StandardSQLFunction("power", Hibernate.DOUBLE) );
+
+ /**
+ * For a list of column types to register, see section A-1
+ * in 7862 7395, the Unisys JDBC manual.
+ *
+ * Here are column sizes as documented in Table A-1 of
+ * 7831 0760, "Enterprise Relational Database Server
+ * for ClearPath OS2200 Administration Guide"
+ * Numeric - 21
+ * Decimal - 22 (21 digits plus one for sign)
+ * Float - 60 bits
+ * Char - 28000
+ * NChar - 14000
+ * BLOB+ - 4294967296 (4 Gb)
+ * + RDMS JDBC driver does not support BLOBs
+ *
+ * DATE, TIME and TIMESTAMP literal formats are
+ * are all described in section 2.3.4 DATE Literal Format
+ * in 7830 8160.
+ * The DATE literal format is: YYYY-MM-DD
+ * The TIME literal format is: HH:MM:SS[.[FFFFFF]]
+ * The TIMESTAMP literal format is: YYYY-MM-DD HH:MM:SS[.[FFFFFF]]
+ *
+ * Note that $l (dollar-L) will use the length value if provided.
+ * Also new for Hibernate3 is the $p percision and $s (scale) parameters
+ */
+ registerColumnType(Types.BIT, "SMALLINT");
+ registerColumnType(Types.TINYINT, "SMALLINT");
+ registerColumnType(Types.BIGINT, "NUMERIC(21,0)");
+ registerColumnType(Types.SMALLINT, "SMALLINT");
+ registerColumnType(Types.CHAR, "CHARACTER(1)");
+ registerColumnType(Types.DOUBLE, "DOUBLE PRECISION");
+ registerColumnType(Types.FLOAT, "FLOAT");
+ registerColumnType(Types.REAL, "REAL");
+ registerColumnType(Types.INTEGER, "INTEGER");
+ registerColumnType(Types.NUMERIC, "NUMERIC(21,$l)");
+ registerColumnType(Types.DECIMAL, "NUMERIC(21,$l)");
+ registerColumnType(Types.DATE, "DATE");
+ registerColumnType(Types.TIME, "TIME");
+ registerColumnType(Types.TIMESTAMP, "TIMESTAMP");
+ registerColumnType(Types.VARCHAR, "CHARACTER($l)");
+ registerColumnType(Types.BLOB, "BLOB($l)" );
+ /*
+ * The following types are not supported in RDMS/JDBC and therefore commented out.
+ * However, in some cases, mapping them to CHARACTER columns works
+ * for many applications, but does not work for all cases.
+ */
+ // registerColumnType(Types.VARBINARY, "CHARACTER($l)");
+ // registerColumnType(Types.BLOB, "CHARACTER($l)" ); // For use prior to CP 11.0
+ // registerColumnType(Types.CLOB, "CHARACTER($l)" );
+ }
+
+
+ // Dialect method overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * RDMS does not support qualifing index names with the schema name.
+ */
+ public boolean qualifyIndexName() {
+ return false;
+ }
+
+ /**
+ * The RDMS DB supports the 'FOR UPDATE OF' clause. However, the RDMS-JDBC
+ * driver does not support this feature, so a false is return.
+ * The base dialect also returns a false, but we will leave this over-ride
+ * in to make sure it stays false.
+ */
+ public boolean forUpdateOfColumns() {
+ return false;
+ }
+
+ /**
+ * Since the RDMS-JDBC driver does not support for updates, this string is
+ * set to an empty string. Whenever, the driver does support this feature,
+ * the returned string should be " FOR UPDATE OF". Note that RDMS does not
+ * support the string 'FOR UPDATE' string.
+ */
+ public String getForUpdateString() {
+ return ""; // Original Dialect.java returns " for update";
+ }
+
+ /**
+ * RDMS does not support adding Unique constraints via create and alter table.
+ */
+ public boolean supportsUniqueConstraintInCreateAlterTable() {
+ return true;
+ }
+
+ // Verify the state of this new method in Hibernate 3.0 Dialect.java
+ /**
+ * RDMS does not support Cascade Deletes.
+ * Need to review this in the future when support is provided.
+ */
+ public boolean supportsCascadeDelete() {
+ return false; // Origial Dialect.java returns true;
+ }
+
+ /**
+ * Currently, RDMS-JDBC does not support ForUpdate.
+ * Need to review this in the future when support is provided.
+ */
+ public boolean supportsOuterJoinForUpdate() {
+ return false;
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public String getNullColumnString() {
+ // The keyword used to specify a nullable column.
+ return " null";
+ }
+
+ // *** Sequence methods - start. The RDMS dialect needs these
+
+ // methods to make it possible to use the Native Id generator
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ // The where clause was added to eliminate this statement from Brute Force Searches.
+ return "select permuted_id('NEXT',31) from rdms.rdms_dummy where key_col = 1 ";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ // We must return a valid RDMS/RSA command from this method to
+ // prevent RDMS/RSA from issuing *ERROR 400
+ return "";
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ // We must return a valid RDMS/RSA command from this method to
+ // prevent RDMS/RSA from issuing *ERROR 400
+ return "";
+ }
+
+ // *** Sequence methods - end
+
+ public String getCascadeConstraintsString() {
+ // Used with DROP TABLE to delete all records in the table.
+ return " including contents";
+ }
+
+ public CaseFragment createCaseFragment() {
+ return new DecodeCaseFragment();
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public String getLimitString(String sql, int offset, int limit) {
+ if (offset>0) throw new UnsupportedOperationException("RDMS does not support paged queries");
+ return new StringBuffer(sql.length() + 40)
+ .append(sql)
+ .append(" fetch first ")
+ .append(limit)
+ .append(" rows only ")
+ .toString();
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+ public boolean supportsUnionAll() {
+ // RDMS supports the UNION ALL clause.
+ return true;
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // RDMS has no known variation of a "SELECT ... FOR UPDATE" syntax...
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ return new UpdateLockingStrategy( lockable, lockMode );
+ }
+ else {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,67 +0,0 @@
-package org.hibernate.dialect;
-
-import java.io.Serializable;
-import java.io.ObjectStreamException;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * Defines how we need to reference columns in the group-by, having, and order-by
- * clauses.
- *
- * @author Steve Ebersole
- */
-public class ResultColumnReferenceStrategy implements Serializable {
-
- private static final Map INSTANCES = new HashMap();
-
- /**
- * This strategy says to reference the result columns by the qualified column name
- * found in the result source. This strategy is not strictly allowed by ANSI SQL
- * but is Hibernate's legacy behavior and is also the fastest of the strategies; thus
- * it should be used if supported by the underlying database.
- */
- public static final ResultColumnReferenceStrategy SOURCE = new ResultColumnReferenceStrategy( "source");
-
- /**
- * For databases which do not support {@link #SOURCE}, ANSI SQL defines two allowable
- * approaches. One is to reference the result column by the alias it is given in the
- * result source (if it is given an alias). This strategy says to use this approach.
- * <p/>
- * The other QNSI SQL compliant approach is {@link #ORDINAL}.
- */
- public static final ResultColumnReferenceStrategy ALIAS = new ResultColumnReferenceStrategy( "alias" );
-
- /**
- * For databases which do not support {@link #SOURCE}, ANSI SQL defines two allowable
- * approaches. One is to reference the result column by the ordinal position at which
- * it appears in the result source. This strategy says to use this approach.
- * <p/>
- * The other QNSI SQL compliant approach is {@link #ALIAS}.
- */
- public static final ResultColumnReferenceStrategy ORDINAL = new ResultColumnReferenceStrategy( "ordinal" );
-
- static {
- ResultColumnReferenceStrategy.INSTANCES.put( ResultColumnReferenceStrategy.SOURCE.name, ResultColumnReferenceStrategy.SOURCE );
- ResultColumnReferenceStrategy.INSTANCES.put( ResultColumnReferenceStrategy.ALIAS.name, ResultColumnReferenceStrategy.ALIAS );
- ResultColumnReferenceStrategy.INSTANCES.put( ResultColumnReferenceStrategy.ORDINAL.name, ResultColumnReferenceStrategy.ORDINAL );
- }
-
- private final String name;
-
- public ResultColumnReferenceStrategy(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- private Object readResolve() throws ObjectStreamException {
- return parse( name );
- }
-
- public static ResultColumnReferenceStrategy parse(String name) {
- return ( ResultColumnReferenceStrategy ) ResultColumnReferenceStrategy.INSTANCES.get( name );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/ResultColumnReferenceStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,91 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.io.Serializable;
+import java.io.ObjectStreamException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Defines how we need to reference columns in the group-by, having, and order-by
+ * clauses.
+ *
+ * @author Steve Ebersole
+ */
+public class ResultColumnReferenceStrategy implements Serializable {
+
+ private static final Map INSTANCES = new HashMap();
+
+ /**
+ * This strategy says to reference the result columns by the qualified column name
+ * found in the result source. This strategy is not strictly allowed by ANSI SQL
+ * but is Hibernate's legacy behavior and is also the fastest of the strategies; thus
+ * it should be used if supported by the underlying database.
+ */
+ public static final ResultColumnReferenceStrategy SOURCE = new ResultColumnReferenceStrategy( "source");
+
+ /**
+ * For databases which do not support {@link #SOURCE}, ANSI SQL defines two allowable
+ * approaches. One is to reference the result column by the alias it is given in the
+ * result source (if it is given an alias). This strategy says to use this approach.
+ * <p/>
+ * The other QNSI SQL compliant approach is {@link #ORDINAL}.
+ */
+ public static final ResultColumnReferenceStrategy ALIAS = new ResultColumnReferenceStrategy( "alias" );
+
+ /**
+ * For databases which do not support {@link #SOURCE}, ANSI SQL defines two allowable
+ * approaches. One is to reference the result column by the ordinal position at which
+ * it appears in the result source. This strategy says to use this approach.
+ * <p/>
+ * The other QNSI SQL compliant approach is {@link #ALIAS}.
+ */
+ public static final ResultColumnReferenceStrategy ORDINAL = new ResultColumnReferenceStrategy( "ordinal" );
+
+ static {
+ ResultColumnReferenceStrategy.INSTANCES.put( ResultColumnReferenceStrategy.SOURCE.name, ResultColumnReferenceStrategy.SOURCE );
+ ResultColumnReferenceStrategy.INSTANCES.put( ResultColumnReferenceStrategy.ALIAS.name, ResultColumnReferenceStrategy.ALIAS );
+ ResultColumnReferenceStrategy.INSTANCES.put( ResultColumnReferenceStrategy.ORDINAL.name, ResultColumnReferenceStrategy.ORDINAL );
+ }
+
+ private final String name;
+
+ public ResultColumnReferenceStrategy(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ return parse( name );
+ }
+
+ public static ResultColumnReferenceStrategy parse(String name) {
+ return ( ResultColumnReferenceStrategy ) ResultColumnReferenceStrategy.INSTANCES.get( name );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,205 +0,0 @@
-//$Id: SAPDBDialect.java 8749 2005-12-04 17:32:04Z oneovthafew $
-// contributed by Brad Clow
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.sql.CaseFragment;
-import org.hibernate.sql.DecodeCaseFragment;
-import org.hibernate.sql.OracleJoinFragment;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.util.StringHelper;
-
-/**
- * An SQL dialect compatible with SAP DB.
- * @author Brad Clow
- */
-public class SAPDBDialect extends Dialect {
-
- public SAPDBDialect() {
- super();
- registerColumnType( Types.BIT, "boolean" );
- registerColumnType( Types.BIGINT, "fixed(19,0)" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "fixed(3,0)" );
- registerColumnType( Types.INTEGER, "int" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "date" );
- registerColumnType( Types.TIME, "time" );
- registerColumnType( Types.TIMESTAMP, "timestamp" );
- registerColumnType( Types.VARBINARY, "long byte" );
- registerColumnType( Types.NUMERIC, "fixed($p,$s)" );
- registerColumnType( Types.CLOB, "long varchar" );
- registerColumnType( Types.BLOB, "long byte" );
-
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction( "log", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
- registerFunction( "pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
- registerFunction( "power", new StandardSQLFunction("power") );
- registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
- registerFunction( "cot", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
- registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
- registerFunction( "radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
- registerFunction( "degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
- registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE) );
-
- registerFunction( "round", new StandardSQLFunction("round") );
- registerFunction( "trunc", new StandardSQLFunction("trunc") );
- registerFunction( "ceil", new StandardSQLFunction("ceil") );
- registerFunction( "floor", new StandardSQLFunction("floor") );
- registerFunction( "greatest", new StandardSQLFunction("greatest") );
- registerFunction( "least", new StandardSQLFunction("least") );
-
- registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
- registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
- registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
- registerFunction("microsecond", new StandardSQLFunction("microsecond", Hibernate.INTEGER) );
-
- registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "second(?1)") );
- registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "minute(?1)") );
- registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "hour(?1)") );
- registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "day(?1)") );
- registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "month(?1)") );
- registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "year(?1)") );
-
- registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "?1(?3)") );
-
- registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
- registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
- registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER) );
- registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
- registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
- registerFunction("weekofyear", new StandardSQLFunction("weekofyear", Hibernate.INTEGER) );
-
- registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
- registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
- registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
- registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
- registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
- registerFunction( "initcap", new StandardSQLFunction("initcap", Hibernate.STRING) );
- registerFunction( "lower", new StandardSQLFunction("lower", Hibernate.STRING) );
- registerFunction( "ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING) );
- registerFunction( "rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING) );
- registerFunction( "lfill", new StandardSQLFunction("ltrim", Hibernate.STRING) );
- registerFunction( "rfill", new StandardSQLFunction("rtrim", Hibernate.STRING) );
- registerFunction( "soundex", new StandardSQLFunction("soundex", Hibernate.STRING) );
- registerFunction( "upper", new StandardSQLFunction("upper", Hibernate.STRING) );
- registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.STRING) );
- registerFunction( "index", new StandardSQLFunction("index", Hibernate.INTEGER) );
-
- registerFunction( "value", new StandardSQLFunction( "value" ) );
-
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
- registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
- registerFunction( "locate", new StandardSQLFunction("index", Hibernate.INTEGER) );
- registerFunction( "coalesce", new StandardSQLFunction( "value" ) );
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
-
- }
-
- public boolean dropConstraints() {
- return false;
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public String getAddForeignKeyConstraintString(
- String constraintName,
- String[] foreignKey,
- String referencedTable,
- String[] primaryKey, boolean referencesPrimaryKey
- ) {
- StringBuffer res = new StringBuffer(30)
- .append(" foreign key ")
- .append(constraintName)
- .append(" (")
- .append( StringHelper.join(", ", foreignKey) )
- .append(") references ")
- .append(referencedTable);
-
- if(!referencesPrimaryKey) {
- res.append(" (")
- .append( StringHelper.join(", ", primaryKey) )
- .append(')');
- }
-
- return res.toString();
- }
-
- public String getAddPrimaryKeyConstraintString(String constraintName) {
- return " primary key ";
- }
-
- public String getNullColumnString() {
- return " null";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return sequenceName + ".nextval";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getQuerySequencesString() {
- return "select sequence_name from domain.sequences";
- }
-
- public JoinFragment createOuterJoinFragment() {
- return new OracleJoinFragment();
- }
-
-
- public boolean supportsSequences() {
- return true;
- }
-
- public CaseFragment createCaseFragment() {
- return new DecodeCaseFragment();
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "ignore rollback";
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- return "temp." + super.generateTemporaryTableName(baseTableName);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SAPDBDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,227 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.sql.CaseFragment;
+import org.hibernate.sql.DecodeCaseFragment;
+import org.hibernate.sql.OracleJoinFragment;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.util.StringHelper;
+
+/**
+ * An SQL dialect compatible with SAP DB.
+ * @author Brad Clow
+ */
+public class SAPDBDialect extends Dialect {
+
+ public SAPDBDialect() {
+ super();
+ registerColumnType( Types.BIT, "boolean" );
+ registerColumnType( Types.BIGINT, "fixed(19,0)" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "fixed(3,0)" );
+ registerColumnType( Types.INTEGER, "int" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "date" );
+ registerColumnType( Types.TIME, "time" );
+ registerColumnType( Types.TIMESTAMP, "timestamp" );
+ registerColumnType( Types.VARBINARY, "long byte" );
+ registerColumnType( Types.NUMERIC, "fixed($p,$s)" );
+ registerColumnType( Types.CLOB, "long varchar" );
+ registerColumnType( Types.BLOB, "long byte" );
+
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction( "ln", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction( "log", new StandardSQLFunction("ln", Hibernate.DOUBLE) );
+ registerFunction( "pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
+ registerFunction( "power", new StandardSQLFunction("power") );
+ registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction( "cosh", new StandardSQLFunction("cosh", Hibernate.DOUBLE) );
+ registerFunction( "cot", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction( "sinh", new StandardSQLFunction("sinh", Hibernate.DOUBLE) );
+ registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction( "tanh", new StandardSQLFunction("tanh", Hibernate.DOUBLE) );
+ registerFunction( "radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
+ registerFunction( "degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
+ registerFunction( "atan2", new StandardSQLFunction("atan2", Hibernate.DOUBLE) );
+
+ registerFunction( "round", new StandardSQLFunction("round") );
+ registerFunction( "trunc", new StandardSQLFunction("trunc") );
+ registerFunction( "ceil", new StandardSQLFunction("ceil") );
+ registerFunction( "floor", new StandardSQLFunction("floor") );
+ registerFunction( "greatest", new StandardSQLFunction("greatest") );
+ registerFunction( "least", new StandardSQLFunction("least") );
+
+ registerFunction("time", new StandardSQLFunction("time", Hibernate.TIME) );
+ registerFunction("timestamp", new StandardSQLFunction("timestamp", Hibernate.TIMESTAMP) );
+ registerFunction("date", new StandardSQLFunction("date", Hibernate.DATE) );
+ registerFunction("microsecond", new StandardSQLFunction("microsecond", Hibernate.INTEGER) );
+
+ registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "second(?1)") );
+ registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "minute(?1)") );
+ registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "hour(?1)") );
+ registerFunction( "day", new SQLFunctionTemplate(Hibernate.INTEGER, "day(?1)") );
+ registerFunction( "month", new SQLFunctionTemplate(Hibernate.INTEGER, "month(?1)") );
+ registerFunction( "year", new SQLFunctionTemplate(Hibernate.INTEGER, "year(?1)") );
+
+ registerFunction( "extract", new SQLFunctionTemplate(Hibernate.INTEGER, "?1(?3)") );
+
+ registerFunction("dayname", new StandardSQLFunction("dayname", Hibernate.STRING) );
+ registerFunction("monthname", new StandardSQLFunction("monthname", Hibernate.STRING) );
+ registerFunction("dayofmonth", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER) );
+ registerFunction("dayofweek", new StandardSQLFunction("dayofweek", Hibernate.INTEGER) );
+ registerFunction("dayofyear", new StandardSQLFunction("dayofyear", Hibernate.INTEGER) );
+ registerFunction("weekofyear", new StandardSQLFunction("weekofyear", Hibernate.INTEGER) );
+
+ registerFunction( "replace", new StandardSQLFunction("replace", Hibernate.STRING) );
+ registerFunction( "translate", new StandardSQLFunction("translate", Hibernate.STRING) );
+ registerFunction( "lpad", new StandardSQLFunction("lpad", Hibernate.STRING) );
+ registerFunction( "rpad", new StandardSQLFunction("rpad", Hibernate.STRING) );
+ registerFunction( "substr", new StandardSQLFunction("substr", Hibernate.STRING) );
+ registerFunction( "initcap", new StandardSQLFunction("initcap", Hibernate.STRING) );
+ registerFunction( "lower", new StandardSQLFunction("lower", Hibernate.STRING) );
+ registerFunction( "ltrim", new StandardSQLFunction("ltrim", Hibernate.STRING) );
+ registerFunction( "rtrim", new StandardSQLFunction("rtrim", Hibernate.STRING) );
+ registerFunction( "lfill", new StandardSQLFunction("ltrim", Hibernate.STRING) );
+ registerFunction( "rfill", new StandardSQLFunction("rtrim", Hibernate.STRING) );
+ registerFunction( "soundex", new StandardSQLFunction("soundex", Hibernate.STRING) );
+ registerFunction( "upper", new StandardSQLFunction("upper", Hibernate.STRING) );
+ registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.STRING) );
+ registerFunction( "index", new StandardSQLFunction("index", Hibernate.INTEGER) );
+
+ registerFunction( "value", new StandardSQLFunction( "value" ) );
+
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+ registerFunction( "substring", new StandardSQLFunction( "substr", Hibernate.STRING ) );
+ registerFunction( "locate", new StandardSQLFunction("index", Hibernate.INTEGER) );
+ registerFunction( "coalesce", new StandardSQLFunction( "value" ) );
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+
+ }
+
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public String getAddForeignKeyConstraintString(
+ String constraintName,
+ String[] foreignKey,
+ String referencedTable,
+ String[] primaryKey, boolean referencesPrimaryKey
+ ) {
+ StringBuffer res = new StringBuffer(30)
+ .append(" foreign key ")
+ .append(constraintName)
+ .append(" (")
+ .append( StringHelper.join(", ", foreignKey) )
+ .append(") references ")
+ .append(referencedTable);
+
+ if(!referencesPrimaryKey) {
+ res.append(" (")
+ .append( StringHelper.join(", ", primaryKey) )
+ .append(')');
+ }
+
+ return res.toString();
+ }
+
+ public String getAddPrimaryKeyConstraintString(String constraintName) {
+ return " primary key ";
+ }
+
+ public String getNullColumnString() {
+ return " null";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select " + getSelectSequenceNextValString( sequenceName ) + " from dual";
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getQuerySequencesString() {
+ return "select sequence_name from domain.sequences";
+ }
+
+ public JoinFragment createOuterJoinFragment() {
+ return new OracleJoinFragment();
+ }
+
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public CaseFragment createCaseFragment() {
+ return new DecodeCaseFragment();
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "ignore rollback";
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ return "temp." + super.generateTemporaryTableName(baseTableName);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,140 +0,0 @@
-//$Id: SQLServerDialect.java 11303 2007-03-19 22:06:14Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.Types;
-import java.util.Map;
-import java.util.Iterator;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.util.StringHelper;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.AnsiTrimEmulationFunction;
-
-/**
- * A dialect for Microsoft SQL Server 2000 and 2005
- *
- * @author Gavin King
- */
-public class SQLServerDialect extends SybaseDialect {
-
- public SQLServerDialect() {
- registerColumnType( Types.VARBINARY, "image" );
- registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
-
- registerFunction( "second", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(second, ?1)" ) );
- registerFunction( "minute", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(minute, ?1)" ) );
- registerFunction( "hour", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(hour, ?1)" ) );
- registerFunction( "locate", new StandardSQLFunction( "charindex", Hibernate.INTEGER ) );
-
- registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(?1, ?3)" ) );
- registerFunction( "mod", new SQLFunctionTemplate( Hibernate.INTEGER, "?1 % ?2" ) );
- registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "datalength(?1) * 8" ) );
-
- registerFunction( "trim", new AnsiTrimEmulationFunction() );
-
- registerKeyword( "top" );
- }
-
- public String getNoColumnsInsertString() {
- return "default values";
- }
-
- static int getAfterSelectInsertPoint(String sql) {
- int selectIndex = sql.toLowerCase().indexOf( "select" );
- final int selectDistinctIndex = sql.toLowerCase().indexOf( "select distinct" );
- return selectIndex + ( selectDistinctIndex == selectIndex ? 15 : 6 );
- }
-
- public String getLimitString(String querySelect, int offset, int limit) {
- if ( offset > 0 ) {
- throw new UnsupportedOperationException( "sql server has no offset" );
- }
- return new StringBuffer( querySelect.length() + 8 )
- .append( querySelect )
- .insert( getAfterSelectInsertPoint( querySelect ), " top " + limit )
- .toString();
- }
-
- /**
- * Use <tt>insert table(...) values(...) select SCOPE_IDENTITY()</tt>
- */
- public String appendIdentitySelectToInsert(String insertSQL) {
- return insertSQL + " select scope_identity()";
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
- public char closeQuote() {
- return ']';
- }
-
- public char openQuote() {
- return '[';
- }
-
- public String appendLockHint(LockMode mode, String tableName) {
- if ( mode.greaterThan( LockMode.READ ) ) {
- // does this need holdlock also? : return tableName + " with (updlock, rowlock, holdlock)";
- return tableName + " with (updlock, rowlock)";
- }
- else {
- return tableName;
- }
- }
-
- public String getSelectGUIDString() {
- return "select newid()";
- }
-
- // The current_timestamp is more accurate, but only known to be supported
- // in SQL Server 7.0 and later (i.e., Sybase not known to support it at all)
- public String getCurrentTimestampSelectString() {
- return "select current_timestamp";
- }
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean areStringComparisonsCaseInsensitive() {
- return true;
- }
-
- public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
- return false;
- }
-
- public boolean supportsCircularCascadeDeleteConstraints() {
- // SQL Server (at least up through 2005) does not support defining
- // cascade delete constraints which can circel back to the mutating
- // table
- return false;
- }
-
- public boolean supportsLobValueChangePropogation() {
- // note: at least my local SQL Server 2005 Express shows this not working...
- return false;
- }
-
- public boolean doesReadCommittedCauseWritersToBlockReaders() {
- return false; // here assume SQLServer2005 using snapshot isolation, which does not have this problem
- }
-
- public boolean doesRepeatableReadCauseReadersToBlockWriters() {
- return false; // here assume SQLServer2005 using snapshot isolation, which does not have this problem
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SQLServerDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,160 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.AnsiTrimEmulationFunction;
+
+/**
+ * A dialect for Microsoft SQL Server 2000 and 2005
+ *
+ * @author Gavin King
+ */
+public class SQLServerDialect extends SybaseDialect {
+
+ public SQLServerDialect() {
+ registerColumnType( Types.VARBINARY, "image" );
+ registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
+
+ registerFunction( "second", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(second, ?1)" ) );
+ registerFunction( "minute", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(minute, ?1)" ) );
+ registerFunction( "hour", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(hour, ?1)" ) );
+ registerFunction( "locate", new StandardSQLFunction( "charindex", Hibernate.INTEGER ) );
+
+ registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(?1, ?3)" ) );
+ registerFunction( "mod", new SQLFunctionTemplate( Hibernate.INTEGER, "?1 % ?2" ) );
+ registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "datalength(?1) * 8" ) );
+
+ registerFunction( "trim", new AnsiTrimEmulationFunction() );
+
+ registerKeyword( "top" );
+ }
+
+ public String getNoColumnsInsertString() {
+ return "default values";
+ }
+
+ static int getAfterSelectInsertPoint(String sql) {
+ int selectIndex = sql.toLowerCase().indexOf( "select" );
+ final int selectDistinctIndex = sql.toLowerCase().indexOf( "select distinct" );
+ return selectIndex + ( selectDistinctIndex == selectIndex ? 15 : 6 );
+ }
+
+ public String getLimitString(String querySelect, int offset, int limit) {
+ if ( offset > 0 ) {
+ throw new UnsupportedOperationException( "sql server has no offset" );
+ }
+ return new StringBuffer( querySelect.length() + 8 )
+ .append( querySelect )
+ .insert( getAfterSelectInsertPoint( querySelect ), " top " + limit )
+ .toString();
+ }
+
+ /**
+ * Use <tt>insert table(...) values(...) select SCOPE_IDENTITY()</tt>
+ */
+ public String appendIdentitySelectToInsert(String insertSQL) {
+ return insertSQL + " select scope_identity()";
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+ public char closeQuote() {
+ return ']';
+ }
+
+ public char openQuote() {
+ return '[';
+ }
+
+ public String appendLockHint(LockMode mode, String tableName) {
+ if ( mode.greaterThan( LockMode.READ ) ) {
+ // does this need holdlock also? : return tableName + " with (updlock, rowlock, holdlock)";
+ return tableName + " with (updlock, rowlock)";
+ }
+ else {
+ return tableName;
+ }
+ }
+
+ public String getSelectGUIDString() {
+ return "select newid()";
+ }
+
+ // The current_timestamp is more accurate, but only known to be supported
+ // in SQL Server 7.0 and later (i.e., Sybase not known to support it at all)
+ public String getCurrentTimestampSelectString() {
+ return "select current_timestamp";
+ }
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean areStringComparisonsCaseInsensitive() {
+ return true;
+ }
+
+ public boolean supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() {
+ return false;
+ }
+
+ public boolean supportsCircularCascadeDeleteConstraints() {
+ // SQL Server (at least up through 2005) does not support defining
+ // cascade delete constraints which can circel back to the mutating
+ // table
+ return false;
+ }
+
+ public boolean supportsLobValueChangePropogation() {
+ // note: at least my local SQL Server 2005 Express shows this not working...
+ return false;
+ }
+
+ public boolean doesReadCommittedCauseWritersToBlockReaders() {
+ return false; // here assume SQLServer2005 using snapshot isolation, which does not have this problem
+ }
+
+ public boolean doesRepeatableReadCauseReadersToBlockWriters() {
+ return false; // here assume SQLServer2005 using snapshot isolation, which does not have this problem
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,20 +0,0 @@
-//$Id: Sybase11Dialect.java 3890 2004-06-03 16:31:32Z steveebersole $
-package org.hibernate.dialect;
-
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.Sybase11JoinFragment;
-
-/**
- * A SQL dialect suitable for use with Sybase 11.9.2 (specifically: avoids ANSI JOIN syntax)
- * @author Colm O' Flaherty
- */
-public class Sybase11Dialect extends SybaseDialect {
- public Sybase11Dialect() {
- super();
- }
-
- public JoinFragment createOuterJoinFragment() {
- return new Sybase11JoinFragment();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/Sybase11Dialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.Sybase11JoinFragment;
+
+/**
+ * A SQL dialect suitable for use with Sybase 11.9.2 (specifically: avoids ANSI JOIN syntax)
+ * @author Colm O' Flaherty
+ */
+public class Sybase11Dialect extends SybaseDialect {
+ public Sybase11Dialect() {
+ super();
+ }
+
+ public JoinFragment createOuterJoinFragment() {
+ return new Sybase11JoinFragment();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,32 +0,0 @@
-package org.hibernate.dialect;
-
-/**
- * SQL Dialect for Sybase Anywhere
- * extending Sybase (Enterprise) Dialect
- * (Tested on ASA 8.x)
- * @author ?
- */
-public class SybaseAnywhereDialect extends SybaseDialect {
-
- /**
- * Sybase Anywhere syntax would require a "DEFAULT" for each column specified,
- * but I suppose Hibernate use this syntax only with tables with just 1 column
- */
- public String getNoColumnsInsertString() {
- return "values (default)";
- }
-
-
- /**
- * ASA does not require to drop constraint before dropping tables, and DROP statement
- * syntax used by Hibernate to drop constraint is not compatible with ASA, so disable it
- */
- public boolean dropConstraints() {
- return false;
- }
-
- public boolean supportsInsertSelectIdentity() {
- return false;
- }
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseAnywhereDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+/**
+ * SQL Dialect for Sybase Anywhere
+ * extending Sybase (Enterprise) Dialect
+ * (Tested on ASA 8.x)
+ * @author ?
+ */
+public class SybaseAnywhereDialect extends SybaseDialect {
+
+ /**
+ * Sybase Anywhere syntax would require a "DEFAULT" for each column specified,
+ * but I suppose Hibernate use this syntax only with tables with just 1 column
+ */
+ public String getNoColumnsInsertString() {
+ return "values (default)";
+ }
+
+
+ /**
+ * ASA does not require to drop constraint before dropping tables, and DROP statement
+ * syntax used by Hibernate to drop constraint is not compatible with ASA, so disable it
+ */
+ public boolean dropConstraints() {
+ return false;
+ }
+
+ public boolean supportsInsertSelectIdentity() {
+ return false;
+ }
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/SybaseDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,238 +0,0 @@
-//$Id: SybaseDialect.java 11303 2007-03-19 22:06:14Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Map;
-import java.util.Iterator;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.CharIndexFunction;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-
-/**
- * An SQL dialect compatible with Sybase and MS SQL Server.
- * @author Gavin King
- */
-
-public class SybaseDialect extends Dialect {
- public SybaseDialect() {
- super();
- registerColumnType( Types.BIT, "tinyint" ); //Sybase BIT type does not support null values
- registerColumnType( Types.BIGINT, "numeric(19,0)" );
- registerColumnType( Types.SMALLINT, "smallint" );
- registerColumnType( Types.TINYINT, "tinyint" );
- registerColumnType( Types.INTEGER, "int" );
- registerColumnType( Types.CHAR, "char(1)" );
- registerColumnType( Types.VARCHAR, "varchar($l)" );
- registerColumnType( Types.FLOAT, "float" );
- registerColumnType( Types.DOUBLE, "double precision" );
- registerColumnType( Types.DATE, "datetime" );
- registerColumnType( Types.TIME, "datetime" );
- registerColumnType( Types.TIMESTAMP, "datetime" );
- registerColumnType( Types.VARBINARY, "varbinary($l)" );
- registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
- registerColumnType( Types.BLOB, "image" );
- registerColumnType( Types.CLOB, "text" );
-
- registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
- registerFunction( "char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
- registerFunction( "len", new StandardSQLFunction("len", Hibernate.LONG) );
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "str", new StandardSQLFunction("str", Hibernate.STRING) );
- registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
- registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
- registerFunction( "reverse", new StandardSQLFunction("reverse") );
- registerFunction( "space", new StandardSQLFunction("space", Hibernate.STRING) );
-
- registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING) );
-
- registerFunction( "current_timestamp", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
- registerFunction( "current_time", new NoArgSQLFunction("getdate", Hibernate.TIME) );
- registerFunction( "current_date", new NoArgSQLFunction("getdate", Hibernate.DATE) );
-
- registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
- registerFunction( "getutcdate", new NoArgSQLFunction("getutcdate", Hibernate.TIMESTAMP) );
- registerFunction( "day", new StandardSQLFunction("day", Hibernate.INTEGER) );
- registerFunction( "month", new StandardSQLFunction("month", Hibernate.INTEGER) );
- registerFunction( "year", new StandardSQLFunction("year", Hibernate.INTEGER) );
- registerFunction( "datename", new StandardSQLFunction("datename", Hibernate.STRING) );
-
- registerFunction( "abs", new StandardSQLFunction("abs") );
- registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
-
- registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
- registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
- registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
- registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
- registerFunction( "cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
- registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
- registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE) );
- registerFunction( "log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
- registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
- registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
- registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
- registerFunction( "pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
- registerFunction( "square", new StandardSQLFunction("square") );
- registerFunction( "rand", new StandardSQLFunction("rand", Hibernate.FLOAT) );
-
- registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
- registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
-
- registerFunction( "round", new StandardSQLFunction("round") );
- registerFunction( "ceiling", new StandardSQLFunction("ceiling") );
- registerFunction( "floor", new StandardSQLFunction("floor") );
-
- registerFunction( "isnull", new StandardSQLFunction("isnull") );
-
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","+",")" ) );
-
- registerFunction( "length", new StandardSQLFunction( "len", Hibernate.INTEGER ) );
- registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "ltrim(rtrim(?1))") );
- registerFunction( "locate", new CharIndexFunction() );
-
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
- }
-
- public String getAddColumnString() {
- return "add";
- }
- public String getNullColumnString() {
- return " null";
- }
- public boolean qualifyIndexName() {
- return false;
- }
-
- public String getForUpdateString() {
- return "";
- }
-
- public boolean supportsIdentityColumns() {
- return true;
- }
- public String getIdentitySelectString() {
- return "select @@identity";
- }
- public String getIdentityColumnString() {
- return "identity not null"; //starts with 1, implicitly
- }
-
- public boolean supportsInsertSelectIdentity() {
- return true;
- }
-
- public String appendIdentitySelectToInsert(String insertSQL) {
- return insertSQL + "\nselect @@identity";
- }
-
- public String appendLockHint(LockMode mode, String tableName) {
- if ( mode.greaterThan( LockMode.READ ) ) {
- return tableName + " holdlock";
- }
- else {
- return tableName;
- }
- }
-
- public String applyLocksToSql(String sql, Map aliasedLockModes, Map keyColumnNames) {
- Iterator itr = aliasedLockModes.entrySet().iterator();
- StringBuffer buffer = new StringBuffer( sql );
- int correction = 0;
- while ( itr.hasNext() ) {
- final Map.Entry entry = ( Map.Entry ) itr.next();
- final LockMode lockMode = ( LockMode ) entry.getValue();
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- final String alias = ( String ) entry.getKey();
- int start = -1, end = -1;
- if ( sql.endsWith( " " + alias ) ) {
- start = ( sql.length() - alias.length() ) + correction;
- end = start + alias.length();
- }
- else {
- int position = sql.indexOf( " " + alias + " " );
- if ( position <= -1 ) {
- position = sql.indexOf( " " + alias + "," );
- }
- if ( position > -1 ) {
- start = position + correction + 1;
- end = start + alias.length();
- }
- }
-
- if ( start > -1 ) {
- final String lockHint = appendLockHint( lockMode, alias );
- buffer.replace( start, end, lockHint );
- correction += ( lockHint.length() - alias.length() );
- }
- }
- }
- return buffer.toString();
- }
-
- public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
- return col; // sql server just returns automatically
- }
-
- public ResultSet getResultSet(CallableStatement ps) throws SQLException {
- boolean isResultSet = ps.execute();
-// This assumes you will want to ignore any update counts
- while ( !isResultSet && ps.getUpdateCount() != -1 ) {
- isResultSet = ps.getMoreResults();
- }
-// You may still have other ResultSets or update counts left to process here
-// but you can't do it now or the ResultSet you just got will be closed
- return ps.getResultSet();
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public String getCurrentTimestampSelectString() {
- return "select getdate()";
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- return "#" + baseTableName;
- }
-
- public boolean dropTemporaryTableAfterUse() {
- return true; // sql-server, at least needed this dropped after use; strange!
- }
-
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public boolean supportsExistsInSelect() {
- return false;
- }
-
- public boolean doesReadCommittedCauseWritersToBlockReaders() {
- return true;
- }
-
- public boolean doesRepeatableReadCauseReadersToBlockWriters() {
- return true;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/SybaseDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/SybaseDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,261 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.CallableStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Map;
+import java.util.Iterator;
+
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.CharIndexFunction;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+
+/**
+ * An SQL dialect compatible with Sybase and MS SQL Server.
+ * @author Gavin King
+ */
+
+public class SybaseDialect extends Dialect {
+ public SybaseDialect() {
+ super();
+ registerColumnType( Types.BIT, "tinyint" ); //Sybase BIT type does not support null values
+ registerColumnType( Types.BIGINT, "numeric(19,0)" );
+ registerColumnType( Types.SMALLINT, "smallint" );
+ registerColumnType( Types.TINYINT, "tinyint" );
+ registerColumnType( Types.INTEGER, "int" );
+ registerColumnType( Types.CHAR, "char(1)" );
+ registerColumnType( Types.VARCHAR, "varchar($l)" );
+ registerColumnType( Types.FLOAT, "float" );
+ registerColumnType( Types.DOUBLE, "double precision" );
+ registerColumnType( Types.DATE, "datetime" );
+ registerColumnType( Types.TIME, "datetime" );
+ registerColumnType( Types.TIMESTAMP, "datetime" );
+ registerColumnType( Types.VARBINARY, "varbinary($l)" );
+ registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
+ registerColumnType( Types.BLOB, "image" );
+ registerColumnType( Types.CLOB, "text" );
+
+ registerFunction( "ascii", new StandardSQLFunction("ascii", Hibernate.INTEGER) );
+ registerFunction( "char", new StandardSQLFunction("char", Hibernate.CHARACTER) );
+ registerFunction( "len", new StandardSQLFunction("len", Hibernate.LONG) );
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "str", new StandardSQLFunction("str", Hibernate.STRING) );
+ registerFunction( "ltrim", new StandardSQLFunction("ltrim") );
+ registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
+ registerFunction( "reverse", new StandardSQLFunction("reverse") );
+ registerFunction( "space", new StandardSQLFunction("space", Hibernate.STRING) );
+
+ registerFunction( "user", new NoArgSQLFunction("user", Hibernate.STRING) );
+
+ registerFunction( "current_timestamp", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
+ registerFunction( "current_time", new NoArgSQLFunction("getdate", Hibernate.TIME) );
+ registerFunction( "current_date", new NoArgSQLFunction("getdate", Hibernate.DATE) );
+
+ registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP) );
+ registerFunction( "getutcdate", new NoArgSQLFunction("getutcdate", Hibernate.TIMESTAMP) );
+ registerFunction( "day", new StandardSQLFunction("day", Hibernate.INTEGER) );
+ registerFunction( "month", new StandardSQLFunction("month", Hibernate.INTEGER) );
+ registerFunction( "year", new StandardSQLFunction("year", Hibernate.INTEGER) );
+ registerFunction( "datename", new StandardSQLFunction("datename", Hibernate.STRING) );
+
+ registerFunction( "abs", new StandardSQLFunction("abs") );
+ registerFunction( "sign", new StandardSQLFunction("sign", Hibernate.INTEGER) );
+
+ registerFunction( "acos", new StandardSQLFunction("acos", Hibernate.DOUBLE) );
+ registerFunction( "asin", new StandardSQLFunction("asin", Hibernate.DOUBLE) );
+ registerFunction( "atan", new StandardSQLFunction("atan", Hibernate.DOUBLE) );
+ registerFunction( "cos", new StandardSQLFunction("cos", Hibernate.DOUBLE) );
+ registerFunction( "cot", new StandardSQLFunction("cot", Hibernate.DOUBLE) );
+ registerFunction( "exp", new StandardSQLFunction("exp", Hibernate.DOUBLE) );
+ registerFunction( "log", new StandardSQLFunction( "log", Hibernate.DOUBLE) );
+ registerFunction( "log10", new StandardSQLFunction("log10", Hibernate.DOUBLE) );
+ registerFunction( "sin", new StandardSQLFunction("sin", Hibernate.DOUBLE) );
+ registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
+ registerFunction( "tan", new StandardSQLFunction("tan", Hibernate.DOUBLE) );
+ registerFunction( "pi", new NoArgSQLFunction("pi", Hibernate.DOUBLE) );
+ registerFunction( "square", new StandardSQLFunction("square") );
+ registerFunction( "rand", new StandardSQLFunction("rand", Hibernate.FLOAT) );
+
+ registerFunction("radians", new StandardSQLFunction("radians", Hibernate.DOUBLE) );
+ registerFunction("degrees", new StandardSQLFunction("degrees", Hibernate.DOUBLE) );
+
+ registerFunction( "round", new StandardSQLFunction("round") );
+ registerFunction( "ceiling", new StandardSQLFunction("ceiling") );
+ registerFunction( "floor", new StandardSQLFunction("floor") );
+
+ registerFunction( "isnull", new StandardSQLFunction("isnull") );
+
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(","+",")" ) );
+
+ registerFunction( "length", new StandardSQLFunction( "len", Hibernate.INTEGER ) );
+ registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "ltrim(rtrim(?1))") );
+ registerFunction( "locate", new CharIndexFunction() );
+
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+ public String getNullColumnString() {
+ return " null";
+ }
+ public boolean qualifyIndexName() {
+ return false;
+ }
+
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public boolean supportsIdentityColumns() {
+ return true;
+ }
+ public String getIdentitySelectString() {
+ return "select @@identity";
+ }
+ public String getIdentityColumnString() {
+ return "identity not null"; //starts with 1, implicitly
+ }
+
+ public boolean supportsInsertSelectIdentity() {
+ return true;
+ }
+
+ public String appendIdentitySelectToInsert(String insertSQL) {
+ return insertSQL + "\nselect @@identity";
+ }
+
+ public String appendLockHint(LockMode mode, String tableName) {
+ if ( mode.greaterThan( LockMode.READ ) ) {
+ return tableName + " holdlock";
+ }
+ else {
+ return tableName;
+ }
+ }
+
+ public String applyLocksToSql(String sql, Map aliasedLockModes, Map keyColumnNames) {
+ Iterator itr = aliasedLockModes.entrySet().iterator();
+ StringBuffer buffer = new StringBuffer( sql );
+ int correction = 0;
+ while ( itr.hasNext() ) {
+ final Map.Entry entry = ( Map.Entry ) itr.next();
+ final LockMode lockMode = ( LockMode ) entry.getValue();
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ final String alias = ( String ) entry.getKey();
+ int start = -1, end = -1;
+ if ( sql.endsWith( " " + alias ) ) {
+ start = ( sql.length() - alias.length() ) + correction;
+ end = start + alias.length();
+ }
+ else {
+ int position = sql.indexOf( " " + alias + " " );
+ if ( position <= -1 ) {
+ position = sql.indexOf( " " + alias + "," );
+ }
+ if ( position > -1 ) {
+ start = position + correction + 1;
+ end = start + alias.length();
+ }
+ }
+
+ if ( start > -1 ) {
+ final String lockHint = appendLockHint( lockMode, alias );
+ buffer.replace( start, end, lockHint );
+ correction += ( lockHint.length() - alias.length() );
+ }
+ }
+ }
+ return buffer.toString();
+ }
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
+ return col; // sql server just returns automatically
+ }
+
+ public ResultSet getResultSet(CallableStatement ps) throws SQLException {
+ boolean isResultSet = ps.execute();
+// This assumes you will want to ignore any update counts
+ while ( !isResultSet && ps.getUpdateCount() != -1 ) {
+ isResultSet = ps.getMoreResults();
+ }
+// You may still have other ResultSets or update counts left to process here
+// but you can't do it now or the ResultSet you just got will be closed
+ return ps.getResultSet();
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select getdate()";
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ return "#" + baseTableName;
+ }
+
+ public boolean dropTemporaryTableAfterUse() {
+ return true; // sql-server, at least needed this dropped after use; strange!
+ }
+
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public boolean supportsExistsInSelect() {
+ return false;
+ }
+
+ public boolean doesReadCommittedCauseWritersToBlockReaders() {
+ return true;
+ }
+
+ public boolean doesRepeatableReadCauseReadersToBlockWriters() {
+ return true;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/TeradataDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,237 +0,0 @@
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.SQLFunctionTemplate;
-import org.hibernate.dialect.function.VarArgsSQLFunction;
-
-/**
- * A dialect for the Teradata database created by MCR as part of the
- * dialect certification process.
- *
- * @author Jay Nance
- */
-public class TeradataDialect extends Dialect {
-
- /**
- * Constructor
- */
- public TeradataDialect() {
- super();
- //registerColumnType data types
- registerColumnType( Types.NUMERIC, "NUMERIC($p,$s)" );
- registerColumnType( Types.DOUBLE, "DOUBLE PRECISION" );
- registerColumnType( Types.BIGINT, "NUMERIC(18,0)" );
- registerColumnType( Types.BIT, "BYTEINT" );
- registerColumnType( Types.TINYINT, "BYTEINT" );
- registerColumnType( Types.VARBINARY, "VARBYTE($l)" );
- registerColumnType( Types.BINARY, "BYTEINT" );
- registerColumnType( Types.LONGVARCHAR, "LONG VARCHAR" );
- registerColumnType( Types.CHAR, "CHAR(1)" );
- registerColumnType( Types.DECIMAL, "DECIMAL" );
- registerColumnType( Types.INTEGER, "INTEGER" );
- registerColumnType( Types.SMALLINT, "SMALLINT" );
- registerColumnType( Types.FLOAT, "FLOAT" );
- registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
- registerColumnType( Types.DATE, "DATE" );
- registerColumnType( Types.TIME, "TIME" );
- registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
- registerColumnType( Types.BOOLEAN, "BYTEINT" ); // hibernate seems to ignore this type...
- registerColumnType( Types.BLOB, "BLOB" );
- registerColumnType( Types.CLOB, "CLOB" );
-
- registerFunction( "year", new SQLFunctionTemplate( Hibernate.INTEGER, "extract(year from ?1)" ) );
- registerFunction( "length", new SQLFunctionTemplate( Hibernate.INTEGER, "character_length(?1)" ) );
- registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
- registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 from ?2 for ?3)" ) );
- registerFunction( "locate", new SQLFunctionTemplate( Hibernate.STRING, "position(?1 in ?2)" ) );
- registerFunction( "mod", new SQLFunctionTemplate( Hibernate.STRING, "?1 mod ?2" ) );
- registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "cast(?1 as varchar(255))" ) );
-
- // bit_length feels a bit broken to me. We have to cast to char in order to
- // pass when a numeric value is supplied. But of course the answers given will
- // be wildly different for these two datatypes. 1234.5678 will be 9 bytes as
- // a char string but will be 8 or 16 bytes as a true numeric.
- // Jay Nance 2006-09-22
- registerFunction(
- "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(cast(?1 as char))*4" )
- );
-
- // The preference here would be
- // SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp(?1)", false)
- // but this appears not to work.
- // Jay Nance 2006-09-22
- registerFunction( "current_timestamp", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp" ) );
- registerFunction( "current_time", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_time" ) );
- registerFunction( "current_date", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_date" ) );
- // IBID for current_time and current_date
-
- registerKeyword( "password" );
- registerKeyword( "type" );
- registerKeyword( "title" );
- registerKeyword( "year" );
- registerKeyword( "month" );
- registerKeyword( "summary" );
- registerKeyword( "alias" );
- registerKeyword( "value" );
- registerKeyword( "first" );
- registerKeyword( "role" );
- registerKeyword( "account" );
- registerKeyword( "class" );
-
- // Tell hibernate to use getBytes instead of getBinaryStream
- getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
- // No batch statements
- getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
- }
-
- /**
- * Does this dialect support the <tt>FOR UPDATE</tt> syntax?
- *
- * @return empty string ... Teradata does not support <tt>FOR UPDATE<tt> syntax
- */
- public String getForUpdateString() {
- return "";
- }
-
- public boolean supportsIdentityColumns() {
- return false;
- }
-
- public boolean supportsSequences() {
- return false;
- }
-
- public String getAddColumnString() {
- return "Add Column";
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String getCreateTemporaryTableString() {
- return "create global temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return " on commit preserve rows";
- }
-
- public Boolean performTemporaryTableDDLInIsolation() {
- return Boolean.TRUE;
- }
-
- public boolean dropTemporaryTableAfterUse() {
- return false;
- }
-
- /**
- * Get the name of the database type associated with the given
- * <tt>java.sql.Types</tt> typecode.
- *
- * @param code <tt>java.sql.Types</tt> typecode
- * @param length the length or precision of the column
- * @param precision the precision of the column
- * @param scale the scale of the column
- *
- * @return the database type name
- *
- * @throws HibernateException
- */
- public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
- /*
- * We might want a special case for 19,2. This is very common for money types
- * and here it is converted to 18,1
- */
- float f = precision > 0 ? ( float ) scale / ( float ) precision : 0;
- int p = ( precision > 18 ? 18 : precision );
- int s = ( precision > 18 ? ( int ) ( 18.0 * f ) : ( scale > 18 ? 18 : scale ) );
-
- return super.getTypeName( code, length, p, s );
- }
-
- public boolean supportsCascadeDelete() {
- return false;
- }
-
- public boolean supportsCircularCascadeDeleteConstraints() {
- return false;
- }
-
- public boolean areStringComparisonsCaseInsensitive() {
- return true;
- }
-
- public boolean supportsEmptyInList() {
- return false;
- }
-
- public String getSelectClauseNullString(int sqlType) {
- String v = "null";
-
- switch ( sqlType ) {
- case Types.BIT:
- case Types.TINYINT:
- case Types.SMALLINT:
- case Types.INTEGER:
- case Types.BIGINT:
- case Types.FLOAT:
- case Types.REAL:
- case Types.DOUBLE:
- case Types.NUMERIC:
- case Types.DECIMAL:
- v = "cast(null as decimal)";
- break;
- case Types.CHAR:
- case Types.VARCHAR:
- case Types.LONGVARCHAR:
- v = "cast(null as varchar(255))";
- break;
- case Types.DATE:
- case Types.TIME:
- case Types.TIMESTAMP:
- v = "cast(null as timestamp)";
- break;
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- case Types.NULL:
- case Types.OTHER:
- case Types.JAVA_OBJECT:
- case Types.DISTINCT:
- case Types.STRUCT:
- case Types.ARRAY:
- case Types.BLOB:
- case Types.CLOB:
- case Types.REF:
- case Types.DATALINK:
- case Types.BOOLEAN:
- break;
- }
- return v;
- }
-
- public String getCreateMultisetTableString() {
- return "create multiset table ";
- }
-
- public boolean supportsLobValueChangePropogation() {
- return false;
- }
-
- public boolean doesReadCommittedCauseWritersToBlockReaders() {
- return true;
- }
-
- public boolean doesRepeatableReadCauseReadersToBlockWriters() {
- return true;
- }
-
- public boolean supportsBindAsCallableArgument() {
- return false;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/TeradataDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TeradataDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,261 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.SQLFunctionTemplate;
+import org.hibernate.dialect.function.VarArgsSQLFunction;
+
+/**
+ * A dialect for the Teradata database created by MCR as part of the
+ * dialect certification process.
+ *
+ * @author Jay Nance
+ */
+public class TeradataDialect extends Dialect {
+
+ /**
+ * Constructor
+ */
+ public TeradataDialect() {
+ super();
+ //registerColumnType data types
+ registerColumnType( Types.NUMERIC, "NUMERIC($p,$s)" );
+ registerColumnType( Types.DOUBLE, "DOUBLE PRECISION" );
+ registerColumnType( Types.BIGINT, "NUMERIC(18,0)" );
+ registerColumnType( Types.BIT, "BYTEINT" );
+ registerColumnType( Types.TINYINT, "BYTEINT" );
+ registerColumnType( Types.VARBINARY, "VARBYTE($l)" );
+ registerColumnType( Types.BINARY, "BYTEINT" );
+ registerColumnType( Types.LONGVARCHAR, "LONG VARCHAR" );
+ registerColumnType( Types.CHAR, "CHAR(1)" );
+ registerColumnType( Types.DECIMAL, "DECIMAL" );
+ registerColumnType( Types.INTEGER, "INTEGER" );
+ registerColumnType( Types.SMALLINT, "SMALLINT" );
+ registerColumnType( Types.FLOAT, "FLOAT" );
+ registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
+ registerColumnType( Types.DATE, "DATE" );
+ registerColumnType( Types.TIME, "TIME" );
+ registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
+ registerColumnType( Types.BOOLEAN, "BYTEINT" ); // hibernate seems to ignore this type...
+ registerColumnType( Types.BLOB, "BLOB" );
+ registerColumnType( Types.CLOB, "CLOB" );
+
+ registerFunction( "year", new SQLFunctionTemplate( Hibernate.INTEGER, "extract(year from ?1)" ) );
+ registerFunction( "length", new SQLFunctionTemplate( Hibernate.INTEGER, "character_length(?1)" ) );
+ registerFunction( "concat", new VarArgsSQLFunction( Hibernate.STRING, "(", "||", ")" ) );
+ registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1 from ?2 for ?3)" ) );
+ registerFunction( "locate", new SQLFunctionTemplate( Hibernate.STRING, "position(?1 in ?2)" ) );
+ registerFunction( "mod", new SQLFunctionTemplate( Hibernate.STRING, "?1 mod ?2" ) );
+ registerFunction( "str", new SQLFunctionTemplate( Hibernate.STRING, "cast(?1 as varchar(255))" ) );
+
+ // bit_length feels a bit broken to me. We have to cast to char in order to
+ // pass when a numeric value is supplied. But of course the answers given will
+ // be wildly different for these two datatypes. 1234.5678 will be 9 bytes as
+ // a char string but will be 8 or 16 bytes as a true numeric.
+ // Jay Nance 2006-09-22
+ registerFunction(
+ "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "octet_length(cast(?1 as char))*4" )
+ );
+
+ // The preference here would be
+ // SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp(?1)", false)
+ // but this appears not to work.
+ // Jay Nance 2006-09-22
+ registerFunction( "current_timestamp", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_timestamp" ) );
+ registerFunction( "current_time", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_time" ) );
+ registerFunction( "current_date", new SQLFunctionTemplate( Hibernate.TIMESTAMP, "current_date" ) );
+ // IBID for current_time and current_date
+
+ registerKeyword( "password" );
+ registerKeyword( "type" );
+ registerKeyword( "title" );
+ registerKeyword( "year" );
+ registerKeyword( "month" );
+ registerKeyword( "summary" );
+ registerKeyword( "alias" );
+ registerKeyword( "value" );
+ registerKeyword( "first" );
+ registerKeyword( "role" );
+ registerKeyword( "account" );
+ registerKeyword( "class" );
+
+ // Tell hibernate to use getBytes instead of getBinaryStream
+ getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
+ // No batch statements
+ getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
+ }
+
+ /**
+ * Does this dialect support the <tt>FOR UPDATE</tt> syntax?
+ *
+ * @return empty string ... Teradata does not support <tt>FOR UPDATE<tt> syntax
+ */
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public boolean supportsIdentityColumns() {
+ return false;
+ }
+
+ public boolean supportsSequences() {
+ return false;
+ }
+
+ public String getAddColumnString() {
+ return "Add Column";
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return " on commit preserve rows";
+ }
+
+ public Boolean performTemporaryTableDDLInIsolation() {
+ return Boolean.TRUE;
+ }
+
+ public boolean dropTemporaryTableAfterUse() {
+ return false;
+ }
+
+ /**
+ * Get the name of the database type associated with the given
+ * <tt>java.sql.Types</tt> typecode.
+ *
+ * @param code <tt>java.sql.Types</tt> typecode
+ * @param length the length or precision of the column
+ * @param precision the precision of the column
+ * @param scale the scale of the column
+ *
+ * @return the database type name
+ *
+ * @throws HibernateException
+ */
+ public String getTypeName(int code, int length, int precision, int scale) throws HibernateException {
+ /*
+ * We might want a special case for 19,2. This is very common for money types
+ * and here it is converted to 18,1
+ */
+ float f = precision > 0 ? ( float ) scale / ( float ) precision : 0;
+ int p = ( precision > 18 ? 18 : precision );
+ int s = ( precision > 18 ? ( int ) ( 18.0 * f ) : ( scale > 18 ? 18 : scale ) );
+
+ return super.getTypeName( code, length, p, s );
+ }
+
+ public boolean supportsCascadeDelete() {
+ return false;
+ }
+
+ public boolean supportsCircularCascadeDeleteConstraints() {
+ return false;
+ }
+
+ public boolean areStringComparisonsCaseInsensitive() {
+ return true;
+ }
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+
+ public String getSelectClauseNullString(int sqlType) {
+ String v = "null";
+
+ switch ( sqlType ) {
+ case Types.BIT:
+ case Types.TINYINT:
+ case Types.SMALLINT:
+ case Types.INTEGER:
+ case Types.BIGINT:
+ case Types.FLOAT:
+ case Types.REAL:
+ case Types.DOUBLE:
+ case Types.NUMERIC:
+ case Types.DECIMAL:
+ v = "cast(null as decimal)";
+ break;
+ case Types.CHAR:
+ case Types.VARCHAR:
+ case Types.LONGVARCHAR:
+ v = "cast(null as varchar(255))";
+ break;
+ case Types.DATE:
+ case Types.TIME:
+ case Types.TIMESTAMP:
+ v = "cast(null as timestamp)";
+ break;
+ case Types.BINARY:
+ case Types.VARBINARY:
+ case Types.LONGVARBINARY:
+ case Types.NULL:
+ case Types.OTHER:
+ case Types.JAVA_OBJECT:
+ case Types.DISTINCT:
+ case Types.STRUCT:
+ case Types.ARRAY:
+ case Types.BLOB:
+ case Types.CLOB:
+ case Types.REF:
+ case Types.DATALINK:
+ case Types.BOOLEAN:
+ break;
+ }
+ return v;
+ }
+
+ public String getCreateMultisetTableString() {
+ return "create multiset table ";
+ }
+
+ public boolean supportsLobValueChangePropogation() {
+ return false;
+ }
+
+ public boolean doesReadCommittedCauseWritersToBlockReaders() {
+ return true;
+ }
+
+ public boolean doesRepeatableReadCauseReadersToBlockWriters() {
+ return true;
+ }
+
+ public boolean supportsBindAsCallableArgument() {
+ return false;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,205 +0,0 @@
-package org.hibernate.dialect;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.cfg.Environment;
-import org.hibernate.dialect.function.NoArgSQLFunction;
-import org.hibernate.dialect.function.StandardSQLFunction;
-import org.hibernate.dialect.lock.LockingStrategy;
-import org.hibernate.dialect.lock.UpdateLockingStrategy;
-import org.hibernate.dialect.lock.SelectLockingStrategy;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.OracleJoinFragment;
-
-/**
- * A SQL dialect for TimesTen 5.1.
- *
- * Known limitations:
- * joined-subclass support because of no CASE support in TimesTen
- * No support for subqueries that includes aggregation
- * - size() in HQL not supported
- * - user queries that does subqueries with aggregation
- * No CLOB/BLOB support
- * No cascade delete support.
- * No Calendar support
- * No support for updating primary keys.
- *
- * @author Sherry Listgarten and Max Andersen
- */
-public class TimesTenDialect extends Dialect {
-
- public TimesTenDialect() {
- super();
- registerColumnType( Types.BIT, "TINYINT" );
- registerColumnType( Types.BIGINT, "BIGINT" );
- registerColumnType( Types.SMALLINT, "SMALLINT" );
- registerColumnType( Types.TINYINT, "TINYINT" );
- registerColumnType( Types.INTEGER, "INTEGER" );
- registerColumnType( Types.CHAR, "CHAR(1)" );
- registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
- registerColumnType( Types.FLOAT, "FLOAT" );
- registerColumnType( Types.DOUBLE, "DOUBLE" );
- registerColumnType( Types.DATE, "DATE" );
- registerColumnType( Types.TIME, "TIME" );
- registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
- registerColumnType( Types.VARBINARY, "VARBINARY($l)" );
- registerColumnType( Types.NUMERIC, "DECIMAL($p, $s)" );
- // TimesTen has no BLOB/CLOB support, but these types may be suitable
- // for some applications. The length is limited to 4 million bytes.
- registerColumnType( Types.BLOB, "VARBINARY(4000000)" );
- registerColumnType( Types.CLOB, "VARCHAR(4000000)" );
-
- getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
- getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
- registerFunction( "lower", new StandardSQLFunction("lower") );
- registerFunction( "upper", new StandardSQLFunction("upper") );
- registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
- registerFunction( "concat", new StandardSQLFunction("concat", Hibernate.STRING) );
- registerFunction( "mod", new StandardSQLFunction("mod") );
- registerFunction( "to_char", new StandardSQLFunction("to_char",Hibernate.STRING) );
- registerFunction( "to_date", new StandardSQLFunction("to_date",Hibernate.TIMESTAMP) );
- registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false) );
- registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP, false) );
- registerFunction( "nvl", new StandardSQLFunction("nvl") );
-
- }
-
- public boolean dropConstraints() {
- return true;
- }
-
- public boolean qualifyIndexName() {
- return false;
- }
-
- public boolean supportsUnique() {
- return false;
- }
-
- public boolean supportsUniqueConstraintInCreateAlterTable() {
- return false;
- }
-
- public String getAddColumnString() {
- return "add";
- }
-
- public boolean supportsSequences() {
- return true;
- }
-
- public String getSelectSequenceNextValString(String sequenceName) {
- return sequenceName + ".nextval";
- }
-
- public String getSequenceNextValString(String sequenceName) {
- return "select first 1 " + sequenceName + ".nextval from sys.tables";
- }
-
- public String getCreateSequenceString(String sequenceName) {
- return "create sequence " + sequenceName;
- }
-
- public String getDropSequenceString(String sequenceName) {
- return "drop sequence " + sequenceName;
- }
-
- public String getQuerySequencesString() {
- return "select NAME from sys.sequences";
- }
-
- public JoinFragment createOuterJoinFragment() {
- return new OracleJoinFragment();
- }
-
- // new methods in dialect3
- /*public boolean supportsForUpdateNowait() {
- return false;
- }*/
-
- public String getForUpdateString() {
- return "";
- }
-
- public boolean supportsColumnCheck() {
- return false;
- }
-
- public boolean supportsTableCheck() {
- return false;
- }
-
- public boolean supportsLimitOffset() {
- return false;
- }
-
- public boolean supportsVariableLimit() {
- return false;
- }
-
- public boolean supportsLimit() {
- return true;
- }
-
- public boolean useMaxForLimit() {
- return true;
- }
-
- public String getLimitString(String querySelect, int offset, int limit) {
- if ( offset > 0 ) {
- throw new UnsupportedOperationException( "TimesTen does not support offset" );
- }
- return new StringBuffer( querySelect.length()+8 )
- .append(querySelect)
- .insert( 6, " first " + limit )
- .toString();
- }
-
- public boolean supportsCurrentTimestampSelection() {
- return true;
- }
-
- public String getCurrentTimestampSelectString() {
- return "select first 1 sysdate from sys.tables";
- }
-
- public boolean isCurrentTimestampSelectStringCallable() {
- return false;
- }
-
- public boolean supportsTemporaryTables() {
- return true;
- }
-
- public String generateTemporaryTableName(String baseTableName) {
- String name = super.generateTemporaryTableName(baseTableName);
- return name.length() > 30 ? name.substring( 1, 30 ) : name;
- }
-
- public String getCreateTemporaryTableString() {
- return "create global temporary table";
- }
-
- public String getCreateTemporaryTablePostfix() {
- return "on commit delete rows";
- }
-
- public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
- // TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
- if ( lockMode.greaterThan( LockMode.READ ) ) {
- return new UpdateLockingStrategy( lockable, lockMode );
- }
- else {
- return new SelectLockingStrategy( lockable, lockMode );
- }
- }
-
- // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public boolean supportsEmptyInList() {
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TimesTenDialect.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,229 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.LockMode;
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.function.NoArgSQLFunction;
+import org.hibernate.dialect.function.StandardSQLFunction;
+import org.hibernate.dialect.lock.LockingStrategy;
+import org.hibernate.dialect.lock.UpdateLockingStrategy;
+import org.hibernate.dialect.lock.SelectLockingStrategy;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.OracleJoinFragment;
+
+/**
+ * A SQL dialect for TimesTen 5.1.
+ *
+ * Known limitations:
+ * joined-subclass support because of no CASE support in TimesTen
+ * No support for subqueries that includes aggregation
+ * - size() in HQL not supported
+ * - user queries that does subqueries with aggregation
+ * No CLOB/BLOB support
+ * No cascade delete support.
+ * No Calendar support
+ * No support for updating primary keys.
+ *
+ * @author Sherry Listgarten and Max Andersen
+ */
+public class TimesTenDialect extends Dialect {
+
+ public TimesTenDialect() {
+ super();
+ registerColumnType( Types.BIT, "TINYINT" );
+ registerColumnType( Types.BIGINT, "BIGINT" );
+ registerColumnType( Types.SMALLINT, "SMALLINT" );
+ registerColumnType( Types.TINYINT, "TINYINT" );
+ registerColumnType( Types.INTEGER, "INTEGER" );
+ registerColumnType( Types.CHAR, "CHAR(1)" );
+ registerColumnType( Types.VARCHAR, "VARCHAR($l)" );
+ registerColumnType( Types.FLOAT, "FLOAT" );
+ registerColumnType( Types.DOUBLE, "DOUBLE" );
+ registerColumnType( Types.DATE, "DATE" );
+ registerColumnType( Types.TIME, "TIME" );
+ registerColumnType( Types.TIMESTAMP, "TIMESTAMP" );
+ registerColumnType( Types.VARBINARY, "VARBINARY($l)" );
+ registerColumnType( Types.NUMERIC, "DECIMAL($p, $s)" );
+ // TimesTen has no BLOB/CLOB support, but these types may be suitable
+ // for some applications. The length is limited to 4 million bytes.
+ registerColumnType( Types.BLOB, "VARBINARY(4000000)" );
+ registerColumnType( Types.CLOB, "VARCHAR(4000000)" );
+
+ getDefaultProperties().setProperty(Environment.USE_STREAMS_FOR_BINARY, "true");
+ getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
+ registerFunction( "lower", new StandardSQLFunction("lower") );
+ registerFunction( "upper", new StandardSQLFunction("upper") );
+ registerFunction( "rtrim", new StandardSQLFunction("rtrim") );
+ registerFunction( "concat", new StandardSQLFunction("concat", Hibernate.STRING) );
+ registerFunction( "mod", new StandardSQLFunction("mod") );
+ registerFunction( "to_char", new StandardSQLFunction("to_char",Hibernate.STRING) );
+ registerFunction( "to_date", new StandardSQLFunction("to_date",Hibernate.TIMESTAMP) );
+ registerFunction( "sysdate", new NoArgSQLFunction("sysdate", Hibernate.TIMESTAMP, false) );
+ registerFunction( "getdate", new NoArgSQLFunction("getdate", Hibernate.TIMESTAMP, false) );
+ registerFunction( "nvl", new StandardSQLFunction("nvl") );
+
+ }
+
+ public boolean dropConstraints() {
+ return true;
+ }
+
+ public boolean qualifyIndexName() {
+ return false;
+ }
+
+ public boolean supportsUnique() {
+ return false;
+ }
+
+ public boolean supportsUniqueConstraintInCreateAlterTable() {
+ return false;
+ }
+
+ public String getAddColumnString() {
+ return "add";
+ }
+
+ public boolean supportsSequences() {
+ return true;
+ }
+
+ public String getSelectSequenceNextValString(String sequenceName) {
+ return sequenceName + ".nextval";
+ }
+
+ public String getSequenceNextValString(String sequenceName) {
+ return "select first 1 " + sequenceName + ".nextval from sys.tables";
+ }
+
+ public String getCreateSequenceString(String sequenceName) {
+ return "create sequence " + sequenceName;
+ }
+
+ public String getDropSequenceString(String sequenceName) {
+ return "drop sequence " + sequenceName;
+ }
+
+ public String getQuerySequencesString() {
+ return "select NAME from sys.sequences";
+ }
+
+ public JoinFragment createOuterJoinFragment() {
+ return new OracleJoinFragment();
+ }
+
+ // new methods in dialect3
+ /*public boolean supportsForUpdateNowait() {
+ return false;
+ }*/
+
+ public String getForUpdateString() {
+ return "";
+ }
+
+ public boolean supportsColumnCheck() {
+ return false;
+ }
+
+ public boolean supportsTableCheck() {
+ return false;
+ }
+
+ public boolean supportsLimitOffset() {
+ return false;
+ }
+
+ public boolean supportsVariableLimit() {
+ return false;
+ }
+
+ public boolean supportsLimit() {
+ return true;
+ }
+
+ public boolean useMaxForLimit() {
+ return true;
+ }
+
+ public String getLimitString(String querySelect, int offset, int limit) {
+ if ( offset > 0 ) {
+ throw new UnsupportedOperationException( "TimesTen does not support offset" );
+ }
+ return new StringBuffer( querySelect.length()+8 )
+ .append(querySelect)
+ .insert( 6, " first " + limit )
+ .toString();
+ }
+
+ public boolean supportsCurrentTimestampSelection() {
+ return true;
+ }
+
+ public String getCurrentTimestampSelectString() {
+ return "select first 1 sysdate from sys.tables";
+ }
+
+ public boolean isCurrentTimestampSelectStringCallable() {
+ return false;
+ }
+
+ public boolean supportsTemporaryTables() {
+ return true;
+ }
+
+ public String generateTemporaryTableName(String baseTableName) {
+ String name = super.generateTemporaryTableName(baseTableName);
+ return name.length() > 30 ? name.substring( 1, 30 ) : name;
+ }
+
+ public String getCreateTemporaryTableString() {
+ return "create global temporary table";
+ }
+
+ public String getCreateTemporaryTablePostfix() {
+ return "on commit delete rows";
+ }
+
+ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
+ // TimesTen has no known variation of a "SELECT ... FOR UPDATE" syntax...
+ if ( lockMode.greaterThan( LockMode.READ ) ) {
+ return new UpdateLockingStrategy( lockable, lockMode );
+ }
+ else {
+ return new SelectLockingStrategy( lockable, lockMode );
+ }
+ }
+
+ // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public boolean supportsEmptyInList() {
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/TypeNames.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,116 +0,0 @@
-//$Id: TypeNames.java 6254 2005-03-30 18:01:41Z oneovthafew $
-package org.hibernate.dialect;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.TreeMap;
-import java.util.Iterator;
-
-import org.hibernate.MappingException;
-import org.hibernate.util.StringHelper;
-
-/**
- * This class maps a type to names. Associations
- * may be marked with a capacity. Calling the get()
- * method with a type and actual size n will return
- * the associated name with smallest capacity >= n,
- * if available and an unmarked default type otherwise.
- * Eg, setting
- * <pre>
- * names.put(type, "TEXT" );
- * names.put(type, 255, "VARCHAR($l)" );
- * names.put(type, 65534, "LONGVARCHAR($l)" );
- * </pre>
- * will give you back the following:
- * <pre>
- * names.get(type) // --> "TEXT" (default)
- * names.get(type, 100) // --> "VARCHAR(100)" (100 is in [0:255])
- * names.get(type, 1000) // --> "LONGVARCHAR(1000)" (1000 is in [256:65534])
- * names.get(type, 100000) // --> "TEXT" (default)
- * </pre>
- * On the other hand, simply putting
- * <pre>
- * names.put(type, "VARCHAR($l)" );
- * </pre>
- * would result in
- * <pre>
- * names.get(type) // --> "VARCHAR($l)" (will cause trouble)
- * names.get(type, 100) // --> "VARCHAR(100)"
- * names.get(type, 10000) // --> "VARCHAR(10000)"
- * </pre>
- *
- * @author Christoph Beck
- */
-public class TypeNames {
-
- private HashMap weighted = new HashMap();
- private HashMap defaults = new HashMap();
-
- /**
- * get default type name for specified type
- * @param typecode the type key
- * @return the default type name associated with specified key
- */
- public String get(int typecode) throws MappingException {
- String result = (String) defaults.get( new Integer(typecode) );
- if (result==null) throw new MappingException("No Dialect mapping for JDBC type: " + typecode);
- return result;
- }
-
- /**
- * get type name for specified type and size
- * @param typecode the type key
- * @param size the SQL length
- * @param scale the SQL scale
- * @param precision the SQL precision
- * @return the associated name with smallest capacity >= size,
- * if available and the default type name otherwise
- */
- public String get(int typecode, int size, int precision, int scale) throws MappingException {
- Map map = (Map) weighted.get( new Integer(typecode) );
- if ( map!=null && map.size()>0 ) {
- // iterate entries ordered by capacity to find first fit
- Iterator entries = map.entrySet().iterator();
- while ( entries.hasNext() ) {
- Map.Entry entry = (Map.Entry)entries.next();
- if ( size <= ( (Integer) entry.getKey() ).intValue() ) {
- return replace( (String) entry.getValue(), size, precision, scale );
- }
- }
- }
- return replace( get(typecode), size, precision, scale );
- }
-
- private static String replace(String type, int size, int precision, int scale) {
- type = StringHelper.replaceOnce(type, "$s", Integer.toString(scale) );
- type = StringHelper.replaceOnce(type, "$l", Integer.toString(size) );
- return StringHelper.replaceOnce(type, "$p", Integer.toString(precision) );
- }
-
- /**
- * set a type name for specified type key and capacity
- * @param typecode the type key
- */
- public void put(int typecode, int capacity, String value) {
- TreeMap map = (TreeMap)weighted.get( new Integer(typecode) );
- if (map == null) {// add new ordered map
- map = new TreeMap();
- weighted.put( new Integer(typecode), map );
- }
- map.put(new Integer(capacity), value);
- }
-
- /**
- * set a default type name for specified type key
- * @param typecode the type key
- */
- public void put(int typecode, String value) {
- defaults.put( new Integer(typecode), value );
- }
-}
-
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/TypeNames.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/TypeNames.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,139 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.TreeMap;
+import java.util.Iterator;
+
+import org.hibernate.MappingException;
+import org.hibernate.util.StringHelper;
+
+/**
+ * This class maps a type to names. Associations
+ * may be marked with a capacity. Calling the get()
+ * method with a type and actual size n will return
+ * the associated name with smallest capacity >= n,
+ * if available and an unmarked default type otherwise.
+ * Eg, setting
+ * <pre>
+ * names.put(type, "TEXT" );
+ * names.put(type, 255, "VARCHAR($l)" );
+ * names.put(type, 65534, "LONGVARCHAR($l)" );
+ * </pre>
+ * will give you back the following:
+ * <pre>
+ * names.get(type) // --> "TEXT" (default)
+ * names.get(type, 100) // --> "VARCHAR(100)" (100 is in [0:255])
+ * names.get(type, 1000) // --> "LONGVARCHAR(1000)" (1000 is in [256:65534])
+ * names.get(type, 100000) // --> "TEXT" (default)
+ * </pre>
+ * On the other hand, simply putting
+ * <pre>
+ * names.put(type, "VARCHAR($l)" );
+ * </pre>
+ * would result in
+ * <pre>
+ * names.get(type) // --> "VARCHAR($l)" (will cause trouble)
+ * names.get(type, 100) // --> "VARCHAR(100)"
+ * names.get(type, 10000) // --> "VARCHAR(10000)"
+ * </pre>
+ *
+ * @author Christoph Beck
+ */
+public class TypeNames {
+
+ private HashMap weighted = new HashMap();
+ private HashMap defaults = new HashMap();
+
+ /**
+ * get default type name for specified type
+ * @param typecode the type key
+ * @return the default type name associated with specified key
+ */
+ public String get(int typecode) throws MappingException {
+ String result = (String) defaults.get( new Integer(typecode) );
+ if (result==null) throw new MappingException("No Dialect mapping for JDBC type: " + typecode);
+ return result;
+ }
+
+ /**
+ * get type name for specified type and size
+ * @param typecode the type key
+ * @param size the SQL length
+ * @param scale the SQL scale
+ * @param precision the SQL precision
+ * @return the associated name with smallest capacity >= size,
+ * if available and the default type name otherwise
+ */
+ public String get(int typecode, int size, int precision, int scale) throws MappingException {
+ Map map = (Map) weighted.get( new Integer(typecode) );
+ if ( map!=null && map.size()>0 ) {
+ // iterate entries ordered by capacity to find first fit
+ Iterator entries = map.entrySet().iterator();
+ while ( entries.hasNext() ) {
+ Map.Entry entry = (Map.Entry)entries.next();
+ if ( size <= ( (Integer) entry.getKey() ).intValue() ) {
+ return replace( (String) entry.getValue(), size, precision, scale );
+ }
+ }
+ }
+ return replace( get(typecode), size, precision, scale );
+ }
+
+ private static String replace(String type, int size, int precision, int scale) {
+ type = StringHelper.replaceOnce(type, "$s", Integer.toString(scale) );
+ type = StringHelper.replaceOnce(type, "$l", Integer.toString(size) );
+ return StringHelper.replaceOnce(type, "$p", Integer.toString(precision) );
+ }
+
+ /**
+ * set a type name for specified type key and capacity
+ * @param typecode the type key
+ */
+ public void put(int typecode, int capacity, String value) {
+ TreeMap map = (TreeMap)weighted.get( new Integer(typecode) );
+ if (map == null) {// add new ordered map
+ map = new TreeMap();
+ weighted.put( new Integer(typecode), map );
+ }
+ map.put(new Integer(capacity), value);
+ }
+
+ /**
+ * set a default type name for specified type key
+ * @param typecode the type key
+ */
+ public void put(int typecode, String value) {
+ defaults.put( new Integer(typecode), value );
+ }
+}
+
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,146 +0,0 @@
-package org.hibernate.dialect.function;
-
-import org.hibernate.Hibernate;
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * A {@link SQLFunction} implementation that emulates the ANSI SQL trim function
- * on dialects which do not support the full definition. However, this function
- * definition does assume the availability of ltrim, rtrim, and replace functions
- * which it uses in various combinations to emulate the desired ANSI trim()
- * functionality.
- *
- * @author Steve Ebersole
- */
-public class AnsiTrimEmulationFunction implements SQLFunction {
-
- private static final SQLFunction LEADING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( ?1 )");
- private static final SQLFunction TRAILING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "rtrim( ?1 )");
- private static final SQLFunction BOTH_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?1 ) )");
- private static final SQLFunction BOTH_SPACE_TRIM_FROM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?2 ) )");
-
- private static final SQLFunction LEADING_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "replace( replace( rtrim( replace( replace( ?1, ' ', '${space}$' ), ?2, ' ' ) ), ' ', ?2 ), '${space}$', ' ' )" );
- private static final SQLFunction TRAILING_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "replace( replace( ltrim( replace( replace( ?1, ' ', '${space}$' ), ?2, ' ' ) ), ' ', ?2 ), '${space}$', ' ' )" );
- private static final SQLFunction BOTH_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "replace( replace( ltrim( rtrim( replace( replace( ?1, ' ', '${space}$' ), ?2, ' ' ) ) ), ' ', ?2 ), '${space}$', ' ' )" );
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return Hibernate.STRING;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return false;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- // according to both the ANSI-SQL and EJB3 specs, trim can either take
- // exactly one parameter or a variable number of parameters between 1 and 4.
- // from the SQL spec:
- //
- // <trim function> ::=
- // TRIM <left paren> <trim operands> <right paren>
- //
- // <trim operands> ::=
- // [ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
- //
- // <trim specification> ::=
- // LEADING
- // | TRAILING
- // | BOTH
- //
- // If only <trim specification> is omitted, BOTH is assumed;
- // if <trim character> is omitted, space is assumed
- if ( args.size() == 1 ) {
- // we have the form: trim(trimSource)
- // so we trim leading and trailing spaces
- return BOTH_SPACE_TRIM.render( args, factory );
- }
- else if ( "from".equalsIgnoreCase( ( String ) args.get( 0 ) ) ) {
- // we have the form: trim(from trimSource).
- // This is functionally equivalent to trim(trimSource)
- return BOTH_SPACE_TRIM_FROM.render( args, factory );
- }
- else {
- // otherwise, a trim-specification and/or a trim-character
- // have been specified; we need to decide which options
- // are present and "do the right thing"
- boolean leading = true; // should leading trim-characters be trimmed?
- boolean trailing = true; // should trailing trim-characters be trimmed?
- String trimCharacter = null; // the trim-character
- String trimSource = null; // the trim-source
-
- // potentialTrimCharacterArgIndex = 1 assumes that a
- // trim-specification has been specified. we handle the
- // exception to that explicitly
- int potentialTrimCharacterArgIndex = 1;
- String firstArg = ( String ) args.get( 0 );
- if ( "leading".equalsIgnoreCase( firstArg ) ) {
- trailing = false;
- }
- else if ( "trailing".equalsIgnoreCase( firstArg ) ) {
- leading = false;
- }
- else if ( "both".equalsIgnoreCase( firstArg ) ) {
- }
- else {
- potentialTrimCharacterArgIndex = 0;
- }
-
- String potentialTrimCharacter = ( String ) args.get( potentialTrimCharacterArgIndex );
- if ( "from".equalsIgnoreCase( potentialTrimCharacter ) ) {
- trimCharacter = "' '";
- trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
- }
- else if ( potentialTrimCharacterArgIndex + 1 >= args.size() ) {
- trimCharacter = "' '";
- trimSource = potentialTrimCharacter;
- }
- else {
- trimCharacter = potentialTrimCharacter;
- if ( "from".equalsIgnoreCase( ( String ) args.get( potentialTrimCharacterArgIndex + 1 ) ) ) {
- trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 2 );
- }
- else {
- trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
- }
- }
-
- List argsToUse = null;
- argsToUse = new ArrayList();
- argsToUse.add( trimSource );
- argsToUse.add( trimCharacter );
-
- if ( trimCharacter.equals( "' '" ) ) {
- if ( leading && trailing ) {
- return BOTH_SPACE_TRIM.render( argsToUse, factory );
- }
- else if ( leading ) {
- return LEADING_SPACE_TRIM.render( argsToUse, factory );
- }
- else {
- return TRAILING_SPACE_TRIM.render( argsToUse, factory );
- }
- }
- else {
- if ( leading && trailing ) {
- return BOTH_TRIM.render( argsToUse, factory );
- }
- else if ( leading ) {
- return LEADING_TRIM.render( argsToUse, factory );
- }
- else {
- return TRAILING_TRIM.render( argsToUse, factory );
- }
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/AnsiTrimEmulationFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,170 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import org.hibernate.Hibernate;
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A {@link SQLFunction} implementation that emulates the ANSI SQL trim function
+ * on dialects which do not support the full definition. However, this function
+ * definition does assume the availability of ltrim, rtrim, and replace functions
+ * which it uses in various combinations to emulate the desired ANSI trim()
+ * functionality.
+ *
+ * @author Steve Ebersole
+ */
+public class AnsiTrimEmulationFunction implements SQLFunction {
+
+ private static final SQLFunction LEADING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( ?1 )");
+ private static final SQLFunction TRAILING_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "rtrim( ?1 )");
+ private static final SQLFunction BOTH_SPACE_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?1 ) )");
+ private static final SQLFunction BOTH_SPACE_TRIM_FROM = new SQLFunctionTemplate( Hibernate.STRING, "ltrim( rtrim( ?2 ) )");
+
+ private static final SQLFunction LEADING_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "replace( replace( rtrim( replace( replace( ?1, ' ', '${space}$' ), ?2, ' ' ) ), ' ', ?2 ), '${space}$', ' ' )" );
+ private static final SQLFunction TRAILING_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "replace( replace( ltrim( replace( replace( ?1, ' ', '${space}$' ), ?2, ' ' ) ), ' ', ?2 ), '${space}$', ' ' )" );
+ private static final SQLFunction BOTH_TRIM = new SQLFunctionTemplate( Hibernate.STRING, "replace( replace( ltrim( rtrim( replace( replace( ?1, ' ', '${space}$' ), ?2, ' ' ) ) ), ' ', ?2 ), '${space}$', ' ' )" );
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return Hibernate.STRING;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return false;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ // according to both the ANSI-SQL and EJB3 specs, trim can either take
+ // exactly one parameter or a variable number of parameters between 1 and 4.
+ // from the SQL spec:
+ //
+ // <trim function> ::=
+ // TRIM <left paren> <trim operands> <right paren>
+ //
+ // <trim operands> ::=
+ // [ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
+ //
+ // <trim specification> ::=
+ // LEADING
+ // | TRAILING
+ // | BOTH
+ //
+ // If only <trim specification> is omitted, BOTH is assumed;
+ // if <trim character> is omitted, space is assumed
+ if ( args.size() == 1 ) {
+ // we have the form: trim(trimSource)
+ // so we trim leading and trailing spaces
+ return BOTH_SPACE_TRIM.render( args, factory );
+ }
+ else if ( "from".equalsIgnoreCase( ( String ) args.get( 0 ) ) ) {
+ // we have the form: trim(from trimSource).
+ // This is functionally equivalent to trim(trimSource)
+ return BOTH_SPACE_TRIM_FROM.render( args, factory );
+ }
+ else {
+ // otherwise, a trim-specification and/or a trim-character
+ // have been specified; we need to decide which options
+ // are present and "do the right thing"
+ boolean leading = true; // should leading trim-characters be trimmed?
+ boolean trailing = true; // should trailing trim-characters be trimmed?
+ String trimCharacter = null; // the trim-character
+ String trimSource = null; // the trim-source
+
+ // potentialTrimCharacterArgIndex = 1 assumes that a
+ // trim-specification has been specified. we handle the
+ // exception to that explicitly
+ int potentialTrimCharacterArgIndex = 1;
+ String firstArg = ( String ) args.get( 0 );
+ if ( "leading".equalsIgnoreCase( firstArg ) ) {
+ trailing = false;
+ }
+ else if ( "trailing".equalsIgnoreCase( firstArg ) ) {
+ leading = false;
+ }
+ else if ( "both".equalsIgnoreCase( firstArg ) ) {
+ }
+ else {
+ potentialTrimCharacterArgIndex = 0;
+ }
+
+ String potentialTrimCharacter = ( String ) args.get( potentialTrimCharacterArgIndex );
+ if ( "from".equalsIgnoreCase( potentialTrimCharacter ) ) {
+ trimCharacter = "' '";
+ trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
+ }
+ else if ( potentialTrimCharacterArgIndex + 1 >= args.size() ) {
+ trimCharacter = "' '";
+ trimSource = potentialTrimCharacter;
+ }
+ else {
+ trimCharacter = potentialTrimCharacter;
+ if ( "from".equalsIgnoreCase( ( String ) args.get( potentialTrimCharacterArgIndex + 1 ) ) ) {
+ trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 2 );
+ }
+ else {
+ trimSource = ( String ) args.get( potentialTrimCharacterArgIndex + 1 );
+ }
+ }
+
+ List argsToUse = null;
+ argsToUse = new ArrayList();
+ argsToUse.add( trimSource );
+ argsToUse.add( trimCharacter );
+
+ if ( trimCharacter.equals( "' '" ) ) {
+ if ( leading && trailing ) {
+ return BOTH_SPACE_TRIM.render( argsToUse, factory );
+ }
+ else if ( leading ) {
+ return LEADING_SPACE_TRIM.render( argsToUse, factory );
+ }
+ else {
+ return TRAILING_SPACE_TRIM.render( argsToUse, factory );
+ }
+ }
+ else {
+ if ( leading && trailing ) {
+ return BOTH_TRIM.render( argsToUse, factory );
+ }
+ else if ( leading ) {
+ return LEADING_TRIM.render( argsToUse, factory );
+ }
+ else {
+ return TRAILING_TRIM.render( argsToUse, factory );
+ }
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/CastFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,55 +0,0 @@
-//$Id: CastFunction.java 7368 2005-07-04 02:54:27Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-import org.hibernate.type.TypeFactory;
-
-/**
- * ANSI-SQL style <tt>cast(foo as type)</tt> where the type is
- * a Hibernate type
- * @author Gavin King
- */
-public class CastFunction implements SQLFunction {
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return columnType; //note there is a wierd implementation in the client side
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- if ( args.size()!=2 ) {
- throw new QueryException("cast() requires two arguments");
- }
- String type = (String) args.get(1);
- int[] sqlTypeCodes = TypeFactory.heuristicType(type).sqlTypes(factory);
- if ( sqlTypeCodes.length!=1 ) {
- throw new QueryException("invalid Hibernate type for cast()");
- }
- String sqlType = factory.getDialect().getCastTypeName( sqlTypeCodes[0] );
- if (sqlType==null) {
- //TODO: never reached, since getTypeName() actually throws an exception!
- sqlType = type;
- }
- /*else {
- //trim off the length/precision/scale
- int loc = sqlType.indexOf('(');
- if (loc>-1) {
- sqlType = sqlType.substring(0, loc);
- }
- }*/
- return "cast(" + args.get(0) + " as " + sqlType + ')';
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/CastFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CastFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+import org.hibernate.type.TypeFactory;
+
+/**
+ * ANSI-SQL style <tt>cast(foo as type)</tt> where the type is
+ * a Hibernate type
+ * @author Gavin King
+ */
+public class CastFunction implements SQLFunction {
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return columnType; //note there is a wierd implementation in the client side
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ if ( args.size()!=2 ) {
+ throw new QueryException("cast() requires two arguments");
+ }
+ String type = (String) args.get(1);
+ int[] sqlTypeCodes = TypeFactory.heuristicType(type).sqlTypes(factory);
+ if ( sqlTypeCodes.length!=1 ) {
+ throw new QueryException("invalid Hibernate type for cast()");
+ }
+ String sqlType = factory.getDialect().getCastTypeName( sqlTypeCodes[0] );
+ if (sqlType==null) {
+ //TODO: never reached, since getTypeName() actually throws an exception!
+ sqlType = type;
+ }
+ /*else {
+ //trim off the length/precision/scale
+ int loc = sqlType.indexOf('(');
+ if (loc>-1) {
+ sqlType = sqlType.substring(0, loc);
+ }
+ }*/
+ return "cast(" + args.get(0) + " as " + sqlType + ')';
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: CharIndexFunction.java 8470 2005-10-26 22:12:27Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.Hibernate;
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Emulation of <tt>locate()</tt> on Sybase
- * @author Nathan Moon
- */
-public class CharIndexFunction implements SQLFunction {
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return Hibernate.INTEGER;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- boolean threeArgs = args.size() > 2;
- Object pattern = args.get(0);
- Object string = args.get(1);
- Object start = threeArgs ? args.get(2) : null;
-
- StringBuffer buf = new StringBuffer();
- buf.append("charindex(").append( pattern ).append(", ");
- if (threeArgs) buf.append( "right(");
- buf.append( string );
- if (threeArgs) buf.append( ", char_length(" ).append( string ).append(")-(").append( start ).append("-1))");
- buf.append(')');
- return buf.toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/CharIndexFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.Hibernate;
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Emulation of <tt>locate()</tt> on Sybase
+ * @author Nathan Moon
+ */
+public class CharIndexFunction implements SQLFunction {
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return Hibernate.INTEGER;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ boolean threeArgs = args.size() > 2;
+ Object pattern = args.get(0);
+ Object string = args.get(1);
+ Object start = threeArgs ? args.get(2) : null;
+
+ StringBuffer buf = new StringBuffer();
+ buf.append("charindex(").append( pattern ).append(", ");
+ if (threeArgs) buf.append( "right(");
+ buf.append( string );
+ if (threeArgs) buf.append( ", char_length(" ).append( string ).append(")-(").append( start ).append("-1))");
+ buf.append(')');
+ return buf.toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,42 +0,0 @@
-/**
- *
- */
-package org.hibernate.dialect.function;
-
-import java.sql.Types;
-
-import org.hibernate.Hibernate;
-import org.hibernate.MappingException;
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.type.Type;
-
-/**
- * Classic AVG sqlfunction that return types as it was done in Hibernate 3.1
- *
- * @author Max Rydahl Andersen
- *
- */
-public class ClassicAvgFunction extends StandardSQLFunction {
- public ClassicAvgFunction() {
- super( "avg" );
- }
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- int[] sqlTypes;
- try {
- sqlTypes = columnType.sqlTypes( mapping );
- }
- catch ( MappingException me ) {
- throw new QueryException( me );
- }
- if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in avg()" );
- int sqlType = sqlTypes[0];
- if ( sqlType == Types.INTEGER || sqlType == Types.BIGINT || sqlType == Types.TINYINT ) {
- return Hibernate.FLOAT;
- }
- else {
- return columnType;
- }
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicAvgFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,63 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.MappingException;
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.type.Type;
+
+/**
+ * Classic AVG sqlfunction that return types as it was done in Hibernate 3.1
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class ClassicAvgFunction extends StandardSQLFunction {
+ public ClassicAvgFunction() {
+ super( "avg" );
+ }
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ int[] sqlTypes;
+ try {
+ sqlTypes = columnType.sqlTypes( mapping );
+ }
+ catch ( MappingException me ) {
+ throw new QueryException( me );
+ }
+ if ( sqlTypes.length != 1 ) throw new QueryException( "multi-column type in avg()" );
+ int sqlType = sqlTypes[0];
+ if ( sqlType == Types.INTEGER || sqlType == Types.BIGINT || sqlType == Types.TINYINT ) {
+ return Hibernate.FLOAT;
+ }
+ else {
+ return columnType;
+ }
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,25 +0,0 @@
-/**
- *
- */
-package org.hibernate.dialect.function;
-
-import org.hibernate.Hibernate;
-import org.hibernate.engine.Mapping;
-import org.hibernate.type.Type;
-
-
-/**
- * Classic COUNT sqlfunction that return types as it was done in Hibernate 3.1
- *
- * @author Max Rydahl Andersen
- *
- */
-public class ClassicCountFunction extends StandardSQLFunction {
- public ClassicCountFunction() {
- super( "count" );
- }
-
- public Type getReturnType(Type columnType, Mapping mapping) {
- return Hibernate.INTEGER;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicCountFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import org.hibernate.Hibernate;
+import org.hibernate.engine.Mapping;
+import org.hibernate.type.Type;
+
+
+/**
+ * Classic COUNT sqlfunction that return types as it was done in Hibernate 3.1
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class ClassicCountFunction extends StandardSQLFunction {
+ public ClassicCountFunction() {
+ super( "count" );
+ }
+
+ public Type getReturnType(Type columnType, Mapping mapping) {
+ return Hibernate.INTEGER;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,17 +0,0 @@
-/**
- *
- */
-package org.hibernate.dialect.function;
-
-
-/**
- * Classic SUM sqlfunction that return types as it was done in Hibernate 3.1
- *
- * @author Max Rydahl Andersen
- *
- */
-public class ClassicSumFunction extends StandardSQLFunction {
- public ClassicSumFunction() {
- super( "sum" );
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ClassicSumFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+
+/**
+ * Classic SUM sqlfunction that return types as it was done in Hibernate 3.1
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class ClassicSumFunction extends StandardSQLFunction {
+ public ClassicSumFunction() {
+ super( "sum" );
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: ConditionalParenthesisFunction.java,v 1.4 2005/04/26 18:08:01 oneovthafew Exp $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Essentially the same as {@link org.hibernate.dialect.function.StandardSQLFunction},
- * except that here the parentheses are not included when no arguments are given.
- *
- * @author Jonathan Levinson
- */
-public class ConditionalParenthesisFunction extends StandardSQLFunction {
-
- public ConditionalParenthesisFunction(String name) {
- super( name );
- }
-
- public ConditionalParenthesisFunction(String name, Type type) {
- super( name, type );
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return false;
- }
-
- public String render(List args, SessionFactoryImplementor factory) {
- final boolean hasArgs = !args.isEmpty();
- StringBuffer buf = new StringBuffer();
- buf.append( getName() );
- if ( hasArgs ) {
- buf.append( "(" );
- for ( int i = 0; i < args.size(); i++ ) {
- buf.append( args.get( i ) );
- if ( i < args.size() - 1 ) {
- buf.append( ", " );
- }
- }
- buf.append( ")" );
- }
- return buf.toString();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConditionalParenthesisFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Essentially the same as {@link org.hibernate.dialect.function.StandardSQLFunction},
+ * except that here the parentheses are not included when no arguments are given.
+ *
+ * @author Jonathan Levinson
+ */
+public class ConditionalParenthesisFunction extends StandardSQLFunction {
+
+ public ConditionalParenthesisFunction(String name) {
+ super( name );
+ }
+
+ public ConditionalParenthesisFunction(String name, Type type) {
+ super( name, type );
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return false;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) {
+ final boolean hasArgs = !args.isEmpty();
+ StringBuffer buf = new StringBuffer();
+ buf.append( getName() );
+ if ( hasArgs ) {
+ buf.append( "(" );
+ for ( int i = 0; i < args.size(); i++ ) {
+ buf.append( args.get( i ) );
+ if ( i < args.size() - 1 ) {
+ buf.append( ", " );
+ }
+ }
+ buf.append( ")" );
+ }
+ return buf.toString();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,45 +0,0 @@
-//$Id: CastFunction.java 7368 2005-07-04 02:54:27Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.QueryException;
-import org.hibernate.Hibernate;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * A Caché defintion of a convert function.
- *
- * @author Jonathan Levinson
- */
-public class ConvertFunction implements SQLFunction {
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return Hibernate.STRING;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- if ( args.size() != 2 && args.size() != 3 ) {
- throw new QueryException( "convert() requires two or three arguments" );
- }
- String type = ( String ) args.get( 1 );
-
- if ( args.size() == 2 ) {
- return "{fn convert(" + args.get( 0 ) + " , " + type + ")}";
- }
- else {
- return "convert(" + args.get( 0 ) + " , " + type + "," + args.get( 2 ) + ")";
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/ConvertFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.QueryException;
+import org.hibernate.Hibernate;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * A Caché defintion of a convert function.
+ *
+ * @author Jonathan Levinson
+ */
+public class ConvertFunction implements SQLFunction {
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return Hibernate.STRING;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ if ( args.size() != 2 && args.size() != 3 ) {
+ throw new QueryException( "convert() requires two or three arguments" );
+ }
+ String type = ( String ) args.get( 1 );
+
+ if ( args.size() == 2 ) {
+ return "{fn convert(" + args.get( 0 ) + " , " + type + ")}";
+ }
+ else {
+ return "convert(" + args.get( 0 ) + " , " + type + "," + args.get( 2 ) + ")";
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,49 +0,0 @@
-//$Id: NoArgSQLFunction.java 6608 2005-04-29 15:32:30Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-
-/**
- * A function which takes no arguments
- * @author Michi
- */
-public class NoArgSQLFunction implements SQLFunction {
- private Type returnType;
- private boolean hasParenthesesIfNoArguments;
- private String name;
-
- public NoArgSQLFunction(String name, Type returnType) {
- this(name, returnType, true);
- }
-
- public NoArgSQLFunction(String name, Type returnType, boolean hasParenthesesIfNoArguments) {
- this.returnType = returnType;
- this.hasParenthesesIfNoArguments = hasParenthesesIfNoArguments;
- this.name = name;
- }
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return returnType;
- }
-
- public boolean hasArguments() {
- return false;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return hasParenthesesIfNoArguments;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- if ( args.size()>0 ) {
- throw new QueryException("function takes no arguments: " + name);
- }
- return hasParenthesesIfNoArguments ? name + "()" : name;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NoArgSQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,72 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+
+/**
+ * A function which takes no arguments
+ * @author Michi
+ */
+public class NoArgSQLFunction implements SQLFunction {
+ private Type returnType;
+ private boolean hasParenthesesIfNoArguments;
+ private String name;
+
+ public NoArgSQLFunction(String name, Type returnType) {
+ this(name, returnType, true);
+ }
+
+ public NoArgSQLFunction(String name, Type returnType, boolean hasParenthesesIfNoArguments) {
+ this.returnType = returnType;
+ this.hasParenthesesIfNoArguments = hasParenthesesIfNoArguments;
+ this.name = name;
+ }
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return returnType;
+ }
+
+ public boolean hasArguments() {
+ return false;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return hasParenthesesIfNoArguments;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ if ( args.size()>0 ) {
+ throw new QueryException("function takes no arguments: " + name);
+ }
+ return hasParenthesesIfNoArguments ? name + "()" : name;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,42 +0,0 @@
-//$Id: NvlFunction.java 6608 2005-04-29 15:32:30Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Emulation of <tt>coalesce()</tt> on Oracle, using multiple
- * <tt>nvl()</tt> calls
- * @author Gavin King
- */
-public class NvlFunction implements SQLFunction {
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return columnType;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- int lastIndex = args.size()-1;
- Object last = args.remove(lastIndex);
- if ( lastIndex==0 ) return last.toString();
- Object secondLast = args.get(lastIndex-1);
- String nvl = "nvl(" + secondLast + ", " + last + ")";
- args.set(lastIndex-1, nvl);
- return render(args, factory);
- }
-
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/NvlFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,65 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Emulation of <tt>coalesce()</tt> on Oracle, using multiple
+ * <tt>nvl()</tt> calls
+ * @author Gavin King
+ */
+public class NvlFunction implements SQLFunction {
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return columnType;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ int lastIndex = args.size()-1;
+ Object last = args.remove(lastIndex);
+ if ( lastIndex==0 ) return last.toString();
+ Object secondLast = args.get(lastIndex-1);
+ String nvl = "nvl(" + secondLast + ", " + last + ")";
+ args.set(lastIndex-1, nvl);
+ return render(args, factory);
+ }
+
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,48 +0,0 @@
-//$Id: PositionSubstringFunction.java 6608 2005-04-29 15:32:30Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.Hibernate;
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Emulation of <tt>locate()</tt> on PostgreSQL
- * @author Gavin King
- */
-public class PositionSubstringFunction implements SQLFunction {
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return Hibernate.INTEGER;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- boolean threeArgs = args.size() > 2;
- Object pattern = args.get(0);
- Object string = args.get(1);
- Object start = threeArgs ? args.get(2) : null;
-
- StringBuffer buf = new StringBuffer();
- if (threeArgs) buf.append('(');
- buf.append("position(").append( pattern ).append(" in ");
- if (threeArgs) buf.append( "substring(");
- buf.append( string );
- if (threeArgs) buf.append( ", " ).append( start ).append(')');
- buf.append(')');
- if (threeArgs) buf.append('+').append( start ).append("-1)");
- return buf.toString();
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/PositionSubstringFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,71 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.Hibernate;
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Emulation of <tt>locate()</tt> on PostgreSQL
+ * @author Gavin King
+ */
+public class PositionSubstringFunction implements SQLFunction {
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return Hibernate.INTEGER;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ boolean threeArgs = args.size() > 2;
+ Object pattern = args.get(0);
+ Object string = args.get(1);
+ Object start = threeArgs ? args.get(2) : null;
+
+ StringBuffer buf = new StringBuffer();
+ if (threeArgs) buf.append('(');
+ buf.append("position(").append( pattern ).append(" in ");
+ if (threeArgs) buf.append( "substring(");
+ buf.append( string );
+ if (threeArgs) buf.append( ", " ).append( start ).append(')');
+ buf.append(')');
+ if (threeArgs) buf.append('+').append( start ).append("-1)");
+ return buf.toString();
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,58 +0,0 @@
-//$Id: SQLFunction.java 10774 2006-11-08 16:54:55Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Provides support routines for the HQL functions as used
- * in the various SQL Dialects
- *
- * Provides an interface for supporting various HQL functions that are
- * translated to SQL. The Dialect and its sub-classes use this interface to
- * provide details required for processing of the function.
- *
- * @author David Channon
- */
-public interface SQLFunction {
- /**
- * The return type of the function. May be either a concrete type which
- * is preset, or variable depending upon the type of the first function
- * argument.
- *
- * @param columnType the type of the first argument
- * @param mapping The mapping source.
- * @return The type to be expected as a return.
- * @throws org.hibernate.QueryException Indicates an issue resolving the return type.
- */
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException;
-
- /**
- * Does this function have any arguments?
- *
- * @return True if the function expects to have parameters; false otherwise.
- */
- public boolean hasArguments();
-
- /**
- * If there are no arguments, are parens required?
- *
- * @return True if a no-arg call of this function requires parentheses.
- */
- public boolean hasParenthesesIfNoArguments();
-
- /**
- * Render the function call as SQL fragment.
- *
- * @param args The function arguments
- * @param factory The SessionFactory
- * @return The rendered function call
- * @throws org.hibernate.QueryException Indicates a problem rendering the
- * function call.
- */
- public String render(List args, SessionFactoryImplementor factory) throws QueryException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Provides support routines for the HQL functions as used
+ * in the various SQL Dialects
+ *
+ * Provides an interface for supporting various HQL functions that are
+ * translated to SQL. The Dialect and its sub-classes use this interface to
+ * provide details required for processing of the function.
+ *
+ * @author David Channon
+ */
+public interface SQLFunction {
+ /**
+ * The return type of the function. May be either a concrete type which
+ * is preset, or variable depending upon the type of the first function
+ * argument.
+ *
+ * @param columnType the type of the first argument
+ * @param mapping The mapping source.
+ * @return The type to be expected as a return.
+ * @throws org.hibernate.QueryException Indicates an issue resolving the return type.
+ */
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException;
+
+ /**
+ * Does this function have any arguments?
+ *
+ * @return True if the function expects to have parameters; false otherwise.
+ */
+ public boolean hasArguments();
+
+ /**
+ * If there are no arguments, are parens required?
+ *
+ * @return True if a no-arg call of this function requires parentheses.
+ */
+ public boolean hasParenthesesIfNoArguments();
+
+ /**
+ * Render the function call as SQL fragment.
+ *
+ * @param args The function arguments
+ * @param factory The SessionFactory
+ * @return The rendered function call
+ * @throws org.hibernate.QueryException Indicates a problem rendering the
+ * function call.
+ */
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,33 +0,0 @@
-package org.hibernate.dialect.function;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.dialect.Dialect;
-
-public class SQLFunctionRegistry {
-
- private final Dialect dialect;
- private final Map userFunctions;
-
- public SQLFunctionRegistry(Dialect dialect, Map userFunctions) {
- this.dialect = dialect;
- this.userFunctions = new HashMap();
- this.userFunctions.putAll( userFunctions );
- }
-
- public SQLFunction findSQLFunction(String functionName) {
- String name = functionName.toLowerCase();
- SQLFunction userFunction = (SQLFunction) userFunctions.get( name );
-
- return userFunction!=null?userFunction:(SQLFunction) dialect.getFunctions().get(name); // TODO: lowercasing done here. Was done "at random" before; maybe not needed at all ?
- }
-
- public boolean hasFunction(String functionName) {
- String name = functionName.toLowerCase();
- boolean hasUserFunction = userFunctions.containsKey ( name );
-
- return hasUserFunction || dialect.getFunctions().containsKey ( name ); // TODO: toLowerCase was not done before. Only used in Template.
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,57 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.dialect.Dialect;
+
+public class SQLFunctionRegistry {
+
+ private final Dialect dialect;
+ private final Map userFunctions;
+
+ public SQLFunctionRegistry(Dialect dialect, Map userFunctions) {
+ this.dialect = dialect;
+ this.userFunctions = new HashMap();
+ this.userFunctions.putAll( userFunctions );
+ }
+
+ public SQLFunction findSQLFunction(String functionName) {
+ String name = functionName.toLowerCase();
+ SQLFunction userFunction = (SQLFunction) userFunctions.get( name );
+
+ return userFunction!=null?userFunction:(SQLFunction) dialect.getFunctions().get(name); // TODO: lowercasing done here. Was done "at random" before; maybe not needed at all ?
+ }
+
+ public boolean hasFunction(String functionName) {
+ String name = functionName.toLowerCase();
+ boolean hasUserFunction = userFunctions.containsKey ( name );
+
+ return hasUserFunction || dialect.getFunctions().containsKey ( name ); // TODO: toLowerCase was not done before. Only used in Template.
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,123 +0,0 @@
-//$Id: SQLFunctionTemplate.java 6608 2005-04-29 15:32:30Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents HQL functions that can have different representations in different SQL dialects.
- * E.g. in HQL we can define function <code>concat(?1, ?2)</code> to concatenate two strings
- * p1 and p2. Target SQL function will be dialect-specific, e.g. <code>(?1 || ?2)</code> for
- * Oracle, <code>concat(?1, ?2)</code> for MySql, <code>(?1 + ?2)</code> for MS SQL.
- * Each dialect will define a template as a string (exactly like above) marking function
- * parameters with '?' followed by parameter's index (first index is 1).
- *
- * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
- * @version <tt>$Revision: 6608 $</tt>
- */
-public class SQLFunctionTemplate implements SQLFunction {
- private final Type type;
- private final boolean hasArguments;
- private final boolean hasParenthesesIfNoArgs;
-
- private final String template;
- private final String[] chunks;
- private final int[] paramIndexes;
-
- public SQLFunctionTemplate(Type type, String template) {
- this( type, template, true );
- }
-
- public SQLFunctionTemplate(Type type, String template, boolean hasParenthesesIfNoArgs) {
- this.type = type;
- this.template = template;
-
- List chunkList = new ArrayList();
- List paramList = new ArrayList();
- StringBuffer chunk = new StringBuffer( 10 );
- StringBuffer index = new StringBuffer( 2 );
-
- for ( int i = 0; i < template.length(); ++i ) {
- char c = template.charAt( i );
- if ( c == '?' ) {
- chunkList.add( chunk.toString() );
- chunk.delete( 0, chunk.length() );
-
- while ( ++i < template.length() ) {
- c = template.charAt( i );
- if ( Character.isDigit( c ) ) {
- index.append( c );
- }
- else {
- chunk.append( c );
- break;
- }
- }
-
- paramList.add( new Integer( Integer.parseInt( index.toString() ) - 1 ) );
- index.delete( 0, index.length() );
- }
- else {
- chunk.append( c );
- }
- }
-
- if ( chunk.length() > 0 ) {
- chunkList.add( chunk.toString() );
- }
-
- chunks = ( String[] ) chunkList.toArray( new String[chunkList.size()] );
- paramIndexes = new int[paramList.size()];
- for ( int i = 0; i < paramIndexes.length; ++i ) {
- paramIndexes[i] = ( ( Integer ) paramList.get( i ) ).intValue();
- }
-
- hasArguments = paramIndexes.length > 0;
- this.hasParenthesesIfNoArgs = hasParenthesesIfNoArgs;
- }
-
- /**
- * Applies the template to passed in arguments.
- * @param args function arguments
- *
- * @return generated SQL function call
- */
- public String render(List args, SessionFactoryImplementor factory) {
- StringBuffer buf = new StringBuffer();
- for ( int i = 0; i < chunks.length; ++i ) {
- if ( i < paramIndexes.length ) {
- Object arg = paramIndexes[i] < args.size() ? args.get( paramIndexes[i] ) : null;
- if ( arg != null ) {
- buf.append( chunks[i] ).append( arg );
- }
- }
- else {
- buf.append( chunks[i] );
- }
- }
- return buf.toString();
- }
-
- // SQLFunction implementation
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return type;
- }
-
- public boolean hasArguments() {
- return hasArguments;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return hasParenthesesIfNoArgs;
- }
-
- public String toString() {
- return template;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/SQLFunctionTemplate.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,146 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents HQL functions that can have different representations in different SQL dialects.
+ * E.g. in HQL we can define function <code>concat(?1, ?2)</code> to concatenate two strings
+ * p1 and p2. Target SQL function will be dialect-specific, e.g. <code>(?1 || ?2)</code> for
+ * Oracle, <code>concat(?1, ?2)</code> for MySql, <code>(?1 + ?2)</code> for MS SQL.
+ * Each dialect will define a template as a string (exactly like above) marking function
+ * parameters with '?' followed by parameter's index (first index is 1).
+ *
+ * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: 6608 $</tt>
+ */
+public class SQLFunctionTemplate implements SQLFunction {
+ private final Type type;
+ private final boolean hasArguments;
+ private final boolean hasParenthesesIfNoArgs;
+
+ private final String template;
+ private final String[] chunks;
+ private final int[] paramIndexes;
+
+ public SQLFunctionTemplate(Type type, String template) {
+ this( type, template, true );
+ }
+
+ public SQLFunctionTemplate(Type type, String template, boolean hasParenthesesIfNoArgs) {
+ this.type = type;
+ this.template = template;
+
+ List chunkList = new ArrayList();
+ List paramList = new ArrayList();
+ StringBuffer chunk = new StringBuffer( 10 );
+ StringBuffer index = new StringBuffer( 2 );
+
+ for ( int i = 0; i < template.length(); ++i ) {
+ char c = template.charAt( i );
+ if ( c == '?' ) {
+ chunkList.add( chunk.toString() );
+ chunk.delete( 0, chunk.length() );
+
+ while ( ++i < template.length() ) {
+ c = template.charAt( i );
+ if ( Character.isDigit( c ) ) {
+ index.append( c );
+ }
+ else {
+ chunk.append( c );
+ break;
+ }
+ }
+
+ paramList.add( new Integer( Integer.parseInt( index.toString() ) - 1 ) );
+ index.delete( 0, index.length() );
+ }
+ else {
+ chunk.append( c );
+ }
+ }
+
+ if ( chunk.length() > 0 ) {
+ chunkList.add( chunk.toString() );
+ }
+
+ chunks = ( String[] ) chunkList.toArray( new String[chunkList.size()] );
+ paramIndexes = new int[paramList.size()];
+ for ( int i = 0; i < paramIndexes.length; ++i ) {
+ paramIndexes[i] = ( ( Integer ) paramList.get( i ) ).intValue();
+ }
+
+ hasArguments = paramIndexes.length > 0;
+ this.hasParenthesesIfNoArgs = hasParenthesesIfNoArgs;
+ }
+
+ /**
+ * Applies the template to passed in arguments.
+ * @param args function arguments
+ *
+ * @return generated SQL function call
+ */
+ public String render(List args, SessionFactoryImplementor factory) {
+ StringBuffer buf = new StringBuffer();
+ for ( int i = 0; i < chunks.length; ++i ) {
+ if ( i < paramIndexes.length ) {
+ Object arg = paramIndexes[i] < args.size() ? args.get( paramIndexes[i] ) : null;
+ if ( arg != null ) {
+ buf.append( chunks[i] ).append( arg );
+ }
+ }
+ else {
+ buf.append( chunks[i] );
+ }
+ }
+ return buf.toString();
+ }
+
+ // SQLFunction implementation
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return type;
+ }
+
+ public boolean hasArguments() {
+ return hasArguments;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return hasParenthesesIfNoArgs;
+ }
+
+ public String toString() {
+ return template;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.type.Type;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * Analogous to {@link org.hibernate.dialect.function.StandardSQLFunction}
- * except that standard JDBC escape sequences (i.e. {fn blah}) are used when
- * rendering the SQL.
- *
- * @author Steve Ebersole
- */
-public class StandardJDBCEscapeFunction extends StandardSQLFunction {
- public StandardJDBCEscapeFunction(String name) {
- super( name );
- }
-
- public StandardJDBCEscapeFunction(String name, Type typeValue) {
- super( name, typeValue );
- }
-
- public String render(List args, SessionFactoryImplementor factory) {
- return "{fn " + super.render( args, factory ) + "}";
- }
-
- public String toString() {
- return "{fn " + getName() + "...}";
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardJDBCEscapeFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.type.Type;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * Analogous to {@link org.hibernate.dialect.function.StandardSQLFunction}
+ * except that standard JDBC escape sequences (i.e. {fn blah}) are used when
+ * rendering the SQL.
+ *
+ * @author Steve Ebersole
+ */
+public class StandardJDBCEscapeFunction extends StandardSQLFunction {
+ public StandardJDBCEscapeFunction(String name) {
+ super( name );
+ }
+
+ public StandardJDBCEscapeFunction(String name, Type typeValue) {
+ super( name, typeValue );
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) {
+ return "{fn " + super.render( args, factory ) + "}";
+ }
+
+ public String toString() {
+ return "{fn " + getName() + "...}";
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,107 +0,0 @@
-//$Id: StandardSQLFunction.java 10774 2006-11-08 16:54:55Z steve.ebersole(a)jboss.com $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Provides a standard implementation that supports the majority of the HQL
- * functions that are translated to SQL. The Dialect and its sub-classes use
- * this class to provide details required for processing of the associated
- * function.
- *
- * @author David Channon
- */
-public class StandardSQLFunction implements SQLFunction {
- private final String name;
- private final Type type;
-
- /**
- * Construct a standard SQL function definition with a variable return type;
- * the actual return type will depend on the types to which the function
- * is applied.
- * <p/>
- * Using this form, the return type is considered non-static and assumed
- * to be the type of the first argument.
- *
- * @param name The name of the function.
- */
- public StandardSQLFunction(String name) {
- this( name, null );
- }
-
- /**
- * Construct a standard SQL function definition with a static return type.
- *
- * @param name The name of the function.
- * @param type The static return type.
- */
- public StandardSQLFunction(String name, Type type) {
- this.name = name;
- this.type = type;
- }
-
- /**
- * Function name accessor
- *
- * @return The function name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * Function static return type accessor.
- *
- * @return The static function return type; or null if return type is
- * not static.
- */
- public Type getType() {
- return type;
- }
-
- /**
- * {@inheritDoc}
- */
- public Type getReturnType(Type columnType, Mapping mapping) {
- // return the concrete type, or the underlying type if a concrete type
- // was not specified
- return type == null ? columnType : type;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasArguments() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public String render(List args, SessionFactoryImplementor factory) {
- StringBuffer buf = new StringBuffer();
- buf.append( name ).append( '(' );
- for ( int i = 0; i < args.size(); i++ ) {
- buf.append( args.get( i ) );
- if ( i < args.size() - 1 ) {
- buf.append( ", " );
- }
- }
- return buf.append( ')' ).toString();
- }
-
- public String toString() {
- return name;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/StandardSQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,130 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Provides a standard implementation that supports the majority of the HQL
+ * functions that are translated to SQL. The Dialect and its sub-classes use
+ * this class to provide details required for processing of the associated
+ * function.
+ *
+ * @author David Channon
+ */
+public class StandardSQLFunction implements SQLFunction {
+ private final String name;
+ private final Type type;
+
+ /**
+ * Construct a standard SQL function definition with a variable return type;
+ * the actual return type will depend on the types to which the function
+ * is applied.
+ * <p/>
+ * Using this form, the return type is considered non-static and assumed
+ * to be the type of the first argument.
+ *
+ * @param name The name of the function.
+ */
+ public StandardSQLFunction(String name) {
+ this( name, null );
+ }
+
+ /**
+ * Construct a standard SQL function definition with a static return type.
+ *
+ * @param name The name of the function.
+ * @param type The static return type.
+ */
+ public StandardSQLFunction(String name, Type type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ /**
+ * Function name accessor
+ *
+ * @return The function name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Function static return type accessor.
+ *
+ * @return The static function return type; or null if return type is
+ * not static.
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Type getReturnType(Type columnType, Mapping mapping) {
+ // return the concrete type, or the underlying type if a concrete type
+ // was not specified
+ return type == null ? columnType : type;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasArguments() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String render(List args, SessionFactoryImplementor factory) {
+ StringBuffer buf = new StringBuffer();
+ buf.append( name ).append( '(' );
+ for ( int i = 0; i < args.size(); i++ ) {
+ buf.append( args.get( i ) );
+ if ( i < args.size() - 1 ) {
+ buf.append( ", " );
+ }
+ }
+ return buf.append( ')' ).toString();
+ }
+
+ public String toString() {
+ return name;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,58 +0,0 @@
-//$Id: VarArgsSQLFunction.java 6608 2005-04-29 15:32:30Z oneovthafew $
-package org.hibernate.dialect.function;
-
-import java.util.List;
-
-import org.hibernate.QueryException;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Support for slightly more general templating than <tt>StandardSQLFunction</tt>,
- * with an unlimited number of arguments.
- * @author Gavin King
- */
-public class VarArgsSQLFunction implements SQLFunction {
-
- private final String begin;
- private final String sep;
- private final String end;
- private final Type type;
-
- public VarArgsSQLFunction(Type type, String begin, String sep, String end) {
- this.begin = begin;
- this.sep = sep;
- this.end = end;
- this.type = type;
- }
-
- public VarArgsSQLFunction(String begin, String sep, String end) {
- this.begin = begin;
- this.sep = sep;
- this.end = end;
- this.type = null;
- }
-
- public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
- return type==null ? columnType : type;
- }
-
- public boolean hasArguments() {
- return true;
- }
-
- public boolean hasParenthesesIfNoArguments() {
- return true;
- }
-
- public String render(List args, SessionFactoryImplementor factory) throws QueryException {
- StringBuffer buf = new StringBuffer().append(begin);
- for ( int i=0; i<args.size(); i++ ) {
- buf.append( args.get(i) );
- if (i<args.size()-1) buf.append(sep);
- }
- return buf.append(end).toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/VarArgsSQLFunction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,81 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.function;
+
+import java.util.List;
+
+import org.hibernate.QueryException;
+import org.hibernate.engine.Mapping;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Support for slightly more general templating than <tt>StandardSQLFunction</tt>,
+ * with an unlimited number of arguments.
+ * @author Gavin King
+ */
+public class VarArgsSQLFunction implements SQLFunction {
+
+ private final String begin;
+ private final String sep;
+ private final String end;
+ private final Type type;
+
+ public VarArgsSQLFunction(Type type, String begin, String sep, String end) {
+ this.begin = begin;
+ this.sep = sep;
+ this.end = end;
+ this.type = type;
+ }
+
+ public VarArgsSQLFunction(String begin, String sep, String end) {
+ this.begin = begin;
+ this.sep = sep;
+ this.end = end;
+ this.type = null;
+ }
+
+ public Type getReturnType(Type columnType, Mapping mapping) throws QueryException {
+ return type==null ? columnType : type;
+ }
+
+ public boolean hasArguments() {
+ return true;
+ }
+
+ public boolean hasParenthesesIfNoArguments() {
+ return true;
+ }
+
+ public String render(List args, SessionFactoryImplementor factory) throws QueryException {
+ StringBuffer buf = new StringBuffer().append(begin);
+ for ( int i=0; i<args.size(); i++ ) {
+ buf.append( args.get(i) );
+ if (i<args.size()-1) buf.append(sep);
+ }
+ return buf.append(end).toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/function/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,9 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- A framework for defining database-specific SQL functions
- that are available via the dialect.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/function/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/function/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ A framework for defining database-specific SQL functions
+ that are available via the dialect.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,37 +0,0 @@
-package org.hibernate.dialect.lock;
-
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.StaleObjectStateException;
-import org.hibernate.JDBCException;
-
-import java.io.Serializable;
-
-/**
- * A strategy abstraction for how locks are obtained in the underlying database.
- * <p/>
- * All locking provided implemenations assume the underlying database supports
- * (and that the connection is in) at least read-committed transaction isolation.
- * The most glaring exclusion to this is HSQLDB which only offers support for
- * READ_UNCOMMITTED isolation.
- *
- * @see org.hibernate.dialect.Dialect#getLockingStrategy
- * @since 3.2
- *
- * @author Steve Ebersole
- */
-public interface LockingStrategy {
- /**
- * Acquire an appropriate type of lock on the underlying data that will
- * endure until the end of the current transaction.
- *
- * @param id The id of the row to be locked
- * @param version The current version (or null if not versioned)
- * @param object The object logically being locked (currently not used)
- * @param session The session from which the lock request originated
- * @throws StaleObjectStateException Indicates an optimisitic lock failure
- * as part of acquiring the requested database lock.
- * @throws JDBCException
- */
- public void lock(Serializable id, Object version, Object object, SessionImplementor session)
- throws StaleObjectStateException, JDBCException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/LockingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,61 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.lock;
+
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.StaleObjectStateException;
+import org.hibernate.JDBCException;
+
+import java.io.Serializable;
+
+/**
+ * A strategy abstraction for how locks are obtained in the underlying database.
+ * <p/>
+ * All locking provided implemenations assume the underlying database supports
+ * (and that the connection is in) at least read-committed transaction isolation.
+ * The most glaring exclusion to this is HSQLDB which only offers support for
+ * READ_UNCOMMITTED isolation.
+ *
+ * @see org.hibernate.dialect.Dialect#getLockingStrategy
+ * @since 3.2
+ *
+ * @author Steve Ebersole
+ */
+public interface LockingStrategy {
+ /**
+ * Acquire an appropriate type of lock on the underlying data that will
+ * endure until the end of the current transaction.
+ *
+ * @param id The id of the row to be locked
+ * @param version The current version (or null if not versioned)
+ * @param object The object logically being locked (currently not used)
+ * @param session The session from which the lock request originated
+ * @throws StaleObjectStateException Indicates an optimisitic lock failure
+ * as part of acquiring the requested database lock.
+ * @throws JDBCException
+ */
+ public void lock(Serializable id, Object version, Object object, SessionImplementor session)
+ throws StaleObjectStateException, JDBCException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,119 +0,0 @@
-package org.hibernate.dialect.lock;
-
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.StaleObjectStateException;
-import org.hibernate.JDBCException;
-import org.hibernate.LockMode;
-import org.hibernate.sql.SimpleSelect;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.exception.JDBCExceptionHelper;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-/**
- * A locking strategy where the locks are obtained through select statements.
- * <p/>
- * For non-read locks, this is achieved through the Dialect's specific
- * SELECT ... FOR UPDATE syntax.
- *
- * @see org.hibernate.dialect.Dialect#getForUpdateString(org.hibernate.LockMode)
- * @see org.hibernate.dialect.Dialect#appendLockHint(org.hibernate.LockMode, String)
- * @since 3.2
- *
- * @author Steve Ebersole
- */
-public class SelectLockingStrategy implements LockingStrategy {
-
- private final Lockable lockable;
- private final LockMode lockMode;
- private final String sql;
-
- /**
- * Construct a locking strategy based on SQL SELECT statements.
- *
- * @param lockable The metadata for the entity to be locked.
- * @param lockMode Indictates the type of lock to be acquired.
- */
- public SelectLockingStrategy(Lockable lockable, LockMode lockMode) {
- this.lockable = lockable;
- this.lockMode = lockMode;
- this.sql = generateLockString();
- }
-
- /**
- * @see LockingStrategy#lock
- */
- public void lock(
- Serializable id,
- Object version,
- Object object,
- SessionImplementor session) throws StaleObjectStateException, JDBCException {
-
- SessionFactoryImplementor factory = session.getFactory();
- try {
- PreparedStatement st = session.getBatcher().prepareSelectStatement( sql );
- try {
- lockable.getIdentifierType().nullSafeSet( st, id, 1, session );
- if ( lockable.isVersioned() ) {
- lockable.getVersionType().nullSafeSet(
- st,
- version,
- lockable.getIdentifierType().getColumnSpan( factory ) + 1,
- session
- );
- }
-
- ResultSet rs = st.executeQuery();
- try {
- if ( !rs.next() ) {
- if ( factory.getStatistics().isStatisticsEnabled() ) {
- factory.getStatisticsImplementor()
- .optimisticFailure( lockable.getEntityName() );
- }
- throw new StaleObjectStateException( lockable.getEntityName(), id );
- }
- }
- finally {
- rs.close();
- }
- }
- finally {
- session.getBatcher().closeStatement( st );
- }
-
- }
- catch ( SQLException sqle ) {
- throw JDBCExceptionHelper.convert(
- session.getFactory().getSQLExceptionConverter(),
- sqle,
- "could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
- sql
- );
- }
- }
-
- protected LockMode getLockMode() {
- return lockMode;
- }
-
- protected String generateLockString() {
- SessionFactoryImplementor factory = lockable.getFactory();
- SimpleSelect select = new SimpleSelect( factory.getDialect() )
- .setLockMode( lockMode )
- .setTableName( lockable.getRootTableName() )
- .addColumn( lockable.getRootTableIdentifierColumnNames()[0] )
- .addCondition( lockable.getRootTableIdentifierColumnNames(), "=?" );
- if ( lockable.isVersioned() ) {
- select.addCondition( lockable.getVersionColumnName(), "=?" );
- }
- if ( factory.getSettings().isCommentsEnabled() ) {
- select.setComment( lockMode + " lock " + lockable.getEntityName() );
- }
- return select.toStatementString();
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/SelectLockingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,143 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.lock;
+
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.StaleObjectStateException;
+import org.hibernate.JDBCException;
+import org.hibernate.LockMode;
+import org.hibernate.sql.SimpleSelect;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.exception.JDBCExceptionHelper;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * A locking strategy where the locks are obtained through select statements.
+ * <p/>
+ * For non-read locks, this is achieved through the Dialect's specific
+ * SELECT ... FOR UPDATE syntax.
+ *
+ * @see org.hibernate.dialect.Dialect#getForUpdateString(org.hibernate.LockMode)
+ * @see org.hibernate.dialect.Dialect#appendLockHint(org.hibernate.LockMode, String)
+ * @since 3.2
+ *
+ * @author Steve Ebersole
+ */
+public class SelectLockingStrategy implements LockingStrategy {
+
+ private final Lockable lockable;
+ private final LockMode lockMode;
+ private final String sql;
+
+ /**
+ * Construct a locking strategy based on SQL SELECT statements.
+ *
+ * @param lockable The metadata for the entity to be locked.
+ * @param lockMode Indictates the type of lock to be acquired.
+ */
+ public SelectLockingStrategy(Lockable lockable, LockMode lockMode) {
+ this.lockable = lockable;
+ this.lockMode = lockMode;
+ this.sql = generateLockString();
+ }
+
+ /**
+ * @see LockingStrategy#lock
+ */
+ public void lock(
+ Serializable id,
+ Object version,
+ Object object,
+ SessionImplementor session) throws StaleObjectStateException, JDBCException {
+
+ SessionFactoryImplementor factory = session.getFactory();
+ try {
+ PreparedStatement st = session.getBatcher().prepareSelectStatement( sql );
+ try {
+ lockable.getIdentifierType().nullSafeSet( st, id, 1, session );
+ if ( lockable.isVersioned() ) {
+ lockable.getVersionType().nullSafeSet(
+ st,
+ version,
+ lockable.getIdentifierType().getColumnSpan( factory ) + 1,
+ session
+ );
+ }
+
+ ResultSet rs = st.executeQuery();
+ try {
+ if ( !rs.next() ) {
+ if ( factory.getStatistics().isStatisticsEnabled() ) {
+ factory.getStatisticsImplementor()
+ .optimisticFailure( lockable.getEntityName() );
+ }
+ throw new StaleObjectStateException( lockable.getEntityName(), id );
+ }
+ }
+ finally {
+ rs.close();
+ }
+ }
+ finally {
+ session.getBatcher().closeStatement( st );
+ }
+
+ }
+ catch ( SQLException sqle ) {
+ throw JDBCExceptionHelper.convert(
+ session.getFactory().getSQLExceptionConverter(),
+ sqle,
+ "could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
+ sql
+ );
+ }
+ }
+
+ protected LockMode getLockMode() {
+ return lockMode;
+ }
+
+ protected String generateLockString() {
+ SessionFactoryImplementor factory = lockable.getFactory();
+ SimpleSelect select = new SimpleSelect( factory.getDialect() )
+ .setLockMode( lockMode )
+ .setTableName( lockable.getRootTableName() )
+ .addColumn( lockable.getRootTableIdentifierColumnNames()[0] )
+ .addCondition( lockable.getRootTableIdentifierColumnNames(), "=?" );
+ if ( lockable.isVersioned() ) {
+ select.addCondition( lockable.getVersionColumnName(), "=?" );
+ }
+ if ( factory.getSettings().isCommentsEnabled() ) {
+ select.setComment( lockMode + " lock " + lockable.getEntityName() );
+ }
+ return select.toStatementString();
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,122 +0,0 @@
-package org.hibernate.dialect.lock;
-
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.LockMode;
-import org.hibernate.HibernateException;
-import org.hibernate.StaleObjectStateException;
-import org.hibernate.JDBCException;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.sql.Update;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-/**
- * A locking strategy where the locks are obtained through update statements.
- * <p/>
- * This strategy is not valid for read style locks.
- *
- * @since 3.2
- *
- * @author Steve Ebersole
- */
-public class UpdateLockingStrategy implements LockingStrategy {
- private static final Logger log = LoggerFactory.getLogger( UpdateLockingStrategy.class );
-
- private final Lockable lockable;
- private final LockMode lockMode;
- private final String sql;
-
- /**
- * Construct a locking strategy based on SQL UPDATE statements.
- *
- * @param lockable The metadata for the entity to be locked.
- * @param lockMode Indictates the type of lock to be acquired. Note that
- * read-locks are not valid for this strategy.
- */
- public UpdateLockingStrategy(Lockable lockable, LockMode lockMode) {
- this.lockable = lockable;
- this.lockMode = lockMode;
- if ( lockMode.lessThan( LockMode.UPGRADE ) ) {
- throw new HibernateException( "[" + lockMode + "] not valid for update statement" );
- }
- if ( !lockable.isVersioned() ) {
- log.warn( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
- this.sql = null;
- }
- else {
- this.sql = generateLockString();
- }
- }
-
- /**
- * @see LockingStrategy#lock
- */
- public void lock(
- Serializable id,
- Object version,
- Object object,
- SessionImplementor session) throws StaleObjectStateException, JDBCException {
- if ( !lockable.isVersioned() ) {
- throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
- }
- // todo : should we additionally check the current isolation mode explicitly?
- SessionFactoryImplementor factory = session.getFactory();
- try {
- PreparedStatement st = session.getBatcher().prepareSelectStatement( sql );
- try {
- lockable.getVersionType().nullSafeSet( st, version, 1, session );
- int offset = 2;
-
- lockable.getIdentifierType().nullSafeSet( st, id, offset, session );
- offset += lockable.getIdentifierType().getColumnSpan( factory );
-
- if ( lockable.isVersioned() ) {
- lockable.getVersionType().nullSafeSet( st, version, offset, session );
- }
-
- int affected = st.executeUpdate();
- if ( affected < 0 ) {
- factory.getStatisticsImplementor().optimisticFailure( lockable.getEntityName() );
- throw new StaleObjectStateException( lockable.getEntityName(), id );
- }
-
- }
- finally {
- session.getBatcher().closeStatement( st );
- }
-
- }
- catch ( SQLException sqle ) {
- throw JDBCExceptionHelper.convert(
- session.getFactory().getSQLExceptionConverter(),
- sqle,
- "could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
- sql
- );
- }
- }
-
- protected String generateLockString() {
- SessionFactoryImplementor factory = lockable.getFactory();
- Update update = new Update( factory.getDialect() );
- update.setTableName( lockable.getRootTableName() );
- update.setPrimaryKeyColumnNames( lockable.getRootTableIdentifierColumnNames() );
- update.setVersionColumnName( lockable.getVersionColumnName() );
- update.addColumn( lockable.getVersionColumnName() );
- if ( factory.getSettings().isCommentsEnabled() ) {
- update.setComment( lockMode + " lock " + lockable.getEntityName() );
- }
- return update.toStatementString();
- }
-
- protected LockMode getLockMode() {
- return lockMode;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/lock/UpdateLockingStrategy.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,146 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.dialect.lock;
+
+import org.hibernate.persister.entity.Lockable;
+import org.hibernate.LockMode;
+import org.hibernate.HibernateException;
+import org.hibernate.StaleObjectStateException;
+import org.hibernate.JDBCException;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.exception.JDBCExceptionHelper;
+import org.hibernate.sql.Update;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+/**
+ * A locking strategy where the locks are obtained through update statements.
+ * <p/>
+ * This strategy is not valid for read style locks.
+ *
+ * @since 3.2
+ *
+ * @author Steve Ebersole
+ */
+public class UpdateLockingStrategy implements LockingStrategy {
+ private static final Logger log = LoggerFactory.getLogger( UpdateLockingStrategy.class );
+
+ private final Lockable lockable;
+ private final LockMode lockMode;
+ private final String sql;
+
+ /**
+ * Construct a locking strategy based on SQL UPDATE statements.
+ *
+ * @param lockable The metadata for the entity to be locked.
+ * @param lockMode Indictates the type of lock to be acquired. Note that
+ * read-locks are not valid for this strategy.
+ */
+ public UpdateLockingStrategy(Lockable lockable, LockMode lockMode) {
+ this.lockable = lockable;
+ this.lockMode = lockMode;
+ if ( lockMode.lessThan( LockMode.UPGRADE ) ) {
+ throw new HibernateException( "[" + lockMode + "] not valid for update statement" );
+ }
+ if ( !lockable.isVersioned() ) {
+ log.warn( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
+ this.sql = null;
+ }
+ else {
+ this.sql = generateLockString();
+ }
+ }
+
+ /**
+ * @see LockingStrategy#lock
+ */
+ public void lock(
+ Serializable id,
+ Object version,
+ Object object,
+ SessionImplementor session) throws StaleObjectStateException, JDBCException {
+ if ( !lockable.isVersioned() ) {
+ throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
+ }
+ // todo : should we additionally check the current isolation mode explicitly?
+ SessionFactoryImplementor factory = session.getFactory();
+ try {
+ PreparedStatement st = session.getBatcher().prepareSelectStatement( sql );
+ try {
+ lockable.getVersionType().nullSafeSet( st, version, 1, session );
+ int offset = 2;
+
+ lockable.getIdentifierType().nullSafeSet( st, id, offset, session );
+ offset += lockable.getIdentifierType().getColumnSpan( factory );
+
+ if ( lockable.isVersioned() ) {
+ lockable.getVersionType().nullSafeSet( st, version, offset, session );
+ }
+
+ int affected = st.executeUpdate();
+ if ( affected < 0 ) {
+ factory.getStatisticsImplementor().optimisticFailure( lockable.getEntityName() );
+ throw new StaleObjectStateException( lockable.getEntityName(), id );
+ }
+
+ }
+ finally {
+ session.getBatcher().closeStatement( st );
+ }
+
+ }
+ catch ( SQLException sqle ) {
+ throw JDBCExceptionHelper.convert(
+ session.getFactory().getSQLExceptionConverter(),
+ sqle,
+ "could not lock: " + MessageHelper.infoString( lockable, id, session.getFactory() ),
+ sql
+ );
+ }
+ }
+
+ protected String generateLockString() {
+ SessionFactoryImplementor factory = lockable.getFactory();
+ Update update = new Update( factory.getDialect() );
+ update.setTableName( lockable.getRootTableName() );
+ update.setPrimaryKeyColumnNames( lockable.getRootTableIdentifierColumnNames() );
+ update.setVersionColumnName( lockable.getVersionColumnName() );
+ update.addColumn( lockable.getVersionColumnName() );
+ if ( factory.getSettings().isCommentsEnabled() ) {
+ update.setComment( lockMode + " lock " + lockable.getEntityName() );
+ }
+ return update.toStatementString();
+ }
+
+ protected LockMode getLockMode() {
+ return lockMode;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/dialect/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,11 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- This package abstracts the SQL dialect of the underlying database.
-</p>
-<p>
- A concrete <tt>Dialect</tt> may be specifed using <tt>hibernate.dialect</tt>.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/dialect/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/dialect/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,36 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ This package abstracts the SQL dialect of the underlying database.
+</p>
+<p>
+ A concrete <tt>Dialect</tt> may be specifed using <tt>hibernate.dialect</tt>.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,619 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- *
- */
-package org.hibernate.engine;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.action.BulkOperationCleanupAction;
-import org.hibernate.action.CollectionRecreateAction;
-import org.hibernate.action.CollectionRemoveAction;
-import org.hibernate.action.CollectionUpdateAction;
-import org.hibernate.action.EntityDeleteAction;
-import org.hibernate.action.EntityIdentityInsertAction;
-import org.hibernate.action.EntityInsertAction;
-import org.hibernate.action.EntityUpdateAction;
-import org.hibernate.action.Executable;
-import org.hibernate.cache.CacheException;
-import org.hibernate.type.Type;
-
-/**
- * Responsible for maintaining the queue of actions related to events.
- * </p>
- * The ActionQueue holds the DML operations queued as part of a session's
- * transactional-write-behind semantics. DML operations are queued here
- * until a flush forces them to be executed against the database.
- *
- * @author Steve Ebersole
- */
-public class ActionQueue {
-
- private static final Logger log = LoggerFactory.getLogger( ActionQueue.class );
- private static final int INIT_QUEUE_LIST_SIZE = 5;
-
- private SessionImplementor session;
-
- // Object insertions, updates, and deletions have list semantics because
- // they must happen in the right order so as to respect referential
- // integrity
- private ArrayList insertions;
- private ArrayList deletions;
- private ArrayList updates;
- // Actually the semantics of the next three are really "Bag"
- // Note that, unlike objects, collection insertions, updates,
- // deletions are not really remembered between flushes. We
- // just re-use the same Lists for convenience.
- private ArrayList collectionCreations;
- private ArrayList collectionUpdates;
- private ArrayList collectionRemovals;
-
- private ArrayList executions;
-
- /**
- * Constructs an action queue bound to the given session.
- *
- * @param session The session "owning" this queue.
- */
- public ActionQueue(SessionImplementor session) {
- this.session = session;
- init();
- }
-
- private void init() {
- insertions = new ArrayList( INIT_QUEUE_LIST_SIZE );
- deletions = new ArrayList( INIT_QUEUE_LIST_SIZE );
- updates = new ArrayList( INIT_QUEUE_LIST_SIZE );
-
- collectionCreations = new ArrayList( INIT_QUEUE_LIST_SIZE );
- collectionRemovals = new ArrayList( INIT_QUEUE_LIST_SIZE );
- collectionUpdates = new ArrayList( INIT_QUEUE_LIST_SIZE );
-
- executions = new ArrayList( INIT_QUEUE_LIST_SIZE * 3 );
- }
-
- public void clear() {
- updates.clear();
- insertions.clear();
- deletions.clear();
-
- collectionCreations.clear();
- collectionRemovals.clear();
- collectionUpdates.clear();
- }
-
- public void addAction(EntityInsertAction action) {
- insertions.add( action );
- }
-
- public void addAction(EntityDeleteAction action) {
- deletions.add( action );
- }
-
- public void addAction(EntityUpdateAction action) {
- updates.add( action );
- }
-
- public void addAction(CollectionRecreateAction action) {
- collectionCreations.add( action );
- }
-
- public void addAction(CollectionRemoveAction action) {
- collectionRemovals.add( action );
- }
-
- public void addAction(CollectionUpdateAction action) {
- collectionUpdates.add( action );
- }
-
- public void addAction(EntityIdentityInsertAction insert) {
- insertions.add( insert );
- }
-
- public void addAction(BulkOperationCleanupAction cleanupAction) {
- // Add these directly to the executions queue
- executions.add( cleanupAction );
- }
-
- /**
- * Perform all currently queued entity-insertion actions.
- *
- * @throws HibernateException error executing queued insertion actions.
- */
- public void executeInserts() throws HibernateException {
- executeActions( insertions );
- }
-
- /**
- * Perform all currently queued actions.
- *
- * @throws HibernateException error executing queued actions.
- */
- public void executeActions() throws HibernateException {
- executeActions( insertions );
- executeActions( updates );
- executeActions( collectionRemovals );
- executeActions( collectionUpdates );
- executeActions( collectionCreations );
- executeActions( deletions );
- }
-
- /**
- * Prepares the internal action queues for execution.
- *
- * @throws HibernateException error preparing actions.
- */
- public void prepareActions() throws HibernateException {
- prepareActions( collectionRemovals );
- prepareActions( collectionUpdates );
- prepareActions( collectionCreations );
- }
-
- /**
- * Performs cleanup of any held cache softlocks.
- *
- * @param success Was the transaction successful.
- */
- public void afterTransactionCompletion(boolean success) {
- int size = executions.size();
- final boolean invalidateQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
- for ( int i = 0; i < size; i++ ) {
- try {
- Executable exec = ( Executable ) executions.get( i );
- try {
- exec.afterTransactionCompletion( success );
- }
- finally {
- if ( invalidateQueryCache ) {
- session.getFactory().getUpdateTimestampsCache().invalidate( exec.getPropertySpaces() );
- }
- }
- }
- catch ( CacheException ce ) {
- log.error( "could not release a cache lock", ce );
- // continue loop
- }
- catch ( Exception e ) {
- throw new AssertionFailure( "Exception releasing cache locks", e );
- }
- }
- executions.clear();
- }
-
- /**
- * Check whether the given tables/query-spaces are to be executed against
- * given the currently queued actions.
- *
- * @param tables The table/query-spaces to check.
- *
- * @return True if we contain pending actions against any of the given
- * tables; false otherwise.
- */
- public boolean areTablesToBeUpdated(Set tables) {
- return areTablesToUpdated( updates, tables ) ||
- areTablesToUpdated( insertions, tables ) ||
- areTablesToUpdated( deletions, tables ) ||
- areTablesToUpdated( collectionUpdates, tables ) ||
- areTablesToUpdated( collectionCreations, tables ) ||
- areTablesToUpdated( collectionRemovals, tables );
- }
-
- /**
- * Check whether any insertion or deletion actions are currently queued.
- *
- * @return True if insertions or deletions are currently queued; false otherwise.
- */
- public boolean areInsertionsOrDeletionsQueued() {
- return ( insertions.size() > 0 || deletions.size() > 0 );
- }
-
- private static boolean areTablesToUpdated(List executables, Set tablespaces) {
- int size = executables.size();
- for ( int j = 0; j < size; j++ ) {
- Serializable[] spaces = ( ( Executable ) executables.get( j ) ).getPropertySpaces();
- for ( int i = 0; i < spaces.length; i++ ) {
- if ( tablespaces.contains( spaces[i] ) ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "changes must be flushed to space: " + spaces[i] );
- }
- return true;
- }
- }
- }
- return false;
- }
-
- private void executeActions(List list) throws HibernateException {
- int size = list.size();
- for ( int i = 0; i < size; i++ ) {
- execute( ( Executable ) list.get( i ) );
- }
- list.clear();
- session.getBatcher().executeBatch();
- }
-
- public void execute(Executable executable) {
- final boolean lockQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
- if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) {
- executions.add( executable );
- }
- if ( lockQueryCache ) {
- session.getFactory()
- .getUpdateTimestampsCache()
- .preinvalidate( executable.getPropertySpaces() );
- }
- executable.execute();
- }
-
- private void prepareActions(List queue) throws HibernateException {
- int size = queue.size();
- for ( int i = 0; i < size; i++ ) {
- Executable executable = ( Executable ) queue.get( i );
- executable.beforeExecutions();
- }
- }
-
- /**
- * Returns a string representation of the object.
- *
- * @return a string representation of the object.
- */
- public String toString() {
- return new StringBuffer()
- .append( "ActionQueue[insertions=" ).append( insertions )
- .append( " updates=" ).append( updates )
- .append( " deletions=" ).append( deletions )
- .append( " collectionCreations=" ).append( collectionCreations )
- .append( " collectionRemovals=" ).append( collectionRemovals )
- .append( " collectionUpdates=" ).append( collectionUpdates )
- .append( "]" )
- .toString();
- }
-
- public int numberOfCollectionRemovals() {
- return collectionRemovals.size();
- }
-
- public int numberOfCollectionUpdates() {
- return collectionUpdates.size();
- }
-
- public int numberOfCollectionCreations() {
- return collectionCreations.size();
- }
-
- public int numberOfDeletions() {
- return deletions.size();
- }
-
- public int numberOfUpdates() {
- return updates.size();
- }
-
- public int numberOfInsertions() {
- return insertions.size();
- }
-
- public void sortCollectionActions() {
- if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) {
- //sort the updates by fk
- java.util.Collections.sort( collectionCreations );
- java.util.Collections.sort( collectionUpdates );
- java.util.Collections.sort( collectionRemovals );
- }
- }
-
- public void sortActions() {
- if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) {
- //sort the updates by pk
- java.util.Collections.sort( updates );
- }
- if ( session.getFactory().getSettings().isOrderInsertsEnabled() ) {
- sortInsertActions();
- }
- }
-
- /**
- * Order the {@link #insertions} queue such that we group inserts
- * against the same entity together (without violating constraints). The
- * original order is generated by cascade order, which in turn is based on
- * the directionality of foreign-keys. So even though we will be changing
- * the ordering here, we need to make absolutely certain that we do not
- * circumvent this FK ordering to the extent of causing constraint
- * violations
- */
- private void sortInsertActions() {
- new InsertActionSorter().sort();
- }
-
- public ArrayList cloneDeletions() {
- return ( ArrayList ) deletions.clone();
- }
-
- public void clearFromFlushNeededCheck(int previousCollectionRemovalSize) {
- collectionCreations.clear();
- collectionUpdates.clear();
- updates.clear();
- // collection deletions are a special case since update() can add
- // deletions of collections not loaded by the session.
- for ( int i = collectionRemovals.size() - 1; i >= previousCollectionRemovalSize; i-- ) {
- collectionRemovals.remove( i );
- }
- }
-
- public boolean hasAfterTransactionActions() {
- return executions.size() > 0;
- }
-
- public boolean hasAnyQueuedActions() {
- return updates.size() > 0 ||
- insertions.size() > 0 ||
- deletions.size() > 0 ||
- collectionUpdates.size() > 0 ||
- collectionRemovals.size() > 0 ||
- collectionCreations.size() > 0;
- }
-
- /**
- * Used by the owning session to explicitly control serialization of the
- * action queue
- *
- * @param oos The stream to which the action queue should get written
- *
- * @throws IOException
- */
- public void serialize(ObjectOutputStream oos) throws IOException {
- log.trace( "serializing action-queue" );
-
- int queueSize = insertions.size();
- log.trace( "starting serialization of [" + queueSize + "] insertions entries" );
- oos.writeInt( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- oos.writeObject( insertions.get( i ) );
- }
-
- queueSize = deletions.size();
- log.trace( "starting serialization of [" + queueSize + "] deletions entries" );
- oos.writeInt( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- oos.writeObject( deletions.get( i ) );
- }
-
- queueSize = updates.size();
- log.trace( "starting serialization of [" + queueSize + "] updates entries" );
- oos.writeInt( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- oos.writeObject( updates.get( i ) );
- }
-
- queueSize = collectionUpdates.size();
- log.trace( "starting serialization of [" + queueSize + "] collectionUpdates entries" );
- oos.writeInt( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- oos.writeObject( collectionUpdates.get( i ) );
- }
-
- queueSize = collectionRemovals.size();
- log.trace( "starting serialization of [" + queueSize + "] collectionRemovals entries" );
- oos.writeInt( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- oos.writeObject( collectionRemovals.get( i ) );
- }
-
- queueSize = collectionCreations.size();
- log.trace( "starting serialization of [" + queueSize + "] collectionCreations entries" );
- oos.writeInt( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- oos.writeObject( collectionCreations.get( i ) );
- }
- }
-
- /**
- * Used by the owning session to explicitly control deserialization of the
- * action queue
- *
- * @param ois The stream from which to read the action queue
- *
- * @throws IOException
- */
- public static ActionQueue deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- log.trace( "deserializing action-queue" );
- ActionQueue rtn = new ActionQueue( session );
-
- int queueSize = ois.readInt();
- log.trace( "starting deserialization of [" + queueSize + "] insertions entries" );
- rtn.insertions = new ArrayList( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- rtn.insertions.add( ois.readObject() );
- }
-
- queueSize = ois.readInt();
- log.trace( "starting deserialization of [" + queueSize + "] deletions entries" );
- rtn.deletions = new ArrayList( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- rtn.deletions.add( ois.readObject() );
- }
-
- queueSize = ois.readInt();
- log.trace( "starting deserialization of [" + queueSize + "] updates entries" );
- rtn.updates = new ArrayList( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- rtn.updates.add( ois.readObject() );
- }
-
- queueSize = ois.readInt();
- log.trace( "starting deserialization of [" + queueSize + "] collectionUpdates entries" );
- rtn.collectionUpdates = new ArrayList( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- rtn.collectionUpdates.add( ois.readObject() );
- }
-
- queueSize = ois.readInt();
- log.trace( "starting deserialization of [" + queueSize + "] collectionRemovals entries" );
- rtn.collectionRemovals = new ArrayList( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- rtn.collectionRemovals.add( ois.readObject() );
- }
-
- queueSize = ois.readInt();
- log.trace( "starting deserialization of [" + queueSize + "] collectionCreations entries" );
- rtn.collectionCreations = new ArrayList( queueSize );
- for ( int i = 0; i < queueSize; i++ ) {
- rtn.collectionCreations.add( ois.readObject() );
- }
- return rtn;
- }
-
-
- /**
- * Sorts the insert actions using more hashes.
- *
- * @author Jay Erb
- */
- private class InsertActionSorter {
-
- // the mapping of entity names to their latest batch numbers.
- private HashMap latestBatches = new HashMap();
- private HashMap entityBatchNumber;
-
- // the map of batch numbers to EntityInsertAction lists
- private HashMap actionBatches = new HashMap();
-
- public InsertActionSorter() {
- //optimize the hash size to eliminate a rehash.
- entityBatchNumber = new HashMap( insertions.size() + 1, 1.0f );
- }
-
- /**
- * Sort the insert actions.
- */
- public void sort() {
-
- // the list of entity names that indicate the batch number
- for ( Iterator actionItr = insertions.iterator(); actionItr.hasNext(); ) {
- EntityInsertAction action = ( EntityInsertAction ) actionItr.next();
- // remove the current element from insertions. It will be added back later.
- String entityName = action.getEntityName();
-
- // the entity associated with the current action.
- Object currentEntity = action.getInstance();
-
- Integer batchNumber;
- if ( latestBatches.containsKey( entityName ) ) {
- // There is already an existing batch for this type of entity.
- // Check to see if the latest batch is acceptable.
- batchNumber = findBatchNumber( action, entityName );
- }
- else {
- // add an entry for this type of entity.
- // we can be assured that all referenced entities have already
- // been processed,
- // so specify that this entity is with the latest batch.
- // doing the batch number before adding the name to the list is
- // a faster way to get an accurate number.
-
- batchNumber = new Integer( actionBatches.size() );
- latestBatches.put( entityName, batchNumber );
- }
- entityBatchNumber.put( currentEntity, batchNumber );
- addToBatch( batchNumber, action );
- }
- insertions.clear();
-
- // now rebuild the insertions list. There is a batch for each entry in the name list.
- for ( int i = 0; i < actionBatches.size(); i++ ) {
- List batch = ( List ) actionBatches.get( new Integer( i ) );
- for ( Iterator batchItr = batch.iterator(); batchItr.hasNext(); ) {
- EntityInsertAction action = ( EntityInsertAction ) batchItr.next();
- insertions.add( action );
- }
- }
- }
-
- /**
- * Finds an acceptable batch for this entity to be a member.
- */
- private Integer findBatchNumber(EntityInsertAction action,
- String entityName) {
- // loop through all the associated entities and make sure they have been
- // processed before the latest
- // batch associated with this entity type.
-
- // the current batch number is the latest batch for this entity type.
- Integer latestBatchNumberForType = ( Integer ) latestBatches.get( entityName );
-
- // loop through all the associations of the current entity and make sure that they are processed
- // before the current batch number
- Object[] propertyValues = action.getState();
- Type[] propertyTypes = action.getPersister().getClassMetadata()
- .getPropertyTypes();
-
- for ( int i = 0; i < propertyValues.length; i++ ) {
- Object value = propertyValues[i];
- Type type = propertyTypes[i];
- if ( type.isEntityType() && value != null ) {
- // find the batch number associated with the current association, if any.
- Integer associationBatchNumber = ( Integer ) entityBatchNumber.get( value );
- if ( associationBatchNumber != null && associationBatchNumber.compareTo( latestBatchNumberForType ) > 0 ) {
- // create a new batch for this type. The batch number is the number of current batches.
- latestBatchNumberForType = new Integer( actionBatches.size() );
- latestBatches.put( entityName, latestBatchNumberForType );
- // since this entity will now be processed in the latest possible batch,
- // we can be assured that it will come after all other associations,
- // there's not need to continue checking.
- break;
- }
- }
- }
- return latestBatchNumberForType;
- }
-
- private void addToBatch(Integer batchNumber, EntityInsertAction action) {
- List actions = ( List ) actionBatches.get( batchNumber );
-
- if ( actions == null ) {
- actions = new LinkedList();
- actionBatches.put( batchNumber, actions );
- }
- actions.add( action );
- }
-
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/ActionQueue.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ActionQueue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,619 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.action.BulkOperationCleanupAction;
+import org.hibernate.action.CollectionRecreateAction;
+import org.hibernate.action.CollectionRemoveAction;
+import org.hibernate.action.CollectionUpdateAction;
+import org.hibernate.action.EntityDeleteAction;
+import org.hibernate.action.EntityIdentityInsertAction;
+import org.hibernate.action.EntityInsertAction;
+import org.hibernate.action.EntityUpdateAction;
+import org.hibernate.action.Executable;
+import org.hibernate.cache.CacheException;
+import org.hibernate.type.Type;
+
+/**
+ * Responsible for maintaining the queue of actions related to events.
+ * </p>
+ * The ActionQueue holds the DML operations queued as part of a session's
+ * transactional-write-behind semantics. DML operations are queued here
+ * until a flush forces them to be executed against the database.
+ *
+ * @author Steve Ebersole
+ */
+public class ActionQueue {
+
+ private static final Logger log = LoggerFactory.getLogger( ActionQueue.class );
+ private static final int INIT_QUEUE_LIST_SIZE = 5;
+
+ private SessionImplementor session;
+
+ // Object insertions, updates, and deletions have list semantics because
+ // they must happen in the right order so as to respect referential
+ // integrity
+ private ArrayList insertions;
+ private ArrayList deletions;
+ private ArrayList updates;
+ // Actually the semantics of the next three are really "Bag"
+ // Note that, unlike objects, collection insertions, updates,
+ // deletions are not really remembered between flushes. We
+ // just re-use the same Lists for convenience.
+ private ArrayList collectionCreations;
+ private ArrayList collectionUpdates;
+ private ArrayList collectionRemovals;
+
+ private ArrayList executions;
+
+ /**
+ * Constructs an action queue bound to the given session.
+ *
+ * @param session The session "owning" this queue.
+ */
+ public ActionQueue(SessionImplementor session) {
+ this.session = session;
+ init();
+ }
+
+ private void init() {
+ insertions = new ArrayList( INIT_QUEUE_LIST_SIZE );
+ deletions = new ArrayList( INIT_QUEUE_LIST_SIZE );
+ updates = new ArrayList( INIT_QUEUE_LIST_SIZE );
+
+ collectionCreations = new ArrayList( INIT_QUEUE_LIST_SIZE );
+ collectionRemovals = new ArrayList( INIT_QUEUE_LIST_SIZE );
+ collectionUpdates = new ArrayList( INIT_QUEUE_LIST_SIZE );
+
+ executions = new ArrayList( INIT_QUEUE_LIST_SIZE * 3 );
+ }
+
+ public void clear() {
+ updates.clear();
+ insertions.clear();
+ deletions.clear();
+
+ collectionCreations.clear();
+ collectionRemovals.clear();
+ collectionUpdates.clear();
+ }
+
+ public void addAction(EntityInsertAction action) {
+ insertions.add( action );
+ }
+
+ public void addAction(EntityDeleteAction action) {
+ deletions.add( action );
+ }
+
+ public void addAction(EntityUpdateAction action) {
+ updates.add( action );
+ }
+
+ public void addAction(CollectionRecreateAction action) {
+ collectionCreations.add( action );
+ }
+
+ public void addAction(CollectionRemoveAction action) {
+ collectionRemovals.add( action );
+ }
+
+ public void addAction(CollectionUpdateAction action) {
+ collectionUpdates.add( action );
+ }
+
+ public void addAction(EntityIdentityInsertAction insert) {
+ insertions.add( insert );
+ }
+
+ public void addAction(BulkOperationCleanupAction cleanupAction) {
+ // Add these directly to the executions queue
+ executions.add( cleanupAction );
+ }
+
+ /**
+ * Perform all currently queued entity-insertion actions.
+ *
+ * @throws HibernateException error executing queued insertion actions.
+ */
+ public void executeInserts() throws HibernateException {
+ executeActions( insertions );
+ }
+
+ /**
+ * Perform all currently queued actions.
+ *
+ * @throws HibernateException error executing queued actions.
+ */
+ public void executeActions() throws HibernateException {
+ executeActions( insertions );
+ executeActions( updates );
+ executeActions( collectionRemovals );
+ executeActions( collectionUpdates );
+ executeActions( collectionCreations );
+ executeActions( deletions );
+ }
+
+ /**
+ * Prepares the internal action queues for execution.
+ *
+ * @throws HibernateException error preparing actions.
+ */
+ public void prepareActions() throws HibernateException {
+ prepareActions( collectionRemovals );
+ prepareActions( collectionUpdates );
+ prepareActions( collectionCreations );
+ }
+
+ /**
+ * Performs cleanup of any held cache softlocks.
+ *
+ * @param success Was the transaction successful.
+ */
+ public void afterTransactionCompletion(boolean success) {
+ int size = executions.size();
+ final boolean invalidateQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
+ for ( int i = 0; i < size; i++ ) {
+ try {
+ Executable exec = ( Executable ) executions.get( i );
+ try {
+ exec.afterTransactionCompletion( success );
+ }
+ finally {
+ if ( invalidateQueryCache ) {
+ session.getFactory().getUpdateTimestampsCache().invalidate( exec.getPropertySpaces() );
+ }
+ }
+ }
+ catch ( CacheException ce ) {
+ log.error( "could not release a cache lock", ce );
+ // continue loop
+ }
+ catch ( Exception e ) {
+ throw new AssertionFailure( "Exception releasing cache locks", e );
+ }
+ }
+ executions.clear();
+ }
+
+ /**
+ * Check whether the given tables/query-spaces are to be executed against
+ * given the currently queued actions.
+ *
+ * @param tables The table/query-spaces to check.
+ *
+ * @return True if we contain pending actions against any of the given
+ * tables; false otherwise.
+ */
+ public boolean areTablesToBeUpdated(Set tables) {
+ return areTablesToUpdated( updates, tables ) ||
+ areTablesToUpdated( insertions, tables ) ||
+ areTablesToUpdated( deletions, tables ) ||
+ areTablesToUpdated( collectionUpdates, tables ) ||
+ areTablesToUpdated( collectionCreations, tables ) ||
+ areTablesToUpdated( collectionRemovals, tables );
+ }
+
+ /**
+ * Check whether any insertion or deletion actions are currently queued.
+ *
+ * @return True if insertions or deletions are currently queued; false otherwise.
+ */
+ public boolean areInsertionsOrDeletionsQueued() {
+ return ( insertions.size() > 0 || deletions.size() > 0 );
+ }
+
+ private static boolean areTablesToUpdated(List executables, Set tablespaces) {
+ int size = executables.size();
+ for ( int j = 0; j < size; j++ ) {
+ Serializable[] spaces = ( ( Executable ) executables.get( j ) ).getPropertySpaces();
+ for ( int i = 0; i < spaces.length; i++ ) {
+ if ( tablespaces.contains( spaces[i] ) ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "changes must be flushed to space: " + spaces[i] );
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void executeActions(List list) throws HibernateException {
+ int size = list.size();
+ for ( int i = 0; i < size; i++ ) {
+ execute( ( Executable ) list.get( i ) );
+ }
+ list.clear();
+ session.getBatcher().executeBatch();
+ }
+
+ public void execute(Executable executable) {
+ final boolean lockQueryCache = session.getFactory().getSettings().isQueryCacheEnabled();
+ if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) {
+ executions.add( executable );
+ }
+ if ( lockQueryCache ) {
+ session.getFactory()
+ .getUpdateTimestampsCache()
+ .preinvalidate( executable.getPropertySpaces() );
+ }
+ executable.execute();
+ }
+
+ private void prepareActions(List queue) throws HibernateException {
+ int size = queue.size();
+ for ( int i = 0; i < size; i++ ) {
+ Executable executable = ( Executable ) queue.get( i );
+ executable.beforeExecutions();
+ }
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return a string representation of the object.
+ */
+ public String toString() {
+ return new StringBuffer()
+ .append( "ActionQueue[insertions=" ).append( insertions )
+ .append( " updates=" ).append( updates )
+ .append( " deletions=" ).append( deletions )
+ .append( " collectionCreations=" ).append( collectionCreations )
+ .append( " collectionRemovals=" ).append( collectionRemovals )
+ .append( " collectionUpdates=" ).append( collectionUpdates )
+ .append( "]" )
+ .toString();
+ }
+
+ public int numberOfCollectionRemovals() {
+ return collectionRemovals.size();
+ }
+
+ public int numberOfCollectionUpdates() {
+ return collectionUpdates.size();
+ }
+
+ public int numberOfCollectionCreations() {
+ return collectionCreations.size();
+ }
+
+ public int numberOfDeletions() {
+ return deletions.size();
+ }
+
+ public int numberOfUpdates() {
+ return updates.size();
+ }
+
+ public int numberOfInsertions() {
+ return insertions.size();
+ }
+
+ public void sortCollectionActions() {
+ if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) {
+ //sort the updates by fk
+ java.util.Collections.sort( collectionCreations );
+ java.util.Collections.sort( collectionUpdates );
+ java.util.Collections.sort( collectionRemovals );
+ }
+ }
+
+ public void sortActions() {
+ if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) {
+ //sort the updates by pk
+ java.util.Collections.sort( updates );
+ }
+ if ( session.getFactory().getSettings().isOrderInsertsEnabled() ) {
+ sortInsertActions();
+ }
+ }
+
+ /**
+ * Order the {@link #insertions} queue such that we group inserts
+ * against the same entity together (without violating constraints). The
+ * original order is generated by cascade order, which in turn is based on
+ * the directionality of foreign-keys. So even though we will be changing
+ * the ordering here, we need to make absolutely certain that we do not
+ * circumvent this FK ordering to the extent of causing constraint
+ * violations
+ */
+ private void sortInsertActions() {
+ new InsertActionSorter().sort();
+ }
+
+ public ArrayList cloneDeletions() {
+ return ( ArrayList ) deletions.clone();
+ }
+
+ public void clearFromFlushNeededCheck(int previousCollectionRemovalSize) {
+ collectionCreations.clear();
+ collectionUpdates.clear();
+ updates.clear();
+ // collection deletions are a special case since update() can add
+ // deletions of collections not loaded by the session.
+ for ( int i = collectionRemovals.size() - 1; i >= previousCollectionRemovalSize; i-- ) {
+ collectionRemovals.remove( i );
+ }
+ }
+
+ public boolean hasAfterTransactionActions() {
+ return executions.size() > 0;
+ }
+
+ public boolean hasAnyQueuedActions() {
+ return updates.size() > 0 ||
+ insertions.size() > 0 ||
+ deletions.size() > 0 ||
+ collectionUpdates.size() > 0 ||
+ collectionRemovals.size() > 0 ||
+ collectionCreations.size() > 0;
+ }
+
+ /**
+ * Used by the owning session to explicitly control serialization of the
+ * action queue
+ *
+ * @param oos The stream to which the action queue should get written
+ *
+ * @throws IOException
+ */
+ public void serialize(ObjectOutputStream oos) throws IOException {
+ log.trace( "serializing action-queue" );
+
+ int queueSize = insertions.size();
+ log.trace( "starting serialization of [" + queueSize + "] insertions entries" );
+ oos.writeInt( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ oos.writeObject( insertions.get( i ) );
+ }
+
+ queueSize = deletions.size();
+ log.trace( "starting serialization of [" + queueSize + "] deletions entries" );
+ oos.writeInt( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ oos.writeObject( deletions.get( i ) );
+ }
+
+ queueSize = updates.size();
+ log.trace( "starting serialization of [" + queueSize + "] updates entries" );
+ oos.writeInt( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ oos.writeObject( updates.get( i ) );
+ }
+
+ queueSize = collectionUpdates.size();
+ log.trace( "starting serialization of [" + queueSize + "] collectionUpdates entries" );
+ oos.writeInt( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ oos.writeObject( collectionUpdates.get( i ) );
+ }
+
+ queueSize = collectionRemovals.size();
+ log.trace( "starting serialization of [" + queueSize + "] collectionRemovals entries" );
+ oos.writeInt( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ oos.writeObject( collectionRemovals.get( i ) );
+ }
+
+ queueSize = collectionCreations.size();
+ log.trace( "starting serialization of [" + queueSize + "] collectionCreations entries" );
+ oos.writeInt( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ oos.writeObject( collectionCreations.get( i ) );
+ }
+ }
+
+ /**
+ * Used by the owning session to explicitly control deserialization of the
+ * action queue
+ *
+ * @param ois The stream from which to read the action queue
+ *
+ * @throws IOException
+ */
+ public static ActionQueue deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ log.trace( "deserializing action-queue" );
+ ActionQueue rtn = new ActionQueue( session );
+
+ int queueSize = ois.readInt();
+ log.trace( "starting deserialization of [" + queueSize + "] insertions entries" );
+ rtn.insertions = new ArrayList( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ rtn.insertions.add( ois.readObject() );
+ }
+
+ queueSize = ois.readInt();
+ log.trace( "starting deserialization of [" + queueSize + "] deletions entries" );
+ rtn.deletions = new ArrayList( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ rtn.deletions.add( ois.readObject() );
+ }
+
+ queueSize = ois.readInt();
+ log.trace( "starting deserialization of [" + queueSize + "] updates entries" );
+ rtn.updates = new ArrayList( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ rtn.updates.add( ois.readObject() );
+ }
+
+ queueSize = ois.readInt();
+ log.trace( "starting deserialization of [" + queueSize + "] collectionUpdates entries" );
+ rtn.collectionUpdates = new ArrayList( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ rtn.collectionUpdates.add( ois.readObject() );
+ }
+
+ queueSize = ois.readInt();
+ log.trace( "starting deserialization of [" + queueSize + "] collectionRemovals entries" );
+ rtn.collectionRemovals = new ArrayList( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ rtn.collectionRemovals.add( ois.readObject() );
+ }
+
+ queueSize = ois.readInt();
+ log.trace( "starting deserialization of [" + queueSize + "] collectionCreations entries" );
+ rtn.collectionCreations = new ArrayList( queueSize );
+ for ( int i = 0; i < queueSize; i++ ) {
+ rtn.collectionCreations.add( ois.readObject() );
+ }
+ return rtn;
+ }
+
+
+ /**
+ * Sorts the insert actions using more hashes.
+ *
+ * @author Jay Erb
+ */
+ private class InsertActionSorter {
+
+ // the mapping of entity names to their latest batch numbers.
+ private HashMap latestBatches = new HashMap();
+ private HashMap entityBatchNumber;
+
+ // the map of batch numbers to EntityInsertAction lists
+ private HashMap actionBatches = new HashMap();
+
+ public InsertActionSorter() {
+ //optimize the hash size to eliminate a rehash.
+ entityBatchNumber = new HashMap( insertions.size() + 1, 1.0f );
+ }
+
+ /**
+ * Sort the insert actions.
+ */
+ public void sort() {
+
+ // the list of entity names that indicate the batch number
+ for ( Iterator actionItr = insertions.iterator(); actionItr.hasNext(); ) {
+ EntityInsertAction action = ( EntityInsertAction ) actionItr.next();
+ // remove the current element from insertions. It will be added back later.
+ String entityName = action.getEntityName();
+
+ // the entity associated with the current action.
+ Object currentEntity = action.getInstance();
+
+ Integer batchNumber;
+ if ( latestBatches.containsKey( entityName ) ) {
+ // There is already an existing batch for this type of entity.
+ // Check to see if the latest batch is acceptable.
+ batchNumber = findBatchNumber( action, entityName );
+ }
+ else {
+ // add an entry for this type of entity.
+ // we can be assured that all referenced entities have already
+ // been processed,
+ // so specify that this entity is with the latest batch.
+ // doing the batch number before adding the name to the list is
+ // a faster way to get an accurate number.
+
+ batchNumber = new Integer( actionBatches.size() );
+ latestBatches.put( entityName, batchNumber );
+ }
+ entityBatchNumber.put( currentEntity, batchNumber );
+ addToBatch( batchNumber, action );
+ }
+ insertions.clear();
+
+ // now rebuild the insertions list. There is a batch for each entry in the name list.
+ for ( int i = 0; i < actionBatches.size(); i++ ) {
+ List batch = ( List ) actionBatches.get( new Integer( i ) );
+ for ( Iterator batchItr = batch.iterator(); batchItr.hasNext(); ) {
+ EntityInsertAction action = ( EntityInsertAction ) batchItr.next();
+ insertions.add( action );
+ }
+ }
+ }
+
+ /**
+ * Finds an acceptable batch for this entity to be a member.
+ */
+ private Integer findBatchNumber(EntityInsertAction action,
+ String entityName) {
+ // loop through all the associated entities and make sure they have been
+ // processed before the latest
+ // batch associated with this entity type.
+
+ // the current batch number is the latest batch for this entity type.
+ Integer latestBatchNumberForType = ( Integer ) latestBatches.get( entityName );
+
+ // loop through all the associations of the current entity and make sure that they are processed
+ // before the current batch number
+ Object[] propertyValues = action.getState();
+ Type[] propertyTypes = action.getPersister().getClassMetadata()
+ .getPropertyTypes();
+
+ for ( int i = 0; i < propertyValues.length; i++ ) {
+ Object value = propertyValues[i];
+ Type type = propertyTypes[i];
+ if ( type.isEntityType() && value != null ) {
+ // find the batch number associated with the current association, if any.
+ Integer associationBatchNumber = ( Integer ) entityBatchNumber.get( value );
+ if ( associationBatchNumber != null && associationBatchNumber.compareTo( latestBatchNumberForType ) > 0 ) {
+ // create a new batch for this type. The batch number is the number of current batches.
+ latestBatchNumberForType = new Integer( actionBatches.size() );
+ latestBatches.put( entityName, latestBatchNumberForType );
+ // since this entity will now be processed in the latest possible batch,
+ // we can be assured that it will come after all other associations,
+ // there's not need to continue checking.
+ break;
+ }
+ }
+ }
+ return latestBatchNumberForType;
+ }
+
+ private void addToBatch(Integer batchNumber, EntityInsertAction action) {
+ List actions = ( List ) actionBatches.get( batchNumber );
+
+ if ( actions == null ) {
+ actions = new LinkedList();
+ actionBatches.put( batchNumber, actions );
+ }
+ actions.add( action );
+ }
+
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/AssociationKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-//$Id: AssociationKey.java 7458 2005-07-12 20:12:57Z oneovthafew $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-
-/**
- * Identifies a named association belonging to a particular
- * entity instance. Used to record the fact that an association
- * is null during loading.
- *
- * @author Gavin King
- */
-final class AssociationKey implements Serializable {
- private EntityKey ownerKey;
- private String propertyName;
-
- public AssociationKey(EntityKey ownerKey, String propertyName) {
- this.ownerKey = ownerKey;
- this.propertyName = propertyName;
- }
-
- public boolean equals(Object that) {
- AssociationKey key = (AssociationKey) that;
- return key.propertyName.equals(propertyName) &&
- key.ownerKey.equals(ownerKey);
- }
-
- public int hashCode() {
- return ownerKey.hashCode() + propertyName.hashCode();
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/AssociationKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/AssociationKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,54 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+
+/**
+ * Identifies a named association belonging to a particular
+ * entity instance. Used to record the fact that an association
+ * is null during loading.
+ *
+ * @author Gavin King
+ */
+final class AssociationKey implements Serializable {
+ private EntityKey ownerKey;
+ private String propertyName;
+
+ public AssociationKey(EntityKey ownerKey, String propertyName) {
+ this.ownerKey = ownerKey;
+ this.propertyName = propertyName;
+ }
+
+ public boolean equals(Object that) {
+ AssociationKey key = (AssociationKey) that;
+ return key.propertyName.equals(propertyName) &&
+ key.ownerKey.equals(ownerKey);
+ }
+
+ public int hashCode() {
+ return ownerKey.hashCode() + propertyName.hashCode();
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,276 +0,0 @@
-//$Id: BatchFetchQueue.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.hibernate.EntityMode;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.util.MarkerObject;
-
-/**
- * Tracks entity and collection keys that are available for batch
- * fetching, and the queries which were used to load entities, which
- * can be re-used as a subquery for loading owned collections.
- *
- * @author Gavin King
- */
-public class BatchFetchQueue {
-
- public static final Object MARKER = new MarkerObject( "MARKER" );
-
- /**
- * Defines a sequence of {@link EntityKey} elements that are currently
- * elegible for batch-fetching.
- * <p/>
- * Even though this is a map, we only use the keys. A map was chosen in
- * order to utilize a {@link LinkedHashMap} to maintain sequencing
- * as well as uniqueness.
- * <p/>
- * TODO : this would be better as a SequencedReferenceSet, but no such beast exists!
- */
- private final Map batchLoadableEntityKeys = new LinkedHashMap(8);
-
- /**
- * A map of {@link SubselectFetch subselect-fetch descriptors} keyed by the
- * {@link EntityKey) against which the descriptor is registered.
- */
- private final Map subselectsByEntityKey = new HashMap(8);
-
- /**
- * The owning persistence context.
- */
- private final PersistenceContext context;
-
- /**
- * Constructs a queue for the given context.
- *
- * @param context The owning context.
- */
- public BatchFetchQueue(PersistenceContext context) {
- this.context = context;
- }
-
- /**
- * Clears all entries from this fetch queue.
- */
- public void clear() {
- batchLoadableEntityKeys.clear();
- subselectsByEntityKey.clear();
- }
-
- /**
- * Retrieve the fetch descriptor associated with the given entity key.
- *
- * @param key The entity key for which to locate any defined subselect fetch.
- * @return The fetch descriptor; may return null if no subselect fetch queued for
- * this entity key.
- */
- public SubselectFetch getSubselect(EntityKey key) {
- return (SubselectFetch) subselectsByEntityKey.get(key);
- }
-
- /**
- * Adds a subselect fetch decriptor for the given entity key.
- *
- * @param key The entity for which to register the subselect fetch.
- * @param subquery The fetch descriptor.
- */
- public void addSubselect(EntityKey key, SubselectFetch subquery) {
- subselectsByEntityKey.put(key, subquery);
- }
-
- /**
- * After evicting or deleting an entity, we don't need to
- * know the query that was used to load it anymore (don't
- * call this after loading the entity, since we might still
- * need to load its collections)
- */
- public void removeSubselect(EntityKey key) {
- subselectsByEntityKey.remove(key);
- }
-
- /**
- * Clears all pending subselect fetches from the queue.
- * <p/>
- * Called after flushing.
- */
- public void clearSubselects() {
- subselectsByEntityKey.clear();
- }
-
- /**
- * If an EntityKey represents a batch loadable entity, add
- * it to the queue.
- * <p/>
- * Note that the contract here is such that any key passed in should
- * previously have been been checked for existence within the
- * {@link PersistenceContext}; failure to do so may cause the
- * referenced entity to be included in a batch even though it is
- * already associated with the {@link PersistenceContext}.
- */
- public void addBatchLoadableEntityKey(EntityKey key) {
- if ( key.isBatchLoadable() ) {
- batchLoadableEntityKeys.put( key, MARKER );
- }
- }
-
- /**
- * After evicting or deleting or loading an entity, we don't
- * need to batch fetch it anymore, remove it from the queue
- * if necessary
- */
- public void removeBatchLoadableEntityKey(EntityKey key) {
- if ( key.isBatchLoadable() ) batchLoadableEntityKeys.remove(key);
- }
-
- /**
- * Get a batch of uninitialized collection keys for a given role
- *
- * @param collectionPersister The persister for the collection role.
- * @param id A key that must be included in the batch fetch
- * @param batchSize the maximum number of keys to return
- * @return an array of collection keys, of length batchSize (padded with nulls)
- */
- public Serializable[] getCollectionBatch(
- final CollectionPersister collectionPersister,
- final Serializable id,
- final int batchSize,
- final EntityMode entityMode) {
- Serializable[] keys = new Serializable[batchSize];
- keys[0] = id;
- int i = 1;
- //int count = 0;
- int end = -1;
- boolean checkForEnd = false;
- // this only works because collection entries are kept in a sequenced
- // map by persistence context (maybe we should do like entities and
- // keep a separate sequences set...)
- Iterator iter = context.getCollectionEntries().entrySet().iterator(); //TODO: calling entrySet on an IdentityMap is SLOW!!
- while ( iter.hasNext() ) {
- Map.Entry me = (Map.Entry) iter.next();
-
- CollectionEntry ce = (CollectionEntry) me.getValue();
- PersistentCollection collection = (PersistentCollection) me.getKey();
- if ( !collection.wasInitialized() && ce.getLoadedPersister() == collectionPersister ) {
-
- if ( checkForEnd && i == end ) {
- return keys; //the first key found after the given key
- }
-
- //if ( end == -1 && count > batchSize*10 ) return keys; //try out ten batches, max
-
- final boolean isEqual = collectionPersister.getKeyType().isEqual(
- id,
- ce.getLoadedKey(),
- entityMode,
- collectionPersister.getFactory()
- );
-
- if ( isEqual ) {
- end = i;
- //checkForEnd = false;
- }
- else if ( !isCached( ce.getLoadedKey(), collectionPersister, entityMode ) ) {
- keys[i++] = ce.getLoadedKey();
- //count++;
- }
-
- if ( i == batchSize ) {
- i = 1; //end of array, start filling again from start
- if ( end != -1 ) {
- checkForEnd = true;
- }
- }
- }
-
- }
- return keys; //we ran out of keys to try
- }
-
- /**
- * Get a batch of unloaded identifiers for this class, using a slightly
- * complex algorithm that tries to grab keys registered immediately after
- * the given key.
- *
- * @param persister The persister for the entities being loaded.
- * @param id The identifier of the entity currently demanding load.
- * @param batchSize The maximum number of keys to return
- * @return an array of identifiers, of length batchSize (possibly padded with nulls)
- */
- public Serializable[] getEntityBatch(
- final EntityPersister persister,
- final Serializable id,
- final int batchSize,
- final EntityMode entityMode) {
- Serializable[] ids = new Serializable[batchSize];
- ids[0] = id; //first element of array is reserved for the actual instance we are loading!
- int i = 1;
- int end = -1;
- boolean checkForEnd = false;
-
- Iterator iter = batchLoadableEntityKeys.keySet().iterator();
- while ( iter.hasNext() ) {
- EntityKey key = (EntityKey) iter.next();
- if ( key.getEntityName().equals( persister.getEntityName() ) ) { //TODO: this needn't exclude subclasses...
- if ( checkForEnd && i == end ) {
- //the first id found after the given id
- return ids;
- }
- if ( persister.getIdentifierType().isEqual( id, key.getIdentifier(), entityMode ) ) {
- end = i;
- }
- else {
- if ( !isCached( key, persister, entityMode ) ) {
- ids[i++] = key.getIdentifier();
- }
- }
- if ( i == batchSize ) {
- i = 1; //end of array, start filling again from start
- if (end!=-1) checkForEnd = true;
- }
- }
- }
- return ids; //we ran out of ids to try
- }
-
- private boolean isCached(
- EntityKey entityKey,
- EntityPersister persister,
- EntityMode entityMode) {
- if ( persister.hasCache() ) {
- CacheKey key = new CacheKey(
- entityKey.getIdentifier(),
- persister.getIdentifierType(),
- entityKey.getEntityName(),
- entityMode,
- context.getSession().getFactory()
- );
- return persister.getCacheAccessStrategy().get( key, context.getSession().getTimestamp() ) != null;
- }
- return false;
- }
-
- private boolean isCached(
- Serializable collectionKey,
- CollectionPersister persister,
- EntityMode entityMode) {
- if ( persister.hasCache() ) {
- CacheKey cacheKey = new CacheKey(
- collectionKey,
- persister.getKeyType(),
- persister.getRole(),
- entityMode,
- context.getSession().getFactory()
- );
- return persister.getCacheAccessStrategy().get( cacheKey, context.getSession().getTimestamp() ) != null;
- }
- return false;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/BatchFetchQueue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,299 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.hibernate.EntityMode;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.util.MarkerObject;
+
+/**
+ * Tracks entity and collection keys that are available for batch
+ * fetching, and the queries which were used to load entities, which
+ * can be re-used as a subquery for loading owned collections.
+ *
+ * @author Gavin King
+ */
+public class BatchFetchQueue {
+
+ public static final Object MARKER = new MarkerObject( "MARKER" );
+
+ /**
+ * Defines a sequence of {@link EntityKey} elements that are currently
+ * elegible for batch-fetching.
+ * <p/>
+ * Even though this is a map, we only use the keys. A map was chosen in
+ * order to utilize a {@link LinkedHashMap} to maintain sequencing
+ * as well as uniqueness.
+ * <p/>
+ * TODO : this would be better as a SequencedReferenceSet, but no such beast exists!
+ */
+ private final Map batchLoadableEntityKeys = new LinkedHashMap(8);
+
+ /**
+ * A map of {@link SubselectFetch subselect-fetch descriptors} keyed by the
+ * {@link EntityKey) against which the descriptor is registered.
+ */
+ private final Map subselectsByEntityKey = new HashMap(8);
+
+ /**
+ * The owning persistence context.
+ */
+ private final PersistenceContext context;
+
+ /**
+ * Constructs a queue for the given context.
+ *
+ * @param context The owning context.
+ */
+ public BatchFetchQueue(PersistenceContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Clears all entries from this fetch queue.
+ */
+ public void clear() {
+ batchLoadableEntityKeys.clear();
+ subselectsByEntityKey.clear();
+ }
+
+ /**
+ * Retrieve the fetch descriptor associated with the given entity key.
+ *
+ * @param key The entity key for which to locate any defined subselect fetch.
+ * @return The fetch descriptor; may return null if no subselect fetch queued for
+ * this entity key.
+ */
+ public SubselectFetch getSubselect(EntityKey key) {
+ return (SubselectFetch) subselectsByEntityKey.get(key);
+ }
+
+ /**
+ * Adds a subselect fetch decriptor for the given entity key.
+ *
+ * @param key The entity for which to register the subselect fetch.
+ * @param subquery The fetch descriptor.
+ */
+ public void addSubselect(EntityKey key, SubselectFetch subquery) {
+ subselectsByEntityKey.put(key, subquery);
+ }
+
+ /**
+ * After evicting or deleting an entity, we don't need to
+ * know the query that was used to load it anymore (don't
+ * call this after loading the entity, since we might still
+ * need to load its collections)
+ */
+ public void removeSubselect(EntityKey key) {
+ subselectsByEntityKey.remove(key);
+ }
+
+ /**
+ * Clears all pending subselect fetches from the queue.
+ * <p/>
+ * Called after flushing.
+ */
+ public void clearSubselects() {
+ subselectsByEntityKey.clear();
+ }
+
+ /**
+ * If an EntityKey represents a batch loadable entity, add
+ * it to the queue.
+ * <p/>
+ * Note that the contract here is such that any key passed in should
+ * previously have been been checked for existence within the
+ * {@link PersistenceContext}; failure to do so may cause the
+ * referenced entity to be included in a batch even though it is
+ * already associated with the {@link PersistenceContext}.
+ */
+ public void addBatchLoadableEntityKey(EntityKey key) {
+ if ( key.isBatchLoadable() ) {
+ batchLoadableEntityKeys.put( key, MARKER );
+ }
+ }
+
+ /**
+ * After evicting or deleting or loading an entity, we don't
+ * need to batch fetch it anymore, remove it from the queue
+ * if necessary
+ */
+ public void removeBatchLoadableEntityKey(EntityKey key) {
+ if ( key.isBatchLoadable() ) batchLoadableEntityKeys.remove(key);
+ }
+
+ /**
+ * Get a batch of uninitialized collection keys for a given role
+ *
+ * @param collectionPersister The persister for the collection role.
+ * @param id A key that must be included in the batch fetch
+ * @param batchSize the maximum number of keys to return
+ * @return an array of collection keys, of length batchSize (padded with nulls)
+ */
+ public Serializable[] getCollectionBatch(
+ final CollectionPersister collectionPersister,
+ final Serializable id,
+ final int batchSize,
+ final EntityMode entityMode) {
+ Serializable[] keys = new Serializable[batchSize];
+ keys[0] = id;
+ int i = 1;
+ //int count = 0;
+ int end = -1;
+ boolean checkForEnd = false;
+ // this only works because collection entries are kept in a sequenced
+ // map by persistence context (maybe we should do like entities and
+ // keep a separate sequences set...)
+ Iterator iter = context.getCollectionEntries().entrySet().iterator(); //TODO: calling entrySet on an IdentityMap is SLOW!!
+ while ( iter.hasNext() ) {
+ Map.Entry me = (Map.Entry) iter.next();
+
+ CollectionEntry ce = (CollectionEntry) me.getValue();
+ PersistentCollection collection = (PersistentCollection) me.getKey();
+ if ( !collection.wasInitialized() && ce.getLoadedPersister() == collectionPersister ) {
+
+ if ( checkForEnd && i == end ) {
+ return keys; //the first key found after the given key
+ }
+
+ //if ( end == -1 && count > batchSize*10 ) return keys; //try out ten batches, max
+
+ final boolean isEqual = collectionPersister.getKeyType().isEqual(
+ id,
+ ce.getLoadedKey(),
+ entityMode,
+ collectionPersister.getFactory()
+ );
+
+ if ( isEqual ) {
+ end = i;
+ //checkForEnd = false;
+ }
+ else if ( !isCached( ce.getLoadedKey(), collectionPersister, entityMode ) ) {
+ keys[i++] = ce.getLoadedKey();
+ //count++;
+ }
+
+ if ( i == batchSize ) {
+ i = 1; //end of array, start filling again from start
+ if ( end != -1 ) {
+ checkForEnd = true;
+ }
+ }
+ }
+
+ }
+ return keys; //we ran out of keys to try
+ }
+
+ /**
+ * Get a batch of unloaded identifiers for this class, using a slightly
+ * complex algorithm that tries to grab keys registered immediately after
+ * the given key.
+ *
+ * @param persister The persister for the entities being loaded.
+ * @param id The identifier of the entity currently demanding load.
+ * @param batchSize The maximum number of keys to return
+ * @return an array of identifiers, of length batchSize (possibly padded with nulls)
+ */
+ public Serializable[] getEntityBatch(
+ final EntityPersister persister,
+ final Serializable id,
+ final int batchSize,
+ final EntityMode entityMode) {
+ Serializable[] ids = new Serializable[batchSize];
+ ids[0] = id; //first element of array is reserved for the actual instance we are loading!
+ int i = 1;
+ int end = -1;
+ boolean checkForEnd = false;
+
+ Iterator iter = batchLoadableEntityKeys.keySet().iterator();
+ while ( iter.hasNext() ) {
+ EntityKey key = (EntityKey) iter.next();
+ if ( key.getEntityName().equals( persister.getEntityName() ) ) { //TODO: this needn't exclude subclasses...
+ if ( checkForEnd && i == end ) {
+ //the first id found after the given id
+ return ids;
+ }
+ if ( persister.getIdentifierType().isEqual( id, key.getIdentifier(), entityMode ) ) {
+ end = i;
+ }
+ else {
+ if ( !isCached( key, persister, entityMode ) ) {
+ ids[i++] = key.getIdentifier();
+ }
+ }
+ if ( i == batchSize ) {
+ i = 1; //end of array, start filling again from start
+ if (end!=-1) checkForEnd = true;
+ }
+ }
+ }
+ return ids; //we ran out of ids to try
+ }
+
+ private boolean isCached(
+ EntityKey entityKey,
+ EntityPersister persister,
+ EntityMode entityMode) {
+ if ( persister.hasCache() ) {
+ CacheKey key = new CacheKey(
+ entityKey.getIdentifier(),
+ persister.getIdentifierType(),
+ entityKey.getEntityName(),
+ entityMode,
+ context.getSession().getFactory()
+ );
+ return persister.getCacheAccessStrategy().get( key, context.getSession().getTimestamp() ) != null;
+ }
+ return false;
+ }
+
+ private boolean isCached(
+ Serializable collectionKey,
+ CollectionPersister persister,
+ EntityMode entityMode) {
+ if ( persister.hasCache() ) {
+ CacheKey cacheKey = new CacheKey(
+ collectionKey,
+ persister.getKeyType(),
+ persister.getRole(),
+ entityMode,
+ context.getSession().getFactory()
+ );
+ return persister.getCacheAccessStrategy().get( cacheKey, context.getSession().getTimestamp() ) != null;
+ }
+ return false;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/Cascade.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,360 +0,0 @@
-//$Id: Cascade.java 10720 2006-11-06 11:35:40Z max.andersen(a)jboss.com $
-package org.hibernate.engine;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.event.EventSource;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.AbstractComponentType;
-import org.hibernate.type.AssociationType;
-import org.hibernate.type.CollectionType;
-import org.hibernate.type.EntityType;
-import org.hibernate.type.Type;
-import org.hibernate.util.CollectionHelper;
-
-/**
- * Delegate responsible for, in conjunction with the various
- * {@link CascadingAction actions}, implementing cascade processing.
- *
- * @author Gavin King
- * @see CascadingAction
- */
-public final class Cascade {
-
- /**
- * A cascade point that occurs just after the insertion of the parent entity and
- * just before deletion
- */
- public static final int AFTER_INSERT_BEFORE_DELETE = 1;
- /**
- * A cascade point that occurs just before the insertion of the parent entity and
- * just after deletion
- */
- public static final int BEFORE_INSERT_AFTER_DELETE = 2;
- /**
- * A cascade point that occurs just after the insertion of the parent entity and
- * just before deletion, inside a collection
- */
- public static final int AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION = 3;
- /**
- * A cascade point that occurs just after update of the parent entity
- */
- public static final int AFTER_UPDATE = 0;
- /**
- * A cascade point that occurs just before the session is flushed
- */
- public static final int BEFORE_FLUSH = 0;
- /**
- * A cascade point that occurs just after eviction of the parent entity from the
- * session cache
- */
- public static final int AFTER_EVICT = 0;
- /**
- * A cascade point that occurs just after locking a transient parent entity into the
- * session cache
- */
- public static final int BEFORE_REFRESH = 0;
- /**
- * A cascade point that occurs just after refreshing a parent entity
- */
- public static final int AFTER_LOCK = 0;
- /**
- * A cascade point that occurs just before merging from a transient parent entity into
- * the object in the session cache
- */
- public static final int BEFORE_MERGE = 0;
-
-
- private static final Logger log = LoggerFactory.getLogger( Cascade.class );
-
-
- private int cascadeTo;
- private EventSource eventSource;
- private CascadingAction action;
-
- public Cascade(final CascadingAction action, final int cascadeTo, final EventSource eventSource) {
- this.cascadeTo = cascadeTo;
- this.eventSource = eventSource;
- this.action = action;
- }
-
- /**
- * Cascade an action from the parent entity instance to all its children.
- *
- * @param persister The parent's entity persister
- * @param parent The parent reference.
- * @throws HibernateException
- */
- public void cascade(final EntityPersister persister, final Object parent)
- throws HibernateException {
- cascade( persister, parent, null );
- }
-
- /**
- * Cascade an action from the parent entity instance to all its children. This
- * form is typicaly called from within cascade actions.
- *
- * @param persister The parent's entity persister
- * @param parent The parent reference.
- * @param anything Anything ;) Typically some form of cascade-local cache
- * which is specific to each CascadingAction type
- * @throws HibernateException
- */
- public void cascade(final EntityPersister persister, final Object parent, final Object anything)
- throws HibernateException {
-
- if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt
- if ( log.isTraceEnabled() ) {
- log.trace( "processing cascade " + action + " for: " + persister.getEntityName() );
- }
-
- Type[] types = persister.getPropertyTypes();
- CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
- EntityMode entityMode = eventSource.getEntityMode();
- boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent, entityMode );
- for ( int i=0; i<types.length; i++) {
- CascadeStyle style = cascadeStyles[i];
- if ( hasUninitializedLazyProperties && persister.getPropertyLaziness()[i] && ! action.performOnLazyProperty() ) {
- //do nothing to avoid a lazy property initialization
- continue;
- }
-
- if ( style.doCascade( action ) ) {
- cascadeProperty(
- persister.getPropertyValue( parent, i, entityMode ),
- types[i],
- style,
- anything,
- false
- );
- }
- else if ( action.requiresNoCascadeChecking() ) {
- action.noCascade(
- eventSource,
- persister.getPropertyValue( parent, i, entityMode ),
- parent,
- persister,
- i
- );
- }
- }
-
- if ( log.isTraceEnabled() ) {
- log.trace( "done processing cascade " + action + " for: " + persister.getEntityName() );
- }
- }
- }
-
- /**
- * Cascade an action to the child or children
- */
- private void cascadeProperty(
- final Object child,
- final Type type,
- final CascadeStyle style,
- final Object anything,
- final boolean isCascadeDeleteEnabled) throws HibernateException {
-
- if (child!=null) {
- if ( type.isAssociationType() ) {
- AssociationType associationType = (AssociationType) type;
- if ( cascadeAssociationNow( associationType ) ) {
- cascadeAssociation(
- child,
- type,
- style,
- anything,
- isCascadeDeleteEnabled
- );
- }
- }
- else if ( type.isComponentType() ) {
- cascadeComponent( child, (AbstractComponentType) type, anything );
- }
- }
- }
-
- private boolean cascadeAssociationNow(AssociationType associationType) {
- return associationType.getForeignKeyDirection().cascadeNow(cascadeTo) &&
- ( eventSource.getEntityMode()!=EntityMode.DOM4J || associationType.isEmbeddedInXML() );
- }
-
- private void cascadeComponent(
- final Object child,
- final AbstractComponentType componentType,
- final Object anything) {
- Object[] children = componentType.getPropertyValues(child, eventSource);
- Type[] types = componentType.getSubtypes();
- for ( int i=0; i<types.length; i++ ) {
- CascadeStyle componentPropertyStyle = componentType.getCascadeStyle(i);
- if ( componentPropertyStyle.doCascade(action) ) {
- cascadeProperty(
- children[i],
- types[i],
- componentPropertyStyle,
- anything,
- false
- );
- }
- }
- }
-
- private void cascadeAssociation(
- final Object child,
- final Type type,
- final CascadeStyle style,
- final Object anything,
- final boolean isCascadeDeleteEnabled) {
- if ( type.isEntityType() || type.isAnyType() ) {
- cascadeToOne( child, type, style, anything, isCascadeDeleteEnabled );
- }
- else if ( type.isCollectionType() ) {
- cascadeCollection( child, style, anything, (CollectionType) type );
- }
- }
-
- /**
- * Cascade an action to a collection
- */
- private void cascadeCollection(
- final Object child,
- final CascadeStyle style,
- final Object anything,
- final CollectionType type) {
- CollectionPersister persister = eventSource.getFactory()
- .getCollectionPersister( type.getRole() );
- Type elemType = persister.getElementType();
-
- final int oldCascadeTo = cascadeTo;
- if ( cascadeTo==AFTER_INSERT_BEFORE_DELETE) {
- cascadeTo = AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION;
- }
-
- //cascade to current collection elements
- if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) {
- cascadeCollectionElements(
- child,
- type,
- style,
- elemType,
- anything,
- persister.isCascadeDeleteEnabled()
- );
- }
-
- cascadeTo = oldCascadeTo;
- }
-
- /**
- * Cascade an action to a to-one association or any type
- */
- private void cascadeToOne(
- final Object child,
- final Type type,
- final CascadeStyle style,
- final Object anything,
- final boolean isCascadeDeleteEnabled) {
- final String entityName = type.isEntityType()
- ? ( (EntityType) type ).getAssociatedEntityName()
- : null;
- if ( style.reallyDoCascade(action) ) { //not really necessary, but good for consistency...
- action.cascade(eventSource, child, entityName, anything, isCascadeDeleteEnabled);
- }
- }
-
- /**
- * Cascade to the collection elements
- */
- private void cascadeCollectionElements(
- final Object child,
- final CollectionType collectionType,
- final CascadeStyle style,
- final Type elemType,
- final Object anything,
- final boolean isCascadeDeleteEnabled) throws HibernateException {
- // we can't cascade to non-embedded elements
- boolean embeddedElements = eventSource.getEntityMode()!=EntityMode.DOM4J ||
- ( (EntityType) collectionType.getElementType( eventSource.getFactory() ) ).isEmbeddedInXML();
-
- boolean reallyDoCascade = style.reallyDoCascade(action) &&
- embeddedElements && child!=CollectionType.UNFETCHED_COLLECTION;
-
- if ( reallyDoCascade ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascade " + action + " for collection: " + collectionType.getRole() );
- }
-
- Iterator iter = action.getCascadableChildrenIterator(eventSource, collectionType, child);
- while ( iter.hasNext() ) {
- cascadeProperty(
- iter.next(),
- elemType,
- style,
- anything,
- isCascadeDeleteEnabled
- );
- }
-
- if ( log.isTraceEnabled() ) {
- log.trace( "done cascade " + action + " for collection: " + collectionType.getRole() );
- }
- }
-
- final boolean deleteOrphans = style.hasOrphanDelete() &&
- action.deleteOrphans() &&
- elemType.isEntityType() &&
- child instanceof PersistentCollection; //a newly instantiated collection can't have orphans
-
- if ( deleteOrphans ) { // handle orphaned entities!!
- if ( log.isTraceEnabled() ) {
- log.trace( "deleting orphans for collection: " + collectionType.getRole() );
- }
-
- // we can do the cast since orphan-delete does not apply to:
- // 1. newly instantiated collections
- // 2. arrays (we can't track orphans for detached arrays)
- final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() );
- deleteOrphans( entityName, (PersistentCollection) child );
-
- if ( log.isTraceEnabled() ) {
- log.trace( "done deleting orphans for collection: " + collectionType.getRole() );
- }
- }
- }
-
- /**
- * Delete any entities that were removed from the collection
- */
- private void deleteOrphans(String entityName, PersistentCollection pc) throws HibernateException {
- //TODO: suck this logic into the collection!
- final Collection orphans;
- if ( pc.wasInitialized() ) {
- CollectionEntry ce = eventSource.getPersistenceContext().getCollectionEntry(pc);
- orphans = ce==null ?
- CollectionHelper.EMPTY_COLLECTION :
- ce.getOrphans(entityName, pc);
- }
- else {
- orphans = pc.getQueuedOrphans(entityName);
- }
-
- final Iterator orphanIter = orphans.iterator();
- while ( orphanIter.hasNext() ) {
- Object orphan = orphanIter.next();
- if (orphan!=null) {
- if ( log.isTraceEnabled() ) {
- log.trace("deleting orphaned entity instance: " + entityName);
- }
- eventSource.delete( entityName, orphan, false, null );
- }
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/Cascade.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Cascade.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,383 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.event.EventSource;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.AbstractComponentType;
+import org.hibernate.type.AssociationType;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.EntityType;
+import org.hibernate.type.Type;
+import org.hibernate.util.CollectionHelper;
+
+/**
+ * Delegate responsible for, in conjunction with the various
+ * {@link CascadingAction actions}, implementing cascade processing.
+ *
+ * @author Gavin King
+ * @see CascadingAction
+ */
+public final class Cascade {
+
+ /**
+ * A cascade point that occurs just after the insertion of the parent entity and
+ * just before deletion
+ */
+ public static final int AFTER_INSERT_BEFORE_DELETE = 1;
+ /**
+ * A cascade point that occurs just before the insertion of the parent entity and
+ * just after deletion
+ */
+ public static final int BEFORE_INSERT_AFTER_DELETE = 2;
+ /**
+ * A cascade point that occurs just after the insertion of the parent entity and
+ * just before deletion, inside a collection
+ */
+ public static final int AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION = 3;
+ /**
+ * A cascade point that occurs just after update of the parent entity
+ */
+ public static final int AFTER_UPDATE = 0;
+ /**
+ * A cascade point that occurs just before the session is flushed
+ */
+ public static final int BEFORE_FLUSH = 0;
+ /**
+ * A cascade point that occurs just after eviction of the parent entity from the
+ * session cache
+ */
+ public static final int AFTER_EVICT = 0;
+ /**
+ * A cascade point that occurs just after locking a transient parent entity into the
+ * session cache
+ */
+ public static final int BEFORE_REFRESH = 0;
+ /**
+ * A cascade point that occurs just after refreshing a parent entity
+ */
+ public static final int AFTER_LOCK = 0;
+ /**
+ * A cascade point that occurs just before merging from a transient parent entity into
+ * the object in the session cache
+ */
+ public static final int BEFORE_MERGE = 0;
+
+
+ private static final Logger log = LoggerFactory.getLogger( Cascade.class );
+
+
+ private int cascadeTo;
+ private EventSource eventSource;
+ private CascadingAction action;
+
+ public Cascade(final CascadingAction action, final int cascadeTo, final EventSource eventSource) {
+ this.cascadeTo = cascadeTo;
+ this.eventSource = eventSource;
+ this.action = action;
+ }
+
+ /**
+ * Cascade an action from the parent entity instance to all its children.
+ *
+ * @param persister The parent's entity persister
+ * @param parent The parent reference.
+ * @throws HibernateException
+ */
+ public void cascade(final EntityPersister persister, final Object parent)
+ throws HibernateException {
+ cascade( persister, parent, null );
+ }
+
+ /**
+ * Cascade an action from the parent entity instance to all its children. This
+ * form is typicaly called from within cascade actions.
+ *
+ * @param persister The parent's entity persister
+ * @param parent The parent reference.
+ * @param anything Anything ;) Typically some form of cascade-local cache
+ * which is specific to each CascadingAction type
+ * @throws HibernateException
+ */
+ public void cascade(final EntityPersister persister, final Object parent, final Object anything)
+ throws HibernateException {
+
+ if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt
+ if ( log.isTraceEnabled() ) {
+ log.trace( "processing cascade " + action + " for: " + persister.getEntityName() );
+ }
+
+ Type[] types = persister.getPropertyTypes();
+ CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles();
+ EntityMode entityMode = eventSource.getEntityMode();
+ boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent, entityMode );
+ for ( int i=0; i<types.length; i++) {
+ CascadeStyle style = cascadeStyles[i];
+ if ( hasUninitializedLazyProperties && persister.getPropertyLaziness()[i] && ! action.performOnLazyProperty() ) {
+ //do nothing to avoid a lazy property initialization
+ continue;
+ }
+
+ if ( style.doCascade( action ) ) {
+ cascadeProperty(
+ persister.getPropertyValue( parent, i, entityMode ),
+ types[i],
+ style,
+ anything,
+ false
+ );
+ }
+ else if ( action.requiresNoCascadeChecking() ) {
+ action.noCascade(
+ eventSource,
+ persister.getPropertyValue( parent, i, entityMode ),
+ parent,
+ persister,
+ i
+ );
+ }
+ }
+
+ if ( log.isTraceEnabled() ) {
+ log.trace( "done processing cascade " + action + " for: " + persister.getEntityName() );
+ }
+ }
+ }
+
+ /**
+ * Cascade an action to the child or children
+ */
+ private void cascadeProperty(
+ final Object child,
+ final Type type,
+ final CascadeStyle style,
+ final Object anything,
+ final boolean isCascadeDeleteEnabled) throws HibernateException {
+
+ if (child!=null) {
+ if ( type.isAssociationType() ) {
+ AssociationType associationType = (AssociationType) type;
+ if ( cascadeAssociationNow( associationType ) ) {
+ cascadeAssociation(
+ child,
+ type,
+ style,
+ anything,
+ isCascadeDeleteEnabled
+ );
+ }
+ }
+ else if ( type.isComponentType() ) {
+ cascadeComponent( child, (AbstractComponentType) type, anything );
+ }
+ }
+ }
+
+ private boolean cascadeAssociationNow(AssociationType associationType) {
+ return associationType.getForeignKeyDirection().cascadeNow(cascadeTo) &&
+ ( eventSource.getEntityMode()!=EntityMode.DOM4J || associationType.isEmbeddedInXML() );
+ }
+
+ private void cascadeComponent(
+ final Object child,
+ final AbstractComponentType componentType,
+ final Object anything) {
+ Object[] children = componentType.getPropertyValues(child, eventSource);
+ Type[] types = componentType.getSubtypes();
+ for ( int i=0; i<types.length; i++ ) {
+ CascadeStyle componentPropertyStyle = componentType.getCascadeStyle(i);
+ if ( componentPropertyStyle.doCascade(action) ) {
+ cascadeProperty(
+ children[i],
+ types[i],
+ componentPropertyStyle,
+ anything,
+ false
+ );
+ }
+ }
+ }
+
+ private void cascadeAssociation(
+ final Object child,
+ final Type type,
+ final CascadeStyle style,
+ final Object anything,
+ final boolean isCascadeDeleteEnabled) {
+ if ( type.isEntityType() || type.isAnyType() ) {
+ cascadeToOne( child, type, style, anything, isCascadeDeleteEnabled );
+ }
+ else if ( type.isCollectionType() ) {
+ cascadeCollection( child, style, anything, (CollectionType) type );
+ }
+ }
+
+ /**
+ * Cascade an action to a collection
+ */
+ private void cascadeCollection(
+ final Object child,
+ final CascadeStyle style,
+ final Object anything,
+ final CollectionType type) {
+ CollectionPersister persister = eventSource.getFactory()
+ .getCollectionPersister( type.getRole() );
+ Type elemType = persister.getElementType();
+
+ final int oldCascadeTo = cascadeTo;
+ if ( cascadeTo==AFTER_INSERT_BEFORE_DELETE) {
+ cascadeTo = AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION;
+ }
+
+ //cascade to current collection elements
+ if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) {
+ cascadeCollectionElements(
+ child,
+ type,
+ style,
+ elemType,
+ anything,
+ persister.isCascadeDeleteEnabled()
+ );
+ }
+
+ cascadeTo = oldCascadeTo;
+ }
+
+ /**
+ * Cascade an action to a to-one association or any type
+ */
+ private void cascadeToOne(
+ final Object child,
+ final Type type,
+ final CascadeStyle style,
+ final Object anything,
+ final boolean isCascadeDeleteEnabled) {
+ final String entityName = type.isEntityType()
+ ? ( (EntityType) type ).getAssociatedEntityName()
+ : null;
+ if ( style.reallyDoCascade(action) ) { //not really necessary, but good for consistency...
+ action.cascade(eventSource, child, entityName, anything, isCascadeDeleteEnabled);
+ }
+ }
+
+ /**
+ * Cascade to the collection elements
+ */
+ private void cascadeCollectionElements(
+ final Object child,
+ final CollectionType collectionType,
+ final CascadeStyle style,
+ final Type elemType,
+ final Object anything,
+ final boolean isCascadeDeleteEnabled) throws HibernateException {
+ // we can't cascade to non-embedded elements
+ boolean embeddedElements = eventSource.getEntityMode()!=EntityMode.DOM4J ||
+ ( (EntityType) collectionType.getElementType( eventSource.getFactory() ) ).isEmbeddedInXML();
+
+ boolean reallyDoCascade = style.reallyDoCascade(action) &&
+ embeddedElements && child!=CollectionType.UNFETCHED_COLLECTION;
+
+ if ( reallyDoCascade ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascade " + action + " for collection: " + collectionType.getRole() );
+ }
+
+ Iterator iter = action.getCascadableChildrenIterator(eventSource, collectionType, child);
+ while ( iter.hasNext() ) {
+ cascadeProperty(
+ iter.next(),
+ elemType,
+ style,
+ anything,
+ isCascadeDeleteEnabled
+ );
+ }
+
+ if ( log.isTraceEnabled() ) {
+ log.trace( "done cascade " + action + " for collection: " + collectionType.getRole() );
+ }
+ }
+
+ final boolean deleteOrphans = style.hasOrphanDelete() &&
+ action.deleteOrphans() &&
+ elemType.isEntityType() &&
+ child instanceof PersistentCollection; //a newly instantiated collection can't have orphans
+
+ if ( deleteOrphans ) { // handle orphaned entities!!
+ if ( log.isTraceEnabled() ) {
+ log.trace( "deleting orphans for collection: " + collectionType.getRole() );
+ }
+
+ // we can do the cast since orphan-delete does not apply to:
+ // 1. newly instantiated collections
+ // 2. arrays (we can't track orphans for detached arrays)
+ final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() );
+ deleteOrphans( entityName, (PersistentCollection) child );
+
+ if ( log.isTraceEnabled() ) {
+ log.trace( "done deleting orphans for collection: " + collectionType.getRole() );
+ }
+ }
+ }
+
+ /**
+ * Delete any entities that were removed from the collection
+ */
+ private void deleteOrphans(String entityName, PersistentCollection pc) throws HibernateException {
+ //TODO: suck this logic into the collection!
+ final Collection orphans;
+ if ( pc.wasInitialized() ) {
+ CollectionEntry ce = eventSource.getPersistenceContext().getCollectionEntry(pc);
+ orphans = ce==null ?
+ CollectionHelper.EMPTY_COLLECTION :
+ ce.getOrphans(entityName, pc);
+ }
+ else {
+ orphans = pc.getQueuedOrphans(entityName);
+ }
+
+ final Iterator orphanIter = orphans.iterator();
+ while ( orphanIter.hasNext() ) {
+ Object orphan = orphanIter.next();
+ if (orphan!=null) {
+ if ( log.isTraceEnabled() ) {
+ log.trace("deleting orphaned entity instance: " + entityName);
+ }
+ eventSource.delete( entityName, orphan, false, null );
+ }
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/CascadeStyle.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,275 +0,0 @@
-//$Id: CascadeStyle.java 10799 2006-11-13 19:34:33Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.MappingException;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * A contract for defining the aspects of cascading various persistence actions.
- *
- * @see CascadingAction
- *
- * @author Gavin King
- */
-public abstract class CascadeStyle implements Serializable {
-
- /**
- * For this style, should the given action be cascaded?
- *
- * @param action The action to be checked for cascade-ability.
- * @return True if the action should be cascaded under this style; false otherwise.
- */
- public abstract boolean doCascade(CascadingAction action);
-
- /**
- * Probably more aptly named something like doCascadeToCollectionElements(); it is
- * however used from both the collection and to-one logic branches...
- * <p/>
- * For this style, should the given action really be cascaded? The default
- * implementation is simply to return {@link #doCascade}; for certain
- * styles (currently only delete-orphan), however, we need to be able to
- * control this seperately.
- *
- * @param action The action to be checked for cascade-ability.
- * @return True if the action should be really cascaded under this style;
- * false otherwise.
- */
- public boolean reallyDoCascade(CascadingAction action) {
- return doCascade(action);
- }
-
- /**
- * Do we need to delete orphaned collection elements?
- *
- * @return True if this style need to account for orphan delete
- * operations; false othwerwise.
- */
- public boolean hasOrphanDelete() {
- return false;
- }
-
- public static final class MultipleCascadeStyle extends CascadeStyle {
- private final CascadeStyle[] styles;
- public MultipleCascadeStyle(CascadeStyle[] styles) {
- this.styles = styles;
- }
- public boolean doCascade(CascadingAction action) {
- for (int i=0; i<styles.length; i++) {
- if ( styles[i].doCascade(action) ) return true;
- }
- return false;
- }
- public boolean reallyDoCascade(CascadingAction action) {
- for (int i=0; i<styles.length; i++) {
- if ( styles[i].reallyDoCascade(action) ) return true;
- }
- return false;
- }
- public boolean hasOrphanDelete() {
- for (int i=0; i<styles.length; i++) {
- if ( styles[i].hasOrphanDelete() ) return true;
- }
- return false;
- }
- public String toString() {
- return ArrayHelper.toString(styles);
- }
- }
-
- /**
- * save / delete / update / evict / lock / replicate / merge / persist + delete orphans
- */
- public static final CascadeStyle ALL_DELETE_ORPHAN = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return true;
- }
- public boolean hasOrphanDelete() {
- return true;
- }
- public String toString() {
- return "STYLE_ALL_DELETE_ORPHAN";
- }
- };
-
- /**
- * save / delete / update / evict / lock / replicate / merge / persist
- */
- public static final CascadeStyle ALL = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return true;
- }
- public String toString() {
- return "STYLE_ALL";
- }
- };
-
- /**
- * save / update
- */
- public static final CascadeStyle UPDATE = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.SAVE_UPDATE || action==CascadingAction.SAVE_UPDATE_COPY;
- }
- public String toString() {
- return "STYLE_SAVE_UPDATE";
- }
- };
-
- /**
- * lock
- */
- public static final CascadeStyle LOCK = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.LOCK;
- }
- public String toString() {
- return "STYLE_LOCK";
- }
- };
-
- /**
- * refresh
- */
- public static final CascadeStyle REFRESH = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.REFRESH;
- }
- public String toString() {
- return "STYLE_REFRESH";
- }
- };
-
- /**
- * evict
- */
- public static final CascadeStyle EVICT = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.EVICT;
- }
- public String toString() {
- return "STYLE_EVICT";
- }
- };
-
- /**
- * replicate
- */
- public static final CascadeStyle REPLICATE = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.REPLICATE;
- }
- public String toString() {
- return "STYLE_REPLICATE";
- }
- };
- /**
- * merge
- */
- public static final CascadeStyle MERGE = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.MERGE;
- }
- public String toString() {
- return "STYLE_MERGE";
- }
- };
-
- /**
- * create
- */
- public static final CascadeStyle PERSIST = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.PERSIST
- || action==CascadingAction.PERSIST_ON_FLUSH;
- }
- public String toString() {
- return "STYLE_PERSIST";
- }
- };
-
- /**
- * delete
- */
- public static final CascadeStyle DELETE = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.DELETE;
- }
- public String toString() {
- return "STYLE_DELETE";
- }
- };
-
- /**
- * delete + delete orphans
- */
- public static final CascadeStyle DELETE_ORPHAN = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return action==CascadingAction.DELETE || action==CascadingAction.SAVE_UPDATE;
- }
- public boolean reallyDoCascade(CascadingAction action) {
- return action==CascadingAction.DELETE;
- }
- public boolean hasOrphanDelete() {
- return true;
- }
- public String toString() {
- return "STYLE_DELETE_ORPHAN";
- }
- };
-
- /**
- * no cascades
- */
- public static final CascadeStyle NONE = new CascadeStyle() {
- public boolean doCascade(CascadingAction action) {
- return false;
- }
- public String toString() {
- return "STYLE_NONE";
- }
- };
-
- /**
- * package-protected constructor
- */
- CascadeStyle() {
- }
-
- static final Map STYLES = new HashMap();
-
- static {
- STYLES.put( "all", ALL );
- STYLES.put( "all-delete-orphan", ALL_DELETE_ORPHAN );
- STYLES.put( "save-update", UPDATE );
- STYLES.put( "persist", PERSIST );
- STYLES.put( "merge", MERGE );
- STYLES.put( "lock", LOCK );
- STYLES.put( "refresh", REFRESH );
- STYLES.put( "replicate", REPLICATE );
- STYLES.put( "evict", EVICT );
- STYLES.put( "delete", DELETE );
- STYLES.put( "remove", DELETE ); // adds remove as a sort-of alias for delete...
- STYLES.put( "delete-orphan", DELETE_ORPHAN );
- STYLES.put( "none", NONE );
- }
-
- /**
- * Factory method for obtaining named cascade styles
- *
- * @param cascade The named cascade style name.
- * @return The appropriate CascadeStyle
- */
- public static CascadeStyle getCascadeStyle(String cascade) {
- CascadeStyle style = (CascadeStyle) STYLES.get(cascade);
- if (style==null) {
- throw new MappingException("Unsupported cascade style: " + cascade);
- }
- else {
- return style;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/CascadeStyle.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadeStyle.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,298 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.MappingException;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * A contract for defining the aspects of cascading various persistence actions.
+ *
+ * @see CascadingAction
+ *
+ * @author Gavin King
+ */
+public abstract class CascadeStyle implements Serializable {
+
+ /**
+ * For this style, should the given action be cascaded?
+ *
+ * @param action The action to be checked for cascade-ability.
+ * @return True if the action should be cascaded under this style; false otherwise.
+ */
+ public abstract boolean doCascade(CascadingAction action);
+
+ /**
+ * Probably more aptly named something like doCascadeToCollectionElements(); it is
+ * however used from both the collection and to-one logic branches...
+ * <p/>
+ * For this style, should the given action really be cascaded? The default
+ * implementation is simply to return {@link #doCascade}; for certain
+ * styles (currently only delete-orphan), however, we need to be able to
+ * control this seperately.
+ *
+ * @param action The action to be checked for cascade-ability.
+ * @return True if the action should be really cascaded under this style;
+ * false otherwise.
+ */
+ public boolean reallyDoCascade(CascadingAction action) {
+ return doCascade(action);
+ }
+
+ /**
+ * Do we need to delete orphaned collection elements?
+ *
+ * @return True if this style need to account for orphan delete
+ * operations; false othwerwise.
+ */
+ public boolean hasOrphanDelete() {
+ return false;
+ }
+
+ public static final class MultipleCascadeStyle extends CascadeStyle {
+ private final CascadeStyle[] styles;
+ public MultipleCascadeStyle(CascadeStyle[] styles) {
+ this.styles = styles;
+ }
+ public boolean doCascade(CascadingAction action) {
+ for (int i=0; i<styles.length; i++) {
+ if ( styles[i].doCascade(action) ) return true;
+ }
+ return false;
+ }
+ public boolean reallyDoCascade(CascadingAction action) {
+ for (int i=0; i<styles.length; i++) {
+ if ( styles[i].reallyDoCascade(action) ) return true;
+ }
+ return false;
+ }
+ public boolean hasOrphanDelete() {
+ for (int i=0; i<styles.length; i++) {
+ if ( styles[i].hasOrphanDelete() ) return true;
+ }
+ return false;
+ }
+ public String toString() {
+ return ArrayHelper.toString(styles);
+ }
+ }
+
+ /**
+ * save / delete / update / evict / lock / replicate / merge / persist + delete orphans
+ */
+ public static final CascadeStyle ALL_DELETE_ORPHAN = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return true;
+ }
+ public boolean hasOrphanDelete() {
+ return true;
+ }
+ public String toString() {
+ return "STYLE_ALL_DELETE_ORPHAN";
+ }
+ };
+
+ /**
+ * save / delete / update / evict / lock / replicate / merge / persist
+ */
+ public static final CascadeStyle ALL = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return true;
+ }
+ public String toString() {
+ return "STYLE_ALL";
+ }
+ };
+
+ /**
+ * save / update
+ */
+ public static final CascadeStyle UPDATE = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.SAVE_UPDATE || action==CascadingAction.SAVE_UPDATE_COPY;
+ }
+ public String toString() {
+ return "STYLE_SAVE_UPDATE";
+ }
+ };
+
+ /**
+ * lock
+ */
+ public static final CascadeStyle LOCK = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.LOCK;
+ }
+ public String toString() {
+ return "STYLE_LOCK";
+ }
+ };
+
+ /**
+ * refresh
+ */
+ public static final CascadeStyle REFRESH = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.REFRESH;
+ }
+ public String toString() {
+ return "STYLE_REFRESH";
+ }
+ };
+
+ /**
+ * evict
+ */
+ public static final CascadeStyle EVICT = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.EVICT;
+ }
+ public String toString() {
+ return "STYLE_EVICT";
+ }
+ };
+
+ /**
+ * replicate
+ */
+ public static final CascadeStyle REPLICATE = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.REPLICATE;
+ }
+ public String toString() {
+ return "STYLE_REPLICATE";
+ }
+ };
+ /**
+ * merge
+ */
+ public static final CascadeStyle MERGE = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.MERGE;
+ }
+ public String toString() {
+ return "STYLE_MERGE";
+ }
+ };
+
+ /**
+ * create
+ */
+ public static final CascadeStyle PERSIST = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.PERSIST
+ || action==CascadingAction.PERSIST_ON_FLUSH;
+ }
+ public String toString() {
+ return "STYLE_PERSIST";
+ }
+ };
+
+ /**
+ * delete
+ */
+ public static final CascadeStyle DELETE = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.DELETE;
+ }
+ public String toString() {
+ return "STYLE_DELETE";
+ }
+ };
+
+ /**
+ * delete + delete orphans
+ */
+ public static final CascadeStyle DELETE_ORPHAN = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return action==CascadingAction.DELETE || action==CascadingAction.SAVE_UPDATE;
+ }
+ public boolean reallyDoCascade(CascadingAction action) {
+ return action==CascadingAction.DELETE;
+ }
+ public boolean hasOrphanDelete() {
+ return true;
+ }
+ public String toString() {
+ return "STYLE_DELETE_ORPHAN";
+ }
+ };
+
+ /**
+ * no cascades
+ */
+ public static final CascadeStyle NONE = new CascadeStyle() {
+ public boolean doCascade(CascadingAction action) {
+ return false;
+ }
+ public String toString() {
+ return "STYLE_NONE";
+ }
+ };
+
+ /**
+ * package-protected constructor
+ */
+ CascadeStyle() {
+ }
+
+ static final Map STYLES = new HashMap();
+
+ static {
+ STYLES.put( "all", ALL );
+ STYLES.put( "all-delete-orphan", ALL_DELETE_ORPHAN );
+ STYLES.put( "save-update", UPDATE );
+ STYLES.put( "persist", PERSIST );
+ STYLES.put( "merge", MERGE );
+ STYLES.put( "lock", LOCK );
+ STYLES.put( "refresh", REFRESH );
+ STYLES.put( "replicate", REPLICATE );
+ STYLES.put( "evict", EVICT );
+ STYLES.put( "delete", DELETE );
+ STYLES.put( "remove", DELETE ); // adds remove as a sort-of alias for delete...
+ STYLES.put( "delete-orphan", DELETE_ORPHAN );
+ STYLES.put( "none", NONE );
+ }
+
+ /**
+ * Factory method for obtaining named cascade styles
+ *
+ * @param cascade The named cascade style name.
+ * @return The appropriate CascadeStyle
+ */
+ public static CascadeStyle getCascadeStyle(String cascade) {
+ CascadeStyle style = (CascadeStyle) STYLES.get(cascade);
+ if (style==null) {
+ throw new MappingException("Unsupported cascade style: " + cascade);
+ }
+ else {
+ return style;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,438 +0,0 @@
-//$Id: CascadingAction.java 10451 2006-09-05 06:53:46Z epbernard $
-package org.hibernate.engine;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.ReplicationMode;
-import org.hibernate.TransientObjectException;
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.event.EventSource;
-import org.hibernate.type.CollectionType;
-import org.hibernate.type.Type;
-import org.hibernate.type.EntityType;
-
-/**
- * A session action that may be cascaded from parent entity to its children
- *
- * @author Gavin King
- */
-public abstract class CascadingAction {
-
- private static final Logger log = LoggerFactory.getLogger( CascadingAction.class );
-
-
- // the CascadingAction contract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * protected constructor
- */
- CascadingAction() {
- }
-
- /**
- * Cascade the action to the child object.
- *
- * @param session The session within which the cascade is occuring.
- * @param child The child to which cascading should be performed.
- * @param entityName The child's entity name
- * @param anything Anything ;) Typically some form of cascade-local cache
- * which is specific to each CascadingAction type
- * @param isCascadeDeleteEnabled Are cascading deletes enabled.
- * @throws HibernateException
- */
- public abstract void cascade(
- EventSource session,
- Object child,
- String entityName,
- Object anything,
- boolean isCascadeDeleteEnabled) throws HibernateException;
-
- /**
- * Given a collection, get an iterator of the children upon which the
- * current cascading action should be visited.
- *
- * @param session The session within which the cascade is occuring.
- * @param collectionType The mapping type of the collection.
- * @param collection The collection instance.
- * @return The children iterator.
- */
- public abstract Iterator getCascadableChildrenIterator(
- EventSource session,
- CollectionType collectionType,
- Object collection);
-
- /**
- * Does this action potentially extrapolate to orphan deletes?
- *
- * @return True if this action can lead to deletions of orphans.
- */
- public abstract boolean deleteOrphans();
-
-
- /**
- * Does the specified cascading action require verification of no cascade validity?
- *
- * @return True if this action requires no-cascade verification; false otherwise.
- */
- public boolean requiresNoCascadeChecking() {
- return false;
- }
-
- /**
- * Called (in the case of {@link #requiresNoCascadeChecking} returning true) to validate
- * that no cascade on the given property is considered a valid semantic.
- *
- * @param session The session witin which the cascade is occurring.
- * @param child The property value
- * @param parent The property value owner
- * @param persister The entity persister for the owner
- * @param propertyIndex The index of the property within the owner.
- */
- public void noCascade(EventSource session, Object child, Object parent, EntityPersister persister, int propertyIndex) {
- }
-
- /**
- * Should this action be performed (or noCascade consulted) in the case of lazy properties.
- */
- public boolean performOnLazyProperty() {
- return true;
- }
-
-
- // the CascadingAction implementations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * @see org.hibernate.Session#delete(Object)
- */
- public static final CascadingAction DELETE = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace("cascading to delete: " + entityName);
- }
- session.delete( entityName, child, isCascadeDeleteEnabled, ( Set ) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // delete does cascade to uninitialized collections
- return CascadingAction.getAllElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- // orphans should be deleted during delete
- return true;
- }
- public String toString() {
- return "ACTION_DELETE";
- }
- };
-
- /**
- * @see org.hibernate.Session#lock(Object, LockMode)
- */
- public static final CascadingAction LOCK = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to lock: " + entityName );
- }
- session.lock( entityName, child, LockMode.NONE/*(LockMode) anything*/ );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // lock doesn't cascade to uninitialized collections
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- //TODO: should orphans really be deleted during lock???
- return false;
- }
- public String toString() {
- return "ACTION_LOCK";
- }
- };
-
- /**
- * @see org.hibernate.Session#refresh(Object)
- */
- public static final CascadingAction REFRESH = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to refresh: " + entityName );
- }
- session.refresh( child, (Map) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // refresh doesn't cascade to uninitialized collections
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- return false;
- }
- public String toString() {
- return "ACTION_REFRESH";
- }
- };
-
- /**
- * @see org.hibernate.Session#evict(Object)
- */
- public static final CascadingAction EVICT = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to evict: " + entityName );
- }
- session.evict(child);
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // evicts don't cascade to uninitialized collections
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- return false;
- }
- public boolean performOnLazyProperty() {
- return false;
- }
- public String toString() {
- return "ACTION_EVICT";
- }
- };
-
- /**
- * @see org.hibernate.Session#saveOrUpdate(Object)
- */
- public static final CascadingAction SAVE_UPDATE = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to saveOrUpdate: " + entityName );
- }
- session.saveOrUpdate(entityName, child);
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // saves / updates don't cascade to uninitialized collections
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- // orphans should be deleted during save/update
- return true;
- }
- public boolean performOnLazyProperty() {
- return false;
- }
- public String toString() {
- return "ACTION_SAVE_UPDATE";
- }
- };
-
- /**
- * @see org.hibernate.Session#merge(Object)
- */
- public static final CascadingAction MERGE = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to merge: " + entityName );
- }
- session.merge( entityName, child, (Map) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // merges don't cascade to uninitialized collections
-// //TODO: perhaps this does need to cascade after all....
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- // orphans should not be deleted during merge??
- return false;
- }
- public String toString() {
- return "ACTION_MERGE";
- }
- };
-
- /**
- * @see org.hibernate.classic.Session#saveOrUpdateCopy(Object)
- */
- public static final CascadingAction SAVE_UPDATE_COPY = new CascadingAction() {
- // for deprecated saveOrUpdateCopy()
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to saveOrUpdateCopy: " + entityName );
- }
- session.saveOrUpdateCopy( entityName, child, (Map) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // saves / updates don't cascade to uninitialized collections
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- // orphans should not be deleted during copy??
- return false;
- }
- public String toString() {
- return "ACTION_SAVE_UPDATE_COPY";
- }
- };
-
- /**
- * @see org.hibernate.Session#persist(Object)
- */
- public static final CascadingAction PERSIST = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to persist: " + entityName );
- }
- session.persist( entityName, child, (Map) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // persists don't cascade to uninitialized collections
- return CascadingAction.getAllElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- return false;
- }
- public boolean performOnLazyProperty() {
- return false;
- }
- public String toString() {
- return "ACTION_PERSIST";
- }
- };
-
- /**
- * Execute persist during flush time
- *
- * @see org.hibernate.Session#persist(Object)
- */
- public static final CascadingAction PERSIST_ON_FLUSH = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to persistOnFlush: " + entityName );
- }
- session.persistOnFlush( entityName, child, (Map) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // persists don't cascade to uninitialized collections
- return CascadingAction.getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- return true;
- }
- public boolean requiresNoCascadeChecking() {
- return true;
- }
- public void noCascade(
- EventSource session,
- Object child,
- Object parent,
- EntityPersister persister,
- int propertyIndex) {
- if ( child == null ) {
- return;
- }
- Type type = persister.getPropertyTypes()[propertyIndex];
- if ( type.isEntityType() ) {
- String childEntityName = ( ( EntityType ) type ).getAssociatedEntityName( session.getFactory() );
-
- if ( ! isInManagedState( child, session )
- && ! ( child instanceof HibernateProxy ) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
- && ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
- String parentEntiytName = persister.getEntityName();
- String propertyName = persister.getPropertyNames()[propertyIndex];
- throw new TransientObjectException(
- "object references an unsaved transient instance - " +
- "save the transient instance before flushing: " +
- parentEntiytName + "." + propertyName + " -> " + childEntityName
- );
-
- }
- }
- }
- public boolean performOnLazyProperty() {
- return false;
- }
-
- private boolean isInManagedState(Object child, EventSource session) {
- EntityEntry entry = session.getPersistenceContext().getEntry( child );
- return entry != null && (entry.getStatus() == Status.MANAGED || entry.getStatus() == Status.READ_ONLY);
- }
-
- public String toString() {
- return "ACTION_PERSIST_ON_FLUSH";
- }
- };
-
- /**
- * @see org.hibernate.Session#replicate(Object, org.hibernate.ReplicationMode)
- */
- public static final CascadingAction REPLICATE = new CascadingAction() {
- public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "cascading to replicate: " + entityName );
- }
- session.replicate( entityName, child, (ReplicationMode) anything );
- }
- public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
- // replicate does cascade to uninitialized collections
- return getLoadedElementsIterator(session, collectionType, collection);
- }
- public boolean deleteOrphans() {
- return false; //I suppose?
- }
- public String toString() {
- return "ACTION_REPLICATE";
- }
- };
-
-
- // static helper methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Given a collection, get an iterator of all its children, loading them
- * from the database if necessary.
- *
- * @param session The session within which the cascade is occuring.
- * @param collectionType The mapping type of the collection.
- * @param collection The collection instance.
- * @return The children iterator.
- */
- private static Iterator getAllElementsIterator(
- EventSource session,
- CollectionType collectionType,
- Object collection) {
- return collectionType.getElementsIterator( collection, session );
- }
-
- /**
- * Iterate just the elements of the collection that are already there. Don't load
- * any new elements from the database.
- */
- public static Iterator getLoadedElementsIterator(SessionImplementor session, CollectionType collectionType, Object collection) {
- if ( collectionIsInitialized(collection) ) {
- // handles arrays and newly instantiated collections
- return collectionType.getElementsIterator(collection, session);
- }
- else {
- // does not handle arrays (thats ok, cos they can't be lazy)
- // or newly instantiated collections, so we can do the cast
- return ( (PersistentCollection) collection ).queuedAdditionIterator();
- }
- }
-
- private static boolean collectionIsInitialized(Object collection) {
- return !(collection instanceof PersistentCollection) || ( (PersistentCollection) collection ).wasInitialized();
- }
-
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CascadingAction.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,461 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.ReplicationMode;
+import org.hibernate.TransientObjectException;
+import org.hibernate.proxy.HibernateProxy;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.event.EventSource;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.Type;
+import org.hibernate.type.EntityType;
+
+/**
+ * A session action that may be cascaded from parent entity to its children
+ *
+ * @author Gavin King
+ */
+public abstract class CascadingAction {
+
+ private static final Logger log = LoggerFactory.getLogger( CascadingAction.class );
+
+
+ // the CascadingAction contract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * protected constructor
+ */
+ CascadingAction() {
+ }
+
+ /**
+ * Cascade the action to the child object.
+ *
+ * @param session The session within which the cascade is occuring.
+ * @param child The child to which cascading should be performed.
+ * @param entityName The child's entity name
+ * @param anything Anything ;) Typically some form of cascade-local cache
+ * which is specific to each CascadingAction type
+ * @param isCascadeDeleteEnabled Are cascading deletes enabled.
+ * @throws HibernateException
+ */
+ public abstract void cascade(
+ EventSource session,
+ Object child,
+ String entityName,
+ Object anything,
+ boolean isCascadeDeleteEnabled) throws HibernateException;
+
+ /**
+ * Given a collection, get an iterator of the children upon which the
+ * current cascading action should be visited.
+ *
+ * @param session The session within which the cascade is occuring.
+ * @param collectionType The mapping type of the collection.
+ * @param collection The collection instance.
+ * @return The children iterator.
+ */
+ public abstract Iterator getCascadableChildrenIterator(
+ EventSource session,
+ CollectionType collectionType,
+ Object collection);
+
+ /**
+ * Does this action potentially extrapolate to orphan deletes?
+ *
+ * @return True if this action can lead to deletions of orphans.
+ */
+ public abstract boolean deleteOrphans();
+
+
+ /**
+ * Does the specified cascading action require verification of no cascade validity?
+ *
+ * @return True if this action requires no-cascade verification; false otherwise.
+ */
+ public boolean requiresNoCascadeChecking() {
+ return false;
+ }
+
+ /**
+ * Called (in the case of {@link #requiresNoCascadeChecking} returning true) to validate
+ * that no cascade on the given property is considered a valid semantic.
+ *
+ * @param session The session witin which the cascade is occurring.
+ * @param child The property value
+ * @param parent The property value owner
+ * @param persister The entity persister for the owner
+ * @param propertyIndex The index of the property within the owner.
+ */
+ public void noCascade(EventSource session, Object child, Object parent, EntityPersister persister, int propertyIndex) {
+ }
+
+ /**
+ * Should this action be performed (or noCascade consulted) in the case of lazy properties.
+ */
+ public boolean performOnLazyProperty() {
+ return true;
+ }
+
+
+ // the CascadingAction implementations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * @see org.hibernate.Session#delete(Object)
+ */
+ public static final CascadingAction DELETE = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace("cascading to delete: " + entityName);
+ }
+ session.delete( entityName, child, isCascadeDeleteEnabled, ( Set ) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // delete does cascade to uninitialized collections
+ return CascadingAction.getAllElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ // orphans should be deleted during delete
+ return true;
+ }
+ public String toString() {
+ return "ACTION_DELETE";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#lock(Object, LockMode)
+ */
+ public static final CascadingAction LOCK = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to lock: " + entityName );
+ }
+ session.lock( entityName, child, LockMode.NONE/*(LockMode) anything*/ );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // lock doesn't cascade to uninitialized collections
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ //TODO: should orphans really be deleted during lock???
+ return false;
+ }
+ public String toString() {
+ return "ACTION_LOCK";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#refresh(Object)
+ */
+ public static final CascadingAction REFRESH = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to refresh: " + entityName );
+ }
+ session.refresh( child, (Map) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // refresh doesn't cascade to uninitialized collections
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ return false;
+ }
+ public String toString() {
+ return "ACTION_REFRESH";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#evict(Object)
+ */
+ public static final CascadingAction EVICT = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to evict: " + entityName );
+ }
+ session.evict(child);
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // evicts don't cascade to uninitialized collections
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ return false;
+ }
+ public boolean performOnLazyProperty() {
+ return false;
+ }
+ public String toString() {
+ return "ACTION_EVICT";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#saveOrUpdate(Object)
+ */
+ public static final CascadingAction SAVE_UPDATE = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to saveOrUpdate: " + entityName );
+ }
+ session.saveOrUpdate(entityName, child);
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // saves / updates don't cascade to uninitialized collections
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ // orphans should be deleted during save/update
+ return true;
+ }
+ public boolean performOnLazyProperty() {
+ return false;
+ }
+ public String toString() {
+ return "ACTION_SAVE_UPDATE";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#merge(Object)
+ */
+ public static final CascadingAction MERGE = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to merge: " + entityName );
+ }
+ session.merge( entityName, child, (Map) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // merges don't cascade to uninitialized collections
+// //TODO: perhaps this does need to cascade after all....
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ // orphans should not be deleted during merge??
+ return false;
+ }
+ public String toString() {
+ return "ACTION_MERGE";
+ }
+ };
+
+ /**
+ * @see org.hibernate.classic.Session#saveOrUpdateCopy(Object)
+ */
+ public static final CascadingAction SAVE_UPDATE_COPY = new CascadingAction() {
+ // for deprecated saveOrUpdateCopy()
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to saveOrUpdateCopy: " + entityName );
+ }
+ session.saveOrUpdateCopy( entityName, child, (Map) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // saves / updates don't cascade to uninitialized collections
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ // orphans should not be deleted during copy??
+ return false;
+ }
+ public String toString() {
+ return "ACTION_SAVE_UPDATE_COPY";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#persist(Object)
+ */
+ public static final CascadingAction PERSIST = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to persist: " + entityName );
+ }
+ session.persist( entityName, child, (Map) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // persists don't cascade to uninitialized collections
+ return CascadingAction.getAllElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ return false;
+ }
+ public boolean performOnLazyProperty() {
+ return false;
+ }
+ public String toString() {
+ return "ACTION_PERSIST";
+ }
+ };
+
+ /**
+ * Execute persist during flush time
+ *
+ * @see org.hibernate.Session#persist(Object)
+ */
+ public static final CascadingAction PERSIST_ON_FLUSH = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to persistOnFlush: " + entityName );
+ }
+ session.persistOnFlush( entityName, child, (Map) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // persists don't cascade to uninitialized collections
+ return CascadingAction.getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ return true;
+ }
+ public boolean requiresNoCascadeChecking() {
+ return true;
+ }
+ public void noCascade(
+ EventSource session,
+ Object child,
+ Object parent,
+ EntityPersister persister,
+ int propertyIndex) {
+ if ( child == null ) {
+ return;
+ }
+ Type type = persister.getPropertyTypes()[propertyIndex];
+ if ( type.isEntityType() ) {
+ String childEntityName = ( ( EntityType ) type ).getAssociatedEntityName( session.getFactory() );
+
+ if ( ! isInManagedState( child, session )
+ && ! ( child instanceof HibernateProxy ) //a proxy cannot be transient and it breaks ForeignKeys.isTransient
+ && ForeignKeys.isTransient( childEntityName, child, null, session ) ) {
+ String parentEntiytName = persister.getEntityName();
+ String propertyName = persister.getPropertyNames()[propertyIndex];
+ throw new TransientObjectException(
+ "object references an unsaved transient instance - " +
+ "save the transient instance before flushing: " +
+ parentEntiytName + "." + propertyName + " -> " + childEntityName
+ );
+
+ }
+ }
+ }
+ public boolean performOnLazyProperty() {
+ return false;
+ }
+
+ private boolean isInManagedState(Object child, EventSource session) {
+ EntityEntry entry = session.getPersistenceContext().getEntry( child );
+ return entry != null && (entry.getStatus() == Status.MANAGED || entry.getStatus() == Status.READ_ONLY);
+ }
+
+ public String toString() {
+ return "ACTION_PERSIST_ON_FLUSH";
+ }
+ };
+
+ /**
+ * @see org.hibernate.Session#replicate(Object, org.hibernate.ReplicationMode)
+ */
+ public static final CascadingAction REPLICATE = new CascadingAction() {
+ public void cascade(EventSource session, Object child, String entityName, Object anything, boolean isCascadeDeleteEnabled)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "cascading to replicate: " + entityName );
+ }
+ session.replicate( entityName, child, (ReplicationMode) anything );
+ }
+ public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
+ // replicate does cascade to uninitialized collections
+ return getLoadedElementsIterator(session, collectionType, collection);
+ }
+ public boolean deleteOrphans() {
+ return false; //I suppose?
+ }
+ public String toString() {
+ return "ACTION_REPLICATE";
+ }
+ };
+
+
+ // static helper methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Given a collection, get an iterator of all its children, loading them
+ * from the database if necessary.
+ *
+ * @param session The session within which the cascade is occuring.
+ * @param collectionType The mapping type of the collection.
+ * @param collection The collection instance.
+ * @return The children iterator.
+ */
+ private static Iterator getAllElementsIterator(
+ EventSource session,
+ CollectionType collectionType,
+ Object collection) {
+ return collectionType.getElementsIterator( collection, session );
+ }
+
+ /**
+ * Iterate just the elements of the collection that are already there. Don't load
+ * any new elements from the database.
+ */
+ public static Iterator getLoadedElementsIterator(SessionImplementor session, CollectionType collectionType, Object collection) {
+ if ( collectionIsInitialized(collection) ) {
+ // handles arrays and newly instantiated collections
+ return collectionType.getElementsIterator(collection, session);
+ }
+ else {
+ // does not handle arrays (thats ok, cos they can't be lazy)
+ // or newly instantiated collections, so we can do the cast
+ return ( (PersistentCollection) collection ).queuedAdditionIterator();
+ }
+ }
+
+ private static boolean collectionIsInitialized(Object collection) {
+ return !(collection instanceof PersistentCollection) || ( (PersistentCollection) collection ).wasInitialized();
+ }
+
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/CollectionEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,397 +0,0 @@
-//$Id: CollectionEntry.java 9551 2006-03-04 03:49:55Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Collection;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.HibernateException;
-import org.hibernate.MappingException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-
-/**
- * We need an entry to tell us all about the current state
- * of a collection with respect to its persistent state
- *
- * @author Gavin King
- */
-public final class CollectionEntry implements Serializable {
-
- private static final Logger log = LoggerFactory.getLogger(CollectionEntry.class);
-
- //ATTRIBUTES MAINTAINED BETWEEN FLUSH CYCLES
-
- // session-start/post-flush persistent state
- private Serializable snapshot;
- // allow the CollectionSnapshot to be serialized
- private String role;
-
- // "loaded" means the reference that is consistent
- // with the current database state
- private transient CollectionPersister loadedPersister;
- private Serializable loadedKey;
-
- // ATTRIBUTES USED ONLY DURING FLUSH CYCLE
-
- // during flush, we navigate the object graph to
- // collections and decide what to do with them
- private transient boolean reached;
- private transient boolean processed;
- private transient boolean doupdate;
- private transient boolean doremove;
- private transient boolean dorecreate;
- // if we instantiate a collection during the flush() process,
- // we must ignore it for the rest of the flush()
- private transient boolean ignore;
-
- // "current" means the reference that was found during flush()
- private transient CollectionPersister currentPersister;
- private transient Serializable currentKey;
-
- /**
- * For newly wrapped collections, or dereferenced collection wrappers
- */
- public CollectionEntry(CollectionPersister persister, PersistentCollection collection) {
- // new collections that get found + wrapped
- // during flush shouldn't be ignored
- ignore = false;
-
- collection.clearDirty(); //a newly wrapped collection is NOT dirty (or we get unnecessary version updates)
-
- snapshot = persister.isMutable() ?
- collection.getSnapshot(persister) :
- null;
- collection.setSnapshot(loadedKey, role, snapshot);
- }
-
- /**
- * For collections just loaded from the database
- */
- public CollectionEntry(
- final PersistentCollection collection,
- final CollectionPersister loadedPersister,
- final Serializable loadedKey,
- final boolean ignore
- ) {
- this.ignore=ignore;
-
- //collection.clearDirty()
-
- this.loadedKey = loadedKey;
- setLoadedPersister(loadedPersister);
-
- collection.setSnapshot(loadedKey, role, null);
-
- //postInitialize() will be called after initialization
- }
-
- /**
- * For uninitialized detached collections
- */
- public CollectionEntry(CollectionPersister loadedPersister, Serializable loadedKey) {
- // detached collection wrappers that get found + reattached
- // during flush shouldn't be ignored
- ignore = false;
-
- //collection.clearDirty()
-
- this.loadedKey = loadedKey;
- setLoadedPersister(loadedPersister);
- }
-
- /**
- * For initialized detached collections
- */
- CollectionEntry(PersistentCollection collection, SessionFactoryImplementor factory)
- throws MappingException {
- // detached collections that get found + reattached
- // during flush shouldn't be ignored
- ignore = false;
-
- loadedKey = collection.getKey();
- setLoadedPersister( factory.getCollectionPersister( collection.getRole() ) );
-
- snapshot = collection.getStoredSnapshot();
- }
-
- /**
- * Used from custom serialization.
- *
- * @see #serialize
- * @see #deserialize
- */
- private CollectionEntry(
- String role,
- Serializable snapshot,
- Serializable loadedKey,
- SessionFactoryImplementor factory) {
- this.role = role;
- this.snapshot = snapshot;
- this.loadedKey = loadedKey;
- if ( role != null ) {
- afterDeserialize( factory );
- }
- }
-
- /**
- * Determine if the collection is "really" dirty, by checking dirtiness
- * of the collection elements, if necessary
- */
- private void dirty(PersistentCollection collection) throws HibernateException {
-
- boolean forceDirty = collection.wasInitialized() &&
- !collection.isDirty() && //optimization
- getLoadedPersister() != null &&
- getLoadedPersister().isMutable() && //optimization
- ( collection.isDirectlyAccessible() || getLoadedPersister().getElementType().isMutable() ) && //optimization
- !collection.equalsSnapshot( getLoadedPersister() );
-
- if ( forceDirty ) {
- collection.dirty();
- }
-
- }
-
- public void preFlush(PersistentCollection collection) throws HibernateException {
-
- boolean nonMutableChange = collection.isDirty() &&
- getLoadedPersister()!=null &&
- !getLoadedPersister().isMutable();
- if (nonMutableChange) {
- throw new HibernateException(
- "changed an immutable collection instance: " +
- MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() )
- );
- }
-
- dirty(collection);
-
- if ( log.isDebugEnabled() && collection.isDirty() && getLoadedPersister() != null ) {
- log.debug(
- "Collection dirty: " +
- MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() )
- );
- }
-
- setDoupdate(false);
- setDoremove(false);
- setDorecreate(false);
- setReached(false);
- setProcessed(false);
- }
-
- public void postInitialize(PersistentCollection collection) throws HibernateException {
- snapshot = getLoadedPersister().isMutable() ?
- collection.getSnapshot( getLoadedPersister() ) :
- null;
- collection.setSnapshot(loadedKey, role, snapshot);
- }
-
- /**
- * Called after a successful flush
- */
- public void postFlush(PersistentCollection collection) throws HibernateException {
- if ( isIgnore() ) {
- ignore = false;
- }
- else if ( !isProcessed() ) {
- throw new AssertionFailure( "collection [" + collection.getRole() + "] was not processed by flush()" );
- }
- collection.setSnapshot(loadedKey, role, snapshot);
- }
-
- /**
- * Called after execution of an action
- */
- public void afterAction(PersistentCollection collection) {
- loadedKey = getCurrentKey();
- setLoadedPersister( getCurrentPersister() );
-
- boolean resnapshot = collection.wasInitialized() &&
- ( isDoremove() || isDorecreate() || isDoupdate() );
- if ( resnapshot ) {
- snapshot = loadedPersister==null || !loadedPersister.isMutable() ?
- null :
- collection.getSnapshot(loadedPersister); //re-snapshot
- }
-
- collection.postAction();
- }
-
- public Serializable getKey() {
- return getLoadedKey();
- }
-
- public String getRole() {
- return role;
- }
-
- public Serializable getSnapshot() {
- return snapshot;
- }
-
- private void setLoadedPersister(CollectionPersister persister) {
- loadedPersister = persister;
- setRole( persister == null ? null : persister.getRole() );
- }
-
- void afterDeserialize(SessionFactoryImplementor factory) {
- loadedPersister = factory.getCollectionPersister(role);
- }
-
- public boolean wasDereferenced() {
- return getLoadedKey() == null;
- }
-
- public boolean isReached() {
- return reached;
- }
-
- public void setReached(boolean reached) {
- this.reached = reached;
- }
-
- public boolean isProcessed() {
- return processed;
- }
-
- public void setProcessed(boolean processed) {
- this.processed = processed;
- }
-
- public boolean isDoupdate() {
- return doupdate;
- }
-
- public void setDoupdate(boolean doupdate) {
- this.doupdate = doupdate;
- }
-
- public boolean isDoremove() {
- return doremove;
- }
-
- public void setDoremove(boolean doremove) {
- this.doremove = doremove;
- }
-
- public boolean isDorecreate() {
- return dorecreate;
- }
-
- public void setDorecreate(boolean dorecreate) {
- this.dorecreate = dorecreate;
- }
-
- public boolean isIgnore() {
- return ignore;
- }
-
- public CollectionPersister getCurrentPersister() {
- return currentPersister;
- }
-
- public void setCurrentPersister(CollectionPersister currentPersister) {
- this.currentPersister = currentPersister;
- }
-
- /**
- * This is only available late during the flush
- * cycle
- */
- public Serializable getCurrentKey() {
- return currentKey;
- }
-
- public void setCurrentKey(Serializable currentKey) {
- this.currentKey = currentKey;
- }
-
- /**
- * This is only available late during the flush cycle
- */
- public CollectionPersister getLoadedPersister() {
- return loadedPersister;
- }
-
- public Serializable getLoadedKey() {
- return loadedKey;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public String toString() {
- String result = "CollectionEntry" +
- MessageHelper.collectionInfoString( loadedPersister.getRole(), loadedKey );
- if (currentPersister!=null) {
- result += "->" +
- MessageHelper.collectionInfoString( currentPersister.getRole(), currentKey );
- }
- return result;
- }
-
- /**
- * Get the collection orphans (entities which were removed from the collection)
- */
- public Collection getOrphans(String entityName, PersistentCollection collection)
- throws HibernateException {
- if (snapshot==null) {
- throw new AssertionFailure("no collection snapshot for orphan delete");
- }
- return collection.getOrphans( snapshot, entityName );
- }
-
- public boolean isSnapshotEmpty(PersistentCollection collection) {
- //TODO: does this really need to be here?
- // does the collection already have
- // it's own up-to-date snapshot?
- return collection.wasInitialized() &&
- ( getLoadedPersister()==null || getLoadedPersister().isMutable() ) &&
- collection.isSnapshotEmpty( getSnapshot() );
- }
-
-
-
- /**
- * Custom serialization routine used during serialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param oos The stream to which we should write the serial data.
- * @throws java.io.IOException
- */
- void serialize(ObjectOutputStream oos) throws IOException {
- oos.writeObject( role );
- oos.writeObject( snapshot );
- oos.writeObject( loadedKey );
- }
-
- /**
- * Custom deserialization routine used during deserialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param ois The stream from which to read the entry.
- * @param session The session being deserialized.
- * @return The deserialized CollectionEntry
- * @throws IOException
- * @throws ClassNotFoundException
- */
- static CollectionEntry deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- return new CollectionEntry(
- ( String ) ois.readObject(),
- ( Serializable ) ois.readObject(),
- ( Serializable ) ois.readObject(),
- session.getFactory()
- );
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/CollectionEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,420 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Collection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.AssertionFailure;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+
+/**
+ * We need an entry to tell us all about the current state
+ * of a collection with respect to its persistent state
+ *
+ * @author Gavin King
+ */
+public final class CollectionEntry implements Serializable {
+
+ private static final Logger log = LoggerFactory.getLogger(CollectionEntry.class);
+
+ //ATTRIBUTES MAINTAINED BETWEEN FLUSH CYCLES
+
+ // session-start/post-flush persistent state
+ private Serializable snapshot;
+ // allow the CollectionSnapshot to be serialized
+ private String role;
+
+ // "loaded" means the reference that is consistent
+ // with the current database state
+ private transient CollectionPersister loadedPersister;
+ private Serializable loadedKey;
+
+ // ATTRIBUTES USED ONLY DURING FLUSH CYCLE
+
+ // during flush, we navigate the object graph to
+ // collections and decide what to do with them
+ private transient boolean reached;
+ private transient boolean processed;
+ private transient boolean doupdate;
+ private transient boolean doremove;
+ private transient boolean dorecreate;
+ // if we instantiate a collection during the flush() process,
+ // we must ignore it for the rest of the flush()
+ private transient boolean ignore;
+
+ // "current" means the reference that was found during flush()
+ private transient CollectionPersister currentPersister;
+ private transient Serializable currentKey;
+
+ /**
+ * For newly wrapped collections, or dereferenced collection wrappers
+ */
+ public CollectionEntry(CollectionPersister persister, PersistentCollection collection) {
+ // new collections that get found + wrapped
+ // during flush shouldn't be ignored
+ ignore = false;
+
+ collection.clearDirty(); //a newly wrapped collection is NOT dirty (or we get unnecessary version updates)
+
+ snapshot = persister.isMutable() ?
+ collection.getSnapshot(persister) :
+ null;
+ collection.setSnapshot(loadedKey, role, snapshot);
+ }
+
+ /**
+ * For collections just loaded from the database
+ */
+ public CollectionEntry(
+ final PersistentCollection collection,
+ final CollectionPersister loadedPersister,
+ final Serializable loadedKey,
+ final boolean ignore
+ ) {
+ this.ignore=ignore;
+
+ //collection.clearDirty()
+
+ this.loadedKey = loadedKey;
+ setLoadedPersister(loadedPersister);
+
+ collection.setSnapshot(loadedKey, role, null);
+
+ //postInitialize() will be called after initialization
+ }
+
+ /**
+ * For uninitialized detached collections
+ */
+ public CollectionEntry(CollectionPersister loadedPersister, Serializable loadedKey) {
+ // detached collection wrappers that get found + reattached
+ // during flush shouldn't be ignored
+ ignore = false;
+
+ //collection.clearDirty()
+
+ this.loadedKey = loadedKey;
+ setLoadedPersister(loadedPersister);
+ }
+
+ /**
+ * For initialized detached collections
+ */
+ CollectionEntry(PersistentCollection collection, SessionFactoryImplementor factory)
+ throws MappingException {
+ // detached collections that get found + reattached
+ // during flush shouldn't be ignored
+ ignore = false;
+
+ loadedKey = collection.getKey();
+ setLoadedPersister( factory.getCollectionPersister( collection.getRole() ) );
+
+ snapshot = collection.getStoredSnapshot();
+ }
+
+ /**
+ * Used from custom serialization.
+ *
+ * @see #serialize
+ * @see #deserialize
+ */
+ private CollectionEntry(
+ String role,
+ Serializable snapshot,
+ Serializable loadedKey,
+ SessionFactoryImplementor factory) {
+ this.role = role;
+ this.snapshot = snapshot;
+ this.loadedKey = loadedKey;
+ if ( role != null ) {
+ afterDeserialize( factory );
+ }
+ }
+
+ /**
+ * Determine if the collection is "really" dirty, by checking dirtiness
+ * of the collection elements, if necessary
+ */
+ private void dirty(PersistentCollection collection) throws HibernateException {
+
+ boolean forceDirty = collection.wasInitialized() &&
+ !collection.isDirty() && //optimization
+ getLoadedPersister() != null &&
+ getLoadedPersister().isMutable() && //optimization
+ ( collection.isDirectlyAccessible() || getLoadedPersister().getElementType().isMutable() ) && //optimization
+ !collection.equalsSnapshot( getLoadedPersister() );
+
+ if ( forceDirty ) {
+ collection.dirty();
+ }
+
+ }
+
+ public void preFlush(PersistentCollection collection) throws HibernateException {
+
+ boolean nonMutableChange = collection.isDirty() &&
+ getLoadedPersister()!=null &&
+ !getLoadedPersister().isMutable();
+ if (nonMutableChange) {
+ throw new HibernateException(
+ "changed an immutable collection instance: " +
+ MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() )
+ );
+ }
+
+ dirty(collection);
+
+ if ( log.isDebugEnabled() && collection.isDirty() && getLoadedPersister() != null ) {
+ log.debug(
+ "Collection dirty: " +
+ MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() )
+ );
+ }
+
+ setDoupdate(false);
+ setDoremove(false);
+ setDorecreate(false);
+ setReached(false);
+ setProcessed(false);
+ }
+
+ public void postInitialize(PersistentCollection collection) throws HibernateException {
+ snapshot = getLoadedPersister().isMutable() ?
+ collection.getSnapshot( getLoadedPersister() ) :
+ null;
+ collection.setSnapshot(loadedKey, role, snapshot);
+ }
+
+ /**
+ * Called after a successful flush
+ */
+ public void postFlush(PersistentCollection collection) throws HibernateException {
+ if ( isIgnore() ) {
+ ignore = false;
+ }
+ else if ( !isProcessed() ) {
+ throw new AssertionFailure( "collection [" + collection.getRole() + "] was not processed by flush()" );
+ }
+ collection.setSnapshot(loadedKey, role, snapshot);
+ }
+
+ /**
+ * Called after execution of an action
+ */
+ public void afterAction(PersistentCollection collection) {
+ loadedKey = getCurrentKey();
+ setLoadedPersister( getCurrentPersister() );
+
+ boolean resnapshot = collection.wasInitialized() &&
+ ( isDoremove() || isDorecreate() || isDoupdate() );
+ if ( resnapshot ) {
+ snapshot = loadedPersister==null || !loadedPersister.isMutable() ?
+ null :
+ collection.getSnapshot(loadedPersister); //re-snapshot
+ }
+
+ collection.postAction();
+ }
+
+ public Serializable getKey() {
+ return getLoadedKey();
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public Serializable getSnapshot() {
+ return snapshot;
+ }
+
+ private void setLoadedPersister(CollectionPersister persister) {
+ loadedPersister = persister;
+ setRole( persister == null ? null : persister.getRole() );
+ }
+
+ void afterDeserialize(SessionFactoryImplementor factory) {
+ loadedPersister = factory.getCollectionPersister(role);
+ }
+
+ public boolean wasDereferenced() {
+ return getLoadedKey() == null;
+ }
+
+ public boolean isReached() {
+ return reached;
+ }
+
+ public void setReached(boolean reached) {
+ this.reached = reached;
+ }
+
+ public boolean isProcessed() {
+ return processed;
+ }
+
+ public void setProcessed(boolean processed) {
+ this.processed = processed;
+ }
+
+ public boolean isDoupdate() {
+ return doupdate;
+ }
+
+ public void setDoupdate(boolean doupdate) {
+ this.doupdate = doupdate;
+ }
+
+ public boolean isDoremove() {
+ return doremove;
+ }
+
+ public void setDoremove(boolean doremove) {
+ this.doremove = doremove;
+ }
+
+ public boolean isDorecreate() {
+ return dorecreate;
+ }
+
+ public void setDorecreate(boolean dorecreate) {
+ this.dorecreate = dorecreate;
+ }
+
+ public boolean isIgnore() {
+ return ignore;
+ }
+
+ public CollectionPersister getCurrentPersister() {
+ return currentPersister;
+ }
+
+ public void setCurrentPersister(CollectionPersister currentPersister) {
+ this.currentPersister = currentPersister;
+ }
+
+ /**
+ * This is only available late during the flush
+ * cycle
+ */
+ public Serializable getCurrentKey() {
+ return currentKey;
+ }
+
+ public void setCurrentKey(Serializable currentKey) {
+ this.currentKey = currentKey;
+ }
+
+ /**
+ * This is only available late during the flush cycle
+ */
+ public CollectionPersister getLoadedPersister() {
+ return loadedPersister;
+ }
+
+ public Serializable getLoadedKey() {
+ return loadedKey;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public String toString() {
+ String result = "CollectionEntry" +
+ MessageHelper.collectionInfoString( loadedPersister.getRole(), loadedKey );
+ if (currentPersister!=null) {
+ result += "->" +
+ MessageHelper.collectionInfoString( currentPersister.getRole(), currentKey );
+ }
+ return result;
+ }
+
+ /**
+ * Get the collection orphans (entities which were removed from the collection)
+ */
+ public Collection getOrphans(String entityName, PersistentCollection collection)
+ throws HibernateException {
+ if (snapshot==null) {
+ throw new AssertionFailure("no collection snapshot for orphan delete");
+ }
+ return collection.getOrphans( snapshot, entityName );
+ }
+
+ public boolean isSnapshotEmpty(PersistentCollection collection) {
+ //TODO: does this really need to be here?
+ // does the collection already have
+ // it's own up-to-date snapshot?
+ return collection.wasInitialized() &&
+ ( getLoadedPersister()==null || getLoadedPersister().isMutable() ) &&
+ collection.isSnapshotEmpty( getSnapshot() );
+ }
+
+
+
+ /**
+ * Custom serialization routine used during serialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param oos The stream to which we should write the serial data.
+ * @throws java.io.IOException
+ */
+ void serialize(ObjectOutputStream oos) throws IOException {
+ oos.writeObject( role );
+ oos.writeObject( snapshot );
+ oos.writeObject( loadedKey );
+ }
+
+ /**
+ * Custom deserialization routine used during deserialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param ois The stream from which to read the entry.
+ * @param session The session being deserialized.
+ * @return The deserialized CollectionEntry
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ static CollectionEntry deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ return new CollectionEntry(
+ ( String ) ois.readObject(),
+ ( Serializable ) ois.readObject(),
+ ( Serializable ) ois.readObject(),
+ session.getFactory()
+ );
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/CollectionKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,113 +0,0 @@
-//$Id: CollectionKey.java 9194 2006-02-01 19:59:07Z steveebersole $
-package org.hibernate.engine;
-
-import org.hibernate.EntityMode;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.type.Type;
-
-
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-/**
- * Uniquely identifies a collection instance in a particular session.
- *
- * @author Gavin King
- */
-public final class CollectionKey implements Serializable {
-
- private final String role;
- private final Serializable key;
- private final Type keyType;
- private final SessionFactoryImplementor factory;
- private final int hashCode;
- private EntityMode entityMode;
-
- public CollectionKey(CollectionPersister persister, Serializable key, EntityMode em) {
- this( persister.getRole(), key, persister.getKeyType(), em, persister.getFactory() );
- }
-
- private CollectionKey(
- String role,
- Serializable key,
- Type keyType,
- EntityMode entityMode,
- SessionFactoryImplementor factory) {
- this.role = role;
- this.key = key;
- this.keyType = keyType;
- this.entityMode = entityMode;
- this.factory = factory;
- this.hashCode = generateHashCode(); //cache the hashcode
- }
-
- public boolean equals(Object other) {
- CollectionKey that = (CollectionKey) other;
- return that.role.equals(role) &&
- keyType.isEqual(that.key, key, entityMode, factory);
- }
-
- public int generateHashCode() {
- int result = 17;
- result = 37 * result + role.hashCode();
- result = 37 * result + keyType.getHashCode(key, entityMode, factory);
- return result;
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public String getRole() {
- return role;
- }
-
- public Serializable getKey() {
- return key;
- }
-
- public String toString() {
- return "CollectionKey" +
- MessageHelper.collectionInfoString( factory.getCollectionPersister(role), key, factory );
- }
-
- /**
- * Custom serialization routine used during serialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param oos The stream to which we should write the serial data.
- * @throws java.io.IOException
- */
- void serialize(ObjectOutputStream oos) throws IOException {
- oos.writeObject( role );
- oos.writeObject( key );
- oos.writeObject( keyType );
- oos.writeObject( entityMode.toString() );
- }
-
- /**
- * Custom deserialization routine used during deserialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param ois The stream from which to read the entry.
- * @param session The session being deserialized.
- * @return The deserialized CollectionKey
- * @throws IOException
- * @throws ClassNotFoundException
- */
- static CollectionKey deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- return new CollectionKey(
- ( String ) ois.readObject(),
- ( Serializable ) ois.readObject(),
- ( Type ) ois.readObject(),
- EntityMode.parse( ( String ) ois.readObject() ),
- session.getFactory()
- );
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/CollectionKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/CollectionKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,134 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.EntityMode;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * Uniquely identifies a collection instance in a particular session.
+ *
+ * @author Gavin King
+ */
+public final class CollectionKey implements Serializable {
+
+ private final String role;
+ private final Serializable key;
+ private final Type keyType;
+ private final SessionFactoryImplementor factory;
+ private final int hashCode;
+ private EntityMode entityMode;
+
+ public CollectionKey(CollectionPersister persister, Serializable key, EntityMode em) {
+ this( persister.getRole(), key, persister.getKeyType(), em, persister.getFactory() );
+ }
+
+ private CollectionKey(
+ String role,
+ Serializable key,
+ Type keyType,
+ EntityMode entityMode,
+ SessionFactoryImplementor factory) {
+ this.role = role;
+ this.key = key;
+ this.keyType = keyType;
+ this.entityMode = entityMode;
+ this.factory = factory;
+ this.hashCode = generateHashCode(); //cache the hashcode
+ }
+
+ public boolean equals(Object other) {
+ CollectionKey that = (CollectionKey) other;
+ return that.role.equals(role) &&
+ keyType.isEqual(that.key, key, entityMode, factory);
+ }
+
+ public int generateHashCode() {
+ int result = 17;
+ result = 37 * result + role.hashCode();
+ result = 37 * result + keyType.getHashCode(key, entityMode, factory);
+ return result;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public Serializable getKey() {
+ return key;
+ }
+
+ public String toString() {
+ return "CollectionKey" +
+ MessageHelper.collectionInfoString( factory.getCollectionPersister(role), key, factory );
+ }
+
+ /**
+ * Custom serialization routine used during serialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param oos The stream to which we should write the serial data.
+ * @throws java.io.IOException
+ */
+ void serialize(ObjectOutputStream oos) throws IOException {
+ oos.writeObject( role );
+ oos.writeObject( key );
+ oos.writeObject( keyType );
+ oos.writeObject( entityMode.toString() );
+ }
+
+ /**
+ * Custom deserialization routine used during deserialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param ois The stream from which to read the entry.
+ * @param session The session being deserialized.
+ * @return The deserialized CollectionKey
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ static CollectionKey deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ return new CollectionKey(
+ ( String ) ois.readObject(),
+ ( Serializable ) ois.readObject(),
+ ( Type ) ois.readObject(),
+ EntityMode.parse( ( String ) ois.readObject() ),
+ session.getFactory()
+ );
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/Collections.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,254 +0,0 @@
-//$Id: Collections.java 8694 2005-11-28 19:28:17Z steveebersole $
-package org.hibernate.engine;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.type.CollectionType;
-
-import java.io.Serializable;
-
-/**
- * Implements book-keeping for the collection persistence by reachability algorithm
- * @author Gavin King
- */
-public final class Collections {
-
- private Collections() {}
-
- private static final Logger log = LoggerFactory.getLogger(Collections.class);
-
- /**
- * record the fact that this collection was dereferenced
- *
- * @param coll The collection to be updated by unreachability.
- * @throws HibernateException
- */
- public static void processUnreachableCollection(PersistentCollection coll, SessionImplementor session)
- throws HibernateException {
-
- if ( coll.getOwner()==null ) {
- processNeverReferencedCollection(coll, session);
- }
- else {
- processDereferencedCollection(coll, session);
- }
-
- }
-
- private static void processDereferencedCollection(PersistentCollection coll, SessionImplementor session)
- throws HibernateException {
-
- final PersistenceContext persistenceContext = session.getPersistenceContext();
- CollectionEntry entry = persistenceContext.getCollectionEntry(coll);
- final CollectionPersister loadedPersister = entry.getLoadedPersister();
-
- if ( log.isDebugEnabled() && loadedPersister != null )
- log.debug(
- "Collection dereferenced: " +
- MessageHelper.collectionInfoString(
- loadedPersister,
- entry.getLoadedKey(),
- session.getFactory()
- )
- );
-
- // do a check
- boolean hasOrphanDelete = loadedPersister != null &&
- loadedPersister.hasOrphanDelete();
- if (hasOrphanDelete) {
- Serializable ownerId = loadedPersister.getOwnerEntityPersister()
- .getIdentifier( coll.getOwner(), session.getEntityMode() );
- if ( ownerId == null ) {
- // the owning entity may have been deleted and its identifier unset due to
- // identifier-rollback; in which case, try to look up its identifier from
- // the persistence context
- if ( session.getFactory().getSettings().isIdentifierRollbackEnabled() ) {
- EntityEntry ownerEntry = persistenceContext.getEntry( coll.getOwner() );
- if ( ownerEntry != null ) {
- ownerId = ownerEntry.getId();
- }
- }
- if ( ownerId == null ) {
- throw new AssertionFailure( "Unable to determine collection owner identifier for orphan-delete processing" );
- }
- }
- EntityKey key = new EntityKey(
- ownerId,
- loadedPersister.getOwnerEntityPersister(),
- session.getEntityMode()
- );
- Object owner = persistenceContext.getEntity(key);
- if ( owner == null ) {
- throw new AssertionFailure(
- "collection owner not associated with session: " +
- loadedPersister.getRole()
- );
- }
- EntityEntry e = persistenceContext.getEntry(owner);
- //only collections belonging to deleted entities are allowed to be dereferenced in the case of orphan delete
- if ( e != null && e.getStatus() != Status.DELETED && e.getStatus() != Status.GONE ) {
- throw new HibernateException(
- "A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance: " +
- loadedPersister.getRole()
- );
- }
- }
-
- // do the work
- entry.setCurrentPersister(null);
- entry.setCurrentKey(null);
- prepareCollectionForUpdate( coll, entry, session.getEntityMode(), session.getFactory() );
-
- }
-
- private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session)
- throws HibernateException {
-
- final PersistenceContext persistenceContext = session.getPersistenceContext();
- CollectionEntry entry = persistenceContext.getCollectionEntry(coll);
-
- log.debug(
- "Found collection with unloaded owner: " +
- MessageHelper.collectionInfoString(
- entry.getLoadedPersister(),
- entry.getLoadedKey(),
- session.getFactory()
- )
- );
-
- entry.setCurrentPersister( entry.getLoadedPersister() );
- entry.setCurrentKey( entry.getLoadedKey() );
-
- prepareCollectionForUpdate( coll, entry, session.getEntityMode(), session.getFactory() );
-
- }
-
- /**
- * Initialize the role of the collection.
- *
- * @param collection The collection to be updated by reachibility.
- * @param type The type of the collection.
- * @param entity The owner of the collection.
- * @throws HibernateException
- */
- public static void processReachableCollection(
- PersistentCollection collection,
- CollectionType type,
- Object entity,
- SessionImplementor session)
- throws HibernateException {
-
- collection.setOwner(entity);
-
- CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(collection);
-
- if ( ce == null ) {
- // refer to comment in StatefulPersistenceContext.addCollection()
- throw new HibernateException(
- "Found two representations of same collection: " +
- type.getRole()
- );
- }
-
- // The CollectionEntry.isReached() stuff is just to detect any silly users
- // who set up circular or shared references between/to collections.
- if ( ce.isReached() ) {
- // We've been here before
- throw new HibernateException(
- "Found shared references to a collection: " +
- type.getRole()
- );
- }
- ce.setReached(true);
-
- SessionFactoryImplementor factory = session.getFactory();
- CollectionPersister persister = factory.getCollectionPersister( type.getRole() );
- ce.setCurrentPersister(persister);
- ce.setCurrentKey( type.getKeyOfOwner(entity, session) ); //TODO: better to pass the id in as an argument?
-
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Collection found: " +
- MessageHelper.collectionInfoString( persister, ce.getCurrentKey(), factory ) +
- ", was: " +
- MessageHelper.collectionInfoString( ce.getLoadedPersister(), ce.getLoadedKey(), factory ) +
- ( collection.wasInitialized() ? " (initialized)" : " (uninitialized)" )
- );
- }
-
- prepareCollectionForUpdate( collection, ce, session.getEntityMode(), factory );
-
- }
-
- /**
- * 1. record the collection role that this collection is referenced by
- * 2. decide if the collection needs deleting/creating/updating (but
- * don't actually schedule the action yet)
- */
- private static void prepareCollectionForUpdate(
- PersistentCollection collection,
- CollectionEntry entry,
- EntityMode entityMode,
- SessionFactoryImplementor factory)
- throws HibernateException {
-
- if ( entry.isProcessed() ) {
- throw new AssertionFailure( "collection was processed twice by flush()" );
- }
- entry.setProcessed(true);
-
- final CollectionPersister loadedPersister = entry.getLoadedPersister();
- final CollectionPersister currentPersister = entry.getCurrentPersister();
- if ( loadedPersister != null || currentPersister != null ) { // it is or was referenced _somewhere_
-
- boolean ownerChanged = loadedPersister != currentPersister || // if either its role changed,
- !currentPersister
- .getKeyType().isEqual( // or its key changed
- entry.getLoadedKey(),
- entry.getCurrentKey(),
- entityMode, factory
- );
-
- if (ownerChanged) {
-
- // do a check
- final boolean orphanDeleteAndRoleChanged = loadedPersister != null &&
- currentPersister != null &&
- loadedPersister.hasOrphanDelete();
-
- if (orphanDeleteAndRoleChanged) {
- throw new HibernateException(
- "Don't change the reference to a collection with cascade=\"all-delete-orphan\": " +
- loadedPersister.getRole()
- );
- }
-
- // do the work
- if ( currentPersister != null ) {
- entry.setDorecreate(true); // we will need to create new entries
- }
-
- if ( loadedPersister != null ) {
- entry.setDoremove(true); // we will need to remove ye olde entries
- if ( entry.isDorecreate() ) {
- log.trace( "Forcing collection initialization" );
- collection.forceInitialization(); // force initialize!
- }
- }
-
- }
- else if ( collection.isDirty() ) { // else if it's elements changed
- entry.setDoupdate(true);
- }
-
- }
-
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/Collections.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Collections.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,277 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.AssertionFailure;
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.type.CollectionType;
+
+import java.io.Serializable;
+
+/**
+ * Implements book-keeping for the collection persistence by reachability algorithm
+ * @author Gavin King
+ */
+public final class Collections {
+
+ private Collections() {}
+
+ private static final Logger log = LoggerFactory.getLogger(Collections.class);
+
+ /**
+ * record the fact that this collection was dereferenced
+ *
+ * @param coll The collection to be updated by unreachability.
+ * @throws HibernateException
+ */
+ public static void processUnreachableCollection(PersistentCollection coll, SessionImplementor session)
+ throws HibernateException {
+
+ if ( coll.getOwner()==null ) {
+ processNeverReferencedCollection(coll, session);
+ }
+ else {
+ processDereferencedCollection(coll, session);
+ }
+
+ }
+
+ private static void processDereferencedCollection(PersistentCollection coll, SessionImplementor session)
+ throws HibernateException {
+
+ final PersistenceContext persistenceContext = session.getPersistenceContext();
+ CollectionEntry entry = persistenceContext.getCollectionEntry(coll);
+ final CollectionPersister loadedPersister = entry.getLoadedPersister();
+
+ if ( log.isDebugEnabled() && loadedPersister != null )
+ log.debug(
+ "Collection dereferenced: " +
+ MessageHelper.collectionInfoString(
+ loadedPersister,
+ entry.getLoadedKey(),
+ session.getFactory()
+ )
+ );
+
+ // do a check
+ boolean hasOrphanDelete = loadedPersister != null &&
+ loadedPersister.hasOrphanDelete();
+ if (hasOrphanDelete) {
+ Serializable ownerId = loadedPersister.getOwnerEntityPersister()
+ .getIdentifier( coll.getOwner(), session.getEntityMode() );
+ if ( ownerId == null ) {
+ // the owning entity may have been deleted and its identifier unset due to
+ // identifier-rollback; in which case, try to look up its identifier from
+ // the persistence context
+ if ( session.getFactory().getSettings().isIdentifierRollbackEnabled() ) {
+ EntityEntry ownerEntry = persistenceContext.getEntry( coll.getOwner() );
+ if ( ownerEntry != null ) {
+ ownerId = ownerEntry.getId();
+ }
+ }
+ if ( ownerId == null ) {
+ throw new AssertionFailure( "Unable to determine collection owner identifier for orphan-delete processing" );
+ }
+ }
+ EntityKey key = new EntityKey(
+ ownerId,
+ loadedPersister.getOwnerEntityPersister(),
+ session.getEntityMode()
+ );
+ Object owner = persistenceContext.getEntity(key);
+ if ( owner == null ) {
+ throw new AssertionFailure(
+ "collection owner not associated with session: " +
+ loadedPersister.getRole()
+ );
+ }
+ EntityEntry e = persistenceContext.getEntry(owner);
+ //only collections belonging to deleted entities are allowed to be dereferenced in the case of orphan delete
+ if ( e != null && e.getStatus() != Status.DELETED && e.getStatus() != Status.GONE ) {
+ throw new HibernateException(
+ "A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance: " +
+ loadedPersister.getRole()
+ );
+ }
+ }
+
+ // do the work
+ entry.setCurrentPersister(null);
+ entry.setCurrentKey(null);
+ prepareCollectionForUpdate( coll, entry, session.getEntityMode(), session.getFactory() );
+
+ }
+
+ private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session)
+ throws HibernateException {
+
+ final PersistenceContext persistenceContext = session.getPersistenceContext();
+ CollectionEntry entry = persistenceContext.getCollectionEntry(coll);
+
+ log.debug(
+ "Found collection with unloaded owner: " +
+ MessageHelper.collectionInfoString(
+ entry.getLoadedPersister(),
+ entry.getLoadedKey(),
+ session.getFactory()
+ )
+ );
+
+ entry.setCurrentPersister( entry.getLoadedPersister() );
+ entry.setCurrentKey( entry.getLoadedKey() );
+
+ prepareCollectionForUpdate( coll, entry, session.getEntityMode(), session.getFactory() );
+
+ }
+
+ /**
+ * Initialize the role of the collection.
+ *
+ * @param collection The collection to be updated by reachibility.
+ * @param type The type of the collection.
+ * @param entity The owner of the collection.
+ * @throws HibernateException
+ */
+ public static void processReachableCollection(
+ PersistentCollection collection,
+ CollectionType type,
+ Object entity,
+ SessionImplementor session)
+ throws HibernateException {
+
+ collection.setOwner(entity);
+
+ CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(collection);
+
+ if ( ce == null ) {
+ // refer to comment in StatefulPersistenceContext.addCollection()
+ throw new HibernateException(
+ "Found two representations of same collection: " +
+ type.getRole()
+ );
+ }
+
+ // The CollectionEntry.isReached() stuff is just to detect any silly users
+ // who set up circular or shared references between/to collections.
+ if ( ce.isReached() ) {
+ // We've been here before
+ throw new HibernateException(
+ "Found shared references to a collection: " +
+ type.getRole()
+ );
+ }
+ ce.setReached(true);
+
+ SessionFactoryImplementor factory = session.getFactory();
+ CollectionPersister persister = factory.getCollectionPersister( type.getRole() );
+ ce.setCurrentPersister(persister);
+ ce.setCurrentKey( type.getKeyOfOwner(entity, session) ); //TODO: better to pass the id in as an argument?
+
+ if ( log.isDebugEnabled() ) {
+ log.debug(
+ "Collection found: " +
+ MessageHelper.collectionInfoString( persister, ce.getCurrentKey(), factory ) +
+ ", was: " +
+ MessageHelper.collectionInfoString( ce.getLoadedPersister(), ce.getLoadedKey(), factory ) +
+ ( collection.wasInitialized() ? " (initialized)" : " (uninitialized)" )
+ );
+ }
+
+ prepareCollectionForUpdate( collection, ce, session.getEntityMode(), factory );
+
+ }
+
+ /**
+ * 1. record the collection role that this collection is referenced by
+ * 2. decide if the collection needs deleting/creating/updating (but
+ * don't actually schedule the action yet)
+ */
+ private static void prepareCollectionForUpdate(
+ PersistentCollection collection,
+ CollectionEntry entry,
+ EntityMode entityMode,
+ SessionFactoryImplementor factory)
+ throws HibernateException {
+
+ if ( entry.isProcessed() ) {
+ throw new AssertionFailure( "collection was processed twice by flush()" );
+ }
+ entry.setProcessed(true);
+
+ final CollectionPersister loadedPersister = entry.getLoadedPersister();
+ final CollectionPersister currentPersister = entry.getCurrentPersister();
+ if ( loadedPersister != null || currentPersister != null ) { // it is or was referenced _somewhere_
+
+ boolean ownerChanged = loadedPersister != currentPersister || // if either its role changed,
+ !currentPersister
+ .getKeyType().isEqual( // or its key changed
+ entry.getLoadedKey(),
+ entry.getCurrentKey(),
+ entityMode, factory
+ );
+
+ if (ownerChanged) {
+
+ // do a check
+ final boolean orphanDeleteAndRoleChanged = loadedPersister != null &&
+ currentPersister != null &&
+ loadedPersister.hasOrphanDelete();
+
+ if (orphanDeleteAndRoleChanged) {
+ throw new HibernateException(
+ "Don't change the reference to a collection with cascade=\"all-delete-orphan\": " +
+ loadedPersister.getRole()
+ );
+ }
+
+ // do the work
+ if ( currentPersister != null ) {
+ entry.setDorecreate(true); // we will need to create new entries
+ }
+
+ if ( loadedPersister != null ) {
+ entry.setDoremove(true); // we will need to remove ye olde entries
+ if ( entry.isDorecreate() ) {
+ log.trace( "Forcing collection initialization" );
+ collection.forceInitialization(); // force initialize!
+ }
+ }
+
+ }
+ else if ( collection.isDirty() ) { // else if it's elements changed
+ entry.setDoupdate(true);
+ }
+
+ }
+
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,316 +0,0 @@
-//$Id: EntityEntry.java 9283 2006-02-14 03:24:18Z steveebersole $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.intercept.FieldInterceptionHelper;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.persister.entity.UniqueKeyLoadable;
-import org.hibernate.pretty.MessageHelper;
-
-/**
- * We need an entry to tell us all about the current state
- * of an object with respect to its persistent state
- *
- * @author Gavin King
- */
-public final class EntityEntry implements Serializable {
-
- private LockMode lockMode;
- private Status status;
- private final Serializable id;
- private Object[] loadedState;
- private Object[] deletedState;
- private boolean existsInDatabase;
- private Object version;
- private transient EntityPersister persister; // for convenience to save some lookups
- private final EntityMode entityMode;
- private final String entityName;
- private boolean isBeingReplicated;
- private boolean loadedWithLazyPropertiesUnfetched; //NOTE: this is not updated when properties are fetched lazily!
- private final transient Object rowId;
-
- EntityEntry(
- final Status status,
- final Object[] loadedState,
- final Object rowId,
- final Serializable id,
- final Object version,
- final LockMode lockMode,
- final boolean existsInDatabase,
- final EntityPersister persister,
- final EntityMode entityMode,
- final boolean disableVersionIncrement,
- final boolean lazyPropertiesAreUnfetched) {
- this.status=status;
- this.loadedState=loadedState;
- this.id=id;
- this.rowId=rowId;
- this.existsInDatabase=existsInDatabase;
- this.version=version;
- this.lockMode=lockMode;
- this.isBeingReplicated=disableVersionIncrement;
- this.loadedWithLazyPropertiesUnfetched = lazyPropertiesAreUnfetched;
- this.persister=persister;
- this.entityMode = entityMode;
- this.entityName = persister == null ?
- null : persister.getEntityName();
- }
-
- /**
- * Used during custom deserialization
- */
- private EntityEntry(
- final SessionFactoryImplementor factory,
- final String entityName,
- final Serializable id,
- final EntityMode entityMode,
- final Status status,
- final Object[] loadedState,
- final Object[] deletedState,
- final Object version,
- final LockMode lockMode,
- final boolean existsInDatabase,
- final boolean isBeingReplicated,
- final boolean loadedWithLazyPropertiesUnfetched) {
- this.entityName = entityName;
- this.persister = factory.getEntityPersister( entityName );
- this.id = id;
- this.entityMode = entityMode;
- this.status = status;
- this.loadedState = loadedState;
- this.deletedState = deletedState;
- this.version = version;
- this.lockMode = lockMode;
- this.existsInDatabase = existsInDatabase;
- this.isBeingReplicated = isBeingReplicated;
- this.loadedWithLazyPropertiesUnfetched = loadedWithLazyPropertiesUnfetched;
- this.rowId = null; // this is equivalent to the old behavior...
- }
-
- public LockMode getLockMode() {
- return lockMode;
- }
-
- public void setLockMode(LockMode lockMode) {
- this.lockMode = lockMode;
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- if (status==Status.READ_ONLY) {
- loadedState = null; //memory optimization
- }
- this.status = status;
- }
-
- public Serializable getId() {
- return id;
- }
-
- public Object[] getLoadedState() {
- return loadedState;
- }
-
- public Object[] getDeletedState() {
- return deletedState;
- }
-
- public void setDeletedState(Object[] deletedState) {
- this.deletedState = deletedState;
- }
-
- public boolean isExistsInDatabase() {
- return existsInDatabase;
- }
-
- public Object getVersion() {
- return version;
- }
-
- public EntityPersister getPersister() {
- return persister;
- }
-
- void afterDeserialize(SessionFactoryImplementor factory) {
- persister = factory.getEntityPersister( entityName );
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public boolean isBeingReplicated() {
- return isBeingReplicated;
- }
-
- public Object getRowId() {
- return rowId;
- }
-
- /**
- * After actually updating the database, update the snapshot information,
- * and escalate the lock mode
- */
- public void postUpdate(Object entity, Object[] updatedState, Object nextVersion) {
- this.loadedState = updatedState;
-
- setLockMode(LockMode.WRITE);
-
- if ( getPersister().isVersioned() ) {
- this.version = nextVersion;
- getPersister().setPropertyValue(
- entity,
- getPersister().getVersionProperty(),
- nextVersion,
- entityMode
- );
- }
-
- FieldInterceptionHelper.clearDirty( entity );
- }
-
- /**
- * After actually deleting a row, record the fact that the instance no longer
- * exists in the database
- */
- public void postDelete() {
- status = Status.GONE;
- existsInDatabase = false;
- }
-
- /**
- * After actually inserting a row, record the fact that the instance exists on the
- * database (needed for identity-column key generation)
- */
- public void postInsert() {
- existsInDatabase = true;
- }
-
- public boolean isNullifiable(boolean earlyInsert, SessionImplementor session) {
- return getStatus() == Status.SAVING || (
- earlyInsert ?
- !isExistsInDatabase() :
- session.getPersistenceContext().getNullifiableEntityKeys()
- .contains( new EntityKey( getId(), getPersister(), entityMode ) )
- );
- }
-
- public Object getLoadedValue(String propertyName) {
- int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex(propertyName);
- return loadedState[propertyIndex];
- }
-
-
- public boolean requiresDirtyCheck(Object entity) {
-
- boolean isMutableInstance =
- status != Status.READ_ONLY &&
- persister.isMutable();
-
- return isMutableInstance && (
- getPersister().hasMutableProperties() ||
- !FieldInterceptionHelper.isInstrumented( entity ) ||
- FieldInterceptionHelper.extractFieldInterceptor( entity).isDirty()
- );
-
- }
-
- public void forceLocked(Object entity, Object nextVersion) {
- version = nextVersion;
- loadedState[ persister.getVersionProperty() ] = version;
- setLockMode( LockMode.FORCE );
- persister.setPropertyValue(
- entity,
- getPersister().getVersionProperty(),
- nextVersion,
- entityMode
- );
- }
-
- public void setReadOnly(boolean readOnly, Object entity) {
- if (status!=Status.MANAGED && status!=Status.READ_ONLY) {
- throw new HibernateException("instance was not in a valid state");
- }
- if (readOnly) {
- setStatus(Status.READ_ONLY);
- loadedState = null;
- }
- else {
- setStatus(Status.MANAGED);
- loadedState = getPersister().getPropertyValues(entity, entityMode);
- }
- }
-
- public String toString() {
- return "EntityEntry" +
- MessageHelper.infoString(entityName, id) +
- '(' + status + ')';
- }
-
- public boolean isLoadedWithLazyPropertiesUnfetched() {
- return loadedWithLazyPropertiesUnfetched;
- }
-
-
- /**
- * Custom serialization routine used during serialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param oos The stream to which we should write the serial data.
- * @throws java.io.IOException
- */
- void serialize(ObjectOutputStream oos) throws IOException {
- oos.writeObject( entityName );
- oos.writeObject( id );
- oos.writeObject( entityMode.toString() );
- oos.writeObject( status.toString() );
- // todo : potentially look at optimizing these two arrays
- oos.writeObject( loadedState );
- oos.writeObject( deletedState );
- oos.writeObject( version );
- oos.writeObject( lockMode.toString() );
- oos.writeBoolean( existsInDatabase );
- oos.writeBoolean( isBeingReplicated );
- oos.writeBoolean( loadedWithLazyPropertiesUnfetched );
- }
-
- /**
- * Custom deserialization routine used during deserialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param ois The stream from which to read the entry.
- * @param session The session being deserialized.
- * @return The deserialized EntityEntry
- * @throws IOException
- * @throws ClassNotFoundException
- */
- static EntityEntry deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- return new EntityEntry(
- session.getFactory(),
- ( String ) ois.readObject(),
- ( Serializable ) ois.readObject(),
- EntityMode.parse( ( String ) ois.readObject() ),
- Status.parse( ( String ) ois.readObject() ),
- ( Object[] ) ois.readObject(),
- ( Object[] ) ois.readObject(),
- ( Object ) ois.readObject(),
- LockMode.parse( ( String ) ois.readObject() ),
- ois.readBoolean(),
- ois.readBoolean(),
- ois.readBoolean()
- );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/EntityEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,339 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.intercept.FieldInterceptionHelper;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.persister.entity.UniqueKeyLoadable;
+import org.hibernate.pretty.MessageHelper;
+
+/**
+ * We need an entry to tell us all about the current state
+ * of an object with respect to its persistent state
+ *
+ * @author Gavin King
+ */
+public final class EntityEntry implements Serializable {
+
+ private LockMode lockMode;
+ private Status status;
+ private final Serializable id;
+ private Object[] loadedState;
+ private Object[] deletedState;
+ private boolean existsInDatabase;
+ private Object version;
+ private transient EntityPersister persister; // for convenience to save some lookups
+ private final EntityMode entityMode;
+ private final String entityName;
+ private boolean isBeingReplicated;
+ private boolean loadedWithLazyPropertiesUnfetched; //NOTE: this is not updated when properties are fetched lazily!
+ private final transient Object rowId;
+
+ EntityEntry(
+ final Status status,
+ final Object[] loadedState,
+ final Object rowId,
+ final Serializable id,
+ final Object version,
+ final LockMode lockMode,
+ final boolean existsInDatabase,
+ final EntityPersister persister,
+ final EntityMode entityMode,
+ final boolean disableVersionIncrement,
+ final boolean lazyPropertiesAreUnfetched) {
+ this.status=status;
+ this.loadedState=loadedState;
+ this.id=id;
+ this.rowId=rowId;
+ this.existsInDatabase=existsInDatabase;
+ this.version=version;
+ this.lockMode=lockMode;
+ this.isBeingReplicated=disableVersionIncrement;
+ this.loadedWithLazyPropertiesUnfetched = lazyPropertiesAreUnfetched;
+ this.persister=persister;
+ this.entityMode = entityMode;
+ this.entityName = persister == null ?
+ null : persister.getEntityName();
+ }
+
+ /**
+ * Used during custom deserialization
+ */
+ private EntityEntry(
+ final SessionFactoryImplementor factory,
+ final String entityName,
+ final Serializable id,
+ final EntityMode entityMode,
+ final Status status,
+ final Object[] loadedState,
+ final Object[] deletedState,
+ final Object version,
+ final LockMode lockMode,
+ final boolean existsInDatabase,
+ final boolean isBeingReplicated,
+ final boolean loadedWithLazyPropertiesUnfetched) {
+ this.entityName = entityName;
+ this.persister = factory.getEntityPersister( entityName );
+ this.id = id;
+ this.entityMode = entityMode;
+ this.status = status;
+ this.loadedState = loadedState;
+ this.deletedState = deletedState;
+ this.version = version;
+ this.lockMode = lockMode;
+ this.existsInDatabase = existsInDatabase;
+ this.isBeingReplicated = isBeingReplicated;
+ this.loadedWithLazyPropertiesUnfetched = loadedWithLazyPropertiesUnfetched;
+ this.rowId = null; // this is equivalent to the old behavior...
+ }
+
+ public LockMode getLockMode() {
+ return lockMode;
+ }
+
+ public void setLockMode(LockMode lockMode) {
+ this.lockMode = lockMode;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ if (status==Status.READ_ONLY) {
+ loadedState = null; //memory optimization
+ }
+ this.status = status;
+ }
+
+ public Serializable getId() {
+ return id;
+ }
+
+ public Object[] getLoadedState() {
+ return loadedState;
+ }
+
+ public Object[] getDeletedState() {
+ return deletedState;
+ }
+
+ public void setDeletedState(Object[] deletedState) {
+ this.deletedState = deletedState;
+ }
+
+ public boolean isExistsInDatabase() {
+ return existsInDatabase;
+ }
+
+ public Object getVersion() {
+ return version;
+ }
+
+ public EntityPersister getPersister() {
+ return persister;
+ }
+
+ void afterDeserialize(SessionFactoryImplementor factory) {
+ persister = factory.getEntityPersister( entityName );
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public boolean isBeingReplicated() {
+ return isBeingReplicated;
+ }
+
+ public Object getRowId() {
+ return rowId;
+ }
+
+ /**
+ * After actually updating the database, update the snapshot information,
+ * and escalate the lock mode
+ */
+ public void postUpdate(Object entity, Object[] updatedState, Object nextVersion) {
+ this.loadedState = updatedState;
+
+ setLockMode(LockMode.WRITE);
+
+ if ( getPersister().isVersioned() ) {
+ this.version = nextVersion;
+ getPersister().setPropertyValue(
+ entity,
+ getPersister().getVersionProperty(),
+ nextVersion,
+ entityMode
+ );
+ }
+
+ FieldInterceptionHelper.clearDirty( entity );
+ }
+
+ /**
+ * After actually deleting a row, record the fact that the instance no longer
+ * exists in the database
+ */
+ public void postDelete() {
+ status = Status.GONE;
+ existsInDatabase = false;
+ }
+
+ /**
+ * After actually inserting a row, record the fact that the instance exists on the
+ * database (needed for identity-column key generation)
+ */
+ public void postInsert() {
+ existsInDatabase = true;
+ }
+
+ public boolean isNullifiable(boolean earlyInsert, SessionImplementor session) {
+ return getStatus() == Status.SAVING || (
+ earlyInsert ?
+ !isExistsInDatabase() :
+ session.getPersistenceContext().getNullifiableEntityKeys()
+ .contains( new EntityKey( getId(), getPersister(), entityMode ) )
+ );
+ }
+
+ public Object getLoadedValue(String propertyName) {
+ int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex(propertyName);
+ return loadedState[propertyIndex];
+ }
+
+
+ public boolean requiresDirtyCheck(Object entity) {
+
+ boolean isMutableInstance =
+ status != Status.READ_ONLY &&
+ persister.isMutable();
+
+ return isMutableInstance && (
+ getPersister().hasMutableProperties() ||
+ !FieldInterceptionHelper.isInstrumented( entity ) ||
+ FieldInterceptionHelper.extractFieldInterceptor( entity).isDirty()
+ );
+
+ }
+
+ public void forceLocked(Object entity, Object nextVersion) {
+ version = nextVersion;
+ loadedState[ persister.getVersionProperty() ] = version;
+ setLockMode( LockMode.FORCE );
+ persister.setPropertyValue(
+ entity,
+ getPersister().getVersionProperty(),
+ nextVersion,
+ entityMode
+ );
+ }
+
+ public void setReadOnly(boolean readOnly, Object entity) {
+ if (status!=Status.MANAGED && status!=Status.READ_ONLY) {
+ throw new HibernateException("instance was not in a valid state");
+ }
+ if (readOnly) {
+ setStatus(Status.READ_ONLY);
+ loadedState = null;
+ }
+ else {
+ setStatus(Status.MANAGED);
+ loadedState = getPersister().getPropertyValues(entity, entityMode);
+ }
+ }
+
+ public String toString() {
+ return "EntityEntry" +
+ MessageHelper.infoString(entityName, id) +
+ '(' + status + ')';
+ }
+
+ public boolean isLoadedWithLazyPropertiesUnfetched() {
+ return loadedWithLazyPropertiesUnfetched;
+ }
+
+
+ /**
+ * Custom serialization routine used during serialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param oos The stream to which we should write the serial data.
+ * @throws java.io.IOException
+ */
+ void serialize(ObjectOutputStream oos) throws IOException {
+ oos.writeObject( entityName );
+ oos.writeObject( id );
+ oos.writeObject( entityMode.toString() );
+ oos.writeObject( status.toString() );
+ // todo : potentially look at optimizing these two arrays
+ oos.writeObject( loadedState );
+ oos.writeObject( deletedState );
+ oos.writeObject( version );
+ oos.writeObject( lockMode.toString() );
+ oos.writeBoolean( existsInDatabase );
+ oos.writeBoolean( isBeingReplicated );
+ oos.writeBoolean( loadedWithLazyPropertiesUnfetched );
+ }
+
+ /**
+ * Custom deserialization routine used during deserialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param ois The stream from which to read the entry.
+ * @param session The session being deserialized.
+ * @return The deserialized EntityEntry
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ static EntityEntry deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ return new EntityEntry(
+ session.getFactory(),
+ ( String ) ois.readObject(),
+ ( Serializable ) ois.readObject(),
+ EntityMode.parse( ( String ) ois.readObject() ),
+ Status.parse( ( String ) ois.readObject() ),
+ ( Object[] ) ois.readObject(),
+ ( Object[] ) ois.readObject(),
+ ( Object ) ois.readObject(),
+ LockMode.parse( ( String ) ois.readObject() ),
+ ois.readBoolean(),
+ ois.readBoolean(),
+ ois.readBoolean()
+ );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/EntityKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,156 +0,0 @@
-//$Id: EntityKey.java 9194 2006-02-01 19:59:07Z steveebersole $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-import org.hibernate.AssertionFailure;
-import org.hibernate.EntityMode;
-import org.hibernate.util.SerializationHelper;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.type.Type;
-
-/**
- * Uniquely identifies of an entity instance in a particular session by identifier.
- * <p/>
- * Uniqueing information consists of the entity-name and the identifier value.
- *
- * @see EntityUniqueKey
- * @author Gavin King
- */
-public final class EntityKey implements Serializable {
- private final Serializable identifier;
- private final String rootEntityName;
- private final String entityName;
- private final Type identifierType;
- private final boolean isBatchLoadable;
- private final SessionFactoryImplementor factory;
- private final int hashCode;
- private final EntityMode entityMode;
-
- /**
- * Construct a unique identifier for an entity class instance
- */
- public EntityKey(Serializable id, EntityPersister persister, EntityMode entityMode) {
- if ( id == null ) {
- throw new AssertionFailure( "null identifier" );
- }
- this.identifier = id;
- this.entityMode = entityMode;
- this.rootEntityName = persister.getRootEntityName();
- this.entityName = persister.getEntityName();
- this.identifierType = persister.getIdentifierType();
- this.isBatchLoadable = persister.isBatchLoadable();
- this.factory = persister.getFactory();
- hashCode = generateHashCode(); //cache the hashcode
- }
-
- /**
- * Used to reconstruct an EntityKey during deserialization.
- *
- * @param identifier The identifier value
- * @param rootEntityName The root entity name
- * @param entityName The specific entity name
- * @param identifierType The type of the identifier value
- * @param batchLoadable Whether represented entity is eligible for batch loading
- * @param factory The session factory
- * @param entityMode The entity's entity mode
- */
- private EntityKey(
- Serializable identifier,
- String rootEntityName,
- String entityName,
- Type identifierType,
- boolean batchLoadable,
- SessionFactoryImplementor factory,
- EntityMode entityMode) {
- this.identifier = identifier;
- this.rootEntityName = rootEntityName;
- this.entityName = entityName;
- this.identifierType = identifierType;
- this.isBatchLoadable = batchLoadable;
- this.factory = factory;
- this.entityMode = entityMode;
- this.hashCode = generateHashCode();
- }
-
- public boolean isBatchLoadable() {
- return isBatchLoadable;
- }
-
- /**
- * Get the user-visible identifier
- */
- public Serializable getIdentifier() {
- return identifier;
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public boolean equals(Object other) {
- EntityKey otherKey = (EntityKey) other;
- return otherKey.rootEntityName.equals(this.rootEntityName) &&
- identifierType.isEqual(otherKey.identifier, this.identifier, entityMode, factory);
- }
-
- private int generateHashCode() {
- int result = 17;
- result = 37 * result + rootEntityName.hashCode();
- result = 37 * result + identifierType.getHashCode( identifier, entityMode, factory );
- return result;
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public String toString() {
- return "EntityKey" +
- MessageHelper.infoString( factory.getEntityPersister( entityName ), identifier, factory );
- }
-
- /**
- * Custom serialization routine used during serialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param oos The stream to which we should write the serial data.
- * @throws IOException
- */
- void serialize(ObjectOutputStream oos) throws IOException {
- oos.writeObject( identifier );
- oos.writeObject( rootEntityName );
- oos.writeObject( entityName );
- oos.writeObject( identifierType );
- oos.writeBoolean( isBatchLoadable );
- oos.writeObject( entityMode.toString() );
- }
-
- /**
- * Custom deserialization routine used during deserialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param ois The stream from which to read the entry.
- * @param session The session being deserialized.
- * @return The deserialized EntityEntry
- * @throws IOException
- * @throws ClassNotFoundException
- */
- static EntityKey deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- return new EntityKey(
- ( Serializable ) ois.readObject(),
- ( String ) ois.readObject(),
- ( String ) ois.readObject(),
- ( Type ) ois.readObject(),
- ois.readBoolean(),
- session.getFactory(),
- EntityMode.parse( ( String ) ois.readObject() )
- );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/EntityKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,178 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import org.hibernate.AssertionFailure;
+import org.hibernate.EntityMode;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.type.Type;
+
+/**
+ * Uniquely identifies of an entity instance in a particular session by identifier.
+ * <p/>
+ * Uniqueing information consists of the entity-name and the identifier value.
+ *
+ * @see EntityUniqueKey
+ * @author Gavin King
+ */
+public final class EntityKey implements Serializable {
+ private final Serializable identifier;
+ private final String rootEntityName;
+ private final String entityName;
+ private final Type identifierType;
+ private final boolean isBatchLoadable;
+ private final SessionFactoryImplementor factory;
+ private final int hashCode;
+ private final EntityMode entityMode;
+
+ /**
+ * Construct a unique identifier for an entity class instance
+ */
+ public EntityKey(Serializable id, EntityPersister persister, EntityMode entityMode) {
+ if ( id == null ) {
+ throw new AssertionFailure( "null identifier" );
+ }
+ this.identifier = id;
+ this.entityMode = entityMode;
+ this.rootEntityName = persister.getRootEntityName();
+ this.entityName = persister.getEntityName();
+ this.identifierType = persister.getIdentifierType();
+ this.isBatchLoadable = persister.isBatchLoadable();
+ this.factory = persister.getFactory();
+ hashCode = generateHashCode(); //cache the hashcode
+ }
+
+ /**
+ * Used to reconstruct an EntityKey during deserialization.
+ *
+ * @param identifier The identifier value
+ * @param rootEntityName The root entity name
+ * @param entityName The specific entity name
+ * @param identifierType The type of the identifier value
+ * @param batchLoadable Whether represented entity is eligible for batch loading
+ * @param factory The session factory
+ * @param entityMode The entity's entity mode
+ */
+ private EntityKey(
+ Serializable identifier,
+ String rootEntityName,
+ String entityName,
+ Type identifierType,
+ boolean batchLoadable,
+ SessionFactoryImplementor factory,
+ EntityMode entityMode) {
+ this.identifier = identifier;
+ this.rootEntityName = rootEntityName;
+ this.entityName = entityName;
+ this.identifierType = identifierType;
+ this.isBatchLoadable = batchLoadable;
+ this.factory = factory;
+ this.entityMode = entityMode;
+ this.hashCode = generateHashCode();
+ }
+
+ public boolean isBatchLoadable() {
+ return isBatchLoadable;
+ }
+
+ /**
+ * Get the user-visible identifier
+ */
+ public Serializable getIdentifier() {
+ return identifier;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public boolean equals(Object other) {
+ EntityKey otherKey = (EntityKey) other;
+ return otherKey.rootEntityName.equals(this.rootEntityName) &&
+ identifierType.isEqual(otherKey.identifier, this.identifier, entityMode, factory);
+ }
+
+ private int generateHashCode() {
+ int result = 17;
+ result = 37 * result + rootEntityName.hashCode();
+ result = 37 * result + identifierType.getHashCode( identifier, entityMode, factory );
+ return result;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public String toString() {
+ return "EntityKey" +
+ MessageHelper.infoString( factory.getEntityPersister( entityName ), identifier, factory );
+ }
+
+ /**
+ * Custom serialization routine used during serialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param oos The stream to which we should write the serial data.
+ * @throws IOException
+ */
+ void serialize(ObjectOutputStream oos) throws IOException {
+ oos.writeObject( identifier );
+ oos.writeObject( rootEntityName );
+ oos.writeObject( entityName );
+ oos.writeObject( identifierType );
+ oos.writeBoolean( isBatchLoadable );
+ oos.writeObject( entityMode.toString() );
+ }
+
+ /**
+ * Custom deserialization routine used during deserialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param ois The stream from which to read the entry.
+ * @param session The session being deserialized.
+ * @return The deserialized EntityEntry
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ static EntityKey deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ return new EntityKey(
+ ( Serializable ) ois.readObject(),
+ ( String ) ois.readObject(),
+ ( String ) ois.readObject(),
+ ( Type ) ois.readObject(),
+ ois.readBoolean(),
+ session.getFactory(),
+ EntityMode.parse( ( String ) ois.readObject() )
+ );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,137 +0,0 @@
-//$Id: EntityUniqueKey.java 9194 2006-02-01 19:59:07Z steveebersole $
-package org.hibernate.engine;
-
-import org.hibernate.EntityMode;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.type.Type;
-
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-
-/**
- * Used to uniquely key an entity instance in relation to a particular session
- * by some unique property reference, as opposed to identifier.
- * <p/>
- * Uniqueing information consists of the entity-name, the referenced
- * property name, and the referenced property value.
- *
- * @see EntityKey
- * @author Gavin King
- */
-public class EntityUniqueKey implements Serializable {
- private final String uniqueKeyName;
- private final String entityName;
- private final Object key;
- private final Type keyType;
- private final EntityMode entityMode;
- private final int hashCode;
-
- public EntityUniqueKey(
- final String entityName,
- final String uniqueKeyName,
- final Object semiResolvedKey,
- final Type keyType,
- final EntityMode entityMode,
- final SessionFactoryImplementor factory
- ) {
- this.uniqueKeyName = uniqueKeyName;
- this.entityName = entityName;
- this.key = semiResolvedKey;
- this.keyType = keyType.getSemiResolvedType(factory);
- this.entityMode = entityMode;
- this.hashCode = generateHashCode(factory);
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public Object getKey() {
- return key;
- }
-
- public String getUniqueKeyName() {
- return uniqueKeyName;
- }
-
- public int generateHashCode(SessionFactoryImplementor factory) {
- int result = 17;
- result = 37 * result + entityName.hashCode();
- result = 37 * result + uniqueKeyName.hashCode();
- result = 37 * result + keyType.getHashCode(key, entityMode, factory);
- return result;
- }
-
- public int hashCode() {
- return hashCode;
- }
-
- public boolean equals(Object other) {
- EntityUniqueKey that = (EntityUniqueKey) other;
- return that.entityName.equals(entityName) &&
- that.uniqueKeyName.equals(uniqueKeyName) &&
- keyType.isEqual(that.key, key, entityMode);
- }
-
- public String toString() {
- return "EntityUniqueKey" + MessageHelper.infoString(entityName, uniqueKeyName, key);
- }
-
- private void writeObject(ObjectOutputStream oos) throws IOException {
- checkAbilityToSerialize();
- oos.defaultWriteObject();
- }
-
- private void checkAbilityToSerialize() {
- // The unique property value represented here may or may not be
- // serializable, so we do an explicit check here in order to generate
- // a better error message
- if ( key != null && ! Serializable.class.isAssignableFrom( key.getClass() ) ) {
- throw new IllegalStateException(
- "Cannot serialize an EntityUniqueKey which represents a non " +
- "serializable property value [" + entityName + "." + uniqueKeyName + "]"
- );
- }
- }
-
- /**
- * Custom serialization routine used during serialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param oos The stream to which we should write the serial data.
- * @throws IOException
- */
- void serialize(ObjectOutputStream oos) throws IOException {
- checkAbilityToSerialize();
- oos.writeObject( uniqueKeyName );
- oos.writeObject( entityName );
- oos.writeObject( key );
- oos.writeObject( keyType );
- oos.writeObject( entityMode );
- }
-
- /**
- * Custom deserialization routine used during deserialization of a
- * Session/PersistenceContext for increased performance.
- *
- * @param ois The stream from which to read the entry.
- * @param session The session being deserialized.
- * @return The deserialized EntityEntry
- * @throws IOException
- * @throws ClassNotFoundException
- */
- static EntityUniqueKey deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- return new EntityUniqueKey(
- ( String ) ois.readObject(),
- ( String ) ois.readObject(),
- ois.readObject(),
- ( Type ) ois.readObject(),
- ( EntityMode ) ois.readObject(),
- session.getFactory()
- );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/EntityUniqueKey.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,160 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.EntityMode;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * Used to uniquely key an entity instance in relation to a particular session
+ * by some unique property reference, as opposed to identifier.
+ * <p/>
+ * Uniqueing information consists of the entity-name, the referenced
+ * property name, and the referenced property value.
+ *
+ * @see EntityKey
+ * @author Gavin King
+ */
+public class EntityUniqueKey implements Serializable {
+ private final String uniqueKeyName;
+ private final String entityName;
+ private final Object key;
+ private final Type keyType;
+ private final EntityMode entityMode;
+ private final int hashCode;
+
+ public EntityUniqueKey(
+ final String entityName,
+ final String uniqueKeyName,
+ final Object semiResolvedKey,
+ final Type keyType,
+ final EntityMode entityMode,
+ final SessionFactoryImplementor factory
+ ) {
+ this.uniqueKeyName = uniqueKeyName;
+ this.entityName = entityName;
+ this.key = semiResolvedKey;
+ this.keyType = keyType.getSemiResolvedType(factory);
+ this.entityMode = entityMode;
+ this.hashCode = generateHashCode(factory);
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public String getUniqueKeyName() {
+ return uniqueKeyName;
+ }
+
+ public int generateHashCode(SessionFactoryImplementor factory) {
+ int result = 17;
+ result = 37 * result + entityName.hashCode();
+ result = 37 * result + uniqueKeyName.hashCode();
+ result = 37 * result + keyType.getHashCode(key, entityMode, factory);
+ return result;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+
+ public boolean equals(Object other) {
+ EntityUniqueKey that = (EntityUniqueKey) other;
+ return that.entityName.equals(entityName) &&
+ that.uniqueKeyName.equals(uniqueKeyName) &&
+ keyType.isEqual(that.key, key, entityMode);
+ }
+
+ public String toString() {
+ return "EntityUniqueKey" + MessageHelper.infoString(entityName, uniqueKeyName, key);
+ }
+
+ private void writeObject(ObjectOutputStream oos) throws IOException {
+ checkAbilityToSerialize();
+ oos.defaultWriteObject();
+ }
+
+ private void checkAbilityToSerialize() {
+ // The unique property value represented here may or may not be
+ // serializable, so we do an explicit check here in order to generate
+ // a better error message
+ if ( key != null && ! Serializable.class.isAssignableFrom( key.getClass() ) ) {
+ throw new IllegalStateException(
+ "Cannot serialize an EntityUniqueKey which represents a non " +
+ "serializable property value [" + entityName + "." + uniqueKeyName + "]"
+ );
+ }
+ }
+
+ /**
+ * Custom serialization routine used during serialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param oos The stream to which we should write the serial data.
+ * @throws IOException
+ */
+ void serialize(ObjectOutputStream oos) throws IOException {
+ checkAbilityToSerialize();
+ oos.writeObject( uniqueKeyName );
+ oos.writeObject( entityName );
+ oos.writeObject( key );
+ oos.writeObject( keyType );
+ oos.writeObject( entityMode );
+ }
+
+ /**
+ * Custom deserialization routine used during deserialization of a
+ * Session/PersistenceContext for increased performance.
+ *
+ * @param ois The stream from which to read the entry.
+ * @param session The session being deserialized.
+ * @return The deserialized EntityEntry
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ static EntityUniqueKey deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ return new EntityUniqueKey(
+ ( String ) ois.readObject(),
+ ( String ) ois.readObject(),
+ ois.readObject(),
+ ( Type ) ois.readObject(),
+ ( EntityMode ) ois.readObject(),
+ session.getFactory()
+ );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,73 +0,0 @@
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.io.ObjectStreamException;
-import java.io.InvalidObjectException;
-
-/**
- * For persistence operations (INSERT, UPDATE, DELETE) what style of determining
- * results (success/failure) is to be used.
- *
- * @author Steve Ebersole
- */
-public class ExecuteUpdateResultCheckStyle implements Serializable {
- /**
- * Do not perform checking. Either user simply does not want checking, or is
- * indicating a {@link java.sql.CallableStatement} execution in which the
- * checks are being performed explicitly and failures are handled through
- * propogation of {@link java.sql.SQLException}s.
- */
- public static final ExecuteUpdateResultCheckStyle NONE = new ExecuteUpdateResultCheckStyle( "none" );
- /**
- * Perform row-count checking. Row counts are the int values returned by both
- * {@link java.sql.PreparedStatement#executeUpdate()} and
- * {@link java.sql.Statement#executeBatch()}. These values are checked
- * against some expected count.
- */
- public static final ExecuteUpdateResultCheckStyle COUNT = new ExecuteUpdateResultCheckStyle( "rowcount" );
- /**
- * Essentially the same as {@link #COUNT} except that the row count actually
- * comes from an output parameter registered as part of a
- * {@link java.sql.CallableStatement}. This style explicitly prohibits
- * statement batching from being used...
- */
- public static final ExecuteUpdateResultCheckStyle PARAM = new ExecuteUpdateResultCheckStyle( "param" );
-
- private final String name;
-
- private ExecuteUpdateResultCheckStyle(String name) {
- this.name = name;
- }
-
- private Object readResolve() throws ObjectStreamException {
- Object resolved = parse( name );
- if ( resolved == null ) {
- throw new InvalidObjectException( "unknown result style [" + name + "]" );
- }
- return resolved;
- }
-
- public static ExecuteUpdateResultCheckStyle parse(String name) {
- if ( name.equals( NONE.name ) ) {
- return NONE;
- }
- else if ( name.equals( COUNT.name ) ) {
- return COUNT;
- }
- else if ( name.equals( PARAM.name ) ) {
- return PARAM;
- }
- else {
- return null;
- }
- }
-
- public static ExecuteUpdateResultCheckStyle determineDefault(String customSql, boolean callable) {
- if ( customSql == null ) {
- return COUNT;
- }
- else {
- return callable ? PARAM : COUNT;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ExecuteUpdateResultCheckStyle.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,97 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.io.ObjectStreamException;
+import java.io.InvalidObjectException;
+
+/**
+ * For persistence operations (INSERT, UPDATE, DELETE) what style of determining
+ * results (success/failure) is to be used.
+ *
+ * @author Steve Ebersole
+ */
+public class ExecuteUpdateResultCheckStyle implements Serializable {
+ /**
+ * Do not perform checking. Either user simply does not want checking, or is
+ * indicating a {@link java.sql.CallableStatement} execution in which the
+ * checks are being performed explicitly and failures are handled through
+ * propogation of {@link java.sql.SQLException}s.
+ */
+ public static final ExecuteUpdateResultCheckStyle NONE = new ExecuteUpdateResultCheckStyle( "none" );
+ /**
+ * Perform row-count checking. Row counts are the int values returned by both
+ * {@link java.sql.PreparedStatement#executeUpdate()} and
+ * {@link java.sql.Statement#executeBatch()}. These values are checked
+ * against some expected count.
+ */
+ public static final ExecuteUpdateResultCheckStyle COUNT = new ExecuteUpdateResultCheckStyle( "rowcount" );
+ /**
+ * Essentially the same as {@link #COUNT} except that the row count actually
+ * comes from an output parameter registered as part of a
+ * {@link java.sql.CallableStatement}. This style explicitly prohibits
+ * statement batching from being used...
+ */
+ public static final ExecuteUpdateResultCheckStyle PARAM = new ExecuteUpdateResultCheckStyle( "param" );
+
+ private final String name;
+
+ private ExecuteUpdateResultCheckStyle(String name) {
+ this.name = name;
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ Object resolved = parse( name );
+ if ( resolved == null ) {
+ throw new InvalidObjectException( "unknown result style [" + name + "]" );
+ }
+ return resolved;
+ }
+
+ public static ExecuteUpdateResultCheckStyle parse(String name) {
+ if ( name.equals( NONE.name ) ) {
+ return NONE;
+ }
+ else if ( name.equals( COUNT.name ) ) {
+ return COUNT;
+ }
+ else if ( name.equals( PARAM.name ) ) {
+ return PARAM;
+ }
+ else {
+ return null;
+ }
+ }
+
+ public static ExecuteUpdateResultCheckStyle determineDefault(String customSql, boolean callable) {
+ if ( customSql == null ) {
+ return COUNT;
+ }
+ else {
+ return callable ? PARAM : COUNT;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/FilterDefinition.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,69 +0,0 @@
-// $Id: FilterDefinition.java 9765 2006-04-19 01:45:07Z max.andersen(a)jboss.com $
-package org.hibernate.engine;
-
-import org.hibernate.type.Type;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-
-/**
- * A FilterDefinition defines the global attributes of a dynamic filter. This
- * information includes its name as well as its defined parameters (name and type).
- *
- * @author Steve Ebersole
- */
-public class FilterDefinition implements Serializable {
- private final String filterName;
- private final String defaultFilterCondition;
- private final Map parameterTypes = new HashMap();
-
- /**
- * Construct a new FilterDefinition instance.
- *
- * @param name The name of the filter for which this configuration is in effect.
- */
- public FilterDefinition(String name, String defaultCondition, Map parameterTypes) {
- this.filterName = name;
- this.defaultFilterCondition = defaultCondition;
- this.parameterTypes.putAll( parameterTypes );
- }
-
- /**
- * Get the name of the filter this configuration defines.
- *
- * @return The filter name for this configuration.
- */
- public String getFilterName() {
- return filterName;
- }
-
- /**
- * Get a set of the parameters defined by this configuration.
- *
- * @return The parameters named by this configuration.
- */
- public Set getParameterNames() {
- return parameterTypes.keySet();
- }
-
- /**
- * Retreive the type of the named parameter defined for this filter.
- *
- * @param parameterName The name of the filter parameter for which to return the type.
- * @return The type of the named parameter.
- */
- public Type getParameterType(String parameterName) {
- return (Type) parameterTypes.get(parameterName);
- }
-
- public String getDefaultFilterCondition() {
- return defaultFilterCondition;
- }
-
- public Map getParameterTypes() {
- return parameterTypes;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/FilterDefinition.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/FilterDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,92 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * A FilterDefinition defines the global attributes of a dynamic filter. This
+ * information includes its name as well as its defined parameters (name and type).
+ *
+ * @author Steve Ebersole
+ */
+public class FilterDefinition implements Serializable {
+ private final String filterName;
+ private final String defaultFilterCondition;
+ private final Map parameterTypes = new HashMap();
+
+ /**
+ * Construct a new FilterDefinition instance.
+ *
+ * @param name The name of the filter for which this configuration is in effect.
+ */
+ public FilterDefinition(String name, String defaultCondition, Map parameterTypes) {
+ this.filterName = name;
+ this.defaultFilterCondition = defaultCondition;
+ this.parameterTypes.putAll( parameterTypes );
+ }
+
+ /**
+ * Get the name of the filter this configuration defines.
+ *
+ * @return The filter name for this configuration.
+ */
+ public String getFilterName() {
+ return filterName;
+ }
+
+ /**
+ * Get a set of the parameters defined by this configuration.
+ *
+ * @return The parameters named by this configuration.
+ */
+ public Set getParameterNames() {
+ return parameterTypes.keySet();
+ }
+
+ /**
+ * Retreive the type of the named parameter defined for this filter.
+ *
+ * @param parameterName The name of the filter parameter for which to return the type.
+ * @return The type of the named parameter.
+ */
+ public Type getParameterType(String parameterName) {
+ return (Type) parameterTypes.get(parameterName);
+ }
+
+ public String getDefaultFilterCondition() {
+ return defaultFilterCondition;
+ }
+
+ public Map getParameterTypes() {
+ return parameterTypes;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ForeignKeys.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,230 +0,0 @@
-//$Id: ForeignKeys.java 10133 2006-07-24 10:35:25Z max.andersen(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-
-import org.hibernate.HibernateException;
-import org.hibernate.TransientObjectException;
-import org.hibernate.intercept.LazyPropertyInitializer;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.proxy.LazyInitializer;
-import org.hibernate.type.AbstractComponentType;
-import org.hibernate.type.EntityType;
-import org.hibernate.type.Type;
-
-/**
- * Algorithms related to foreign key constraint transparency
- *
- * @author Gavin King
- */
-public final class ForeignKeys {
-
- private ForeignKeys() {}
-
- public static class Nullifier {
-
- private final boolean isDelete;
- private final boolean isEarlyInsert;
- private final SessionImplementor session;
- private final Object self;
-
- public Nullifier(Object self, boolean isDelete, boolean isEarlyInsert, SessionImplementor session) {
- this.isDelete = isDelete;
- this.isEarlyInsert = isEarlyInsert;
- this.session = session;
- this.self = self;
- }
-
- /**
- * Nullify all references to entities that have not yet
- * been inserted in the database, where the foreign key
- * points toward that entity
- */
- public void nullifyTransientReferences(final Object[] values, final Type[] types)
- throws HibernateException {
- for ( int i = 0; i < types.length; i++ ) {
- values[i] = nullifyTransientReferences( values[i], types[i] );
- }
- }
-
- /**
- * Return null if the argument is an "unsaved" entity (ie.
- * one with no existing database row), or the input argument
- * otherwise. This is how Hibernate avoids foreign key constraint
- * violations.
- */
- private Object nullifyTransientReferences(final Object value, final Type type)
- throws HibernateException {
- if ( value == null ) {
- return null;
- }
- else if ( type.isEntityType() ) {
- EntityType entityType = (EntityType) type;
- if ( entityType.isOneToOne() ) {
- return value;
- }
- else {
- String entityName = entityType.getAssociatedEntityName();
- return isNullifiable(entityName, value) ? null : value;
- }
- }
- else if ( type.isAnyType() ) {
- return isNullifiable(null, value) ? null : value;
- }
- else if ( type.isComponentType() ) {
- AbstractComponentType actype = (AbstractComponentType) type;
- Object[] subvalues = actype.getPropertyValues(value, session);
- Type[] subtypes = actype.getSubtypes();
- boolean substitute = false;
- for ( int i = 0; i < subvalues.length; i++ ) {
- Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] );
- if ( replacement != subvalues[i] ) {
- substitute = true;
- subvalues[i] = replacement;
- }
- }
- if (substitute) actype.setPropertyValues( value, subvalues, session.getEntityMode() );
- return value;
- }
- else {
- return value;
- }
- }
-
- /**
- * Determine if the object already exists in the database,
- * using a "best guess"
- */
- private boolean isNullifiable(final String entityName, Object object)
- throws HibernateException {
-
- if (object==LazyPropertyInitializer.UNFETCHED_PROPERTY) return false; //this is kinda the best we can do...
-
- if ( object instanceof HibernateProxy ) {
- // if its an uninitialized proxy it can't be transient
- LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
- if ( li.getImplementation(session) == null ) {
- return false;
- // ie. we never have to null out a reference to
- // an uninitialized proxy
- }
- else {
- //unwrap it
- object = li.getImplementation();
- }
- }
-
- // if it was a reference to self, don't need to nullify
- // unless we are using native id generation, in which
- // case we definitely need to nullify
- if ( object == self ) {
- return isEarlyInsert || (
- isDelete &&
- session.getFactory()
- .getDialect()
- .hasSelfReferentialForeignKeyBug()
- );
- }
-
- // See if the entity is already bound to this session, if not look at the
- // entity identifier and assume that the entity is persistent if the
- // id is not "unsaved" (that is, we rely on foreign keys to keep
- // database integrity)
-
- EntityEntry entityEntry = session.getPersistenceContext().getEntry(object);
- if ( entityEntry==null ) {
- return isTransient(entityName, object, null, session);
- }
- else {
- return entityEntry.isNullifiable(isEarlyInsert, session);
- }
-
- }
-
- }
-
- /**
- * Is this instance persistent or detached?
- * If <tt>assumed</tt> is non-null, don't hit the database to make the
- * determination, instead assume that value; the client code must be
- * prepared to "recover" in the case that this assumed result is incorrect.
- */
- public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session)
- throws HibernateException {
- if (entity instanceof HibernateProxy) return true;
- if ( session.getPersistenceContext().isEntryFor(entity) ) return true;
- return !isTransient(entityName, entity, assumed, session);
- }
-
- /**
- * Is this instance, which we know is not persistent, actually transient?
- * If <tt>assumed</tt> is non-null, don't hit the database to make the
- * determination, instead assume that value; the client code must be
- * prepared to "recover" in the case that this assumed result is incorrect.
- */
- public static boolean isTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session)
- throws HibernateException {
-
- if (entity==LazyPropertyInitializer.UNFETCHED_PROPERTY) {
- // an unfetched association can only point to
- // an entity that already exists in the db
- return false;
- }
-
- // let the interceptor inspect the instance to decide
- Boolean isUnsaved = session.getInterceptor().isTransient(entity);
- if (isUnsaved!=null) return isUnsaved.booleanValue();
-
- // let the persister inspect the instance to decide
- EntityPersister persister = session.getEntityPersister(entityName, entity);
- isUnsaved = persister.isTransient(entity, session);
- if (isUnsaved!=null) return isUnsaved.booleanValue();
-
- // we use the assumed value, if there is one, to avoid hitting
- // the database
- if (assumed!=null) return assumed.booleanValue();
-
- // hit the database, after checking the session cache for a snapshot
- Object[] snapshot = session.getPersistenceContext()
- .getDatabaseSnapshot( persister.getIdentifier( entity, session.getEntityMode() ), persister );
- return snapshot==null;
-
- }
-
- /**
- * Return the identifier of the persistent or transient object, or throw
- * an exception if the instance is "unsaved"
- *
- * Used by OneToOneType and ManyToOneType to determine what id value should
- * be used for an object that may or may not be associated with the session.
- * This does a "best guess" using any/all info available to use (not just the
- * EntityEntry).
- */
- public static Serializable getEntityIdentifierIfNotUnsaved(
- final String entityName,
- final Object object,
- final SessionImplementor session)
- throws HibernateException {
- if ( object == null ) {
- return null;
- }
- else {
- Serializable id = session.getContextEntityIdentifier( object );
- if ( id == null ) {
- // context-entity-identifier returns null explicitly if the entity
- // is not associated with the persistence context; so make some
- // deeper checks...
- if ( isTransient(entityName, object, Boolean.FALSE, session) ) {
- throw new TransientObjectException(
- "object references an unsaved transient instance - save the transient instance before flushing: " +
- (entityName == null ? session.guessEntityName( object ) : entityName)
- );
- }
- id = session.getEntityPersister( entityName, object ).getIdentifier( object, session.getEntityMode() );
- }
- return id;
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/ForeignKeys.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ForeignKeys.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,253 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+
+import org.hibernate.HibernateException;
+import org.hibernate.TransientObjectException;
+import org.hibernate.intercept.LazyPropertyInitializer;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.proxy.HibernateProxy;
+import org.hibernate.proxy.LazyInitializer;
+import org.hibernate.type.AbstractComponentType;
+import org.hibernate.type.EntityType;
+import org.hibernate.type.Type;
+
+/**
+ * Algorithms related to foreign key constraint transparency
+ *
+ * @author Gavin King
+ */
+public final class ForeignKeys {
+
+ private ForeignKeys() {}
+
+ public static class Nullifier {
+
+ private final boolean isDelete;
+ private final boolean isEarlyInsert;
+ private final SessionImplementor session;
+ private final Object self;
+
+ public Nullifier(Object self, boolean isDelete, boolean isEarlyInsert, SessionImplementor session) {
+ this.isDelete = isDelete;
+ this.isEarlyInsert = isEarlyInsert;
+ this.session = session;
+ this.self = self;
+ }
+
+ /**
+ * Nullify all references to entities that have not yet
+ * been inserted in the database, where the foreign key
+ * points toward that entity
+ */
+ public void nullifyTransientReferences(final Object[] values, final Type[] types)
+ throws HibernateException {
+ for ( int i = 0; i < types.length; i++ ) {
+ values[i] = nullifyTransientReferences( values[i], types[i] );
+ }
+ }
+
+ /**
+ * Return null if the argument is an "unsaved" entity (ie.
+ * one with no existing database row), or the input argument
+ * otherwise. This is how Hibernate avoids foreign key constraint
+ * violations.
+ */
+ private Object nullifyTransientReferences(final Object value, final Type type)
+ throws HibernateException {
+ if ( value == null ) {
+ return null;
+ }
+ else if ( type.isEntityType() ) {
+ EntityType entityType = (EntityType) type;
+ if ( entityType.isOneToOne() ) {
+ return value;
+ }
+ else {
+ String entityName = entityType.getAssociatedEntityName();
+ return isNullifiable(entityName, value) ? null : value;
+ }
+ }
+ else if ( type.isAnyType() ) {
+ return isNullifiable(null, value) ? null : value;
+ }
+ else if ( type.isComponentType() ) {
+ AbstractComponentType actype = (AbstractComponentType) type;
+ Object[] subvalues = actype.getPropertyValues(value, session);
+ Type[] subtypes = actype.getSubtypes();
+ boolean substitute = false;
+ for ( int i = 0; i < subvalues.length; i++ ) {
+ Object replacement = nullifyTransientReferences( subvalues[i], subtypes[i] );
+ if ( replacement != subvalues[i] ) {
+ substitute = true;
+ subvalues[i] = replacement;
+ }
+ }
+ if (substitute) actype.setPropertyValues( value, subvalues, session.getEntityMode() );
+ return value;
+ }
+ else {
+ return value;
+ }
+ }
+
+ /**
+ * Determine if the object already exists in the database,
+ * using a "best guess"
+ */
+ private boolean isNullifiable(final String entityName, Object object)
+ throws HibernateException {
+
+ if (object==LazyPropertyInitializer.UNFETCHED_PROPERTY) return false; //this is kinda the best we can do...
+
+ if ( object instanceof HibernateProxy ) {
+ // if its an uninitialized proxy it can't be transient
+ LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
+ if ( li.getImplementation(session) == null ) {
+ return false;
+ // ie. we never have to null out a reference to
+ // an uninitialized proxy
+ }
+ else {
+ //unwrap it
+ object = li.getImplementation();
+ }
+ }
+
+ // if it was a reference to self, don't need to nullify
+ // unless we are using native id generation, in which
+ // case we definitely need to nullify
+ if ( object == self ) {
+ return isEarlyInsert || (
+ isDelete &&
+ session.getFactory()
+ .getDialect()
+ .hasSelfReferentialForeignKeyBug()
+ );
+ }
+
+ // See if the entity is already bound to this session, if not look at the
+ // entity identifier and assume that the entity is persistent if the
+ // id is not "unsaved" (that is, we rely on foreign keys to keep
+ // database integrity)
+
+ EntityEntry entityEntry = session.getPersistenceContext().getEntry(object);
+ if ( entityEntry==null ) {
+ return isTransient(entityName, object, null, session);
+ }
+ else {
+ return entityEntry.isNullifiable(isEarlyInsert, session);
+ }
+
+ }
+
+ }
+
+ /**
+ * Is this instance persistent or detached?
+ * If <tt>assumed</tt> is non-null, don't hit the database to make the
+ * determination, instead assume that value; the client code must be
+ * prepared to "recover" in the case that this assumed result is incorrect.
+ */
+ public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session)
+ throws HibernateException {
+ if (entity instanceof HibernateProxy) return true;
+ if ( session.getPersistenceContext().isEntryFor(entity) ) return true;
+ return !isTransient(entityName, entity, assumed, session);
+ }
+
+ /**
+ * Is this instance, which we know is not persistent, actually transient?
+ * If <tt>assumed</tt> is non-null, don't hit the database to make the
+ * determination, instead assume that value; the client code must be
+ * prepared to "recover" in the case that this assumed result is incorrect.
+ */
+ public static boolean isTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session)
+ throws HibernateException {
+
+ if (entity==LazyPropertyInitializer.UNFETCHED_PROPERTY) {
+ // an unfetched association can only point to
+ // an entity that already exists in the db
+ return false;
+ }
+
+ // let the interceptor inspect the instance to decide
+ Boolean isUnsaved = session.getInterceptor().isTransient(entity);
+ if (isUnsaved!=null) return isUnsaved.booleanValue();
+
+ // let the persister inspect the instance to decide
+ EntityPersister persister = session.getEntityPersister(entityName, entity);
+ isUnsaved = persister.isTransient(entity, session);
+ if (isUnsaved!=null) return isUnsaved.booleanValue();
+
+ // we use the assumed value, if there is one, to avoid hitting
+ // the database
+ if (assumed!=null) return assumed.booleanValue();
+
+ // hit the database, after checking the session cache for a snapshot
+ Object[] snapshot = session.getPersistenceContext()
+ .getDatabaseSnapshot( persister.getIdentifier( entity, session.getEntityMode() ), persister );
+ return snapshot==null;
+
+ }
+
+ /**
+ * Return the identifier of the persistent or transient object, or throw
+ * an exception if the instance is "unsaved"
+ *
+ * Used by OneToOneType and ManyToOneType to determine what id value should
+ * be used for an object that may or may not be associated with the session.
+ * This does a "best guess" using any/all info available to use (not just the
+ * EntityEntry).
+ */
+ public static Serializable getEntityIdentifierIfNotUnsaved(
+ final String entityName,
+ final Object object,
+ final SessionImplementor session)
+ throws HibernateException {
+ if ( object == null ) {
+ return null;
+ }
+ else {
+ Serializable id = session.getContextEntityIdentifier( object );
+ if ( id == null ) {
+ // context-entity-identifier returns null explicitly if the entity
+ // is not associated with the persistence context; so make some
+ // deeper checks...
+ if ( isTransient(entityName, object, Boolean.FALSE, session) ) {
+ throw new TransientObjectException(
+ "object references an unsaved transient instance - save the transient instance before flushing: " +
+ (entityName == null ? session.guessEntityName( object ) : entityName)
+ );
+ }
+ id = session.getEntityPersister( entityName, object ).getIdentifier( object, session.getEntityMode() );
+ }
+ return id;
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/HibernateIterator.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,15 +0,0 @@
-//$Id: HibernateIterator.java 4782 2004-11-21 00:11:27Z pgmjsd $
-package org.hibernate.engine;
-
-import org.hibernate.JDBCException;
-
-import java.util.Iterator;
-
-/**
- * An iterator that may be "closed"
- * @see org.hibernate.Hibernate#close(java.util.Iterator)
- * @author Gavin King
- */
-public interface HibernateIterator extends Iterator {
- public void close() throws JDBCException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/HibernateIterator.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/HibernateIterator.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.JDBCException;
+
+import java.util.Iterator;
+
+/**
+ * An iterator that may be "closed"
+ * @see org.hibernate.Hibernate#close(java.util.Iterator)
+ * @author Gavin King
+ */
+public interface HibernateIterator extends Iterator {
+ public void close() throws JDBCException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/IdentifierValue.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,115 +0,0 @@
-//$Id: IdentifierValue.java 7017 2005-06-05 04:31:34Z oneovthafew $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A strategy for determining if an identifier value is an identifier of
- * a new transient instance or a previously persistent transient instance.
- * The strategy is determined by the <tt>unsaved-value</tt> attribute in
- * the mapping file.
- *
- * @author Gavin King
- */
-public class IdentifierValue {
-
- private static final Logger log = LoggerFactory.getLogger(IdentifierValue.class);
-
- private final Serializable value;
-
- /**
- * Always assume the transient instance is newly instantiated
- */
- public static final IdentifierValue ANY = new IdentifierValue() {
- public final Boolean isUnsaved(Serializable id) {
- log.trace("id unsaved-value strategy ANY");
- return Boolean.TRUE;
- }
- public Serializable getDefaultValue(Serializable currentValue) {
- return currentValue;
- }
- public String toString() {
- return "SAVE_ANY";
- }
- };
-
- /**
- * Never assume the transient instance is newly instantiated
- */
- public static final IdentifierValue NONE = new IdentifierValue() {
- public final Boolean isUnsaved(Serializable id) {
- log.trace("id unsaved-value strategy NONE");
- return Boolean.FALSE;
- }
- public Serializable getDefaultValue(Serializable currentValue) {
- return currentValue;
- }
- public String toString() {
- return "SAVE_NONE";
- }
- };
-
- /**
- * Assume the transient instance is newly instantiated if the identifier
- * is null.
- */
- public static final IdentifierValue NULL = new IdentifierValue() {
- public final Boolean isUnsaved(Serializable id) {
- log.trace("id unsaved-value strategy NULL");
- return id==null ? Boolean.TRUE : Boolean.FALSE;
- }
- public Serializable getDefaultValue(Serializable currentValue) {
- return null;
- }
- public String toString() {
- return "SAVE_NULL";
- }
- };
-
- /**
- * Assume nothing.
- */
- public static final IdentifierValue UNDEFINED = new IdentifierValue() {
- public final Boolean isUnsaved(Serializable id) {
- log.trace("id unsaved-value strategy UNDEFINED");
- return null;
- }
- public Serializable getDefaultValue(Serializable currentValue) {
- return null;
- }
- public String toString() {
- return "UNDEFINED";
- }
- };
-
- protected IdentifierValue() {
- this.value = null;
- }
-
- /**
- * Assume the transient instance is newly instantiated if
- * its identifier is null or equal to <tt>value</tt>
- */
- public IdentifierValue(Serializable value) {
- this.value = value;
- }
-
- /**
- * Does the given identifier belong to a new instance?
- */
- public Boolean isUnsaved(Serializable id) {
- if ( log.isTraceEnabled() ) log.trace("id unsaved-value: " + value);
- return id==null || id.equals(value) ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Serializable getDefaultValue(Serializable currentValue) {
- return value;
- }
-
- public String toString() {
- return "identifier unsaved-value: " + value;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/IdentifierValue.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/IdentifierValue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,138 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A strategy for determining if an identifier value is an identifier of
+ * a new transient instance or a previously persistent transient instance.
+ * The strategy is determined by the <tt>unsaved-value</tt> attribute in
+ * the mapping file.
+ *
+ * @author Gavin King
+ */
+public class IdentifierValue {
+
+ private static final Logger log = LoggerFactory.getLogger(IdentifierValue.class);
+
+ private final Serializable value;
+
+ /**
+ * Always assume the transient instance is newly instantiated
+ */
+ public static final IdentifierValue ANY = new IdentifierValue() {
+ public final Boolean isUnsaved(Serializable id) {
+ log.trace("id unsaved-value strategy ANY");
+ return Boolean.TRUE;
+ }
+ public Serializable getDefaultValue(Serializable currentValue) {
+ return currentValue;
+ }
+ public String toString() {
+ return "SAVE_ANY";
+ }
+ };
+
+ /**
+ * Never assume the transient instance is newly instantiated
+ */
+ public static final IdentifierValue NONE = new IdentifierValue() {
+ public final Boolean isUnsaved(Serializable id) {
+ log.trace("id unsaved-value strategy NONE");
+ return Boolean.FALSE;
+ }
+ public Serializable getDefaultValue(Serializable currentValue) {
+ return currentValue;
+ }
+ public String toString() {
+ return "SAVE_NONE";
+ }
+ };
+
+ /**
+ * Assume the transient instance is newly instantiated if the identifier
+ * is null.
+ */
+ public static final IdentifierValue NULL = new IdentifierValue() {
+ public final Boolean isUnsaved(Serializable id) {
+ log.trace("id unsaved-value strategy NULL");
+ return id==null ? Boolean.TRUE : Boolean.FALSE;
+ }
+ public Serializable getDefaultValue(Serializable currentValue) {
+ return null;
+ }
+ public String toString() {
+ return "SAVE_NULL";
+ }
+ };
+
+ /**
+ * Assume nothing.
+ */
+ public static final IdentifierValue UNDEFINED = new IdentifierValue() {
+ public final Boolean isUnsaved(Serializable id) {
+ log.trace("id unsaved-value strategy UNDEFINED");
+ return null;
+ }
+ public Serializable getDefaultValue(Serializable currentValue) {
+ return null;
+ }
+ public String toString() {
+ return "UNDEFINED";
+ }
+ };
+
+ protected IdentifierValue() {
+ this.value = null;
+ }
+
+ /**
+ * Assume the transient instance is newly instantiated if
+ * its identifier is null or equal to <tt>value</tt>
+ */
+ public IdentifierValue(Serializable value) {
+ this.value = value;
+ }
+
+ /**
+ * Does the given identifier belong to a new instance?
+ */
+ public Boolean isUnsaved(Serializable id) {
+ if ( log.isTraceEnabled() ) log.trace("id unsaved-value: " + value);
+ return id==null || id.equals(value) ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Serializable getDefaultValue(Serializable currentValue) {
+ return value;
+ }
+
+ public String toString() {
+ return "identifier unsaved-value: " + value;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/JoinHelper.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,157 +0,0 @@
-//$Id: JoinHelper.java 7586 2005-07-21 01:11:52Z oneovthafew $
-package org.hibernate.engine;
-
-import org.hibernate.persister.entity.Joinable;
-import org.hibernate.persister.entity.OuterJoinLoadable;
-import org.hibernate.persister.entity.PropertyMapping;
-import org.hibernate.type.AssociationType;
-import org.hibernate.util.ArrayHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * @author Gavin King
- */
-public final class JoinHelper {
-
- private JoinHelper() {}
-
- /**
- * Get the aliased columns of the owning entity which are to
- * be used in the join
- */
- public static String[] getAliasedLHSColumnNames(
- AssociationType type,
- String alias,
- int property,
- OuterJoinLoadable lhsPersister,
- Mapping mapping
- ) {
- return getAliasedLHSColumnNames(type, alias, property, 0, lhsPersister, mapping);
- }
-
- /**
- * Get the columns of the owning entity which are to
- * be used in the join
- */
- public static String[] getLHSColumnNames(
- AssociationType type,
- int property,
- OuterJoinLoadable lhsPersister,
- Mapping mapping
- ) {
- return getLHSColumnNames(type, property, 0, lhsPersister, mapping);
- }
-
- /**
- * Get the aliased columns of the owning entity which are to
- * be used in the join
- */
- public static String[] getAliasedLHSColumnNames(
- AssociationType type,
- String alias,
- int property,
- int begin,
- OuterJoinLoadable lhsPersister,
- Mapping mapping
- ) {
- if ( type.useLHSPrimaryKey() ) {
- return StringHelper.qualify( alias, lhsPersister.getIdentifierColumnNames() );
- }
- else {
- String propertyName = type.getLHSPropertyName();
- if (propertyName==null) {
- return ArrayHelper.slice(
- lhsPersister.toColumns(alias, property),
- begin,
- type.getColumnSpan(mapping)
- );
- }
- else {
- return ( (PropertyMapping) lhsPersister ).toColumns(alias, propertyName); //bad cast
- }
- }
- }
-
- /**
- * Get the columns of the owning entity which are to
- * be used in the join
- */
- public static String[] getLHSColumnNames(
- AssociationType type,
- int property,
- int begin,
- OuterJoinLoadable lhsPersister,
- Mapping mapping
- ) {
- if ( type.useLHSPrimaryKey() ) {
- //return lhsPersister.getSubclassPropertyColumnNames(property);
- return lhsPersister.getIdentifierColumnNames();
- }
- else {
- String propertyName = type.getLHSPropertyName();
- if (propertyName==null) {
- //slice, to get the columns for this component
- //property
- return ArrayHelper.slice(
- lhsPersister.getSubclassPropertyColumnNames(property),
- begin,
- type.getColumnSpan(mapping)
- );
- }
- else {
- //property-refs for associations defined on a
- //component are not supported, so no need to slice
- return lhsPersister.getPropertyColumnNames(propertyName);
- }
- }
- }
-
- public static String getLHSTableName(
- AssociationType type,
- int property,
- OuterJoinLoadable lhsPersister
- ) {
- if ( type.useLHSPrimaryKey() ) {
- return lhsPersister.getTableName();
- }
- else {
- String propertyName = type.getLHSPropertyName();
- if (propertyName==null) {
- //if there is no property-ref, assume the join
- //is to the subclass table (ie. the table of the
- //subclass that the association belongs to)
- return lhsPersister.getSubclassPropertyTableName(property);
- }
- else {
- //handle a property-ref
- String propertyRefTable = lhsPersister.getPropertyTableName(propertyName);
- if (propertyRefTable==null) {
- //it is possible that the tree-walking in OuterJoinLoader can get to
- //an association defined by a subclass, in which case the property-ref
- //might refer to a property defined on a subclass of the current class
- //in this case, the table name is not known - this temporary solution
- //assumes that the property-ref refers to a property of the subclass
- //table that the association belongs to (a reasonable guess)
- //TODO: fix this, add: OuterJoinLoadable.getSubclassPropertyTableName(String propertyName)
- propertyRefTable = lhsPersister.getSubclassPropertyTableName(property);
- }
- return propertyRefTable;
- }
- }
- }
-
- /**
- * Get the columns of the associated table which are to
- * be used in the join
- */
- public static String[] getRHSColumnNames(AssociationType type, SessionFactoryImplementor factory) {
- String uniqueKeyPropertyName = type.getRHSUniqueKeyPropertyName();
- Joinable joinable = type.getAssociatedJoinable(factory);
- if (uniqueKeyPropertyName==null) {
- return joinable.getKeyColumnNames();
- }
- else {
- return ( (OuterJoinLoadable) joinable ).getPropertyColumnNames(uniqueKeyPropertyName);
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/JoinHelper.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinHelper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,180 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.persister.entity.Joinable;
+import org.hibernate.persister.entity.OuterJoinLoadable;
+import org.hibernate.persister.entity.PropertyMapping;
+import org.hibernate.type.AssociationType;
+import org.hibernate.util.ArrayHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Gavin King
+ */
+public final class JoinHelper {
+
+ private JoinHelper() {}
+
+ /**
+ * Get the aliased columns of the owning entity which are to
+ * be used in the join
+ */
+ public static String[] getAliasedLHSColumnNames(
+ AssociationType type,
+ String alias,
+ int property,
+ OuterJoinLoadable lhsPersister,
+ Mapping mapping
+ ) {
+ return getAliasedLHSColumnNames(type, alias, property, 0, lhsPersister, mapping);
+ }
+
+ /**
+ * Get the columns of the owning entity which are to
+ * be used in the join
+ */
+ public static String[] getLHSColumnNames(
+ AssociationType type,
+ int property,
+ OuterJoinLoadable lhsPersister,
+ Mapping mapping
+ ) {
+ return getLHSColumnNames(type, property, 0, lhsPersister, mapping);
+ }
+
+ /**
+ * Get the aliased columns of the owning entity which are to
+ * be used in the join
+ */
+ public static String[] getAliasedLHSColumnNames(
+ AssociationType type,
+ String alias,
+ int property,
+ int begin,
+ OuterJoinLoadable lhsPersister,
+ Mapping mapping
+ ) {
+ if ( type.useLHSPrimaryKey() ) {
+ return StringHelper.qualify( alias, lhsPersister.getIdentifierColumnNames() );
+ }
+ else {
+ String propertyName = type.getLHSPropertyName();
+ if (propertyName==null) {
+ return ArrayHelper.slice(
+ lhsPersister.toColumns(alias, property),
+ begin,
+ type.getColumnSpan(mapping)
+ );
+ }
+ else {
+ return ( (PropertyMapping) lhsPersister ).toColumns(alias, propertyName); //bad cast
+ }
+ }
+ }
+
+ /**
+ * Get the columns of the owning entity which are to
+ * be used in the join
+ */
+ public static String[] getLHSColumnNames(
+ AssociationType type,
+ int property,
+ int begin,
+ OuterJoinLoadable lhsPersister,
+ Mapping mapping
+ ) {
+ if ( type.useLHSPrimaryKey() ) {
+ //return lhsPersister.getSubclassPropertyColumnNames(property);
+ return lhsPersister.getIdentifierColumnNames();
+ }
+ else {
+ String propertyName = type.getLHSPropertyName();
+ if (propertyName==null) {
+ //slice, to get the columns for this component
+ //property
+ return ArrayHelper.slice(
+ lhsPersister.getSubclassPropertyColumnNames(property),
+ begin,
+ type.getColumnSpan(mapping)
+ );
+ }
+ else {
+ //property-refs for associations defined on a
+ //component are not supported, so no need to slice
+ return lhsPersister.getPropertyColumnNames(propertyName);
+ }
+ }
+ }
+
+ public static String getLHSTableName(
+ AssociationType type,
+ int property,
+ OuterJoinLoadable lhsPersister
+ ) {
+ if ( type.useLHSPrimaryKey() ) {
+ return lhsPersister.getTableName();
+ }
+ else {
+ String propertyName = type.getLHSPropertyName();
+ if (propertyName==null) {
+ //if there is no property-ref, assume the join
+ //is to the subclass table (ie. the table of the
+ //subclass that the association belongs to)
+ return lhsPersister.getSubclassPropertyTableName(property);
+ }
+ else {
+ //handle a property-ref
+ String propertyRefTable = lhsPersister.getPropertyTableName(propertyName);
+ if (propertyRefTable==null) {
+ //it is possible that the tree-walking in OuterJoinLoader can get to
+ //an association defined by a subclass, in which case the property-ref
+ //might refer to a property defined on a subclass of the current class
+ //in this case, the table name is not known - this temporary solution
+ //assumes that the property-ref refers to a property of the subclass
+ //table that the association belongs to (a reasonable guess)
+ //TODO: fix this, add: OuterJoinLoadable.getSubclassPropertyTableName(String propertyName)
+ propertyRefTable = lhsPersister.getSubclassPropertyTableName(property);
+ }
+ return propertyRefTable;
+ }
+ }
+ }
+
+ /**
+ * Get the columns of the associated table which are to
+ * be used in the join
+ */
+ public static String[] getRHSColumnNames(AssociationType type, SessionFactoryImplementor factory) {
+ String uniqueKeyPropertyName = type.getRHSUniqueKeyPropertyName();
+ Joinable joinable = type.getAssociatedJoinable(factory);
+ if (uniqueKeyPropertyName==null) {
+ return joinable.getKeyColumnNames();
+ }
+ else {
+ return ( (OuterJoinLoadable) joinable ).getPropertyColumnNames(uniqueKeyPropertyName);
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/JoinSequence.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,267 +0,0 @@
-//$Id: JoinSequence.java 9336 2006-02-24 22:12:13Z steveebersole $
-package org.hibernate.engine;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.hibernate.MappingException;
-import org.hibernate.persister.entity.Joinable;
-import org.hibernate.persister.collection.QueryableCollection;
-import org.hibernate.sql.JoinFragment;
-import org.hibernate.sql.QueryJoinFragment;
-import org.hibernate.type.AssociationType;
-import org.hibernate.util.CollectionHelper;
-
-/**
- * @author Gavin King
- */
-public class JoinSequence {
-
- private final SessionFactoryImplementor factory;
- private final List joins = new ArrayList();
- private boolean useThetaStyle = false;
- private final StringBuffer conditions = new StringBuffer();
- private String rootAlias;
- private Joinable rootJoinable;
- private Selector selector;
- private JoinSequence next;
- private boolean isFromPart = false;
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append( "JoinSequence{" );
- if ( rootJoinable != null ) {
- buf.append( rootJoinable )
- .append( '[' )
- .append( rootAlias )
- .append( ']' );
- }
- for ( int i = 0; i < joins.size(); i++ ) {
- buf.append( "->" ).append( joins.get( i ) );
- }
- return buf.append( '}' ).toString();
- }
-
- final class Join {
-
- private final AssociationType associationType;
- private final Joinable joinable;
- private final int joinType;
- private final String alias;
- private final String[] lhsColumns;
-
- Join(AssociationType associationType, String alias, int joinType, String[] lhsColumns)
- throws MappingException {
- this.associationType = associationType;
- this.joinable = associationType.getAssociatedJoinable( factory );
- this.alias = alias;
- this.joinType = joinType;
- this.lhsColumns = lhsColumns;
- }
-
- String getAlias() {
- return alias;
- }
-
- AssociationType getAssociationType() {
- return associationType;
- }
-
- Joinable getJoinable() {
- return joinable;
- }
-
- int getJoinType() {
- return joinType;
- }
-
- String[] getLHSColumns() {
- return lhsColumns;
- }
-
- public String toString() {
- return joinable.toString() + '[' + alias + ']';
- }
- }
-
- public JoinSequence(SessionFactoryImplementor factory) {
- this.factory = factory;
- }
-
- public JoinSequence getFromPart() {
- JoinSequence fromPart = new JoinSequence( factory );
- fromPart.joins.addAll( this.joins );
- fromPart.useThetaStyle = this.useThetaStyle;
- fromPart.rootAlias = this.rootAlias;
- fromPart.rootJoinable = this.rootJoinable;
- fromPart.selector = this.selector;
- fromPart.next = this.next == null ? null : this.next.getFromPart();
- fromPart.isFromPart = true;
- return fromPart;
- }
-
- public JoinSequence copy() {
- JoinSequence copy = new JoinSequence( factory );
- copy.joins.addAll( this.joins );
- copy.useThetaStyle = this.useThetaStyle;
- copy.rootAlias = this.rootAlias;
- copy.rootJoinable = this.rootJoinable;
- copy.selector = this.selector;
- copy.next = this.next == null ? null : this.next.copy();
- copy.isFromPart = this.isFromPart;
- copy.conditions.append( this.conditions.toString() );
- return copy;
- }
-
- public JoinSequence addJoin(AssociationType associationType, String alias, int joinType, String[] referencingKey)
- throws MappingException {
- joins.add( new Join( associationType, alias, joinType, referencingKey ) );
- return this;
- }
-
- public JoinFragment toJoinFragment() throws MappingException {
- return toJoinFragment( CollectionHelper.EMPTY_MAP, true );
- }
-
- public JoinFragment toJoinFragment(Map enabledFilters, boolean includeExtraJoins) throws MappingException {
- return toJoinFragment( enabledFilters, includeExtraJoins, null, null );
- }
-
- public JoinFragment toJoinFragment(
- Map enabledFilters,
- boolean includeExtraJoins,
- String withClauseFragment,
- String withClauseJoinAlias) throws MappingException {
- QueryJoinFragment joinFragment = new QueryJoinFragment( factory.getDialect(), useThetaStyle );
- if ( rootJoinable != null ) {
- joinFragment.addCrossJoin( rootJoinable.getTableName(), rootAlias );
- String filterCondition = rootJoinable.filterFragment( rootAlias, enabledFilters );
- // JoinProcessor needs to know if the where clause fragment came from a dynamic filter or not so it
- // can put the where clause fragment in the right place in the SQL AST. 'hasFilterCondition' keeps track
- // of that fact.
- joinFragment.setHasFilterCondition( joinFragment.addCondition( filterCondition ) );
- if (includeExtraJoins) { //TODO: not quite sure about the full implications of this!
- addExtraJoins( joinFragment, rootAlias, rootJoinable, true );
- }
- }
-
- Joinable last = rootJoinable;
-
- for ( int i = 0; i < joins.size(); i++ ) {
- Join join = ( Join ) joins.get( i );
- String on = join.getAssociationType().getOnCondition( join.getAlias(), factory, enabledFilters );
- String condition = null;
- if ( last != null &&
- isManyToManyRoot( last ) &&
- ( ( QueryableCollection ) last ).getElementType() == join.getAssociationType() ) {
- // the current join represents the join between a many-to-many association table
- // and its "target" table. Here we need to apply any additional filters
- // defined specifically on the many-to-many
- String manyToManyFilter = ( ( QueryableCollection ) last )
- .getManyToManyFilterFragment( join.getAlias(), enabledFilters );
- condition = "".equals( manyToManyFilter )
- ? on
- : "".equals( on )
- ? manyToManyFilter
- : on + " and " + manyToManyFilter;
- }
- else {
- condition = on;
- }
- if ( withClauseFragment != null ) {
- if ( join.getAlias().equals( withClauseJoinAlias ) ) {
- condition += " and " + withClauseFragment;
- }
- }
- joinFragment.addJoin(
- join.getJoinable().getTableName(),
- join.getAlias(),
- join.getLHSColumns(),
- JoinHelper.getRHSColumnNames( join.getAssociationType(), factory ),
- join.joinType,
- condition
- );
- if (includeExtraJoins) { //TODO: not quite sure about the full implications of this!
- addExtraJoins( joinFragment, join.getAlias(), join.getJoinable(), join.joinType == JoinFragment.INNER_JOIN );
- }
- last = join.getJoinable();
- }
- if ( next != null ) {
- joinFragment.addFragment( next.toJoinFragment( enabledFilters, includeExtraJoins ) );
- }
- joinFragment.addCondition( conditions.toString() );
- if ( isFromPart ) joinFragment.clearWherePart();
- return joinFragment;
- }
-
- private boolean isManyToManyRoot(Joinable joinable) {
- if ( joinable != null && joinable.isCollection() ) {
- QueryableCollection persister = ( QueryableCollection ) joinable;
- return persister.isManyToMany();
- }
- return false;
- }
-
- private boolean isIncluded(String alias) {
- return selector != null && selector.includeSubclasses( alias );
- }
-
- private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
- boolean include = isIncluded( alias );
- joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
- joinable.whereJoinFragment( alias, innerJoin, include ) );
- }
-
- public JoinSequence addCondition(String condition) {
- if ( condition.trim().length() != 0 ) {
- if ( !condition.startsWith( " and " ) ) conditions.append( " and " );
- conditions.append( condition );
- }
- return this;
- }
-
- public JoinSequence addCondition(String alias, String[] columns, String condition) {
- for ( int i = 0; i < columns.length; i++ ) {
- conditions.append( " and " )
- .append( alias )
- .append( '.' )
- .append( columns[i] )
- .append( condition );
- }
- return this;
- }
-
- public JoinSequence setRoot(Joinable joinable, String alias) {
- this.rootAlias = alias;
- this.rootJoinable = joinable;
- return this;
- }
-
- public JoinSequence setNext(JoinSequence next) {
- this.next = next;
- return this;
- }
-
- public JoinSequence setSelector(Selector s) {
- this.selector = s;
- return this;
- }
-
- public JoinSequence setUseThetaStyle(boolean useThetaStyle) {
- this.useThetaStyle = useThetaStyle;
- return this;
- }
-
- public boolean isThetaStyle() {
- return useThetaStyle;
- }
-
- public int getJoinCount() {
- return joins.size();
- }
-
- public static interface Selector {
- public boolean includeSubclasses(String alias);
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/JoinSequence.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/JoinSequence.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,290 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.MappingException;
+import org.hibernate.persister.entity.Joinable;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.sql.JoinFragment;
+import org.hibernate.sql.QueryJoinFragment;
+import org.hibernate.type.AssociationType;
+import org.hibernate.util.CollectionHelper;
+
+/**
+ * @author Gavin King
+ */
+public class JoinSequence {
+
+ private final SessionFactoryImplementor factory;
+ private final List joins = new ArrayList();
+ private boolean useThetaStyle = false;
+ private final StringBuffer conditions = new StringBuffer();
+ private String rootAlias;
+ private Joinable rootJoinable;
+ private Selector selector;
+ private JoinSequence next;
+ private boolean isFromPart = false;
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append( "JoinSequence{" );
+ if ( rootJoinable != null ) {
+ buf.append( rootJoinable )
+ .append( '[' )
+ .append( rootAlias )
+ .append( ']' );
+ }
+ for ( int i = 0; i < joins.size(); i++ ) {
+ buf.append( "->" ).append( joins.get( i ) );
+ }
+ return buf.append( '}' ).toString();
+ }
+
+ final class Join {
+
+ private final AssociationType associationType;
+ private final Joinable joinable;
+ private final int joinType;
+ private final String alias;
+ private final String[] lhsColumns;
+
+ Join(AssociationType associationType, String alias, int joinType, String[] lhsColumns)
+ throws MappingException {
+ this.associationType = associationType;
+ this.joinable = associationType.getAssociatedJoinable( factory );
+ this.alias = alias;
+ this.joinType = joinType;
+ this.lhsColumns = lhsColumns;
+ }
+
+ String getAlias() {
+ return alias;
+ }
+
+ AssociationType getAssociationType() {
+ return associationType;
+ }
+
+ Joinable getJoinable() {
+ return joinable;
+ }
+
+ int getJoinType() {
+ return joinType;
+ }
+
+ String[] getLHSColumns() {
+ return lhsColumns;
+ }
+
+ public String toString() {
+ return joinable.toString() + '[' + alias + ']';
+ }
+ }
+
+ public JoinSequence(SessionFactoryImplementor factory) {
+ this.factory = factory;
+ }
+
+ public JoinSequence getFromPart() {
+ JoinSequence fromPart = new JoinSequence( factory );
+ fromPart.joins.addAll( this.joins );
+ fromPart.useThetaStyle = this.useThetaStyle;
+ fromPart.rootAlias = this.rootAlias;
+ fromPart.rootJoinable = this.rootJoinable;
+ fromPart.selector = this.selector;
+ fromPart.next = this.next == null ? null : this.next.getFromPart();
+ fromPart.isFromPart = true;
+ return fromPart;
+ }
+
+ public JoinSequence copy() {
+ JoinSequence copy = new JoinSequence( factory );
+ copy.joins.addAll( this.joins );
+ copy.useThetaStyle = this.useThetaStyle;
+ copy.rootAlias = this.rootAlias;
+ copy.rootJoinable = this.rootJoinable;
+ copy.selector = this.selector;
+ copy.next = this.next == null ? null : this.next.copy();
+ copy.isFromPart = this.isFromPart;
+ copy.conditions.append( this.conditions.toString() );
+ return copy;
+ }
+
+ public JoinSequence addJoin(AssociationType associationType, String alias, int joinType, String[] referencingKey)
+ throws MappingException {
+ joins.add( new Join( associationType, alias, joinType, referencingKey ) );
+ return this;
+ }
+
+ public JoinFragment toJoinFragment() throws MappingException {
+ return toJoinFragment( CollectionHelper.EMPTY_MAP, true );
+ }
+
+ public JoinFragment toJoinFragment(Map enabledFilters, boolean includeExtraJoins) throws MappingException {
+ return toJoinFragment( enabledFilters, includeExtraJoins, null, null );
+ }
+
+ public JoinFragment toJoinFragment(
+ Map enabledFilters,
+ boolean includeExtraJoins,
+ String withClauseFragment,
+ String withClauseJoinAlias) throws MappingException {
+ QueryJoinFragment joinFragment = new QueryJoinFragment( factory.getDialect(), useThetaStyle );
+ if ( rootJoinable != null ) {
+ joinFragment.addCrossJoin( rootJoinable.getTableName(), rootAlias );
+ String filterCondition = rootJoinable.filterFragment( rootAlias, enabledFilters );
+ // JoinProcessor needs to know if the where clause fragment came from a dynamic filter or not so it
+ // can put the where clause fragment in the right place in the SQL AST. 'hasFilterCondition' keeps track
+ // of that fact.
+ joinFragment.setHasFilterCondition( joinFragment.addCondition( filterCondition ) );
+ if (includeExtraJoins) { //TODO: not quite sure about the full implications of this!
+ addExtraJoins( joinFragment, rootAlias, rootJoinable, true );
+ }
+ }
+
+ Joinable last = rootJoinable;
+
+ for ( int i = 0; i < joins.size(); i++ ) {
+ Join join = ( Join ) joins.get( i );
+ String on = join.getAssociationType().getOnCondition( join.getAlias(), factory, enabledFilters );
+ String condition = null;
+ if ( last != null &&
+ isManyToManyRoot( last ) &&
+ ( ( QueryableCollection ) last ).getElementType() == join.getAssociationType() ) {
+ // the current join represents the join between a many-to-many association table
+ // and its "target" table. Here we need to apply any additional filters
+ // defined specifically on the many-to-many
+ String manyToManyFilter = ( ( QueryableCollection ) last )
+ .getManyToManyFilterFragment( join.getAlias(), enabledFilters );
+ condition = "".equals( manyToManyFilter )
+ ? on
+ : "".equals( on )
+ ? manyToManyFilter
+ : on + " and " + manyToManyFilter;
+ }
+ else {
+ condition = on;
+ }
+ if ( withClauseFragment != null ) {
+ if ( join.getAlias().equals( withClauseJoinAlias ) ) {
+ condition += " and " + withClauseFragment;
+ }
+ }
+ joinFragment.addJoin(
+ join.getJoinable().getTableName(),
+ join.getAlias(),
+ join.getLHSColumns(),
+ JoinHelper.getRHSColumnNames( join.getAssociationType(), factory ),
+ join.joinType,
+ condition
+ );
+ if (includeExtraJoins) { //TODO: not quite sure about the full implications of this!
+ addExtraJoins( joinFragment, join.getAlias(), join.getJoinable(), join.joinType == JoinFragment.INNER_JOIN );
+ }
+ last = join.getJoinable();
+ }
+ if ( next != null ) {
+ joinFragment.addFragment( next.toJoinFragment( enabledFilters, includeExtraJoins ) );
+ }
+ joinFragment.addCondition( conditions.toString() );
+ if ( isFromPart ) joinFragment.clearWherePart();
+ return joinFragment;
+ }
+
+ private boolean isManyToManyRoot(Joinable joinable) {
+ if ( joinable != null && joinable.isCollection() ) {
+ QueryableCollection persister = ( QueryableCollection ) joinable;
+ return persister.isManyToMany();
+ }
+ return false;
+ }
+
+ private boolean isIncluded(String alias) {
+ return selector != null && selector.includeSubclasses( alias );
+ }
+
+ private void addExtraJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin) {
+ boolean include = isIncluded( alias );
+ joinFragment.addJoins( joinable.fromJoinFragment( alias, innerJoin, include ),
+ joinable.whereJoinFragment( alias, innerJoin, include ) );
+ }
+
+ public JoinSequence addCondition(String condition) {
+ if ( condition.trim().length() != 0 ) {
+ if ( !condition.startsWith( " and " ) ) conditions.append( " and " );
+ conditions.append( condition );
+ }
+ return this;
+ }
+
+ public JoinSequence addCondition(String alias, String[] columns, String condition) {
+ for ( int i = 0; i < columns.length; i++ ) {
+ conditions.append( " and " )
+ .append( alias )
+ .append( '.' )
+ .append( columns[i] )
+ .append( condition );
+ }
+ return this;
+ }
+
+ public JoinSequence setRoot(Joinable joinable, String alias) {
+ this.rootAlias = alias;
+ this.rootJoinable = joinable;
+ return this;
+ }
+
+ public JoinSequence setNext(JoinSequence next) {
+ this.next = next;
+ return this;
+ }
+
+ public JoinSequence setSelector(Selector s) {
+ this.selector = s;
+ return this;
+ }
+
+ public JoinSequence setUseThetaStyle(boolean useThetaStyle) {
+ this.useThetaStyle = useThetaStyle;
+ return this;
+ }
+
+ public boolean isThetaStyle() {
+ return useThetaStyle;
+ }
+
+ public int getJoinCount() {
+ return joins.size();
+ }
+
+ public static interface Selector {
+ public boolean includeSubclasses(String alias);
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/Mapping.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: Mapping.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import org.hibernate.MappingException;
-import org.hibernate.type.Type;
-
-/**
- * Defines operations common to "compiled" mappings (ie. <tt>SessionFactory</tt>)
- * and "uncompiled" mappings (ie. <tt>Configuration</tt>) that are used by
- * implementors of <tt>Type</tt>.
- *
- * @see org.hibernate.type.Type
- * @see org.hibernate.impl.SessionFactoryImpl
- * @see org.hibernate.cfg.Configuration
- * @author Gavin King
- */
-public interface Mapping {
- public Type getIdentifierType(String className) throws MappingException;
- public String getIdentifierPropertyName(String className) throws MappingException;
- public Type getReferencedPropertyType(String className, String propertyName) throws MappingException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/Mapping.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Mapping.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.MappingException;
+import org.hibernate.type.Type;
+
+/**
+ * Defines operations common to "compiled" mappings (ie. <tt>SessionFactory</tt>)
+ * and "uncompiled" mappings (ie. <tt>Configuration</tt>) that are used by
+ * implementors of <tt>Type</tt>.
+ *
+ * @see org.hibernate.type.Type
+ * @see org.hibernate.impl.SessionFactoryImpl
+ * @see org.hibernate.cfg.Configuration
+ * @author Gavin King
+ */
+public interface Mapping {
+ public Type getIdentifierType(String className) throws MappingException;
+ public String getIdentifierPropertyName(String className) throws MappingException;
+ public Type getReferencedPropertyType(String className, String propertyName) throws MappingException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,123 +0,0 @@
-//$Id: NamedQueryDefinition.java 7966 2005-08-19 23:40:24Z epbernard $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import org.hibernate.CacheMode;
-import org.hibernate.FlushMode;
-
-
-/**
- * Definition of a named query, defined in the mapping metadata.
- *
- * @author Gavin King
- */
-public class NamedQueryDefinition implements Serializable {
- private final String query;
- private final boolean cacheable;
- private final String cacheRegion;
- private final Integer timeout;
- private final Integer fetchSize;
- private final FlushMode flushMode;
- private final Map parameterTypes;
- private CacheMode cacheMode;
- private boolean readOnly;
- private String comment;
-
- // kept for backward compatibility until after the 3.1beta5 release of HA
- public NamedQueryDefinition(
- String query,
- boolean cacheable,
- String cacheRegion,
- Integer timeout,
- Integer fetchSize,
- FlushMode flushMode,
- Map parameterTypes
- ) {
- this(
- query,
- cacheable,
- cacheRegion,
- timeout,
- fetchSize,
- flushMode,
- null,
- false,
- null,
- parameterTypes
- );
- }
-
- public NamedQueryDefinition(
- String query,
- boolean cacheable,
- String cacheRegion,
- Integer timeout,
- Integer fetchSize,
- FlushMode flushMode,
- CacheMode cacheMode,
- boolean readOnly,
- String comment,
- Map parameterTypes
- ) {
- this.query = query;
- this.cacheable = cacheable;
- this.cacheRegion = cacheRegion;
- this.timeout = timeout;
- this.fetchSize = fetchSize;
- this.flushMode = flushMode;
- this.parameterTypes = parameterTypes;
- this.cacheMode = cacheMode;
- this.readOnly = readOnly;
- this.comment = comment;
- }
-
- public String getQueryString() {
- return query;
- }
-
- public boolean isCacheable() {
- return cacheable;
- }
-
- public String getCacheRegion() {
- return cacheRegion;
- }
-
- public Integer getFetchSize() {
- return fetchSize;
- }
-
- public Integer getTimeout() {
- return timeout;
- }
-
- public FlushMode getFlushMode() {
- return flushMode;
- }
-
- public String toString() {
- return getClass().getName() + '(' + query + ')';
- }
-
- public Map getParameterTypes() {
- return parameterTypes;
- }
-
- public String getQuery() {
- return query;
- }
-
- public CacheMode getCacheMode() {
- return cacheMode;
- }
-
- public boolean isReadOnly() {
- return readOnly;
- }
-
- public String getComment() {
- return comment;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedQueryDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,146 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.hibernate.CacheMode;
+import org.hibernate.FlushMode;
+
+
+/**
+ * Definition of a named query, defined in the mapping metadata.
+ *
+ * @author Gavin King
+ */
+public class NamedQueryDefinition implements Serializable {
+ private final String query;
+ private final boolean cacheable;
+ private final String cacheRegion;
+ private final Integer timeout;
+ private final Integer fetchSize;
+ private final FlushMode flushMode;
+ private final Map parameterTypes;
+ private CacheMode cacheMode;
+ private boolean readOnly;
+ private String comment;
+
+ // kept for backward compatibility until after the 3.1beta5 release of HA
+ public NamedQueryDefinition(
+ String query,
+ boolean cacheable,
+ String cacheRegion,
+ Integer timeout,
+ Integer fetchSize,
+ FlushMode flushMode,
+ Map parameterTypes
+ ) {
+ this(
+ query,
+ cacheable,
+ cacheRegion,
+ timeout,
+ fetchSize,
+ flushMode,
+ null,
+ false,
+ null,
+ parameterTypes
+ );
+ }
+
+ public NamedQueryDefinition(
+ String query,
+ boolean cacheable,
+ String cacheRegion,
+ Integer timeout,
+ Integer fetchSize,
+ FlushMode flushMode,
+ CacheMode cacheMode,
+ boolean readOnly,
+ String comment,
+ Map parameterTypes
+ ) {
+ this.query = query;
+ this.cacheable = cacheable;
+ this.cacheRegion = cacheRegion;
+ this.timeout = timeout;
+ this.fetchSize = fetchSize;
+ this.flushMode = flushMode;
+ this.parameterTypes = parameterTypes;
+ this.cacheMode = cacheMode;
+ this.readOnly = readOnly;
+ this.comment = comment;
+ }
+
+ public String getQueryString() {
+ return query;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public String getCacheRegion() {
+ return cacheRegion;
+ }
+
+ public Integer getFetchSize() {
+ return fetchSize;
+ }
+
+ public Integer getTimeout() {
+ return timeout;
+ }
+
+ public FlushMode getFlushMode() {
+ return flushMode;
+ }
+
+ public String toString() {
+ return getClass().getName() + '(' + query + ')';
+ }
+
+ public Map getParameterTypes() {
+ return parameterTypes;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public CacheMode getCacheMode() {
+ return cacheMode;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,185 +0,0 @@
-//$Id: NamedSQLQueryDefinition.java 11198 2007-02-13 21:04:10Z epbernard $
-package org.hibernate.engine;
-
-import java.util.List;
-import java.util.Map;
-
-import org.hibernate.FlushMode;
-import org.hibernate.CacheMode;
-import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
-
-/**
- * Definition of a named native SQL query, defined
- * in the mapping metadata.
- *
- * @author Max Andersen
- */
-public class NamedSQLQueryDefinition extends NamedQueryDefinition {
-
- private NativeSQLQueryReturn[] queryReturns;
- private final List querySpaces;
- private final boolean callable;
- private String resultSetRef;
-
- /**
- * This form used to construct a NamedSQLQueryDefinition from the binder
- * code when a the result-set mapping information is explicitly
- * provided in the query definition (i.e., no resultset-mapping used)
- *
- * @param query The sql query string
- * @param queryReturns The in-lined query return definitions
- * @param querySpaces Any specified query spaces (used for auto-flushing)
- * @param cacheable Whether the query results are cacheable
- * @param cacheRegion If cacheable, the region into which to store the results
- * @param timeout A JDBC-level timeout to be applied
- * @param fetchSize A JDBC-level fetch-size to be applied
- * @param flushMode The flush mode to use for this query
- * @param cacheMode The cache mode to use during execution and subsequent result loading
- * @param readOnly Whether returned entities should be marked as read-only in the session
- * @param comment Any sql comment to be applied to the query
- * @param parameterTypes parameter type map
- * @param callable Does the query string represent a callable object (i.e., proc)
- */
- public NamedSQLQueryDefinition(
- String query,
- NativeSQLQueryReturn[] queryReturns,
- List querySpaces,
- boolean cacheable,
- String cacheRegion,
- Integer timeout,
- Integer fetchSize,
- FlushMode flushMode,
- CacheMode cacheMode,
- boolean readOnly,
- String comment,
- Map parameterTypes,
- boolean callable) {
- super(
- query.trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
- cacheable,
- cacheRegion,
- timeout,
- fetchSize,
- flushMode,
- cacheMode,
- readOnly,
- comment,
- parameterTypes
- );
- this.queryReturns = queryReturns;
- this.querySpaces = querySpaces;
- this.callable = callable;
- }
-
- /**
- * This form used to construct a NamedSQLQueryDefinition from the binder
- * code when a resultset-mapping reference is used.
- *
- * @param query The sql query string
- * @param resultSetRef The resultset-mapping name
- * @param querySpaces Any specified query spaces (used for auto-flushing)
- * @param cacheable Whether the query results are cacheable
- * @param cacheRegion If cacheable, the region into which to store the results
- * @param timeout A JDBC-level timeout to be applied
- * @param fetchSize A JDBC-level fetch-size to be applied
- * @param flushMode The flush mode to use for this query
- * @param cacheMode The cache mode to use during execution and subsequent result loading
- * @param readOnly Whether returned entities should be marked as read-only in the session
- * @param comment Any sql comment to be applied to the query
- * @param parameterTypes parameter type map
- * @param callable Does the query string represent a callable object (i.e., proc)
- */
- public NamedSQLQueryDefinition(
- String query,
- String resultSetRef,
- List querySpaces,
- boolean cacheable,
- String cacheRegion,
- Integer timeout,
- Integer fetchSize,
- FlushMode flushMode,
- CacheMode cacheMode,
- boolean readOnly,
- String comment,
- Map parameterTypes,
- boolean callable) {
- super(
- query.trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
- cacheable,
- cacheRegion,
- timeout,
- fetchSize,
- flushMode,
- cacheMode,
- readOnly,
- comment,
- parameterTypes
- );
- this.resultSetRef = resultSetRef;
- this.querySpaces = querySpaces;
- this.callable = callable;
- }
-
- /**
- * This form used from annotations (?). Essentially the same as the above using a
- * resultset-mapping reference, but without cacheMode, readOnly, and comment.
- *
- * FIXME: annotations do not use it, so it can be remove from my POV
- * @deprecated
- *
- *
- * @param query The sql query string
- * @param resultSetRef The result-set-mapping name
- * @param querySpaces Any specified query spaces (used for auto-flushing)
- * @param cacheable Whether the query results are cacheable
- * @param cacheRegion If cacheable, the region into which to store the results
- * @param timeout A JDBC-level timeout to be applied
- * @param fetchSize A JDBC-level fetch-size to be applied
- * @param flushMode The flush mode to use for this query
- * @param parameterTypes parameter type map
- * @param callable Does the query string represent a callable object (i.e., proc)
- */
- public NamedSQLQueryDefinition(
- String query,
- String resultSetRef,
- List querySpaces,
- boolean cacheable,
- String cacheRegion,
- Integer timeout,
- Integer fetchSize,
- FlushMode flushMode,
- Map parameterTypes,
- boolean callable) {
- this(
- query,
- resultSetRef,
- querySpaces,
- cacheable,
- cacheRegion,
- timeout,
- fetchSize,
- flushMode,
- null,
- false,
- null,
- parameterTypes,
- callable
- );
- }
-
- public NativeSQLQueryReturn[] getQueryReturns() {
- return queryReturns;
- }
-
- public List getQuerySpaces() {
- return querySpaces;
- }
-
- public boolean isCallable() {
- return callable;
- }
-
- public String getResultSetRef() {
- return resultSetRef;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/NamedSQLQueryDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,208 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.FlushMode;
+import org.hibernate.CacheMode;
+import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
+
+/**
+ * Definition of a named native SQL query, defined
+ * in the mapping metadata.
+ *
+ * @author Max Andersen
+ */
+public class NamedSQLQueryDefinition extends NamedQueryDefinition {
+
+ private NativeSQLQueryReturn[] queryReturns;
+ private final List querySpaces;
+ private final boolean callable;
+ private String resultSetRef;
+
+ /**
+ * This form used to construct a NamedSQLQueryDefinition from the binder
+ * code when a the result-set mapping information is explicitly
+ * provided in the query definition (i.e., no resultset-mapping used)
+ *
+ * @param query The sql query string
+ * @param queryReturns The in-lined query return definitions
+ * @param querySpaces Any specified query spaces (used for auto-flushing)
+ * @param cacheable Whether the query results are cacheable
+ * @param cacheRegion If cacheable, the region into which to store the results
+ * @param timeout A JDBC-level timeout to be applied
+ * @param fetchSize A JDBC-level fetch-size to be applied
+ * @param flushMode The flush mode to use for this query
+ * @param cacheMode The cache mode to use during execution and subsequent result loading
+ * @param readOnly Whether returned entities should be marked as read-only in the session
+ * @param comment Any sql comment to be applied to the query
+ * @param parameterTypes parameter type map
+ * @param callable Does the query string represent a callable object (i.e., proc)
+ */
+ public NamedSQLQueryDefinition(
+ String query,
+ NativeSQLQueryReturn[] queryReturns,
+ List querySpaces,
+ boolean cacheable,
+ String cacheRegion,
+ Integer timeout,
+ Integer fetchSize,
+ FlushMode flushMode,
+ CacheMode cacheMode,
+ boolean readOnly,
+ String comment,
+ Map parameterTypes,
+ boolean callable) {
+ super(
+ query.trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
+ cacheable,
+ cacheRegion,
+ timeout,
+ fetchSize,
+ flushMode,
+ cacheMode,
+ readOnly,
+ comment,
+ parameterTypes
+ );
+ this.queryReturns = queryReturns;
+ this.querySpaces = querySpaces;
+ this.callable = callable;
+ }
+
+ /**
+ * This form used to construct a NamedSQLQueryDefinition from the binder
+ * code when a resultset-mapping reference is used.
+ *
+ * @param query The sql query string
+ * @param resultSetRef The resultset-mapping name
+ * @param querySpaces Any specified query spaces (used for auto-flushing)
+ * @param cacheable Whether the query results are cacheable
+ * @param cacheRegion If cacheable, the region into which to store the results
+ * @param timeout A JDBC-level timeout to be applied
+ * @param fetchSize A JDBC-level fetch-size to be applied
+ * @param flushMode The flush mode to use for this query
+ * @param cacheMode The cache mode to use during execution and subsequent result loading
+ * @param readOnly Whether returned entities should be marked as read-only in the session
+ * @param comment Any sql comment to be applied to the query
+ * @param parameterTypes parameter type map
+ * @param callable Does the query string represent a callable object (i.e., proc)
+ */
+ public NamedSQLQueryDefinition(
+ String query,
+ String resultSetRef,
+ List querySpaces,
+ boolean cacheable,
+ String cacheRegion,
+ Integer timeout,
+ Integer fetchSize,
+ FlushMode flushMode,
+ CacheMode cacheMode,
+ boolean readOnly,
+ String comment,
+ Map parameterTypes,
+ boolean callable) {
+ super(
+ query.trim(), /* trim done to workaround stupid oracle bug that cant handle whitespaces before a { in a sp */
+ cacheable,
+ cacheRegion,
+ timeout,
+ fetchSize,
+ flushMode,
+ cacheMode,
+ readOnly,
+ comment,
+ parameterTypes
+ );
+ this.resultSetRef = resultSetRef;
+ this.querySpaces = querySpaces;
+ this.callable = callable;
+ }
+
+ /**
+ * This form used from annotations (?). Essentially the same as the above using a
+ * resultset-mapping reference, but without cacheMode, readOnly, and comment.
+ *
+ * FIXME: annotations do not use it, so it can be remove from my POV
+ * @deprecated
+ *
+ *
+ * @param query The sql query string
+ * @param resultSetRef The result-set-mapping name
+ * @param querySpaces Any specified query spaces (used for auto-flushing)
+ * @param cacheable Whether the query results are cacheable
+ * @param cacheRegion If cacheable, the region into which to store the results
+ * @param timeout A JDBC-level timeout to be applied
+ * @param fetchSize A JDBC-level fetch-size to be applied
+ * @param flushMode The flush mode to use for this query
+ * @param parameterTypes parameter type map
+ * @param callable Does the query string represent a callable object (i.e., proc)
+ */
+ public NamedSQLQueryDefinition(
+ String query,
+ String resultSetRef,
+ List querySpaces,
+ boolean cacheable,
+ String cacheRegion,
+ Integer timeout,
+ Integer fetchSize,
+ FlushMode flushMode,
+ Map parameterTypes,
+ boolean callable) {
+ this(
+ query,
+ resultSetRef,
+ querySpaces,
+ cacheable,
+ cacheRegion,
+ timeout,
+ fetchSize,
+ flushMode,
+ null,
+ false,
+ null,
+ parameterTypes,
+ callable
+ );
+ }
+
+ public NativeSQLQueryReturn[] getQueryReturns() {
+ return queryReturns;
+ }
+
+ public List getQuerySpaces() {
+ return querySpaces;
+ }
+
+ public boolean isCallable() {
+ return callable;
+ }
+
+ public String getResultSetRef() {
+ return resultSetRef;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/Nullability.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,183 +0,0 @@
-//$Id: Nullability.java 7566 2005-07-20 07:16:33Z oneovthafew $
-package org.hibernate.engine;
-
-import java.util.Iterator;
-
-import org.hibernate.HibernateException;
-import org.hibernate.PropertyValueException;
-import org.hibernate.intercept.LazyPropertyInitializer;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.AbstractComponentType;
-import org.hibernate.type.CollectionType;
-import org.hibernate.type.Type;
-
-/**
- * Implements the algorithm for validating property values
- * for illegal null values
- * @author Gavin King
- */
-public final class Nullability {
-
- private final SessionImplementor session;
-
- public Nullability(SessionImplementor session) {
- this.session = session;
- }
- /**
- * Check nullability of the class persister properties
- *
- * @param values entity properties
- * @param persister class persister
- * @param isUpdate wether it is intended to be updated or saved
- * @throws org.hibernate.PropertyValueException Break the nullability of one property
- * @throws HibernateException error while getting Component values
- */
- public void checkNullability(
- final Object[] values,
- final EntityPersister persister,
- final boolean isUpdate)
- throws PropertyValueException, HibernateException {
-
- /*
- * Algorithm
- * Check for any level one nullability breaks
- * Look at non null components to
- * recursively check next level of nullability breaks
- * Look at Collections contraining component to
- * recursively check next level of nullability breaks
- *
- *
- * In the previous implementation, not-null stuffs where checked
- * filtering by level one only updateable
- * or insertable columns. So setting a sub component as update="false"
- * has no effect on not-null check if the main component had good checkeability
- * In this implementation, we keep this feature.
- * However, I never see any documentation mentioning that, but it's for
- * sure a limitation.
- */
-
- final boolean[] nullability = persister.getPropertyNullability();
- final boolean[] checkability = isUpdate ?
- persister.getPropertyUpdateability() :
- persister.getPropertyInsertability();
- final Type[] propertyTypes = persister.getPropertyTypes();
-
- for ( int i = 0; i < values.length; i++ ) {
-
- if ( checkability[i] && values[i]!=LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
- final Object value = values[i];
- if ( !nullability[i] && value == null ) {
-
- //check basic level one nullablilty
- throw new PropertyValueException(
- "not-null property references a null or transient value",
- persister.getEntityName(),
- persister.getPropertyNames()[i]
- );
-
- }
- else if ( value != null ) {
-
- //values is not null and is checkable, we'll look deeper
- String breakProperties = checkSubElementsNullability( propertyTypes[i], value );
- if ( breakProperties != null ) {
- throw new PropertyValueException(
- "not-null property references a null or transient value",
- persister.getEntityName(),
- buildPropertyPath( persister.getPropertyNames()[i], breakProperties )
- );
- }
-
- }
- }
-
- }
- }
-
- /**
- * check sub elements-nullability. Returns property path that break
- * nullability or null if none
- *
- * @param propertyType type to check
- * @param value value to check
- *
- * @return property path
- * @throws HibernateException error while getting subcomponent values
- */
- private String checkSubElementsNullability(final Type propertyType, final Object value)
- throws HibernateException {
- //for non null args, check for components and elements containing components
- if ( propertyType.isComponentType() ) {
- return checkComponentNullability( value, (AbstractComponentType) propertyType );
- }
- else if ( propertyType.isCollectionType() ) {
-
- //persistent collections may have components
- CollectionType collectionType = (CollectionType) propertyType;
- Type collectionElementType = collectionType.getElementType( session.getFactory() );
- if ( collectionElementType.isComponentType() ) {
- //check for all components values in the collection
-
- AbstractComponentType componentType = (AbstractComponentType) collectionElementType;
- Iterator iter = CascadingAction.getLoadedElementsIterator(session, collectionType, value);
- while ( iter.hasNext() ) {
- Object compValue = iter.next();
- if (compValue != null) {
- return checkComponentNullability(compValue, componentType);
- }
- }
- }
- }
- return null;
- }
-
- /**
- * check component nullability. Returns property path that break
- * nullability or null if none
- *
- * @param value component properties
- * @param compType component not-nullable type
- *
- * @return property path
- * @throws HibernateException error while getting subcomponent values
- */
- private String checkComponentNullability(final Object value, final AbstractComponentType compType)
- throws HibernateException {
- /* will check current level if some of them are not null
- * or sublevels if they exist
- */
- boolean[] nullability = compType.getPropertyNullability();
- if ( nullability!=null ) {
- //do the test
- final Object[] values = compType.getPropertyValues( value, session.getEntityMode() );
- final Type[] propertyTypes = compType.getSubtypes();
- for ( int i=0; i<values.length; i++ ) {
- final Object subvalue = values[i];
- if ( !nullability[i] && subvalue==null ) {
- return compType.getPropertyNames()[i];
- }
- else if ( subvalue != null ) {
- String breakProperties = checkSubElementsNullability( propertyTypes[i], subvalue );
- if ( breakProperties != null ) {
- return buildPropertyPath( compType.getPropertyNames()[i], breakProperties );
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Return a well formed property path.
- * Basicaly, it will return parent.child
- *
- * @param parent parent in path
- * @param child child in path
- * @return parent-child path
- */
- private static String buildPropertyPath(String parent, String child) {
- return new StringBuffer( parent.length() + child.length() + 1 )
- .append(parent).append('.').append(child).toString();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/Nullability.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Nullability.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,206 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.Iterator;
+
+import org.hibernate.HibernateException;
+import org.hibernate.PropertyValueException;
+import org.hibernate.intercept.LazyPropertyInitializer;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.AbstractComponentType;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.Type;
+
+/**
+ * Implements the algorithm for validating property values
+ * for illegal null values
+ * @author Gavin King
+ */
+public final class Nullability {
+
+ private final SessionImplementor session;
+
+ public Nullability(SessionImplementor session) {
+ this.session = session;
+ }
+ /**
+ * Check nullability of the class persister properties
+ *
+ * @param values entity properties
+ * @param persister class persister
+ * @param isUpdate wether it is intended to be updated or saved
+ * @throws org.hibernate.PropertyValueException Break the nullability of one property
+ * @throws HibernateException error while getting Component values
+ */
+ public void checkNullability(
+ final Object[] values,
+ final EntityPersister persister,
+ final boolean isUpdate)
+ throws PropertyValueException, HibernateException {
+
+ /*
+ * Algorithm
+ * Check for any level one nullability breaks
+ * Look at non null components to
+ * recursively check next level of nullability breaks
+ * Look at Collections contraining component to
+ * recursively check next level of nullability breaks
+ *
+ *
+ * In the previous implementation, not-null stuffs where checked
+ * filtering by level one only updateable
+ * or insertable columns. So setting a sub component as update="false"
+ * has no effect on not-null check if the main component had good checkeability
+ * In this implementation, we keep this feature.
+ * However, I never see any documentation mentioning that, but it's for
+ * sure a limitation.
+ */
+
+ final boolean[] nullability = persister.getPropertyNullability();
+ final boolean[] checkability = isUpdate ?
+ persister.getPropertyUpdateability() :
+ persister.getPropertyInsertability();
+ final Type[] propertyTypes = persister.getPropertyTypes();
+
+ for ( int i = 0; i < values.length; i++ ) {
+
+ if ( checkability[i] && values[i]!=LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
+ final Object value = values[i];
+ if ( !nullability[i] && value == null ) {
+
+ //check basic level one nullablilty
+ throw new PropertyValueException(
+ "not-null property references a null or transient value",
+ persister.getEntityName(),
+ persister.getPropertyNames()[i]
+ );
+
+ }
+ else if ( value != null ) {
+
+ //values is not null and is checkable, we'll look deeper
+ String breakProperties = checkSubElementsNullability( propertyTypes[i], value );
+ if ( breakProperties != null ) {
+ throw new PropertyValueException(
+ "not-null property references a null or transient value",
+ persister.getEntityName(),
+ buildPropertyPath( persister.getPropertyNames()[i], breakProperties )
+ );
+ }
+
+ }
+ }
+
+ }
+ }
+
+ /**
+ * check sub elements-nullability. Returns property path that break
+ * nullability or null if none
+ *
+ * @param propertyType type to check
+ * @param value value to check
+ *
+ * @return property path
+ * @throws HibernateException error while getting subcomponent values
+ */
+ private String checkSubElementsNullability(final Type propertyType, final Object value)
+ throws HibernateException {
+ //for non null args, check for components and elements containing components
+ if ( propertyType.isComponentType() ) {
+ return checkComponentNullability( value, (AbstractComponentType) propertyType );
+ }
+ else if ( propertyType.isCollectionType() ) {
+
+ //persistent collections may have components
+ CollectionType collectionType = (CollectionType) propertyType;
+ Type collectionElementType = collectionType.getElementType( session.getFactory() );
+ if ( collectionElementType.isComponentType() ) {
+ //check for all components values in the collection
+
+ AbstractComponentType componentType = (AbstractComponentType) collectionElementType;
+ Iterator iter = CascadingAction.getLoadedElementsIterator(session, collectionType, value);
+ while ( iter.hasNext() ) {
+ Object compValue = iter.next();
+ if (compValue != null) {
+ return checkComponentNullability(compValue, componentType);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * check component nullability. Returns property path that break
+ * nullability or null if none
+ *
+ * @param value component properties
+ * @param compType component not-nullable type
+ *
+ * @return property path
+ * @throws HibernateException error while getting subcomponent values
+ */
+ private String checkComponentNullability(final Object value, final AbstractComponentType compType)
+ throws HibernateException {
+ /* will check current level if some of them are not null
+ * or sublevels if they exist
+ */
+ boolean[] nullability = compType.getPropertyNullability();
+ if ( nullability!=null ) {
+ //do the test
+ final Object[] values = compType.getPropertyValues( value, session.getEntityMode() );
+ final Type[] propertyTypes = compType.getSubtypes();
+ for ( int i=0; i<values.length; i++ ) {
+ final Object subvalue = values[i];
+ if ( !nullability[i] && subvalue==null ) {
+ return compType.getPropertyNames()[i];
+ }
+ else if ( subvalue != null ) {
+ String breakProperties = checkSubElementsNullability( propertyTypes[i], subvalue );
+ if ( breakProperties != null ) {
+ return buildPropertyPath( compType.getPropertyNames()[i], breakProperties );
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return a well formed property path.
+ * Basicaly, it will return parent.child
+ *
+ * @param parent parent in path
+ * @param child child in path
+ * @return parent-child path
+ */
+ private static String buildPropertyPath(String parent, String child) {
+ return new StringBuffer( parent.length() + child.length() + 1 )
+ .append(parent).append('.').append(child).toString();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ParameterBinder.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,114 +0,0 @@
-// $Id: ParameterBinder.java 7385 2005-07-06 17:13:15Z steveebersole $
-package org.hibernate.engine;
-
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Map;
-import java.util.Iterator;
-
-/**
- * Centralizes the commonality regarding binding of parameter values into
- * PreparedStatements as this logic is used in many places.
- * <p/>
- * Ideally would like to move to the parameter handling as it is done in
- * the hql.ast package.
- *
- * @author Steve Ebersole
- */
-public class ParameterBinder {
-
- private static final Logger log = LoggerFactory.getLogger( ParameterBinder.class );
-
- public static interface NamedParameterSource {
- public int[] getNamedParameterLocations(String name);
- }
-
- private ParameterBinder() {
- }
-
- public static int bindQueryParameters(
- final PreparedStatement st,
- final QueryParameters queryParameters,
- final int start,
- final NamedParameterSource source,
- SessionImplementor session) throws SQLException, HibernateException {
- int col = start;
- col += bindPositionalParameters( st, queryParameters, col, session );
- col += bindNamedParameters( st, queryParameters, col, source, session );
- return col;
- }
-
- public static int bindPositionalParameters(
- final PreparedStatement st,
- final QueryParameters queryParameters,
- final int start,
- final SessionImplementor session) throws SQLException, HibernateException {
- return bindPositionalParameters(
- st,
- queryParameters.getPositionalParameterValues(),
- queryParameters.getPositionalParameterTypes(),
- start,
- session
- );
- }
-
- public static int bindPositionalParameters(
- final PreparedStatement st,
- final Object[] values,
- final Type[] types,
- final int start,
- final SessionImplementor session) throws SQLException, HibernateException {
- int span = 0;
- for ( int i = 0; i < values.length; i++ ) {
- types[i].nullSafeSet( st, values[i], start + span, session );
- span += types[i].getColumnSpan( session.getFactory() );
- }
- return span;
- }
-
- public static int bindNamedParameters(
- final PreparedStatement ps,
- final QueryParameters queryParameters,
- final int start,
- final NamedParameterSource source,
- final SessionImplementor session) throws SQLException, HibernateException {
- return bindNamedParameters( ps, queryParameters.getNamedParameters(), start, source, session );
- }
-
- public static int bindNamedParameters(
- final PreparedStatement ps,
- final Map namedParams,
- final int start,
- final NamedParameterSource source,
- final SessionImplementor session) throws SQLException, HibernateException {
- if ( namedParams != null ) {
- // assumes that types are all of span 1
- Iterator iter = namedParams.entrySet().iterator();
- int result = 0;
- while ( iter.hasNext() ) {
- Map.Entry e = ( Map.Entry ) iter.next();
- String name = ( String ) e.getKey();
- TypedValue typedval = ( TypedValue ) e.getValue();
- int[] locations = source.getNamedParameterLocations( name );
- for ( int i = 0; i < locations.length; i++ ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "bindNamedParameters() " +
- typedval.getValue() + " -> " + name +
- " [" + ( locations[i] + start ) + "]" );
- }
- typedval.getType().nullSafeSet( ps, typedval.getValue(), locations[i] + start, session );
- }
- result += locations.length;
- }
- return result;
- }
- else {
- return 0;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/ParameterBinder.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ParameterBinder.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,137 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * Centralizes the commonality regarding binding of parameter values into
+ * PreparedStatements as this logic is used in many places.
+ * <p/>
+ * Ideally would like to move to the parameter handling as it is done in
+ * the hql.ast package.
+ *
+ * @author Steve Ebersole
+ */
+public class ParameterBinder {
+
+ private static final Logger log = LoggerFactory.getLogger( ParameterBinder.class );
+
+ public static interface NamedParameterSource {
+ public int[] getNamedParameterLocations(String name);
+ }
+
+ private ParameterBinder() {
+ }
+
+ public static int bindQueryParameters(
+ final PreparedStatement st,
+ final QueryParameters queryParameters,
+ final int start,
+ final NamedParameterSource source,
+ SessionImplementor session) throws SQLException, HibernateException {
+ int col = start;
+ col += bindPositionalParameters( st, queryParameters, col, session );
+ col += bindNamedParameters( st, queryParameters, col, source, session );
+ return col;
+ }
+
+ public static int bindPositionalParameters(
+ final PreparedStatement st,
+ final QueryParameters queryParameters,
+ final int start,
+ final SessionImplementor session) throws SQLException, HibernateException {
+ return bindPositionalParameters(
+ st,
+ queryParameters.getPositionalParameterValues(),
+ queryParameters.getPositionalParameterTypes(),
+ start,
+ session
+ );
+ }
+
+ public static int bindPositionalParameters(
+ final PreparedStatement st,
+ final Object[] values,
+ final Type[] types,
+ final int start,
+ final SessionImplementor session) throws SQLException, HibernateException {
+ int span = 0;
+ for ( int i = 0; i < values.length; i++ ) {
+ types[i].nullSafeSet( st, values[i], start + span, session );
+ span += types[i].getColumnSpan( session.getFactory() );
+ }
+ return span;
+ }
+
+ public static int bindNamedParameters(
+ final PreparedStatement ps,
+ final QueryParameters queryParameters,
+ final int start,
+ final NamedParameterSource source,
+ final SessionImplementor session) throws SQLException, HibernateException {
+ return bindNamedParameters( ps, queryParameters.getNamedParameters(), start, source, session );
+ }
+
+ public static int bindNamedParameters(
+ final PreparedStatement ps,
+ final Map namedParams,
+ final int start,
+ final NamedParameterSource source,
+ final SessionImplementor session) throws SQLException, HibernateException {
+ if ( namedParams != null ) {
+ // assumes that types are all of span 1
+ Iterator iter = namedParams.entrySet().iterator();
+ int result = 0;
+ while ( iter.hasNext() ) {
+ Map.Entry e = ( Map.Entry ) iter.next();
+ String name = ( String ) e.getKey();
+ TypedValue typedval = ( TypedValue ) e.getValue();
+ int[] locations = source.getNamedParameterLocations( name );
+ for ( int i = 0; i < locations.length; i++ ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "bindNamedParameters() " +
+ typedval.getValue() + " -> " + name +
+ " [" + ( locations[i] + start ) + "]" );
+ }
+ typedval.getType().nullSafeSet( ps, typedval.getValue(), locations[i] + start, session );
+ }
+ result += locations.length;
+ }
+ return result;
+ }
+ else {
+ return 0;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/PersistenceContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,462 +0,0 @@
-//$Id: PersistenceContext.java 14312 2008-02-05 23:55:35Z gbadner $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Map;
-
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.MappingException;
-import org.hibernate.engine.loading.LoadContexts;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.persister.entity.EntityPersister;
-
-/**
- * Holds the state of the persistence context, including the
- * first-level cache, entries, snapshots, proxies, etc.
- *
- * @author Gavin King
- */
-public interface PersistenceContext {
-
- public boolean isStateless();
-
- /**
- * Get the session to which this persistence context is bound.
- *
- * @return The session.
- */
- public SessionImplementor getSession();
-
- /**
- * Retrieve this persistence context's managed load context.
- *
- * @return The load context
- */
- public LoadContexts getLoadContexts();
-
- /**
- * Add a collection which has no owner loaded
- */
- public void addUnownedCollection(CollectionKey key, PersistentCollection collection);
-
- /**
- * Get and remove a collection whose owner is not yet loaded,
- * when its owner is being loaded
- */
- public PersistentCollection useUnownedCollection(CollectionKey key);
-
- /**
- * Get the <tt>BatchFetchQueue</tt>, instantiating one if
- * necessary.
- */
- public BatchFetchQueue getBatchFetchQueue();
-
- /**
- * Clear the state of the persistence context
- */
- public void clear();
-
- /**
- * @return false if we know for certain that all the entities are read-only
- */
- public boolean hasNonReadOnlyEntities();
-
- /**
- * Set the status of an entry
- */
- public void setEntryStatus(EntityEntry entry, Status status);
-
- /**
- * Called after transactions end
- */
- public void afterTransactionCompletion();
-
- /**
- * Get the current state of the entity as known to the underlying
- * database, or null if there is no corresponding row
- */
- public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister)
- throws HibernateException;
-
- public Object[] getCachedDatabaseSnapshot(EntityKey key);
-
- /**
- * Get the values of the natural id fields as known to the underlying
- * database, or null if the entity has no natural id or there is no
- * corresponding row.
- */
- public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister)
- throws HibernateException;
-
- /**
- * Add a canonical mapping from entity key to entity instance
- */
- public void addEntity(EntityKey key, Object entity);
-
- /**
- * Get the entity instance associated with the given
- * <tt>EntityKey</tt>
- */
- public Object getEntity(EntityKey key);
-
- /**
- * Is there an entity with the given key in the persistence context
- */
- public boolean containsEntity(EntityKey key);
-
- /**
- * Remove an entity from the session cache, also clear
- * up other state associated with the entity, all except
- * for the <tt>EntityEntry</tt>
- */
- public Object removeEntity(EntityKey key);
-
- /**
- * Get an entity cached by unique key
- */
- public Object getEntity(EntityUniqueKey euk);
-
- /**
- * Add an entity to the cache by unique key
- */
- public void addEntity(EntityUniqueKey euk, Object entity);
-
- /**
- * Retreive the EntityEntry representation of the given entity.
- *
- * @param entity The entity for which to locate the EntityEntry.
- * @return The EntityEntry for the given entity.
- */
- public EntityEntry getEntry(Object entity);
-
- /**
- * Remove an entity entry from the session cache
- */
- public EntityEntry removeEntry(Object entity);
-
- /**
- * Is there an EntityEntry for this instance?
- */
- public boolean isEntryFor(Object entity);
-
- /**
- * Get the collection entry for a persistent collection
- */
- public CollectionEntry getCollectionEntry(PersistentCollection coll);
-
- /**
- * Adds an entity to the internal caches.
- */
- public EntityEntry addEntity(final Object entity, final Status status,
- final Object[] loadedState, final EntityKey entityKey, final Object version,
- final LockMode lockMode, final boolean existsInDatabase,
- final EntityPersister persister, final boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched);
-
- /**
- * Generates an appropriate EntityEntry instance and adds it
- * to the event source's internal caches.
- */
- public EntityEntry addEntry(final Object entity, final Status status,
- final Object[] loadedState, final Object rowId, final Serializable id,
- final Object version, final LockMode lockMode, final boolean existsInDatabase,
- final EntityPersister persister, final boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched);
-
- /**
- * Is the given collection associated with this persistence context?
- */
- public boolean containsCollection(PersistentCollection collection);
-
- /**
- * Is the given proxy associated with this persistence context?
- */
- public boolean containsProxy(Object proxy);
-
- /**
- * Takes the given object and, if it represents a proxy, reassociates it with this event source.
- *
- * @param value The possible proxy to be reassociated.
- * @return Whether the passed value represented an actual proxy which got initialized.
- * @throws MappingException
- */
- public boolean reassociateIfUninitializedProxy(Object value) throws MappingException;
-
- /**
- * If a deleted entity instance is re-saved, and it has a proxy, we need to
- * reset the identifier of the proxy
- */
- public void reassociateProxy(Object value, Serializable id) throws MappingException;
-
- /**
- * Get the entity instance underlying the given proxy, throwing
- * an exception if the proxy is uninitialized. If the given object
- * is not a proxy, simply return the argument.
- */
- public Object unproxy(Object maybeProxy) throws HibernateException;
-
- /**
- * Possibly unproxy the given reference and reassociate it with the current session.
- *
- * @param maybeProxy The reference to be unproxied if it currently represents a proxy.
- * @return The unproxied instance.
- * @throws HibernateException
- */
- public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException;
-
- /**
- * Attempts to check whether the given key represents an entity already loaded within the
- * current session.
- * @param object The entity reference against which to perform the uniqueness check.
- * @throws HibernateException
- */
- public void checkUniqueness(EntityKey key, Object object) throws HibernateException;
-
- /**
- * If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
- * and overwrite the registration of the old one. This breaks == and occurs only for
- * "class" proxies rather than "interface" proxies. Also init the proxy to point to
- * the given target implementation if necessary.
- *
- * @param proxy The proxy instance to be narrowed.
- * @param persister The persister for the proxied entity.
- * @param key The internal cache key for the proxied entity.
- * @param object (optional) the actual proxied entity instance.
- * @return An appropriately narrowed instance.
- * @throws HibernateException
- */
- public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object)
- throws HibernateException;
-
- /**
- * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
- * third argument (the entity associated with the key) if no proxy exists. Init
- * the proxy to the target implementation, if necessary.
- */
- public Object proxyFor(EntityPersister persister, EntityKey key, Object impl)
- throws HibernateException;
-
- /**
- * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
- * argument (the entity associated with the key) if no proxy exists.
- * (slower than the form above)
- */
- public Object proxyFor(Object impl) throws HibernateException;
-
- /**
- * Get the entity that owns this persistent collection
- */
- public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister)
- throws MappingException;
-
- /**
- * Get the entity that owned this persistent collection when it was loaded
- *
- * @param collection The persistent collection
- * @return the owner if its entity ID is available from the collection's loaded key
- * and the owner entity is in the persistence context; otherwise, returns null
- */
- Object getLoadedCollectionOwnerOrNull(PersistentCollection collection);
-
- /**
- * Get the ID for the entity that owned this persistent collection when it was loaded
- *
- * @param collection The persistent collection
- * @return the owner ID if available from the collection's loaded key; otherwise, returns null
- */
- public Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection);
-
- /**
- * add a collection we just loaded up (still needs initializing)
- */
- public void addUninitializedCollection(CollectionPersister persister,
- PersistentCollection collection, Serializable id);
-
- /**
- * add a detached uninitialized collection
- */
- public void addUninitializedDetachedCollection(CollectionPersister persister,
- PersistentCollection collection);
-
- /**
- * Add a new collection (ie. a newly created one, just instantiated by the
- * application, with no database state or snapshot)
- * @param collection The collection to be associated with the persistence context
- */
- public void addNewCollection(CollectionPersister persister, PersistentCollection collection)
- throws HibernateException;
-
- /**
- * add an (initialized) collection that was created by another session and passed
- * into update() (ie. one with a snapshot and existing state on the database)
- */
- public void addInitializedDetachedCollection(CollectionPersister collectionPersister,
- PersistentCollection collection) throws HibernateException;
-
- /**
- * add a collection we just pulled out of the cache (does not need initializing)
- */
- public CollectionEntry addInitializedCollection(CollectionPersister persister,
- PersistentCollection collection, Serializable id) throws HibernateException;
-
- /**
- * Get the collection instance associated with the <tt>CollectionKey</tt>
- */
- public PersistentCollection getCollection(CollectionKey collectionKey);
-
- /**
- * Register a collection for non-lazy loading at the end of the
- * two-phase load
- */
- public void addNonLazyCollection(PersistentCollection collection);
-
- /**
- * Force initialization of all non-lazy collections encountered during
- * the current two-phase load (actually, this is a no-op, unless this
- * is the "outermost" load)
- */
- public void initializeNonLazyCollections() throws HibernateException;
-
- /**
- * Get the <tt>PersistentCollection</tt> object for an array
- */
- public PersistentCollection getCollectionHolder(Object array);
-
- /**
- * Register a <tt>PersistentCollection</tt> object for an array.
- * Associates a holder with an array - MUST be called after loading
- * array, since the array instance is not created until endLoad().
- */
- public void addCollectionHolder(PersistentCollection holder);
-
- /**
- * Remove the mapping of collection to holder during eviction
- * of the owning entity
- */
- public PersistentCollection removeCollectionHolder(Object array);
-
- /**
- * Get the snapshot of the pre-flush collection state
- */
- public Serializable getSnapshot(PersistentCollection coll);
-
- /**
- * Get the collection entry for a collection passed to filter,
- * which might be a collection wrapper, an array, or an unwrapped
- * collection. Return null if there is no entry.
- */
- public CollectionEntry getCollectionEntryOrNull(Object collection);
-
- /**
- * Get an existing proxy by key
- */
- public Object getProxy(EntityKey key);
-
- /**
- * Add a proxy to the session cache
- */
- public void addProxy(EntityKey key, Object proxy);
-
- /**
- * Remove a proxy from the session cache
- */
- public Object removeProxy(EntityKey key);
-
- /**
- * Retrieve the set of EntityKeys representing nullifiable references
- */
- public HashSet getNullifiableEntityKeys();
-
- /**
- * Get the mapping from key value to entity instance
- */
- public Map getEntitiesByKey();
-
- /**
- * Get the mapping from entity instance to entity entry
- */
- public Map getEntityEntries();
-
- /**
- * Get the mapping from collection instance to collection entry
- */
- public Map getCollectionEntries();
-
- /**
- * Get the mapping from collection key to collection instance
- */
- public Map getCollectionsByKey();
-
- /**
- * How deep are we cascaded?
- */
- public int getCascadeLevel();
-
- /**
- * Called before cascading
- */
- public int incrementCascadeLevel();
-
- /**
- * Called after cascading
- */
- public int decrementCascadeLevel();
-
- /**
- * Is a flush cycle currently in process?
- */
- public boolean isFlushing();
-
- /**
- * Called before and after the flushcycle
- */
- public void setFlushing(boolean flushing);
-
- /**
- * Call this before begining a two-phase load
- */
- public void beforeLoad();
-
- /**
- * Call this after finishing a two-phase load
- */
- public void afterLoad();
-
- /**
- * Returns a string representation of the object.
- *
- * @return a string representation of the object.
- */
- public String toString();
-
- /**
- * Search the persistence context for an owner for the child object,
- * given a collection role
- */
- public Serializable getOwnerId(String entity, String property, Object childObject, Map mergeMap);
-
- /**
- * Search the persistence context for an index of the child object,
- * given a collection role
- */
- public Object getIndexInOwner(String entity, String property, Object childObject, Map mergeMap);
-
- /**
- * Record the fact that the association belonging to the keyed
- * entity is null.
- */
- public void addNullProperty(EntityKey ownerKey, String propertyName);
-
- /**
- * Is the association property belonging to the keyed entity null?
- */
- public boolean isPropertyNull(EntityKey ownerKey, String propertyName);
-
- /**
- * Set the object to read only and discard it's snapshot
- */
- public void setReadOnly(Object entity, boolean readOnly);
-
- void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/PersistenceContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/PersistenceContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,485 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.MappingException;
+import org.hibernate.engine.loading.LoadContexts;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * Holds the state of the persistence context, including the
+ * first-level cache, entries, snapshots, proxies, etc.
+ *
+ * @author Gavin King
+ */
+public interface PersistenceContext {
+
+ public boolean isStateless();
+
+ /**
+ * Get the session to which this persistence context is bound.
+ *
+ * @return The session.
+ */
+ public SessionImplementor getSession();
+
+ /**
+ * Retrieve this persistence context's managed load context.
+ *
+ * @return The load context
+ */
+ public LoadContexts getLoadContexts();
+
+ /**
+ * Add a collection which has no owner loaded
+ */
+ public void addUnownedCollection(CollectionKey key, PersistentCollection collection);
+
+ /**
+ * Get and remove a collection whose owner is not yet loaded,
+ * when its owner is being loaded
+ */
+ public PersistentCollection useUnownedCollection(CollectionKey key);
+
+ /**
+ * Get the <tt>BatchFetchQueue</tt>, instantiating one if
+ * necessary.
+ */
+ public BatchFetchQueue getBatchFetchQueue();
+
+ /**
+ * Clear the state of the persistence context
+ */
+ public void clear();
+
+ /**
+ * @return false if we know for certain that all the entities are read-only
+ */
+ public boolean hasNonReadOnlyEntities();
+
+ /**
+ * Set the status of an entry
+ */
+ public void setEntryStatus(EntityEntry entry, Status status);
+
+ /**
+ * Called after transactions end
+ */
+ public void afterTransactionCompletion();
+
+ /**
+ * Get the current state of the entity as known to the underlying
+ * database, or null if there is no corresponding row
+ */
+ public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister)
+ throws HibernateException;
+
+ public Object[] getCachedDatabaseSnapshot(EntityKey key);
+
+ /**
+ * Get the values of the natural id fields as known to the underlying
+ * database, or null if the entity has no natural id or there is no
+ * corresponding row.
+ */
+ public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister)
+ throws HibernateException;
+
+ /**
+ * Add a canonical mapping from entity key to entity instance
+ */
+ public void addEntity(EntityKey key, Object entity);
+
+ /**
+ * Get the entity instance associated with the given
+ * <tt>EntityKey</tt>
+ */
+ public Object getEntity(EntityKey key);
+
+ /**
+ * Is there an entity with the given key in the persistence context
+ */
+ public boolean containsEntity(EntityKey key);
+
+ /**
+ * Remove an entity from the session cache, also clear
+ * up other state associated with the entity, all except
+ * for the <tt>EntityEntry</tt>
+ */
+ public Object removeEntity(EntityKey key);
+
+ /**
+ * Get an entity cached by unique key
+ */
+ public Object getEntity(EntityUniqueKey euk);
+
+ /**
+ * Add an entity to the cache by unique key
+ */
+ public void addEntity(EntityUniqueKey euk, Object entity);
+
+ /**
+ * Retreive the EntityEntry representation of the given entity.
+ *
+ * @param entity The entity for which to locate the EntityEntry.
+ * @return The EntityEntry for the given entity.
+ */
+ public EntityEntry getEntry(Object entity);
+
+ /**
+ * Remove an entity entry from the session cache
+ */
+ public EntityEntry removeEntry(Object entity);
+
+ /**
+ * Is there an EntityEntry for this instance?
+ */
+ public boolean isEntryFor(Object entity);
+
+ /**
+ * Get the collection entry for a persistent collection
+ */
+ public CollectionEntry getCollectionEntry(PersistentCollection coll);
+
+ /**
+ * Adds an entity to the internal caches.
+ */
+ public EntityEntry addEntity(final Object entity, final Status status,
+ final Object[] loadedState, final EntityKey entityKey, final Object version,
+ final LockMode lockMode, final boolean existsInDatabase,
+ final EntityPersister persister, final boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched);
+
+ /**
+ * Generates an appropriate EntityEntry instance and adds it
+ * to the event source's internal caches.
+ */
+ public EntityEntry addEntry(final Object entity, final Status status,
+ final Object[] loadedState, final Object rowId, final Serializable id,
+ final Object version, final LockMode lockMode, final boolean existsInDatabase,
+ final EntityPersister persister, final boolean disableVersionIncrement, boolean lazyPropertiesAreUnfetched);
+
+ /**
+ * Is the given collection associated with this persistence context?
+ */
+ public boolean containsCollection(PersistentCollection collection);
+
+ /**
+ * Is the given proxy associated with this persistence context?
+ */
+ public boolean containsProxy(Object proxy);
+
+ /**
+ * Takes the given object and, if it represents a proxy, reassociates it with this event source.
+ *
+ * @param value The possible proxy to be reassociated.
+ * @return Whether the passed value represented an actual proxy which got initialized.
+ * @throws MappingException
+ */
+ public boolean reassociateIfUninitializedProxy(Object value) throws MappingException;
+
+ /**
+ * If a deleted entity instance is re-saved, and it has a proxy, we need to
+ * reset the identifier of the proxy
+ */
+ public void reassociateProxy(Object value, Serializable id) throws MappingException;
+
+ /**
+ * Get the entity instance underlying the given proxy, throwing
+ * an exception if the proxy is uninitialized. If the given object
+ * is not a proxy, simply return the argument.
+ */
+ public Object unproxy(Object maybeProxy) throws HibernateException;
+
+ /**
+ * Possibly unproxy the given reference and reassociate it with the current session.
+ *
+ * @param maybeProxy The reference to be unproxied if it currently represents a proxy.
+ * @return The unproxied instance.
+ * @throws HibernateException
+ */
+ public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException;
+
+ /**
+ * Attempts to check whether the given key represents an entity already loaded within the
+ * current session.
+ * @param object The entity reference against which to perform the uniqueness check.
+ * @throws HibernateException
+ */
+ public void checkUniqueness(EntityKey key, Object object) throws HibernateException;
+
+ /**
+ * If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
+ * and overwrite the registration of the old one. This breaks == and occurs only for
+ * "class" proxies rather than "interface" proxies. Also init the proxy to point to
+ * the given target implementation if necessary.
+ *
+ * @param proxy The proxy instance to be narrowed.
+ * @param persister The persister for the proxied entity.
+ * @param key The internal cache key for the proxied entity.
+ * @param object (optional) the actual proxied entity instance.
+ * @return An appropriately narrowed instance.
+ * @throws HibernateException
+ */
+ public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object)
+ throws HibernateException;
+
+ /**
+ * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
+ * third argument (the entity associated with the key) if no proxy exists. Init
+ * the proxy to the target implementation, if necessary.
+ */
+ public Object proxyFor(EntityPersister persister, EntityKey key, Object impl)
+ throws HibernateException;
+
+ /**
+ * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
+ * argument (the entity associated with the key) if no proxy exists.
+ * (slower than the form above)
+ */
+ public Object proxyFor(Object impl) throws HibernateException;
+
+ /**
+ * Get the entity that owns this persistent collection
+ */
+ public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister)
+ throws MappingException;
+
+ /**
+ * Get the entity that owned this persistent collection when it was loaded
+ *
+ * @param collection The persistent collection
+ * @return the owner if its entity ID is available from the collection's loaded key
+ * and the owner entity is in the persistence context; otherwise, returns null
+ */
+ Object getLoadedCollectionOwnerOrNull(PersistentCollection collection);
+
+ /**
+ * Get the ID for the entity that owned this persistent collection when it was loaded
+ *
+ * @param collection The persistent collection
+ * @return the owner ID if available from the collection's loaded key; otherwise, returns null
+ */
+ public Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection);
+
+ /**
+ * add a collection we just loaded up (still needs initializing)
+ */
+ public void addUninitializedCollection(CollectionPersister persister,
+ PersistentCollection collection, Serializable id);
+
+ /**
+ * add a detached uninitialized collection
+ */
+ public void addUninitializedDetachedCollection(CollectionPersister persister,
+ PersistentCollection collection);
+
+ /**
+ * Add a new collection (ie. a newly created one, just instantiated by the
+ * application, with no database state or snapshot)
+ * @param collection The collection to be associated with the persistence context
+ */
+ public void addNewCollection(CollectionPersister persister, PersistentCollection collection)
+ throws HibernateException;
+
+ /**
+ * add an (initialized) collection that was created by another session and passed
+ * into update() (ie. one with a snapshot and existing state on the database)
+ */
+ public void addInitializedDetachedCollection(CollectionPersister collectionPersister,
+ PersistentCollection collection) throws HibernateException;
+
+ /**
+ * add a collection we just pulled out of the cache (does not need initializing)
+ */
+ public CollectionEntry addInitializedCollection(CollectionPersister persister,
+ PersistentCollection collection, Serializable id) throws HibernateException;
+
+ /**
+ * Get the collection instance associated with the <tt>CollectionKey</tt>
+ */
+ public PersistentCollection getCollection(CollectionKey collectionKey);
+
+ /**
+ * Register a collection for non-lazy loading at the end of the
+ * two-phase load
+ */
+ public void addNonLazyCollection(PersistentCollection collection);
+
+ /**
+ * Force initialization of all non-lazy collections encountered during
+ * the current two-phase load (actually, this is a no-op, unless this
+ * is the "outermost" load)
+ */
+ public void initializeNonLazyCollections() throws HibernateException;
+
+ /**
+ * Get the <tt>PersistentCollection</tt> object for an array
+ */
+ public PersistentCollection getCollectionHolder(Object array);
+
+ /**
+ * Register a <tt>PersistentCollection</tt> object for an array.
+ * Associates a holder with an array - MUST be called after loading
+ * array, since the array instance is not created until endLoad().
+ */
+ public void addCollectionHolder(PersistentCollection holder);
+
+ /**
+ * Remove the mapping of collection to holder during eviction
+ * of the owning entity
+ */
+ public PersistentCollection removeCollectionHolder(Object array);
+
+ /**
+ * Get the snapshot of the pre-flush collection state
+ */
+ public Serializable getSnapshot(PersistentCollection coll);
+
+ /**
+ * Get the collection entry for a collection passed to filter,
+ * which might be a collection wrapper, an array, or an unwrapped
+ * collection. Return null if there is no entry.
+ */
+ public CollectionEntry getCollectionEntryOrNull(Object collection);
+
+ /**
+ * Get an existing proxy by key
+ */
+ public Object getProxy(EntityKey key);
+
+ /**
+ * Add a proxy to the session cache
+ */
+ public void addProxy(EntityKey key, Object proxy);
+
+ /**
+ * Remove a proxy from the session cache
+ */
+ public Object removeProxy(EntityKey key);
+
+ /**
+ * Retrieve the set of EntityKeys representing nullifiable references
+ */
+ public HashSet getNullifiableEntityKeys();
+
+ /**
+ * Get the mapping from key value to entity instance
+ */
+ public Map getEntitiesByKey();
+
+ /**
+ * Get the mapping from entity instance to entity entry
+ */
+ public Map getEntityEntries();
+
+ /**
+ * Get the mapping from collection instance to collection entry
+ */
+ public Map getCollectionEntries();
+
+ /**
+ * Get the mapping from collection key to collection instance
+ */
+ public Map getCollectionsByKey();
+
+ /**
+ * How deep are we cascaded?
+ */
+ public int getCascadeLevel();
+
+ /**
+ * Called before cascading
+ */
+ public int incrementCascadeLevel();
+
+ /**
+ * Called after cascading
+ */
+ public int decrementCascadeLevel();
+
+ /**
+ * Is a flush cycle currently in process?
+ */
+ public boolean isFlushing();
+
+ /**
+ * Called before and after the flushcycle
+ */
+ public void setFlushing(boolean flushing);
+
+ /**
+ * Call this before begining a two-phase load
+ */
+ public void beforeLoad();
+
+ /**
+ * Call this after finishing a two-phase load
+ */
+ public void afterLoad();
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return a string representation of the object.
+ */
+ public String toString();
+
+ /**
+ * Search the persistence context for an owner for the child object,
+ * given a collection role
+ */
+ public Serializable getOwnerId(String entity, String property, Object childObject, Map mergeMap);
+
+ /**
+ * Search the persistence context for an index of the child object,
+ * given a collection role
+ */
+ public Object getIndexInOwner(String entity, String property, Object childObject, Map mergeMap);
+
+ /**
+ * Record the fact that the association belonging to the keyed
+ * entity is null.
+ */
+ public void addNullProperty(EntityKey ownerKey, String propertyName);
+
+ /**
+ * Is the association property belonging to the keyed entity null?
+ */
+ public boolean isPropertyNull(EntityKey ownerKey, String propertyName);
+
+ /**
+ * Set the object to read only and discard it's snapshot
+ */
+ public void setReadOnly(Object entity, boolean readOnly);
+
+ void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/QueryParameters.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,482 +0,0 @@
-//$Id: QueryParameters.java 9636 2006-03-16 14:14:48Z max.andersen(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.HibernateException;
-import org.hibernate.QueryException;
-import org.hibernate.ScrollMode;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.hql.classic.ParserHelper;
-import org.hibernate.pretty.Printer;
-import org.hibernate.transform.ResultTransformer;
-import org.hibernate.type.Type;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * @author Gavin King
- */
-public final class QueryParameters {
- private static final Logger log = LoggerFactory.getLogger(QueryParameters.class);
-
- private Type[] positionalParameterTypes;
- private Object[] positionalParameterValues;
- private Map namedParameters;
- private Map lockModes;
- private RowSelection rowSelection;
- private boolean cacheable;
- private String cacheRegion;
- private String comment;
- private ScrollMode scrollMode;
- private Serializable[] collectionKeys;
- private Object optionalObject;
- private String optionalEntityName;
- private Serializable optionalId;
- private boolean readOnly;
- private boolean callable = false;
- private boolean autodiscovertypes = false;
- private boolean isNaturalKeyLookup;
-
- private final ResultTransformer resultTransformer; // why is all others non final ?
-
- private String processedSQL;
- private Type[] processedPositionalParameterTypes;
- private Object[] processedPositionalParameterValues;
-
- public QueryParameters() {
- this( ArrayHelper.EMPTY_TYPE_ARRAY, ArrayHelper.EMPTY_OBJECT_ARRAY );
- }
-
- public QueryParameters(Type type, Object value) {
- this( new Type[] {type}, new Object[] {value} );
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] postionalParameterValues,
- final Object optionalObject,
- final String optionalEntityName,
- final Serializable optionalObjectId
- ) {
- this(positionalParameterTypes, postionalParameterValues);
- this.optionalObject = optionalObject;
- this.optionalId = optionalObjectId;
- this.optionalEntityName = optionalEntityName;
-
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] postionalParameterValues
- ) {
- this(
- positionalParameterTypes,
- postionalParameterValues,
- null,
- null,
- false,
- null,
- null,
- false,
- null
- );
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] postionalParameterValues,
- final Serializable[] collectionKeys
- ) {
- this(
- positionalParameterTypes,
- postionalParameterValues,
- null,
- collectionKeys
- );
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] postionalParameterValues,
- final Map namedParameters,
- final Serializable[] collectionKeys
- ) {
- this(
- positionalParameterTypes,
- postionalParameterValues,
- namedParameters,
- null,
- null,
- false,
- false,
- null,
- null,
- collectionKeys,
- null
- );
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] positionalParameterValues,
- final Map lockModes,
- final RowSelection rowSelection,
- final boolean cacheable,
- final String cacheRegion,
- //final boolean forceCacheRefresh,
- final String comment,
- final boolean isLookupByNaturalKey,
- final ResultTransformer transformer
- ) {
- this(
- positionalParameterTypes,
- positionalParameterValues,
- null,
- lockModes,
- rowSelection,
- false,
- cacheable,
- cacheRegion,
- comment,
- null,
- transformer
- );
- isNaturalKeyLookup = isLookupByNaturalKey;
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] positionalParameterValues,
- final Map namedParameters,
- final Map lockModes,
- final RowSelection rowSelection,
- final boolean readOnly,
- final boolean cacheable,
- final String cacheRegion,
- //final boolean forceCacheRefresh,
- final String comment,
- final Serializable[] collectionKeys,
- ResultTransformer transformer
- ) {
- this.positionalParameterTypes = positionalParameterTypes;
- this.positionalParameterValues = positionalParameterValues;
- this.namedParameters = namedParameters;
- this.lockModes = lockModes;
- this.rowSelection = rowSelection;
- this.cacheable = cacheable;
- this.cacheRegion = cacheRegion;
- //this.forceCacheRefresh = forceCacheRefresh;
- this.comment = comment;
- this.collectionKeys = collectionKeys;
- this.readOnly = readOnly;
- this.resultTransformer = transformer;
- }
-
- public QueryParameters(
- final Type[] positionalParameterTypes,
- final Object[] positionalParameterValues,
- final Map namedParameters,
- final Map lockModes,
- final RowSelection rowSelection,
- final boolean readOnly,
- final boolean cacheable,
- final String cacheRegion,
- //final boolean forceCacheRefresh,
- final String comment,
- final Serializable[] collectionKeys,
- final Object optionalObject,
- final String optionalEntityName,
- final Serializable optionalId,
- final ResultTransformer transformer
- ) {
- this(
- positionalParameterTypes,
- positionalParameterValues,
- namedParameters,
- lockModes,
- rowSelection,
- readOnly,
- cacheable,
- cacheRegion,
- comment,
- collectionKeys,
- transformer
- );
- this.optionalEntityName = optionalEntityName;
- this.optionalId = optionalId;
- this.optionalObject = optionalObject;
- }
-
- public boolean hasRowSelection() {
- return rowSelection!=null;
- }
-
- public Map getNamedParameters() {
- return namedParameters;
- }
-
- public Type[] getPositionalParameterTypes() {
- return positionalParameterTypes;
- }
-
- public Object[] getPositionalParameterValues() {
- return positionalParameterValues;
- }
-
- public RowSelection getRowSelection() {
- return rowSelection;
- }
-
- public ResultTransformer getResultTransformer() {
- return resultTransformer;
- }
-
- public void setNamedParameters(Map map) {
- namedParameters = map;
- }
-
- public void setPositionalParameterTypes(Type[] types) {
- positionalParameterTypes = types;
- }
-
- public void setPositionalParameterValues(Object[] objects) {
- positionalParameterValues = objects;
- }
-
- public void setRowSelection(RowSelection selection) {
- rowSelection = selection;
- }
-
- public Map getLockModes() {
- return lockModes;
- }
-
- public void setLockModes(Map map) {
- lockModes = map;
- }
-
- public void traceParameters(SessionFactoryImplementor factory) throws HibernateException {
- Printer print = new Printer(factory);
- if (positionalParameterValues.length!=0) {
- log.trace(
- "parameters: " +
- print.toString(positionalParameterTypes, positionalParameterValues)
- );
- }
- if (namedParameters!=null) {
- log.trace( "named parameters: " + print.toString(namedParameters) );
- }
- }
-
- public boolean isCacheable() {
- return cacheable;
- }
-
- public void setCacheable(boolean b) {
- cacheable = b;
- }
-
- public String getCacheRegion() {
- return cacheRegion;
- }
-
- public void setCacheRegion(String cacheRegion) {
- this.cacheRegion = cacheRegion;
- }
-
- public void validateParameters() throws QueryException {
- int types = positionalParameterTypes==null ? 0 : positionalParameterTypes.length;
- int values = positionalParameterValues==null ? 0 : positionalParameterValues.length;
- if (types!=values) {
- throw new QueryException(
- "Number of positional parameter types:" + types +
- " does not match number of positional parameters: " + values
- );
- }
- }
-
- public String getComment() {
- return comment;
- }
-
- public void setComment(String comment) {
- this.comment = comment;
- }
-
- public ScrollMode getScrollMode() {
- return scrollMode;
- }
-
- public void setScrollMode(ScrollMode scrollMode) {
- this.scrollMode = scrollMode;
- }
-
- public Serializable[] getCollectionKeys() {
- return collectionKeys;
- }
-
- public void setCollectionKeys(Serializable[] collectionKeys) {
- this.collectionKeys = collectionKeys;
- }
-
- public String getOptionalEntityName() {
- return optionalEntityName;
- }
-
- public void setOptionalEntityName(String optionalEntityName) {
- this.optionalEntityName = optionalEntityName;
- }
-
- public Serializable getOptionalId() {
- return optionalId;
- }
-
- public void setOptionalId(Serializable optionalId) {
- this.optionalId = optionalId;
- }
-
- public Object getOptionalObject() {
- return optionalObject;
- }
-
- public void setOptionalObject(Object optionalObject) {
- this.optionalObject = optionalObject;
- }
-
- public boolean isReadOnly() {
- return readOnly;
- }
-
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
-
- public void setCallable(boolean callable) {
- this.callable = callable;
- }
-
- public boolean isCallable() {
- return callable;
- }
-
- public boolean hasAutoDiscoverScalarTypes() {
- return autodiscovertypes;
- }
-
- public void processFilters(String sql, SessionImplementor session) {
-
- if ( session.getEnabledFilters().size()==0 || sql.indexOf(ParserHelper.HQL_VARIABLE_PREFIX)<0 ) {
- // HELLA IMPORTANT OPTIMIZATION!!!
- processedPositionalParameterValues = getPositionalParameterValues();
- processedPositionalParameterTypes = getPositionalParameterTypes();
- processedSQL = sql;
- }
- else {
-
- Dialect dialect = session.getFactory().getDialect();
- String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
- .append( dialect.openQuote() )
- .append( dialect.closeQuote() )
- .toString();
- StringTokenizer tokens = new StringTokenizer( sql, symbols, true );
- StringBuffer result = new StringBuffer();
-
- List parameters = new ArrayList();
- List parameterTypes = new ArrayList();
-
- while ( tokens.hasMoreTokens() ) {
- final String token = tokens.nextToken();
- if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
- String filterParameterName = token.substring( 1 );
- Object value = session.getFilterParameterValue( filterParameterName );
- Type type = session.getFilterParameterType( filterParameterName );
- if ( value != null && Collection.class.isAssignableFrom( value.getClass() ) ) {
- Iterator itr = ( ( Collection ) value ).iterator();
- while ( itr.hasNext() ) {
- Object elementValue = itr.next();
- result.append( '?' );
- parameters.add( elementValue );
- parameterTypes.add( type );
- if ( itr.hasNext() ) {
- result.append( ", " );
- }
- }
- }
- else {
- result.append( '?' );
- parameters.add( value );
- parameterTypes.add( type );
- }
- }
- else {
- result.append( token );
- }
- }
- parameters.addAll( Arrays.asList( getPositionalParameterValues() ) );
- parameterTypes.addAll( Arrays.asList( getPositionalParameterTypes() ) );
- processedPositionalParameterValues = parameters.toArray();
- processedPositionalParameterTypes = ( Type[] ) parameterTypes.toArray( new Type[0] );
- processedSQL = result.toString();
-
- }
- }
-
- public String getFilteredSQL() {
- return processedSQL;
- }
-
- public Object[] getFilteredPositionalParameterValues() {
- return processedPositionalParameterValues;
- }
-
- public Type[] getFilteredPositionalParameterTypes() {
- return processedPositionalParameterTypes;
- }
-
- public boolean isNaturalKeyLookup() {
- return isNaturalKeyLookup;
- }
-
- public void setNaturalKeyLookup(boolean isNaturalKeyLookup) {
- this.isNaturalKeyLookup = isNaturalKeyLookup;
- }
-
- public void setAutoDiscoverScalarTypes(boolean autodiscovertypes) {
- this.autodiscovertypes = autodiscovertypes;
- }
-
- public QueryParameters createCopyUsing(RowSelection selection) {
- QueryParameters copy = new QueryParameters(
- this.positionalParameterTypes,
- this.positionalParameterValues,
- this.namedParameters,
- this.lockModes,
- selection,
- this.readOnly,
- this.cacheable,
- this.cacheRegion,
- this.comment,
- this.collectionKeys,
- this.optionalObject,
- this.optionalEntityName,
- this.optionalId,
- this.resultTransformer
- );
- copy.processedSQL = this.processedSQL;
- copy.processedPositionalParameterTypes = this.processedPositionalParameterTypes;
- copy.processedPositionalParameterValues = this.processedPositionalParameterValues;
- return copy;
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/QueryParameters.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/QueryParameters.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,505 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.HibernateException;
+import org.hibernate.QueryException;
+import org.hibernate.ScrollMode;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.hql.classic.ParserHelper;
+import org.hibernate.pretty.Printer;
+import org.hibernate.transform.ResultTransformer;
+import org.hibernate.type.Type;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * @author Gavin King
+ */
+public final class QueryParameters {
+ private static final Logger log = LoggerFactory.getLogger(QueryParameters.class);
+
+ private Type[] positionalParameterTypes;
+ private Object[] positionalParameterValues;
+ private Map namedParameters;
+ private Map lockModes;
+ private RowSelection rowSelection;
+ private boolean cacheable;
+ private String cacheRegion;
+ private String comment;
+ private ScrollMode scrollMode;
+ private Serializable[] collectionKeys;
+ private Object optionalObject;
+ private String optionalEntityName;
+ private Serializable optionalId;
+ private boolean readOnly;
+ private boolean callable = false;
+ private boolean autodiscovertypes = false;
+ private boolean isNaturalKeyLookup;
+
+ private final ResultTransformer resultTransformer; // why is all others non final ?
+
+ private String processedSQL;
+ private Type[] processedPositionalParameterTypes;
+ private Object[] processedPositionalParameterValues;
+
+ public QueryParameters() {
+ this( ArrayHelper.EMPTY_TYPE_ARRAY, ArrayHelper.EMPTY_OBJECT_ARRAY );
+ }
+
+ public QueryParameters(Type type, Object value) {
+ this( new Type[] {type}, new Object[] {value} );
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] postionalParameterValues,
+ final Object optionalObject,
+ final String optionalEntityName,
+ final Serializable optionalObjectId
+ ) {
+ this(positionalParameterTypes, postionalParameterValues);
+ this.optionalObject = optionalObject;
+ this.optionalId = optionalObjectId;
+ this.optionalEntityName = optionalEntityName;
+
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] postionalParameterValues
+ ) {
+ this(
+ positionalParameterTypes,
+ postionalParameterValues,
+ null,
+ null,
+ false,
+ null,
+ null,
+ false,
+ null
+ );
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] postionalParameterValues,
+ final Serializable[] collectionKeys
+ ) {
+ this(
+ positionalParameterTypes,
+ postionalParameterValues,
+ null,
+ collectionKeys
+ );
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] postionalParameterValues,
+ final Map namedParameters,
+ final Serializable[] collectionKeys
+ ) {
+ this(
+ positionalParameterTypes,
+ postionalParameterValues,
+ namedParameters,
+ null,
+ null,
+ false,
+ false,
+ null,
+ null,
+ collectionKeys,
+ null
+ );
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] positionalParameterValues,
+ final Map lockModes,
+ final RowSelection rowSelection,
+ final boolean cacheable,
+ final String cacheRegion,
+ //final boolean forceCacheRefresh,
+ final String comment,
+ final boolean isLookupByNaturalKey,
+ final ResultTransformer transformer
+ ) {
+ this(
+ positionalParameterTypes,
+ positionalParameterValues,
+ null,
+ lockModes,
+ rowSelection,
+ false,
+ cacheable,
+ cacheRegion,
+ comment,
+ null,
+ transformer
+ );
+ isNaturalKeyLookup = isLookupByNaturalKey;
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] positionalParameterValues,
+ final Map namedParameters,
+ final Map lockModes,
+ final RowSelection rowSelection,
+ final boolean readOnly,
+ final boolean cacheable,
+ final String cacheRegion,
+ //final boolean forceCacheRefresh,
+ final String comment,
+ final Serializable[] collectionKeys,
+ ResultTransformer transformer
+ ) {
+ this.positionalParameterTypes = positionalParameterTypes;
+ this.positionalParameterValues = positionalParameterValues;
+ this.namedParameters = namedParameters;
+ this.lockModes = lockModes;
+ this.rowSelection = rowSelection;
+ this.cacheable = cacheable;
+ this.cacheRegion = cacheRegion;
+ //this.forceCacheRefresh = forceCacheRefresh;
+ this.comment = comment;
+ this.collectionKeys = collectionKeys;
+ this.readOnly = readOnly;
+ this.resultTransformer = transformer;
+ }
+
+ public QueryParameters(
+ final Type[] positionalParameterTypes,
+ final Object[] positionalParameterValues,
+ final Map namedParameters,
+ final Map lockModes,
+ final RowSelection rowSelection,
+ final boolean readOnly,
+ final boolean cacheable,
+ final String cacheRegion,
+ //final boolean forceCacheRefresh,
+ final String comment,
+ final Serializable[] collectionKeys,
+ final Object optionalObject,
+ final String optionalEntityName,
+ final Serializable optionalId,
+ final ResultTransformer transformer
+ ) {
+ this(
+ positionalParameterTypes,
+ positionalParameterValues,
+ namedParameters,
+ lockModes,
+ rowSelection,
+ readOnly,
+ cacheable,
+ cacheRegion,
+ comment,
+ collectionKeys,
+ transformer
+ );
+ this.optionalEntityName = optionalEntityName;
+ this.optionalId = optionalId;
+ this.optionalObject = optionalObject;
+ }
+
+ public boolean hasRowSelection() {
+ return rowSelection!=null;
+ }
+
+ public Map getNamedParameters() {
+ return namedParameters;
+ }
+
+ public Type[] getPositionalParameterTypes() {
+ return positionalParameterTypes;
+ }
+
+ public Object[] getPositionalParameterValues() {
+ return positionalParameterValues;
+ }
+
+ public RowSelection getRowSelection() {
+ return rowSelection;
+ }
+
+ public ResultTransformer getResultTransformer() {
+ return resultTransformer;
+ }
+
+ public void setNamedParameters(Map map) {
+ namedParameters = map;
+ }
+
+ public void setPositionalParameterTypes(Type[] types) {
+ positionalParameterTypes = types;
+ }
+
+ public void setPositionalParameterValues(Object[] objects) {
+ positionalParameterValues = objects;
+ }
+
+ public void setRowSelection(RowSelection selection) {
+ rowSelection = selection;
+ }
+
+ public Map getLockModes() {
+ return lockModes;
+ }
+
+ public void setLockModes(Map map) {
+ lockModes = map;
+ }
+
+ public void traceParameters(SessionFactoryImplementor factory) throws HibernateException {
+ Printer print = new Printer(factory);
+ if (positionalParameterValues.length!=0) {
+ log.trace(
+ "parameters: " +
+ print.toString(positionalParameterTypes, positionalParameterValues)
+ );
+ }
+ if (namedParameters!=null) {
+ log.trace( "named parameters: " + print.toString(namedParameters) );
+ }
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean b) {
+ cacheable = b;
+ }
+
+ public String getCacheRegion() {
+ return cacheRegion;
+ }
+
+ public void setCacheRegion(String cacheRegion) {
+ this.cacheRegion = cacheRegion;
+ }
+
+ public void validateParameters() throws QueryException {
+ int types = positionalParameterTypes==null ? 0 : positionalParameterTypes.length;
+ int values = positionalParameterValues==null ? 0 : positionalParameterValues.length;
+ if (types!=values) {
+ throw new QueryException(
+ "Number of positional parameter types:" + types +
+ " does not match number of positional parameters: " + values
+ );
+ }
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public ScrollMode getScrollMode() {
+ return scrollMode;
+ }
+
+ public void setScrollMode(ScrollMode scrollMode) {
+ this.scrollMode = scrollMode;
+ }
+
+ public Serializable[] getCollectionKeys() {
+ return collectionKeys;
+ }
+
+ public void setCollectionKeys(Serializable[] collectionKeys) {
+ this.collectionKeys = collectionKeys;
+ }
+
+ public String getOptionalEntityName() {
+ return optionalEntityName;
+ }
+
+ public void setOptionalEntityName(String optionalEntityName) {
+ this.optionalEntityName = optionalEntityName;
+ }
+
+ public Serializable getOptionalId() {
+ return optionalId;
+ }
+
+ public void setOptionalId(Serializable optionalId) {
+ this.optionalId = optionalId;
+ }
+
+ public Object getOptionalObject() {
+ return optionalObject;
+ }
+
+ public void setOptionalObject(Object optionalObject) {
+ this.optionalObject = optionalObject;
+ }
+
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public void setCallable(boolean callable) {
+ this.callable = callable;
+ }
+
+ public boolean isCallable() {
+ return callable;
+ }
+
+ public boolean hasAutoDiscoverScalarTypes() {
+ return autodiscovertypes;
+ }
+
+ public void processFilters(String sql, SessionImplementor session) {
+
+ if ( session.getEnabledFilters().size()==0 || sql.indexOf(ParserHelper.HQL_VARIABLE_PREFIX)<0 ) {
+ // HELLA IMPORTANT OPTIMIZATION!!!
+ processedPositionalParameterValues = getPositionalParameterValues();
+ processedPositionalParameterTypes = getPositionalParameterTypes();
+ processedSQL = sql;
+ }
+ else {
+
+ Dialect dialect = session.getFactory().getDialect();
+ String symbols = new StringBuffer().append( ParserHelper.HQL_SEPARATORS )
+ .append( dialect.openQuote() )
+ .append( dialect.closeQuote() )
+ .toString();
+ StringTokenizer tokens = new StringTokenizer( sql, symbols, true );
+ StringBuffer result = new StringBuffer();
+
+ List parameters = new ArrayList();
+ List parameterTypes = new ArrayList();
+
+ while ( tokens.hasMoreTokens() ) {
+ final String token = tokens.nextToken();
+ if ( token.startsWith( ParserHelper.HQL_VARIABLE_PREFIX ) ) {
+ String filterParameterName = token.substring( 1 );
+ Object value = session.getFilterParameterValue( filterParameterName );
+ Type type = session.getFilterParameterType( filterParameterName );
+ if ( value != null && Collection.class.isAssignableFrom( value.getClass() ) ) {
+ Iterator itr = ( ( Collection ) value ).iterator();
+ while ( itr.hasNext() ) {
+ Object elementValue = itr.next();
+ result.append( '?' );
+ parameters.add( elementValue );
+ parameterTypes.add( type );
+ if ( itr.hasNext() ) {
+ result.append( ", " );
+ }
+ }
+ }
+ else {
+ result.append( '?' );
+ parameters.add( value );
+ parameterTypes.add( type );
+ }
+ }
+ else {
+ result.append( token );
+ }
+ }
+ parameters.addAll( Arrays.asList( getPositionalParameterValues() ) );
+ parameterTypes.addAll( Arrays.asList( getPositionalParameterTypes() ) );
+ processedPositionalParameterValues = parameters.toArray();
+ processedPositionalParameterTypes = ( Type[] ) parameterTypes.toArray( new Type[0] );
+ processedSQL = result.toString();
+
+ }
+ }
+
+ public String getFilteredSQL() {
+ return processedSQL;
+ }
+
+ public Object[] getFilteredPositionalParameterValues() {
+ return processedPositionalParameterValues;
+ }
+
+ public Type[] getFilteredPositionalParameterTypes() {
+ return processedPositionalParameterTypes;
+ }
+
+ public boolean isNaturalKeyLookup() {
+ return isNaturalKeyLookup;
+ }
+
+ public void setNaturalKeyLookup(boolean isNaturalKeyLookup) {
+ this.isNaturalKeyLookup = isNaturalKeyLookup;
+ }
+
+ public void setAutoDiscoverScalarTypes(boolean autodiscovertypes) {
+ this.autodiscovertypes = autodiscovertypes;
+ }
+
+ public QueryParameters createCopyUsing(RowSelection selection) {
+ QueryParameters copy = new QueryParameters(
+ this.positionalParameterTypes,
+ this.positionalParameterValues,
+ this.namedParameters,
+ this.lockModes,
+ selection,
+ this.readOnly,
+ this.cacheable,
+ this.cacheRegion,
+ this.comment,
+ this.collectionKeys,
+ this.optionalObject,
+ this.optionalEntityName,
+ this.optionalId,
+ this.resultTransformer
+ );
+ copy.processedSQL = this.processedSQL;
+ copy.processedPositionalParameterTypes = this.processedPositionalParameterTypes;
+ copy.processedPositionalParameterValues = this.processedPositionalParameterValues;
+ return copy;
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,46 +0,0 @@
-//$Id: ResultSetMappingDefinition.java 10018 2006-06-15 05:21:06Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.io.Serializable;
-
-import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
-
-/**
- * Keep a description of the resultset mapping
- *
- * @author Emmanuel Bernard
- */
-public class ResultSetMappingDefinition implements Serializable {
-
- private final String name;
- private final List /*NativeSQLQueryReturn*/ queryReturns = new ArrayList();
-
- public ResultSetMappingDefinition(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void addQueryReturn(NativeSQLQueryReturn queryReturn) {
- queryReturns.add( queryReturn );
- }
-
-// We could also keep these if needed for binary compatibility with annotations, provided
-// it only uses the addXXX() methods...
-// public void addEntityQueryReturn(NativeSQLQueryNonScalarReturn entityQueryReturn) {
-// entityQueryReturns.add(entityQueryReturn);
-// }
-//
-// public void addScalarQueryReturn(NativeSQLQueryScalarReturn scalarQueryReturn) {
-// scalarQueryReturns.add(scalarQueryReturn);
-// }
-
- public NativeSQLQueryReturn[] getQueryReturns() {
- return ( NativeSQLQueryReturn[] ) queryReturns.toArray( new NativeSQLQueryReturn[0] );
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ResultSetMappingDefinition.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.Serializable;
+
+import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
+
+/**
+ * Keep a description of the resultset mapping
+ *
+ * @author Emmanuel Bernard
+ */
+public class ResultSetMappingDefinition implements Serializable {
+
+ private final String name;
+ private final List /*NativeSQLQueryReturn*/ queryReturns = new ArrayList();
+
+ public ResultSetMappingDefinition(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void addQueryReturn(NativeSQLQueryReturn queryReturn) {
+ queryReturns.add( queryReturn );
+ }
+
+// We could also keep these if needed for binary compatibility with annotations, provided
+// it only uses the addXXX() methods...
+// public void addEntityQueryReturn(NativeSQLQueryNonScalarReturn entityQueryReturn) {
+// entityQueryReturns.add(entityQueryReturn);
+// }
+//
+// public void addScalarQueryReturn(NativeSQLQueryScalarReturn scalarQueryReturn) {
+// scalarQueryReturns.add(scalarQueryReturn);
+// }
+
+ public NativeSQLQueryReturn[] getQueryReturns() {
+ return ( NativeSQLQueryReturn[] ) queryReturns.toArray( new NativeSQLQueryReturn[0] );
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/RowSelection.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,50 +0,0 @@
-//$Id: RowSelection.java 9299 2006-02-16 22:51:00Z steveebersole $
-package org.hibernate.engine;
-
-/**
- * Represents a selection of rows in a JDBC <tt>ResultSet</tt>
- * @author Gavin King
- */
-public final class RowSelection {
- private Integer firstRow;
- private Integer maxRows;
- private Integer timeout;
- private Integer fetchSize;
-
- public void setFirstRow(Integer firstRow) {
- this.firstRow = firstRow;
- }
-
- public Integer getFirstRow() {
- return firstRow;
- }
-
- public void setMaxRows(Integer maxRows) {
- this.maxRows = maxRows;
- }
-
- public Integer getMaxRows() {
- return maxRows;
- }
-
- public void setTimeout(Integer timeout) {
- this.timeout = timeout;
- }
-
- public Integer getTimeout() {
- return timeout;
- }
-
- public Integer getFetchSize() {
- return fetchSize;
- }
-
- public void setFetchSize(Integer fetchSize) {
- this.fetchSize = fetchSize;
- }
-
- public boolean definesLimits() {
- return maxRows != null ||
- ( firstRow != null && firstRow.intValue() <= 0 );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/RowSelection.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/RowSelection.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,73 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+/**
+ * Represents a selection of rows in a JDBC <tt>ResultSet</tt>
+ * @author Gavin King
+ */
+public final class RowSelection {
+ private Integer firstRow;
+ private Integer maxRows;
+ private Integer timeout;
+ private Integer fetchSize;
+
+ public void setFirstRow(Integer firstRow) {
+ this.firstRow = firstRow;
+ }
+
+ public Integer getFirstRow() {
+ return firstRow;
+ }
+
+ public void setMaxRows(Integer maxRows) {
+ this.maxRows = maxRows;
+ }
+
+ public Integer getMaxRows() {
+ return maxRows;
+ }
+
+ public void setTimeout(Integer timeout) {
+ this.timeout = timeout;
+ }
+
+ public Integer getTimeout() {
+ return timeout;
+ }
+
+ public Integer getFetchSize() {
+ return fetchSize;
+ }
+
+ public void setFetchSize(Integer fetchSize) {
+ this.fetchSize = fetchSize;
+ }
+
+ public boolean definesLimits() {
+ return maxRows != null ||
+ ( firstRow != null && firstRow.intValue() <= 0 );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,200 +0,0 @@
-//$Id: SessionFactoryImplementor.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.util.Map;
-import java.util.Set;
-import java.sql.Connection;
-
-import javax.transaction.TransactionManager;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.MappingException;
-import org.hibernate.SessionFactory;
-import org.hibernate.ConnectionReleaseMode;
-import org.hibernate.proxy.EntityNotFoundDelegate;
-import org.hibernate.engine.query.QueryPlanCache;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.cache.QueryCache;
-import org.hibernate.cache.UpdateTimestampsCache;
-import org.hibernate.cache.Region;
-import org.hibernate.cfg.Settings;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.function.SQLFunctionRegistry;
-import org.hibernate.exception.SQLExceptionConverter;
-import org.hibernate.id.IdentifierGenerator;
-import org.hibernate.stat.StatisticsImplementor;
-import org.hibernate.type.Type;
-
-/**
- * Defines the internal contract between the <tt>SessionFactory</tt> and other parts of
- * Hibernate such as implementors of <tt>Type</tt>.
- *
- * @see org.hibernate.SessionFactory
- * @see org.hibernate.impl.SessionFactoryImpl
- * @author Gavin King
- */
-public interface SessionFactoryImplementor extends Mapping, SessionFactory {
-
- /**
- * Get the persister for the named entity
- *
- * @param entityName The name of the entity for which to retrieve the persister.
- * @return The persister
- * @throws MappingException Indicates persister could not be found with that name.
- */
- public EntityPersister getEntityPersister(String entityName) throws MappingException;
-
- /**
- * Get the persister object for a collection role.
- *
- * @param role The role (name) of the collection for which to retrieve the
- * persister.
- * @return The persister
- * @throws MappingException Indicates persister could not be found with that role.
- */
- public CollectionPersister getCollectionPersister(String role) throws MappingException;
-
- /**
- * Get the SQL dialect.
- * <p/>
- * Shorthand for {@link #getSettings()}.{@link Settings#getDialect()}
- *
- * @return The dialect
- */
- public Dialect getDialect();
-
- /**
- * Get the factory scoped interceptor for this factory.
- *
- * @return The factory scope interceptor, or null if none.
- */
- public Interceptor getInterceptor();
-
- public QueryPlanCache getQueryPlanCache();
-
- /**
- * Get the return types of a query
- */
- public Type[] getReturnTypes(String queryString) throws HibernateException;
-
- /**
- * Get the return aliases of a query
- */
- public String[] getReturnAliases(String queryString) throws HibernateException;
-
- /**
- * Get the connection provider
- */
- public ConnectionProvider getConnectionProvider();
- /**
- * Get the names of all persistent classes that implement/extend the given interface/class
- */
- public String[] getImplementors(String className) throws MappingException;
- /**
- * Get a class name, using query language imports
- */
- public String getImportedClassName(String name);
-
-
- /**
- * Get the JTA transaction manager
- */
- public TransactionManager getTransactionManager();
-
-
- /**
- * Get the default query cache
- */
- public QueryCache getQueryCache();
- /**
- * Get a particular named query cache, or the default cache
- * @param regionName the name of the cache region, or null for the default query cache
- * @return the existing cache, or a newly created cache if none by that region name
- */
- public QueryCache getQueryCache(String regionName) throws HibernateException;
-
- /**
- * Get the cache of table update timestamps
- */
- public UpdateTimestampsCache getUpdateTimestampsCache();
- /**
- * Statistics SPI
- */
- public StatisticsImplementor getStatisticsImplementor();
-
- public NamedQueryDefinition getNamedQuery(String queryName);
- public NamedSQLQueryDefinition getNamedSQLQuery(String queryName);
- public ResultSetMappingDefinition getResultSetMapping(String name);
-
- /**
- * Get the identifier generator for the hierarchy
- */
- public IdentifierGenerator getIdentifierGenerator(String rootEntityName);
-
- /**
- * Get a named second-level cache region
- *
- * @param regionName The name of the region to retrieve.
- * @return The region
- */
- public Region getSecondLevelCacheRegion(String regionName);
-
- /**
- * Get a map of all the second level cache regions currently maintained in
- * this session factory. The map is structured with the region name as the
- * key and the {@link Region} instances as the values.
- *
- * @return The map of regions
- */
- public Map getAllSecondLevelCacheRegions();
-
- /**
- * Retrieves the SQLExceptionConverter in effect for this SessionFactory.
- *
- * @return The SQLExceptionConverter for this SessionFactory.
- */
- public SQLExceptionConverter getSQLExceptionConverter();
-
- public Settings getSettings();
-
- /**
- * Get a nontransactional "current" session for Hibernate EntityManager
- */
- public org.hibernate.classic.Session openTemporarySession() throws HibernateException;
-
- /**
- * Open a session conforming to the given parameters. Used mainly by
- * {@link org.hibernate.context.JTASessionContext} for current session processing.
- *
- * @param connection The external jdbc connection to use, if one (i.e., optional).
- * @param flushBeforeCompletionEnabled Should the session be auto-flushed
- * prior to transaction completion?
- * @param autoCloseSessionEnabled Should the session be auto-closed after
- * transaction completion?
- * @param connectionReleaseMode The release mode for managed jdbc connections.
- * @return An appropriate session.
- * @throws HibernateException
- */
- public org.hibernate.classic.Session openSession(
- final Connection connection,
- final boolean flushBeforeCompletionEnabled,
- final boolean autoCloseSessionEnabled,
- final ConnectionReleaseMode connectionReleaseMode) throws HibernateException;
-
- /**
- * Retrieves a set of all the collection roles in which the given entity
- * is a participant, as either an index or an element.
- *
- * @param entityName The entity name for which to get the collection roles.
- * @return set of all the collection roles in which the given entityName participates.
- */
- public Set getCollectionRolesByEntityParticipant(String entityName);
-
- public EntityNotFoundDelegate getEntityNotFoundDelegate();
-
- public SQLFunctionRegistry getSqlFunctionRegistry();
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionFactoryImplementor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,223 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.Map;
+import java.util.Set;
+import java.sql.Connection;
+
+import javax.transaction.TransactionManager;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.MappingException;
+import org.hibernate.SessionFactory;
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.proxy.EntityNotFoundDelegate;
+import org.hibernate.engine.query.QueryPlanCache;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.cache.QueryCache;
+import org.hibernate.cache.UpdateTimestampsCache;
+import org.hibernate.cache.Region;
+import org.hibernate.cfg.Settings;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.function.SQLFunctionRegistry;
+import org.hibernate.exception.SQLExceptionConverter;
+import org.hibernate.id.IdentifierGenerator;
+import org.hibernate.stat.StatisticsImplementor;
+import org.hibernate.type.Type;
+
+/**
+ * Defines the internal contract between the <tt>SessionFactory</tt> and other parts of
+ * Hibernate such as implementors of <tt>Type</tt>.
+ *
+ * @see org.hibernate.SessionFactory
+ * @see org.hibernate.impl.SessionFactoryImpl
+ * @author Gavin King
+ */
+public interface SessionFactoryImplementor extends Mapping, SessionFactory {
+
+ /**
+ * Get the persister for the named entity
+ *
+ * @param entityName The name of the entity for which to retrieve the persister.
+ * @return The persister
+ * @throws MappingException Indicates persister could not be found with that name.
+ */
+ public EntityPersister getEntityPersister(String entityName) throws MappingException;
+
+ /**
+ * Get the persister object for a collection role.
+ *
+ * @param role The role (name) of the collection for which to retrieve the
+ * persister.
+ * @return The persister
+ * @throws MappingException Indicates persister could not be found with that role.
+ */
+ public CollectionPersister getCollectionPersister(String role) throws MappingException;
+
+ /**
+ * Get the SQL dialect.
+ * <p/>
+ * Shorthand for {@link #getSettings()}.{@link Settings#getDialect()}
+ *
+ * @return The dialect
+ */
+ public Dialect getDialect();
+
+ /**
+ * Get the factory scoped interceptor for this factory.
+ *
+ * @return The factory scope interceptor, or null if none.
+ */
+ public Interceptor getInterceptor();
+
+ public QueryPlanCache getQueryPlanCache();
+
+ /**
+ * Get the return types of a query
+ */
+ public Type[] getReturnTypes(String queryString) throws HibernateException;
+
+ /**
+ * Get the return aliases of a query
+ */
+ public String[] getReturnAliases(String queryString) throws HibernateException;
+
+ /**
+ * Get the connection provider
+ */
+ public ConnectionProvider getConnectionProvider();
+ /**
+ * Get the names of all persistent classes that implement/extend the given interface/class
+ */
+ public String[] getImplementors(String className) throws MappingException;
+ /**
+ * Get a class name, using query language imports
+ */
+ public String getImportedClassName(String name);
+
+
+ /**
+ * Get the JTA transaction manager
+ */
+ public TransactionManager getTransactionManager();
+
+
+ /**
+ * Get the default query cache
+ */
+ public QueryCache getQueryCache();
+ /**
+ * Get a particular named query cache, or the default cache
+ * @param regionName the name of the cache region, or null for the default query cache
+ * @return the existing cache, or a newly created cache if none by that region name
+ */
+ public QueryCache getQueryCache(String regionName) throws HibernateException;
+
+ /**
+ * Get the cache of table update timestamps
+ */
+ public UpdateTimestampsCache getUpdateTimestampsCache();
+ /**
+ * Statistics SPI
+ */
+ public StatisticsImplementor getStatisticsImplementor();
+
+ public NamedQueryDefinition getNamedQuery(String queryName);
+ public NamedSQLQueryDefinition getNamedSQLQuery(String queryName);
+ public ResultSetMappingDefinition getResultSetMapping(String name);
+
+ /**
+ * Get the identifier generator for the hierarchy
+ */
+ public IdentifierGenerator getIdentifierGenerator(String rootEntityName);
+
+ /**
+ * Get a named second-level cache region
+ *
+ * @param regionName The name of the region to retrieve.
+ * @return The region
+ */
+ public Region getSecondLevelCacheRegion(String regionName);
+
+ /**
+ * Get a map of all the second level cache regions currently maintained in
+ * this session factory. The map is structured with the region name as the
+ * key and the {@link Region} instances as the values.
+ *
+ * @return The map of regions
+ */
+ public Map getAllSecondLevelCacheRegions();
+
+ /**
+ * Retrieves the SQLExceptionConverter in effect for this SessionFactory.
+ *
+ * @return The SQLExceptionConverter for this SessionFactory.
+ */
+ public SQLExceptionConverter getSQLExceptionConverter();
+
+ public Settings getSettings();
+
+ /**
+ * Get a nontransactional "current" session for Hibernate EntityManager
+ */
+ public org.hibernate.classic.Session openTemporarySession() throws HibernateException;
+
+ /**
+ * Open a session conforming to the given parameters. Used mainly by
+ * {@link org.hibernate.context.JTASessionContext} for current session processing.
+ *
+ * @param connection The external jdbc connection to use, if one (i.e., optional).
+ * @param flushBeforeCompletionEnabled Should the session be auto-flushed
+ * prior to transaction completion?
+ * @param autoCloseSessionEnabled Should the session be auto-closed after
+ * transaction completion?
+ * @param connectionReleaseMode The release mode for managed jdbc connections.
+ * @return An appropriate session.
+ * @throws HibernateException
+ */
+ public org.hibernate.classic.Session openSession(
+ final Connection connection,
+ final boolean flushBeforeCompletionEnabled,
+ final boolean autoCloseSessionEnabled,
+ final ConnectionReleaseMode connectionReleaseMode) throws HibernateException;
+
+ /**
+ * Retrieves a set of all the collection roles in which the given entity
+ * is a participant, as either an index or an element.
+ *
+ * @param entityName The entity name for which to get the collection roles.
+ * @return set of all the collection roles in which the given entityName participates.
+ */
+ public Set getCollectionRolesByEntityParticipant(String entityName);
+
+ public EntityNotFoundDelegate getEntityNotFoundDelegate();
+
+ public SQLFunctionRegistry getSqlFunctionRegistry();
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/SessionImplementor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,302 +0,0 @@
-//$Id: SessionImplementor.java 10018 2006-06-15 05:21:06Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.hibernate.CacheMode;
-import org.hibernate.EntityMode;
-import org.hibernate.FlushMode;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.Query;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
-import org.hibernate.Transaction;
-import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.event.EventListeners;
-import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.jdbc.Batcher;
-import org.hibernate.jdbc.JDBCContext;
-import org.hibernate.loader.custom.CustomQuery;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.Type;
-
-
-/**
- * Defines the internal contract between the <tt>Session</tt> and other parts of
- * Hibernate such as implementors of <tt>Type</tt> or <tt>EntityPersister</tt>.
- *
- * @see org.hibernate.Session the interface to the application
- * @see org.hibernate.impl.SessionImpl the actual implementation
- * @author Gavin King
- */
-public interface SessionImplementor extends Serializable {
-
- /**
- * Retrieves the interceptor currently in use by this event source.
- *
- * @return The interceptor.
- */
- public Interceptor getInterceptor();
-
- /**
- * Enable/disable automatic cache clearing from after transaction
- * completion (for EJB3)
- */
- public void setAutoClear(boolean enabled);
-
- /**
- * Does this <tt>Session</tt> have an active Hibernate transaction
- * or is there a JTA transaction in progress?
- */
- public boolean isTransactionInProgress();
-
- /**
- * Initialize the collection (if not already initialized)
- */
- public void initializeCollection(PersistentCollection collection, boolean writing)
- throws HibernateException;
-
- /**
- * Load an instance without checking if it was deleted.
- *
- * When <tt>nullable</tt> is disabled this method may create a new proxy or
- * return an existing proxy; if it does not exist, throw an exception.
- *
- * When <tt>nullable</tt> is enabled, the method does not create new proxies
- * (but might return an existing proxy); if it does not exist, return
- * <tt>null</tt>.
- *
- * When <tt>eager</tt> is enabled, the object is eagerly fetched
- */
- public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)
- throws HibernateException;
-
- /**
- * Load an instance immediately. This method is only called when lazily initializing a proxy.
- * Do not return the proxy.
- */
- public Object immediateLoad(String entityName, Serializable id) throws HibernateException;
-
- /**
- * System time before the start of the transaction
- */
- public long getTimestamp();
- /**
- * Get the creating <tt>SessionFactoryImplementor</tt>
- */
- public SessionFactoryImplementor getFactory();
- /**
- * Get the prepared statement <tt>Batcher</tt> for this session
- */
- public Batcher getBatcher();
-
- /**
- * Execute a <tt>find()</tt> query
- */
- public List list(String query, QueryParameters queryParameters) throws HibernateException;
- /**
- * Execute an <tt>iterate()</tt> query
- */
- public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException;
- /**
- * Execute a <tt>scroll()</tt> query
- */
- public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException;
- /**
- * Execute a criteria query
- */
- public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode);
- /**
- * Execute a criteria query
- */
- public List list(CriteriaImpl criteria);
-
- /**
- * Execute a filter
- */
- public List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException;
- /**
- * Iterate a filter
- */
- public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException;
-
- /**
- * Get the <tt>EntityPersister</tt> for any instance
- * @param entityName optional entity name
- * @param object the entity instance
- */
- public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException;
-
- /**
- * Get the entity instance associated with the given <tt>Key</tt>,
- * calling the Interceptor if necessary
- */
- public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException;
-
- /**
- * Notify the session that the transaction completed, so we no longer
- * own the old locks. (Also we should release cache softlocks.) May
- * be called multiple times during the transaction completion process.
- * Also called after an autocommit, in which case the second argument
- * is null.
- */
- public void afterTransactionCompletion(boolean successful, Transaction tx);
-
- /**
- * Notify the session that the transaction is about to complete
- */
- public void beforeTransactionCompletion(Transaction tx);
-
- /**
- * Return the identifier of the persistent object, or null if
- * not associated with the session
- */
- public Serializable getContextEntityIdentifier(Object object);
-
- /**
- * The best guess entity name for an entity not in an association
- */
- public String bestGuessEntityName(Object object);
-
- /**
- * The guessed entity name for an entity not in an association
- */
- public String guessEntityName(Object entity) throws HibernateException;
-
- /**
- * Instantiate the entity class, initializing with the given identifier
- */
- public Object instantiate(String entityName, Serializable id) throws HibernateException;
-
- /**
- * Execute an SQL Query
- */
- public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
- throws HibernateException;
-
- /**
- * Execute an SQL Query
- */
- public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
- throws HibernateException;
-
- /**
- * Execute a native SQL query, and return the results as a fully built list.
- *
- * @param spec The specification of the native SQL query to execute.
- * @param queryParameters The parameters by which to perform the execution.
- * @return The result list.
- * @throws HibernateException
- */
- public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
- throws HibernateException;
-
- /**
- * Execute a native SQL query, and return the results as a scrollable result.
- *
- * @param spec The specification of the native SQL query to execute.
- * @param queryParameters The parameters by which to perform the execution.
- * @return The resulting scrollable result.
- * @throws HibernateException
- */
- public ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
- throws HibernateException;
-
- /**
- * Retreive the currently set value for a filter parameter.
- *
- * @param filterParameterName The filter parameter name in the format
- * {FILTER_NAME.PARAMETER_NAME}.
- * @return The filter parameter value.
- */
- public Object getFilterParameterValue(String filterParameterName);
-
- /**
- * Retreive the type for a given filter parrameter.
- *
- * @param filterParameterName The filter parameter name in the format
- * {FILTER_NAME.PARAMETER_NAME}.
- */
- public Type getFilterParameterType(String filterParameterName);
-
- /**
- * Return the currently enabled filters. The filter map is keyed by filter
- * name, with values corresponding to the {@link org.hibernate.impl.FilterImpl}
- * instance.
- * @return The currently enabled filters.
- */
- public Map getEnabledFilters();
-
- public int getDontFlushFromFind();
-
- /**
- * Retrieves the configured event listeners from this event source.
- *
- * @return The configured event listeners.
- */
- public EventListeners getListeners();
-
- //TODO: temporary
-
- /**
- * Get the persistence context for this session
- */
- public PersistenceContext getPersistenceContext();
-
- /**
- * Execute a HQL update or delete query
- */
- int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException;
-
- /**
- * Execute a native SQL update or delete query
- */
- int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException;
-
- // copied from Session:
-
- public EntityMode getEntityMode();
- public CacheMode getCacheMode();
- public void setCacheMode(CacheMode cm);
- public boolean isOpen();
- public boolean isConnected();
- public FlushMode getFlushMode();
- public void setFlushMode(FlushMode fm);
- public Connection connection();
- public void flush();
-
- /**
- * Get a Query instance for a named query or named native SQL query
- */
- public Query getNamedQuery(String name);
- /**
- * Get a Query instance for a named native SQL query
- */
- public Query getNamedSQLQuery(String name);
-
- public boolean isEventSource();
-
- public void afterScrollOperation();
-
- public void setFetchProfile(String name);
-
- public String getFetchProfile();
-
- public JDBCContext getJDBCContext();
-
- /**
- * Determine whether the session is closed. Provided seperately from
- * {@link #isOpen()} as this method does not attempt any JTA synch
- * registration, where as {@link #isOpen()} does; which makes this one
- * nicer to use for most internal purposes.
- *
- * @return True if the session is closed; false otherwise.
- */
- public boolean isClosed();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/SessionImplementor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SessionImplementor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,325 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.CacheMode;
+import org.hibernate.EntityMode;
+import org.hibernate.FlushMode;
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.Query;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Transaction;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.event.EventListeners;
+import org.hibernate.impl.CriteriaImpl;
+import org.hibernate.jdbc.Batcher;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.loader.custom.CustomQuery;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.Type;
+
+
+/**
+ * Defines the internal contract between the <tt>Session</tt> and other parts of
+ * Hibernate such as implementors of <tt>Type</tt> or <tt>EntityPersister</tt>.
+ *
+ * @see org.hibernate.Session the interface to the application
+ * @see org.hibernate.impl.SessionImpl the actual implementation
+ * @author Gavin King
+ */
+public interface SessionImplementor extends Serializable {
+
+ /**
+ * Retrieves the interceptor currently in use by this event source.
+ *
+ * @return The interceptor.
+ */
+ public Interceptor getInterceptor();
+
+ /**
+ * Enable/disable automatic cache clearing from after transaction
+ * completion (for EJB3)
+ */
+ public void setAutoClear(boolean enabled);
+
+ /**
+ * Does this <tt>Session</tt> have an active Hibernate transaction
+ * or is there a JTA transaction in progress?
+ */
+ public boolean isTransactionInProgress();
+
+ /**
+ * Initialize the collection (if not already initialized)
+ */
+ public void initializeCollection(PersistentCollection collection, boolean writing)
+ throws HibernateException;
+
+ /**
+ * Load an instance without checking if it was deleted.
+ *
+ * When <tt>nullable</tt> is disabled this method may create a new proxy or
+ * return an existing proxy; if it does not exist, throw an exception.
+ *
+ * When <tt>nullable</tt> is enabled, the method does not create new proxies
+ * (but might return an existing proxy); if it does not exist, return
+ * <tt>null</tt>.
+ *
+ * When <tt>eager</tt> is enabled, the object is eagerly fetched
+ */
+ public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)
+ throws HibernateException;
+
+ /**
+ * Load an instance immediately. This method is only called when lazily initializing a proxy.
+ * Do not return the proxy.
+ */
+ public Object immediateLoad(String entityName, Serializable id) throws HibernateException;
+
+ /**
+ * System time before the start of the transaction
+ */
+ public long getTimestamp();
+ /**
+ * Get the creating <tt>SessionFactoryImplementor</tt>
+ */
+ public SessionFactoryImplementor getFactory();
+ /**
+ * Get the prepared statement <tt>Batcher</tt> for this session
+ */
+ public Batcher getBatcher();
+
+ /**
+ * Execute a <tt>find()</tt> query
+ */
+ public List list(String query, QueryParameters queryParameters) throws HibernateException;
+ /**
+ * Execute an <tt>iterate()</tt> query
+ */
+ public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException;
+ /**
+ * Execute a <tt>scroll()</tt> query
+ */
+ public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException;
+ /**
+ * Execute a criteria query
+ */
+ public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode);
+ /**
+ * Execute a criteria query
+ */
+ public List list(CriteriaImpl criteria);
+
+ /**
+ * Execute a filter
+ */
+ public List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException;
+ /**
+ * Iterate a filter
+ */
+ public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException;
+
+ /**
+ * Get the <tt>EntityPersister</tt> for any instance
+ * @param entityName optional entity name
+ * @param object the entity instance
+ */
+ public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException;
+
+ /**
+ * Get the entity instance associated with the given <tt>Key</tt>,
+ * calling the Interceptor if necessary
+ */
+ public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException;
+
+ /**
+ * Notify the session that the transaction completed, so we no longer
+ * own the old locks. (Also we should release cache softlocks.) May
+ * be called multiple times during the transaction completion process.
+ * Also called after an autocommit, in which case the second argument
+ * is null.
+ */
+ public void afterTransactionCompletion(boolean successful, Transaction tx);
+
+ /**
+ * Notify the session that the transaction is about to complete
+ */
+ public void beforeTransactionCompletion(Transaction tx);
+
+ /**
+ * Return the identifier of the persistent object, or null if
+ * not associated with the session
+ */
+ public Serializable getContextEntityIdentifier(Object object);
+
+ /**
+ * The best guess entity name for an entity not in an association
+ */
+ public String bestGuessEntityName(Object object);
+
+ /**
+ * The guessed entity name for an entity not in an association
+ */
+ public String guessEntityName(Object entity) throws HibernateException;
+
+ /**
+ * Instantiate the entity class, initializing with the given identifier
+ */
+ public Object instantiate(String entityName, Serializable id) throws HibernateException;
+
+ /**
+ * Execute an SQL Query
+ */
+ public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
+ throws HibernateException;
+
+ /**
+ * Execute an SQL Query
+ */
+ public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
+ throws HibernateException;
+
+ /**
+ * Execute a native SQL query, and return the results as a fully built list.
+ *
+ * @param spec The specification of the native SQL query to execute.
+ * @param queryParameters The parameters by which to perform the execution.
+ * @return The result list.
+ * @throws HibernateException
+ */
+ public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
+ throws HibernateException;
+
+ /**
+ * Execute a native SQL query, and return the results as a scrollable result.
+ *
+ * @param spec The specification of the native SQL query to execute.
+ * @param queryParameters The parameters by which to perform the execution.
+ * @return The resulting scrollable result.
+ * @throws HibernateException
+ */
+ public ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
+ throws HibernateException;
+
+ /**
+ * Retreive the currently set value for a filter parameter.
+ *
+ * @param filterParameterName The filter parameter name in the format
+ * {FILTER_NAME.PARAMETER_NAME}.
+ * @return The filter parameter value.
+ */
+ public Object getFilterParameterValue(String filterParameterName);
+
+ /**
+ * Retreive the type for a given filter parrameter.
+ *
+ * @param filterParameterName The filter parameter name in the format
+ * {FILTER_NAME.PARAMETER_NAME}.
+ */
+ public Type getFilterParameterType(String filterParameterName);
+
+ /**
+ * Return the currently enabled filters. The filter map is keyed by filter
+ * name, with values corresponding to the {@link org.hibernate.impl.FilterImpl}
+ * instance.
+ * @return The currently enabled filters.
+ */
+ public Map getEnabledFilters();
+
+ public int getDontFlushFromFind();
+
+ /**
+ * Retrieves the configured event listeners from this event source.
+ *
+ * @return The configured event listeners.
+ */
+ public EventListeners getListeners();
+
+ //TODO: temporary
+
+ /**
+ * Get the persistence context for this session
+ */
+ public PersistenceContext getPersistenceContext();
+
+ /**
+ * Execute a HQL update or delete query
+ */
+ int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException;
+
+ /**
+ * Execute a native SQL update or delete query
+ */
+ int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException;
+
+ // copied from Session:
+
+ public EntityMode getEntityMode();
+ public CacheMode getCacheMode();
+ public void setCacheMode(CacheMode cm);
+ public boolean isOpen();
+ public boolean isConnected();
+ public FlushMode getFlushMode();
+ public void setFlushMode(FlushMode fm);
+ public Connection connection();
+ public void flush();
+
+ /**
+ * Get a Query instance for a named query or named native SQL query
+ */
+ public Query getNamedQuery(String name);
+ /**
+ * Get a Query instance for a named native SQL query
+ */
+ public Query getNamedSQLQuery(String name);
+
+ public boolean isEventSource();
+
+ public void afterScrollOperation();
+
+ public void setFetchProfile(String name);
+
+ public String getFetchProfile();
+
+ public JDBCContext getJDBCContext();
+
+ /**
+ * Determine whether the session is closed. Provided seperately from
+ * {@link #isOpen()} as this method does not attempt any JTA synch
+ * registration, where as {@link #isOpen()} does; which makes this one
+ * nicer to use for most internal purposes.
+ *
+ * @return True if the session is closed; false otherwise.
+ */
+ public boolean isClosed();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,1463 +0,0 @@
-// $Id: StatefulPersistenceContext.java 11490 2007-05-09 01:43:11Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.map.ReferenceMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.Hibernate;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.MappingException;
-import org.hibernate.NonUniqueObjectException;
-import org.hibernate.PersistentObjectException;
-import org.hibernate.TransientObjectException;
-import org.hibernate.engine.loading.LoadContexts;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.proxy.HibernateProxy;
-import org.hibernate.proxy.LazyInitializer;
-import org.hibernate.tuple.ElementWrapper;
-import org.hibernate.util.IdentityMap;
-import org.hibernate.util.MarkerObject;
-
-/**
- * A <tt>PersistenceContext</tt> represents the state of persistent "stuff" which
- * Hibernate is tracking. This includes persistent entities, collections,
- * as well as proxies generated.
- * </p>
- * There is meant to be a one-to-one correspondence between a SessionImpl and
- * a PersistentContext. The SessionImpl uses the PersistentContext to track
- * the current state of its context. Event-listeners then use the
- * PersistentContext to drive their processing.
- *
- * @author Steve Ebersole
- */
-public class StatefulPersistenceContext implements PersistenceContext {
-
- public static final Object NO_ROW = new MarkerObject( "NO_ROW" );
-
- private static final Logger log = LoggerFactory.getLogger( StatefulPersistenceContext.class );
- private static final Logger PROXY_WARN_LOG = LoggerFactory.getLogger( StatefulPersistenceContext.class.getName() + ".ProxyWarnLog" );
- private static final int INIT_COLL_SIZE = 8;
-
- private SessionImplementor session;
-
- // Loaded entity instances, by EntityKey
- private Map entitiesByKey;
-
- // Loaded entity instances, by EntityUniqueKey
- private Map entitiesByUniqueKey;
-
- // Identity map of EntityEntry instances, by the entity instance
- private Map entityEntries;
-
- // Entity proxies, by EntityKey
- private Map proxiesByKey;
-
- // Snapshots of current database state for entities
- // that have *not* been loaded
- private Map entitySnapshotsByKey;
-
- // Identity map of array holder ArrayHolder instances, by the array instance
- private Map arrayHolders;
-
- // Identity map of CollectionEntry instances, by the collection wrapper
- private Map collectionEntries;
-
- // Collection wrappers, by the CollectionKey
- private Map collectionsByKey; //key=CollectionKey, value=PersistentCollection
-
- // Set of EntityKeys of deleted objects
- private HashSet nullifiableEntityKeys;
-
- // properties that we have tried to load, and not found in the database
- private HashSet nullAssociations;
-
- // A list of collection wrappers that were instantiating during result set
- // processing, that we will need to initialize at the end of the query
- private List nonlazyCollections;
-
- // A container for collections we load up when the owning entity is not
- // yet loaded ... for now, this is purely transient!
- private Map unownedCollections;
-
- private int cascading = 0;
- private int loadCounter = 0;
- private boolean flushing = false;
-
- private boolean hasNonReadOnlyEntities = false;
-
- private LoadContexts loadContexts;
- private BatchFetchQueue batchFetchQueue;
-
-
-
- /**
- * Constructs a PersistentContext, bound to the given session.
- *
- * @param session The session "owning" this context.
- */
- public StatefulPersistenceContext(SessionImplementor session) {
- this.session = session;
-
- entitiesByKey = new HashMap( INIT_COLL_SIZE );
- entitiesByUniqueKey = new HashMap( INIT_COLL_SIZE );
- proxiesByKey = new ReferenceMap( ReferenceMap.HARD, ReferenceMap.WEAK );
- entitySnapshotsByKey = new HashMap( INIT_COLL_SIZE );
-
- entityEntries = IdentityMap.instantiateSequenced( INIT_COLL_SIZE );
- collectionEntries = IdentityMap.instantiateSequenced( INIT_COLL_SIZE );
- collectionsByKey = new HashMap( INIT_COLL_SIZE );
- arrayHolders = IdentityMap.instantiate( INIT_COLL_SIZE );
-
- nullifiableEntityKeys = new HashSet();
-
- initTransientState();
- }
-
- private void initTransientState() {
- nullAssociations = new HashSet( INIT_COLL_SIZE );
- nonlazyCollections = new ArrayList( INIT_COLL_SIZE );
- }
-
- public boolean isStateless() {
- return false;
- }
-
- public SessionImplementor getSession() {
- return session;
- }
-
- public LoadContexts getLoadContexts() {
- if ( loadContexts == null ) {
- loadContexts = new LoadContexts( this );
- }
- return loadContexts;
- }
-
- public void addUnownedCollection(CollectionKey key, PersistentCollection collection) {
- if (unownedCollections==null) {
- unownedCollections = new HashMap(8);
- }
- unownedCollections.put(key, collection);
- }
-
- public PersistentCollection useUnownedCollection(CollectionKey key) {
- if (unownedCollections==null) {
- return null;
- }
- else {
- return (PersistentCollection) unownedCollections.remove(key);
- }
- }
-
- /**
- * Get the <tt>BatchFetchQueue</tt>, instantiating one if
- * necessary.
- */
- public BatchFetchQueue getBatchFetchQueue() {
- if (batchFetchQueue==null) {
- batchFetchQueue = new BatchFetchQueue(this);
- }
- return batchFetchQueue;
- }
-
- public void clear() {
- Iterator itr = proxiesByKey.values().iterator();
- while ( itr.hasNext() ) {
- final LazyInitializer li = ( ( HibernateProxy ) itr.next() ).getHibernateLazyInitializer();
- li.setSession( null );
- }
- Map.Entry[] collectionEntryArray = IdentityMap.concurrentEntries( collectionEntries );
- for ( int i = 0; i < collectionEntryArray.length; i++ ) {
- ( ( PersistentCollection ) collectionEntryArray[i].getKey() ).unsetSession( getSession() );
- }
- arrayHolders.clear();
- entitiesByKey.clear();
- entitiesByUniqueKey.clear();
- entityEntries.clear();
- entitySnapshotsByKey.clear();
- collectionsByKey.clear();
- collectionEntries.clear();
- if ( unownedCollections != null ) {
- unownedCollections.clear();
- }
- proxiesByKey.clear();
- nullifiableEntityKeys.clear();
- if ( batchFetchQueue != null ) {
- batchFetchQueue.clear();
- }
- hasNonReadOnlyEntities = false;
- if ( loadContexts != null ) {
- loadContexts.cleanup();
- }
- }
-
- public boolean hasNonReadOnlyEntities() {
- return hasNonReadOnlyEntities;
- }
-
- public void setEntryStatus(EntityEntry entry, Status status) {
- entry.setStatus(status);
- setHasNonReadOnlyEnties(status);
- }
-
- private void setHasNonReadOnlyEnties(Status status) {
- if ( status==Status.DELETED || status==Status.MANAGED || status==Status.SAVING ) {
- hasNonReadOnlyEntities = true;
- }
- }
-
- public void afterTransactionCompletion() {
- // Downgrade locks
- Iterator iter = entityEntries.values().iterator();
- while ( iter.hasNext() ) {
- ( (EntityEntry) iter.next() ).setLockMode(LockMode.NONE);
- }
- }
-
- /**
- * Get the current state of the entity as known to the underlying
- * database, or null if there is no corresponding row
- */
- public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister)
- throws HibernateException {
- EntityKey key = new EntityKey( id, persister, session.getEntityMode() );
- Object cached = entitySnapshotsByKey.get(key);
- if (cached!=null) {
- return cached==NO_ROW ? null : (Object[]) cached;
- }
- else {
- Object[] snapshot = persister.getDatabaseSnapshot( id, session );
- entitySnapshotsByKey.put( key, snapshot==null ? NO_ROW : snapshot );
- return snapshot;
- }
- }
-
- public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister)
- throws HibernateException {
- if ( !persister.hasNaturalIdentifier() ) {
- return null;
- }
-
- // if the natural-id is marked as non-mutable, it is not retrieved during a
- // normal database-snapshot operation...
- int[] props = persister.getNaturalIdentifierProperties();
- boolean[] updateable = persister.getPropertyUpdateability();
- boolean allNatualIdPropsAreUpdateable = true;
- for ( int i = 0; i < props.length; i++ ) {
- if ( !updateable[ props[i] ] ) {
- allNatualIdPropsAreUpdateable = false;
- break;
- }
- }
-
- if ( allNatualIdPropsAreUpdateable ) {
- // do this when all the properties are updateable since there is
- // a certain likelihood that the information will already be
- // snapshot-cached.
- Object[] entitySnapshot = getDatabaseSnapshot( id, persister );
- if ( entitySnapshot == NO_ROW ) {
- return null;
- }
- Object[] naturalIdSnapshot = new Object[ props.length ];
- for ( int i = 0; i < props.length; i++ ) {
- naturalIdSnapshot[i] = entitySnapshot[ props[i] ];
- }
- return naturalIdSnapshot;
- }
- else {
- return persister.getNaturalIdentifierSnapshot( id, session );
- }
- }
-
- /**
- * Retrieve the cached database snapshot for the requested entity key.
- * <p/>
- * This differs from {@link #getDatabaseSnapshot} is two important respects:<ol>
- * <li>no snapshot is obtained from the database if not already cached</li>
- * <li>an entry of {@link #NO_ROW} here is interpretet as an exception</li>
- * </ol>
- * @param key The entity key for which to retrieve the cached snapshot
- * @return The cached snapshot
- * @throws IllegalStateException if the cached snapshot was == {@link #NO_ROW}.
- */
- public Object[] getCachedDatabaseSnapshot(EntityKey key) {
- Object snapshot = entitySnapshotsByKey.get( key );
- if ( snapshot == NO_ROW ) {
- throw new IllegalStateException( "persistence context reported no row snapshot for " + MessageHelper.infoString( key.getEntityName(), key.getIdentifier() ) );
- }
- return ( Object[] ) snapshot;
- }
-
- /*public void removeDatabaseSnapshot(EntityKey key) {
- entitySnapshotsByKey.remove(key);
- }*/
-
- public void addEntity(EntityKey key, Object entity) {
- entitiesByKey.put(key, entity);
- getBatchFetchQueue().removeBatchLoadableEntityKey(key);
- }
-
- /**
- * Get the entity instance associated with the given
- * <tt>EntityKey</tt>
- */
- public Object getEntity(EntityKey key) {
- return entitiesByKey.get(key);
- }
-
- public boolean containsEntity(EntityKey key) {
- return entitiesByKey.containsKey(key);
- }
-
- /**
- * Remove an entity from the session cache, also clear
- * up other state associated with the entity, all except
- * for the <tt>EntityEntry</tt>
- */
- public Object removeEntity(EntityKey key) {
- Object entity = entitiesByKey.remove(key);
- Iterator iter = entitiesByUniqueKey.values().iterator();
- while ( iter.hasNext() ) {
- if ( iter.next()==entity ) iter.remove();
- }
- entitySnapshotsByKey.remove(key);
- nullifiableEntityKeys.remove(key);
- getBatchFetchQueue().removeBatchLoadableEntityKey(key);
- getBatchFetchQueue().removeSubselect(key);
- return entity;
- }
-
- /**
- * Get an entity cached by unique key
- */
- public Object getEntity(EntityUniqueKey euk) {
- return entitiesByUniqueKey.get(euk);
- }
-
- /**
- * Add an entity to the cache by unique key
- */
- public void addEntity(EntityUniqueKey euk, Object entity) {
- entitiesByUniqueKey.put(euk, entity);
- }
-
- /**
- * Retreive the EntityEntry representation of the given entity.
- *
- * @param entity The entity for which to locate the EntityEntry.
- * @return The EntityEntry for the given entity.
- */
- public EntityEntry getEntry(Object entity) {
- return (EntityEntry) entityEntries.get(entity);
- }
-
- /**
- * Remove an entity entry from the session cache
- */
- public EntityEntry removeEntry(Object entity) {
- return (EntityEntry) entityEntries.remove(entity);
- }
-
- /**
- * Is there an EntityEntry for this instance?
- */
- public boolean isEntryFor(Object entity) {
- return entityEntries.containsKey(entity);
- }
-
- /**
- * Get the collection entry for a persistent collection
- */
- public CollectionEntry getCollectionEntry(PersistentCollection coll) {
- return (CollectionEntry) collectionEntries.get(coll);
- }
-
- /**
- * Adds an entity to the internal caches.
- */
- public EntityEntry addEntity(
- final Object entity,
- final Status status,
- final Object[] loadedState,
- final EntityKey entityKey,
- final Object version,
- final LockMode lockMode,
- final boolean existsInDatabase,
- final EntityPersister persister,
- final boolean disableVersionIncrement,
- boolean lazyPropertiesAreUnfetched
- ) {
-
- addEntity( entityKey, entity );
-
- return addEntry(
- entity,
- status,
- loadedState,
- null,
- entityKey.getIdentifier(),
- version,
- lockMode,
- existsInDatabase,
- persister,
- disableVersionIncrement,
- lazyPropertiesAreUnfetched
- );
- }
-
-
- /**
- * Generates an appropriate EntityEntry instance and adds it
- * to the event source's internal caches.
- */
- public EntityEntry addEntry(
- final Object entity,
- final Status status,
- final Object[] loadedState,
- final Object rowId,
- final Serializable id,
- final Object version,
- final LockMode lockMode,
- final boolean existsInDatabase,
- final EntityPersister persister,
- final boolean disableVersionIncrement,
- boolean lazyPropertiesAreUnfetched) {
-
- EntityEntry e = new EntityEntry(
- status,
- loadedState,
- rowId,
- id,
- version,
- lockMode,
- existsInDatabase,
- persister,
- session.getEntityMode(),
- disableVersionIncrement,
- lazyPropertiesAreUnfetched
- );
- entityEntries.put(entity, e);
-
- setHasNonReadOnlyEnties(status);
- return e;
- }
-
- public boolean containsCollection(PersistentCollection collection) {
- return collectionEntries.containsKey(collection);
- }
-
- public boolean containsProxy(Object entity) {
- return proxiesByKey.containsValue( entity );
- }
-
- /**
- * Takes the given object and, if it represents a proxy, reassociates it with this event source.
- *
- * @param value The possible proxy to be reassociated.
- * @return Whether the passed value represented an actual proxy which got initialized.
- * @throws MappingException
- */
- public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
- if ( value instanceof ElementWrapper ) {
- value = ( (ElementWrapper) value ).getElement();
- }
-
- if ( !Hibernate.isInitialized(value) ) {
- HibernateProxy proxy = (HibernateProxy) value;
- LazyInitializer li = proxy.getHibernateLazyInitializer();
- reassociateProxy(li, proxy);
- return true;
- }
- else {
- return false;
- }
- }
-
- /**
- * If a deleted entity instance is re-saved, and it has a proxy, we need to
- * reset the identifier of the proxy
- */
- public void reassociateProxy(Object value, Serializable id) throws MappingException {
- if ( value instanceof ElementWrapper ) {
- value = ( (ElementWrapper) value ).getElement();
- }
-
- if ( value instanceof HibernateProxy ) {
- if ( log.isDebugEnabled() ) log.debug("setting proxy identifier: " + id);
- HibernateProxy proxy = (HibernateProxy) value;
- LazyInitializer li = proxy.getHibernateLazyInitializer();
- li.setIdentifier(id);
- reassociateProxy(li, proxy);
- }
- }
-
- /**
- * Associate a proxy that was instantiated by another session with this session
- *
- * @param li The proxy initializer.
- * @param proxy The proxy to reassociate.
- */
- private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
- if ( li.getSession() != this.getSession() ) {
- EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() );
- EntityKey key = new EntityKey( li.getIdentifier(), persister, session.getEntityMode() );
- // any earlier proxy takes precedence
- if ( !proxiesByKey.containsKey( key ) ) {
- proxiesByKey.put( key, proxy );
- }
- proxy.getHibernateLazyInitializer().setSession( session );
- }
- }
-
- /**
- * Get the entity instance underlying the given proxy, throwing
- * an exception if the proxy is uninitialized. If the given object
- * is not a proxy, simply return the argument.
- */
- public Object unproxy(Object maybeProxy) throws HibernateException {
- if ( maybeProxy instanceof ElementWrapper ) {
- maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
- }
-
- if ( maybeProxy instanceof HibernateProxy ) {
- HibernateProxy proxy = (HibernateProxy) maybeProxy;
- LazyInitializer li = proxy.getHibernateLazyInitializer();
- if ( li.isUninitialized() ) {
- throw new PersistentObjectException(
- "object was an uninitialized proxy for " +
- li.getEntityName()
- );
- }
- return li.getImplementation(); //unwrap the object
- }
- else {
- return maybeProxy;
- }
- }
-
- /**
- * Possibly unproxy the given reference and reassociate it with the current session.
- *
- * @param maybeProxy The reference to be unproxied if it currently represents a proxy.
- * @return The unproxied instance.
- * @throws HibernateException
- */
- public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException {
- if ( maybeProxy instanceof ElementWrapper ) {
- maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
- }
-
- if ( maybeProxy instanceof HibernateProxy ) {
- HibernateProxy proxy = (HibernateProxy) maybeProxy;
- LazyInitializer li = proxy.getHibernateLazyInitializer();
- reassociateProxy(li, proxy);
- return li.getImplementation(); //initialize + unwrap the object
- }
- else {
- return maybeProxy;
- }
- }
-
- /**
- * Attempts to check whether the given key represents an entity already loaded within the
- * current session.
- * @param object The entity reference against which to perform the uniqueness check.
- * @throws HibernateException
- */
- public void checkUniqueness(EntityKey key, Object object) throws HibernateException {
- Object entity = getEntity(key);
- if ( entity == object ) {
- throw new AssertionFailure( "object already associated, but no entry was found" );
- }
- if ( entity != null ) {
- throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() );
- }
- }
-
- /**
- * If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
- * and overwrite the registration of the old one. This breaks == and occurs only for
- * "class" proxies rather than "interface" proxies. Also init the proxy to point to
- * the given target implementation if necessary.
- *
- * @param proxy The proxy instance to be narrowed.
- * @param persister The persister for the proxied entity.
- * @param key The internal cache key for the proxied entity.
- * @param object (optional) the actual proxied entity instance.
- * @return An appropriately narrowed instance.
- * @throws HibernateException
- */
- public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object)
- throws HibernateException {
-
- boolean alreadyNarrow = persister.getConcreteProxyClass( session.getEntityMode() )
- .isAssignableFrom( proxy.getClass() );
-
- if ( !alreadyNarrow ) {
- if ( PROXY_WARN_LOG.isWarnEnabled() ) {
- PROXY_WARN_LOG.warn(
- "Narrowing proxy to " +
- persister.getConcreteProxyClass( session.getEntityMode() ) +
- " - this operation breaks =="
- );
- }
-
- if ( object != null ) {
- proxiesByKey.remove(key);
- return object; //return the proxied object
- }
- else {
- proxy = persister.createProxy( key.getIdentifier(), session );
- proxiesByKey.put(key, proxy); //overwrite old proxy
- return proxy;
- }
-
- }
- else {
-
- if ( object != null ) {
- LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
- li.setImplementation(object);
- }
-
- return proxy;
-
- }
-
- }
-
- /**
- * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
- * third argument (the entity associated with the key) if no proxy exists. Init
- * the proxy to the target implementation, if necessary.
- */
- public Object proxyFor(EntityPersister persister, EntityKey key, Object impl)
- throws HibernateException {
- if ( !persister.hasProxy() ) return impl;
- Object proxy = proxiesByKey.get(key);
- if ( proxy != null ) {
- return narrowProxy(proxy, persister, key, impl);
- }
- else {
- return impl;
- }
- }
-
- /**
- * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
- * argument (the entity associated with the key) if no proxy exists.
- * (slower than the form above)
- */
- public Object proxyFor(Object impl) throws HibernateException {
- EntityEntry e = getEntry(impl);
- EntityPersister p = e.getPersister();
- return proxyFor( p, new EntityKey( e.getId(), p, session.getEntityMode() ), impl );
- }
-
- /**
- * Get the entity that owns this persistent collection
- */
- public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException {
- return getEntity( new EntityKey( key, collectionPersister.getOwnerEntityPersister(), session.getEntityMode() ) );
- }
-
- /**
- * Get the entity that owned this persistent collection when it was loaded
- *
- * @param collection The persistent collection
- * @return the owner, if its entity ID is available from the collection's loaded key
- * and the owner entity is in the persistence context; otherwise, returns null
- */
- public Object getLoadedCollectionOwnerOrNull(PersistentCollection collection) {
- CollectionEntry ce = getCollectionEntry( collection );
- if ( ce.getLoadedPersister() == null ) {
- return null; // early exit...
- }
- Object loadedOwner = null;
- // TODO: an alternative is to check if the owner has changed; if it hasn't then
- // return collection.getOwner()
- Serializable entityId = getLoadedCollectionOwnerIdOrNull( ce );
- if ( entityId != null ) {
- loadedOwner = getCollectionOwner( entityId, ce.getLoadedPersister() );
- }
- return loadedOwner;
- }
-
- /**
- * Get the ID for the entity that owned this persistent collection when it was loaded
- *
- * @param collection The persistent collection
- * @return the owner ID if available from the collection's loaded key; otherwise, returns null
- */
- public Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection) {
- return getLoadedCollectionOwnerIdOrNull( getCollectionEntry( collection ) );
- }
-
- /**
- * Get the ID for the entity that owned this persistent collection when it was loaded
- *
- * @param ce The collection entry
- * @return the owner ID if available from the collection's loaded key; otherwise, returns null
- */
- private Serializable getLoadedCollectionOwnerIdOrNull(CollectionEntry ce) {
- if ( ce == null || ce.getLoadedKey() == null || ce.getLoadedPersister() == null ) {
- return null;
- }
- // TODO: an alternative is to check if the owner has changed; if it hasn't then
- // get the ID from collection.getOwner()
- return ce.getLoadedPersister().getCollectionType().getIdOfOwnerOrNull( ce.getLoadedKey(), session );
- }
-
- /**
- * add a collection we just loaded up (still needs initializing)
- */
- public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) {
- CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing);
- addCollection(collection, ce, id);
- }
-
- /**
- * add a detached uninitialized collection
- */
- public void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection) {
- CollectionEntry ce = new CollectionEntry( persister, collection.getKey() );
- addCollection( collection, ce, collection.getKey() );
- }
-
- /**
- * Add a new collection (ie. a newly created one, just instantiated by the
- * application, with no database state or snapshot)
- * @param collection The collection to be associated with the persistence context
- */
- public void addNewCollection(CollectionPersister persister, PersistentCollection collection)
- throws HibernateException {
- addCollection(collection, persister);
- }
-
- /**
- * Add an collection to the cache, with a given collection entry.
- *
- * @param coll The collection for which we are adding an entry.
- * @param entry The entry representing the collection.
- * @param key The key of the collection's entry.
- */
- private void addCollection(PersistentCollection coll, CollectionEntry entry, Serializable key) {
- collectionEntries.put( coll, entry );
- CollectionKey collectionKey = new CollectionKey( entry.getLoadedPersister(), key, session.getEntityMode() );
- PersistentCollection old = ( PersistentCollection ) collectionsByKey.put( collectionKey, coll );
- if ( old != null ) {
- if ( old == coll ) {
- throw new AssertionFailure("bug adding collection twice");
- }
- // or should it actually throw an exception?
- old.unsetSession( session );
- collectionEntries.remove( old );
- // watch out for a case where old is still referenced
- // somewhere in the object graph! (which is a user error)
- }
- }
-
- /**
- * Add a collection to the cache, creating a new collection entry for it
- *
- * @param collection The collection for which we are adding an entry.
- * @param persister The collection persister
- */
- private void addCollection(PersistentCollection collection, CollectionPersister persister) {
- CollectionEntry ce = new CollectionEntry( persister, collection );
- collectionEntries.put( collection, ce );
- }
-
- /**
- * add an (initialized) collection that was created by another session and passed
- * into update() (ie. one with a snapshot and existing state on the database)
- */
- public void addInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection)
- throws HibernateException {
- if ( collection.isUnreferenced() ) {
- //treat it just like a new collection
- addCollection( collection, collectionPersister );
- }
- else {
- CollectionEntry ce = new CollectionEntry( collection, session.getFactory() );
- addCollection( collection, ce, collection.getKey() );
- }
- }
-
- /**
- * add a collection we just pulled out of the cache (does not need initializing)
- */
- public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
- throws HibernateException {
- CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing);
- ce.postInitialize(collection);
- addCollection(collection, ce, id);
- return ce;
- }
-
- /**
- * Get the collection instance associated with the <tt>CollectionKey</tt>
- */
- public PersistentCollection getCollection(CollectionKey collectionKey) {
- return (PersistentCollection) collectionsByKey.get(collectionKey);
- }
-
- /**
- * Register a collection for non-lazy loading at the end of the
- * two-phase load
- */
- public void addNonLazyCollection(PersistentCollection collection) {
- nonlazyCollections.add(collection);
- }
-
- /**
- * Force initialization of all non-lazy collections encountered during
- * the current two-phase load (actually, this is a no-op, unless this
- * is the "outermost" load)
- */
- public void initializeNonLazyCollections() throws HibernateException {
- if ( loadCounter == 0 ) {
- log.debug( "initializing non-lazy collections" );
- //do this work only at the very highest level of the load
- loadCounter++; //don't let this method be called recursively
- try {
- int size;
- while ( ( size = nonlazyCollections.size() ) > 0 ) {
- //note that each iteration of the loop may add new elements
- ( (PersistentCollection) nonlazyCollections.remove( size - 1 ) ).forceInitialization();
- }
- }
- finally {
- loadCounter--;
- clearNullProperties();
- }
- }
- }
-
-
- /**
- * Get the <tt>PersistentCollection</tt> object for an array
- */
- public PersistentCollection getCollectionHolder(Object array) {
- return (PersistentCollection) arrayHolders.get(array);
- }
-
- /**
- * Register a <tt>PersistentCollection</tt> object for an array.
- * Associates a holder with an array - MUST be called after loading
- * array, since the array instance is not created until endLoad().
- */
- public void addCollectionHolder(PersistentCollection holder) {
- //TODO:refactor + make this method private
- arrayHolders.put( holder.getValue(), holder );
- }
-
- public PersistentCollection removeCollectionHolder(Object array) {
- return (PersistentCollection) arrayHolders.remove(array);
- }
-
- /**
- * Get the snapshot of the pre-flush collection state
- */
- public Serializable getSnapshot(PersistentCollection coll) {
- return getCollectionEntry(coll).getSnapshot();
- }
-
- /**
- * Get the collection entry for a collection passed to filter,
- * which might be a collection wrapper, an array, or an unwrapped
- * collection. Return null if there is no entry.
- */
- public CollectionEntry getCollectionEntryOrNull(Object collection) {
- PersistentCollection coll;
- if ( collection instanceof PersistentCollection ) {
- coll = (PersistentCollection) collection;
- //if (collection==null) throw new TransientObjectException("Collection was not yet persistent");
- }
- else {
- coll = getCollectionHolder(collection);
- if ( coll == null ) {
- //it might be an unwrapped collection reference!
- //try to find a wrapper (slowish)
- Iterator wrappers = IdentityMap.keyIterator(collectionEntries);
- while ( wrappers.hasNext() ) {
- PersistentCollection pc = (PersistentCollection) wrappers.next();
- if ( pc.isWrapper(collection) ) {
- coll = pc;
- break;
- }
- }
- }
- }
-
- return (coll == null) ? null : getCollectionEntry(coll);
- }
-
- /**
- * Get an existing proxy by key
- */
- public Object getProxy(EntityKey key) {
- return proxiesByKey.get(key);
- }
-
- /**
- * Add a proxy to the session cache
- */
- public void addProxy(EntityKey key, Object proxy) {
- proxiesByKey.put(key, proxy);
- }
-
- /**
- * Remove a proxy from the session cache.
- * <p/>
- * Additionally, ensure that any load optimization references
- * such as batch or subselect loading get cleaned up as well.
- *
- * @param key The key of the entity proxy to be removed
- * @return The proxy reference.
- */
- public Object removeProxy(EntityKey key) {
- if ( batchFetchQueue != null ) {
- batchFetchQueue.removeBatchLoadableEntityKey( key );
- batchFetchQueue.removeSubselect( key );
- }
- return proxiesByKey.remove( key );
- }
-
- /**
- * Record the fact that an entity does not exist in the database
- *
- * @param key the primary key of the entity
- */
- /*public void addNonExistantEntityKey(EntityKey key) {
- nonExistantEntityKeys.add(key);
- }*/
-
- /**
- * Record the fact that an entity does not exist in the database
- *
- * @param key a unique key of the entity
- */
- /*public void addNonExistantEntityUniqueKey(EntityUniqueKey key) {
- nonExistentEntityUniqueKeys.add(key);
- }*/
-
- /*public void removeNonExist(EntityKey key) {
- nonExistantEntityKeys.remove(key);
- }*/
-
- /**
- * Retrieve the set of EntityKeys representing nullifiable references
- */
- public HashSet getNullifiableEntityKeys() {
- return nullifiableEntityKeys;
- }
-
- public Map getEntitiesByKey() {
- return entitiesByKey;
- }
-
- public Map getEntityEntries() {
- return entityEntries;
- }
-
- public Map getCollectionEntries() {
- return collectionEntries;
- }
-
- public Map getCollectionsByKey() {
- return collectionsByKey;
- }
-
- /**
- * Do we already know that the entity does not exist in the
- * database?
- */
- /*public boolean isNonExistant(EntityKey key) {
- return nonExistantEntityKeys.contains(key);
- }*/
-
- /**
- * Do we already know that the entity does not exist in the
- * database?
- */
- /*public boolean isNonExistant(EntityUniqueKey key) {
- return nonExistentEntityUniqueKeys.contains(key);
- }*/
-
- public int getCascadeLevel() {
- return cascading;
- }
-
- public int incrementCascadeLevel() {
- return ++cascading;
- }
-
- public int decrementCascadeLevel() {
- return --cascading;
- }
-
- public boolean isFlushing() {
- return flushing;
- }
-
- public void setFlushing(boolean flushing) {
- this.flushing = flushing;
- }
-
- /**
- * Call this before begining a two-phase load
- */
- public void beforeLoad() {
- loadCounter++;
- }
-
- /**
- * Call this after finishing a two-phase load
- */
- public void afterLoad() {
- loadCounter--;
- }
-
- /**
- * Returns a string representation of the object.
- *
- * @return a string representation of the object.
- */
- public String toString() {
- return new StringBuffer()
- .append("PersistenceContext[entityKeys=")
- .append(entitiesByKey.keySet())
- .append(",collectionKeys=")
- .append(collectionsByKey.keySet())
- .append("]")
- .toString();
- }
-
- /**
- * Search <tt>this</tt> persistence context for an associated entity instance which is considered the "owner" of
- * the given <tt>childEntity</tt>, and return that owner's id value. This is performed in the scenario of a
- * uni-directional, non-inverse one-to-many collection (which means that the collection elements do not maintain
- * a direct reference to the owner).
- * <p/>
- * As such, the processing here is basically to loop over every entity currently associated with this persistence
- * context and for those of the correct entity (sub) type to extract its collection role property value and see
- * if the child is contained within that collection. If so, we have found the owner; if not, we go on.
- * <p/>
- * Also need to account for <tt>mergeMap</tt> which acts as a local copy cache managed for the duration of a merge
- * operation. It represents a map of the detached entity instances pointing to the corresponding managed instance.
- *
- * @param entityName The entity name for the entity type which would own the child
- * @param propertyName The name of the property on the owning entity type which would name this child association.
- * @param childEntity The child entity instance for which to locate the owner instance id.
- * @param mergeMap A map of non-persistent instances from an on-going merge operation (possibly null).
- *
- * @return The id of the entityName instance which is said to own the child; null if an appropriate owner not
- * located.
- */
- public Serializable getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap) {
- final String collectionRole = entityName + '.' + propertyName;
- final EntityPersister persister = session.getFactory().getEntityPersister( entityName );
- final CollectionPersister collectionPersister = session.getFactory().getCollectionPersister( collectionRole );
-
- // iterate all the entities currently associated with the persistence context.
- Iterator entities = entityEntries.entrySet().iterator();
- while ( entities.hasNext() ) {
- final Map.Entry me = ( Map.Entry ) entities.next();
- final EntityEntry entityEntry = ( EntityEntry ) me.getValue();
- // does this entity entry pertain to the entity persister in which we are interested (owner)?
- if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) {
- final Object entityEntryInstance = me.getKey();
-
- //check if the managed object is the parent
- boolean found = isFoundInParent(
- propertyName,
- childEntity,
- persister,
- collectionPersister,
- entityEntryInstance
- );
-
- if ( !found && mergeMap != null ) {
- //check if the detached object being merged is the parent
- Object unmergedInstance = mergeMap.get( entityEntryInstance );
- Object unmergedChild = mergeMap.get( childEntity );
- if ( unmergedInstance != null && unmergedChild != null ) {
- found = isFoundInParent(
- propertyName,
- unmergedChild,
- persister,
- collectionPersister,
- unmergedInstance
- );
- }
- }
-
- if ( found ) {
- return entityEntry.getId();
- }
-
- }
- }
-
- // if we get here, it is possible that we have a proxy 'in the way' of the merge map resolution...
- // NOTE: decided to put this here rather than in the above loop as I was nervous about the performance
- // of the loop-in-loop especially considering this is far more likely the 'edge case'
- if ( mergeMap != null ) {
- Iterator mergeMapItr = mergeMap.entrySet().iterator();
- while ( mergeMapItr.hasNext() ) {
- final Map.Entry mergeMapEntry = ( Map.Entry ) mergeMapItr.next();
- if ( mergeMapEntry.getKey() instanceof HibernateProxy ) {
- final HibernateProxy proxy = ( HibernateProxy ) mergeMapEntry.getKey();
- if ( persister.isSubclassEntityName( proxy.getHibernateLazyInitializer().getEntityName() ) ) {
- boolean found = isFoundInParent(
- propertyName,
- childEntity,
- persister,
- collectionPersister,
- mergeMap.get( proxy )
- );
- if ( !found ) {
- found = isFoundInParent(
- propertyName,
- mergeMap.get( childEntity ),
- persister,
- collectionPersister,
- mergeMap.get( proxy )
- );
- }
- if ( found ) {
- return proxy.getHibernateLazyInitializer().getIdentifier();
- }
- }
- }
- }
- }
-
- return null;
- }
-
- private boolean isFoundInParent(
- String property,
- Object childEntity,
- EntityPersister persister,
- CollectionPersister collectionPersister,
- Object potentialParent) {
- Object collection = persister.getPropertyValue(
- potentialParent,
- property,
- session.getEntityMode()
- );
- return collection != null
- && Hibernate.isInitialized( collection )
- && collectionPersister.getCollectionType().contains( collection, childEntity, session );
- }
-
- /**
- * Search the persistence context for an index of the child object,
- * given a collection role
- */
- public Object getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap) {
-
- EntityPersister persister = session.getFactory()
- .getEntityPersister(entity);
- CollectionPersister cp = session.getFactory()
- .getCollectionPersister(entity + '.' + property);
- Iterator entities = entityEntries.entrySet().iterator();
- while ( entities.hasNext() ) {
- Map.Entry me = (Map.Entry) entities.next();
- EntityEntry ee = (EntityEntry) me.getValue();
- if ( persister.isSubclassEntityName( ee.getEntityName() ) ) {
- Object instance = me.getKey();
-
- Object index = getIndexInParent(property, childEntity, persister, cp, instance);
-
- if (index==null && mergeMap!=null) {
- Object unmergedInstance = mergeMap.get(instance);
- Object unmergedChild = mergeMap.get(childEntity);
- if ( unmergedInstance!=null && unmergedChild!=null ) {
- index = getIndexInParent(property, unmergedChild, persister, cp, unmergedInstance);
- }
- }
-
- if (index!=null) return index;
- }
- }
- return null;
- }
-
- private Object getIndexInParent(
- String property,
- Object childEntity,
- EntityPersister persister,
- CollectionPersister collectionPersister,
- Object potentialParent
- ){
- Object collection = persister.getPropertyValue( potentialParent, property, session.getEntityMode() );
- if ( collection!=null && Hibernate.isInitialized(collection) ) {
- return collectionPersister.getCollectionType().indexOf(collection, childEntity);
- }
- else {
- return null;
- }
- }
-
- /**
- * Record the fact that the association belonging to the keyed
- * entity is null.
- */
- public void addNullProperty(EntityKey ownerKey, String propertyName) {
- nullAssociations.add( new AssociationKey(ownerKey, propertyName) );
- }
-
- /**
- * Is the association property belonging to the keyed entity null?
- */
- public boolean isPropertyNull(EntityKey ownerKey, String propertyName) {
- return nullAssociations.contains( new AssociationKey(ownerKey, propertyName) );
- }
-
- private void clearNullProperties() {
- nullAssociations.clear();
- }
-
- public void setReadOnly(Object entity, boolean readOnly) {
- EntityEntry entry = getEntry(entity);
- if (entry==null) {
- throw new TransientObjectException("Instance was not associated with the session");
- }
- entry.setReadOnly(readOnly, entity);
- hasNonReadOnlyEntities = hasNonReadOnlyEntities || !readOnly;
- }
-
- public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId) {
- Object entity = entitiesByKey.remove( oldKey );
- EntityEntry oldEntry = ( EntityEntry ) entityEntries.remove( entity );
-
- EntityKey newKey = new EntityKey( generatedId, oldEntry.getPersister(), getSession().getEntityMode() );
- addEntity( newKey, entity );
- addEntry(
- entity,
- oldEntry.getStatus(),
- oldEntry.getLoadedState(),
- oldEntry.getRowId(),
- generatedId,
- oldEntry.getVersion(),
- oldEntry.getLockMode(),
- oldEntry.isExistsInDatabase(),
- oldEntry.getPersister(),
- oldEntry.isBeingReplicated(),
- oldEntry.isLoadedWithLazyPropertiesUnfetched()
- );
- }
-
- /**
- * Used by the owning session to explicitly control serialization of the
- * persistence context.
- *
- * @param oos The stream to which the persistence context should get written
- * @throws IOException serialization errors.
- */
- public void serialize(ObjectOutputStream oos) throws IOException {
- log.trace( "serializing persistent-context" );
-
- oos.writeBoolean( hasNonReadOnlyEntities );
-
- oos.writeInt( entitiesByKey.size() );
- log.trace( "starting serialization of [" + entitiesByKey.size() + "] entitiesByKey entries" );
- Iterator itr = entitiesByKey.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- ( ( EntityKey ) entry.getKey() ).serialize( oos );
- oos.writeObject( entry.getValue() );
- }
-
- oos.writeInt( entitiesByUniqueKey.size() );
- log.trace( "starting serialization of [" + entitiesByUniqueKey.size() + "] entitiesByUniqueKey entries" );
- itr = entitiesByUniqueKey.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- ( ( EntityUniqueKey ) entry.getKey() ).serialize( oos );
- oos.writeObject( entry.getValue() );
- }
-
- oos.writeInt( proxiesByKey.size() );
- log.trace( "starting serialization of [" + proxiesByKey.size() + "] proxiesByKey entries" );
- itr = proxiesByKey.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- ( ( EntityKey ) entry.getKey() ).serialize( oos );
- oos.writeObject( entry.getValue() );
- }
-
- oos.writeInt( entitySnapshotsByKey.size() );
- log.trace( "starting serialization of [" + entitySnapshotsByKey.size() + "] entitySnapshotsByKey entries" );
- itr = entitySnapshotsByKey.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- ( ( EntityKey ) entry.getKey() ).serialize( oos );
- oos.writeObject( entry.getValue() );
- }
-
- oos.writeInt( entityEntries.size() );
- log.trace( "starting serialization of [" + entityEntries.size() + "] entityEntries entries" );
- itr = entityEntries.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- oos.writeObject( entry.getKey() );
- ( ( EntityEntry ) entry.getValue() ).serialize( oos );
- }
-
- oos.writeInt( collectionsByKey.size() );
- log.trace( "starting serialization of [" + collectionsByKey.size() + "] collectionsByKey entries" );
- itr = collectionsByKey.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- ( ( CollectionKey ) entry.getKey() ).serialize( oos );
- oos.writeObject( entry.getValue() );
- }
-
- oos.writeInt( collectionEntries.size() );
- log.trace( "starting serialization of [" + collectionEntries.size() + "] collectionEntries entries" );
- itr = collectionEntries.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- oos.writeObject( entry.getKey() );
- ( ( CollectionEntry ) entry.getValue() ).serialize( oos );
- }
-
- oos.writeInt( arrayHolders.size() );
- log.trace( "starting serialization of [" + arrayHolders.size() + "] arrayHolders entries" );
- itr = arrayHolders.entrySet().iterator();
- while ( itr.hasNext() ) {
- Map.Entry entry = ( Map.Entry ) itr.next();
- oos.writeObject( entry.getKey() );
- oos.writeObject( entry.getValue() );
- }
-
- oos.writeInt( nullifiableEntityKeys.size() );
- log.trace( "starting serialization of [" + nullifiableEntityKeys.size() + "] nullifiableEntityKeys entries" );
- itr = nullifiableEntityKeys.iterator();
- while ( itr.hasNext() ) {
- EntityKey entry = ( EntityKey ) itr.next();
- entry.serialize( oos );
- }
- }
-
- public static StatefulPersistenceContext deserialize(
- ObjectInputStream ois,
- SessionImplementor session) throws IOException, ClassNotFoundException {
- log.trace( "deserializing persistent-context" );
- StatefulPersistenceContext rtn = new StatefulPersistenceContext( session );
-
- // during deserialization, we need to reconnect all proxies and
- // collections to this session, as well as the EntityEntry and
- // CollectionEntry instances; these associations are transient
- // because serialization is used for different things.
-
- try {
- // todo : we can actually just determine this from the incoming EntityEntry-s
- rtn.hasNonReadOnlyEntities = ois.readBoolean();
-
- int count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] entitiesByKey entries" );
- rtn.entitiesByKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- rtn.entitiesByKey.put( EntityKey.deserialize( ois, session ), ois.readObject() );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] entitiesByUniqueKey entries" );
- rtn.entitiesByUniqueKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- rtn.entitiesByUniqueKey.put( EntityUniqueKey.deserialize( ois, session ), ois.readObject() );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] proxiesByKey entries" );
- rtn.proxiesByKey = new ReferenceMap( ReferenceMap.HARD, ReferenceMap.WEAK, count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count, .75f );
- for ( int i = 0; i < count; i++ ) {
- EntityKey ek = EntityKey.deserialize( ois, session );
- Object proxy = ois.readObject();
- if ( proxy instanceof HibernateProxy ) {
- ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().setSession( session );
- rtn.proxiesByKey.put( ek, proxy );
- }
- else {
- log.trace( "encountered prunded proxy" );
- }
- // otherwise, the proxy was pruned during the serialization process
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] entitySnapshotsByKey entries" );
- rtn.entitySnapshotsByKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- rtn.entitySnapshotsByKey.put( EntityKey.deserialize( ois, session ), ois.readObject() );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] entityEntries entries" );
- rtn.entityEntries = IdentityMap.instantiateSequenced( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- Object entity = ois.readObject();
- EntityEntry entry = EntityEntry.deserialize( ois, session );
- rtn.entityEntries.put( entity, entry );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] collectionsByKey entries" );
- rtn.collectionsByKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- rtn.collectionsByKey.put( CollectionKey.deserialize( ois, session ), ois.readObject() );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] collectionEntries entries" );
- rtn.collectionEntries = IdentityMap.instantiateSequenced( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- final PersistentCollection pc = ( PersistentCollection ) ois.readObject();
- final CollectionEntry ce = CollectionEntry.deserialize( ois, session );
- pc.setCurrentSession( session );
- rtn.collectionEntries.put( pc, ce );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] arrayHolders entries" );
- rtn.arrayHolders = IdentityMap.instantiate( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
- for ( int i = 0; i < count; i++ ) {
- rtn.arrayHolders.put( ois.readObject(), ois.readObject() );
- }
-
- count = ois.readInt();
- log.trace( "staring deserialization of [" + count + "] nullifiableEntityKeys entries" );
- rtn.nullifiableEntityKeys = new HashSet();
- for ( int i = 0; i < count; i++ ) {
- rtn.nullifiableEntityKeys.add( EntityKey.deserialize( ois, session ) );
- }
-
- }
- catch ( HibernateException he ) {
- throw new InvalidObjectException( he.getMessage() );
- }
-
- return rtn;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/StatefulPersistenceContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,1486 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.collections.map.ReferenceMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.AssertionFailure;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.MappingException;
+import org.hibernate.NonUniqueObjectException;
+import org.hibernate.PersistentObjectException;
+import org.hibernate.TransientObjectException;
+import org.hibernate.engine.loading.LoadContexts;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.proxy.HibernateProxy;
+import org.hibernate.proxy.LazyInitializer;
+import org.hibernate.tuple.ElementWrapper;
+import org.hibernate.util.IdentityMap;
+import org.hibernate.util.MarkerObject;
+
+/**
+ * A <tt>PersistenceContext</tt> represents the state of persistent "stuff" which
+ * Hibernate is tracking. This includes persistent entities, collections,
+ * as well as proxies generated.
+ * </p>
+ * There is meant to be a one-to-one correspondence between a SessionImpl and
+ * a PersistentContext. The SessionImpl uses the PersistentContext to track
+ * the current state of its context. Event-listeners then use the
+ * PersistentContext to drive their processing.
+ *
+ * @author Steve Ebersole
+ */
+public class StatefulPersistenceContext implements PersistenceContext {
+
+ public static final Object NO_ROW = new MarkerObject( "NO_ROW" );
+
+ private static final Logger log = LoggerFactory.getLogger( StatefulPersistenceContext.class );
+ private static final Logger PROXY_WARN_LOG = LoggerFactory.getLogger( StatefulPersistenceContext.class.getName() + ".ProxyWarnLog" );
+ private static final int INIT_COLL_SIZE = 8;
+
+ private SessionImplementor session;
+
+ // Loaded entity instances, by EntityKey
+ private Map entitiesByKey;
+
+ // Loaded entity instances, by EntityUniqueKey
+ private Map entitiesByUniqueKey;
+
+ // Identity map of EntityEntry instances, by the entity instance
+ private Map entityEntries;
+
+ // Entity proxies, by EntityKey
+ private Map proxiesByKey;
+
+ // Snapshots of current database state for entities
+ // that have *not* been loaded
+ private Map entitySnapshotsByKey;
+
+ // Identity map of array holder ArrayHolder instances, by the array instance
+ private Map arrayHolders;
+
+ // Identity map of CollectionEntry instances, by the collection wrapper
+ private Map collectionEntries;
+
+ // Collection wrappers, by the CollectionKey
+ private Map collectionsByKey; //key=CollectionKey, value=PersistentCollection
+
+ // Set of EntityKeys of deleted objects
+ private HashSet nullifiableEntityKeys;
+
+ // properties that we have tried to load, and not found in the database
+ private HashSet nullAssociations;
+
+ // A list of collection wrappers that were instantiating during result set
+ // processing, that we will need to initialize at the end of the query
+ private List nonlazyCollections;
+
+ // A container for collections we load up when the owning entity is not
+ // yet loaded ... for now, this is purely transient!
+ private Map unownedCollections;
+
+ private int cascading = 0;
+ private int loadCounter = 0;
+ private boolean flushing = false;
+
+ private boolean hasNonReadOnlyEntities = false;
+
+ private LoadContexts loadContexts;
+ private BatchFetchQueue batchFetchQueue;
+
+
+
+ /**
+ * Constructs a PersistentContext, bound to the given session.
+ *
+ * @param session The session "owning" this context.
+ */
+ public StatefulPersistenceContext(SessionImplementor session) {
+ this.session = session;
+
+ entitiesByKey = new HashMap( INIT_COLL_SIZE );
+ entitiesByUniqueKey = new HashMap( INIT_COLL_SIZE );
+ proxiesByKey = new ReferenceMap( ReferenceMap.HARD, ReferenceMap.WEAK );
+ entitySnapshotsByKey = new HashMap( INIT_COLL_SIZE );
+
+ entityEntries = IdentityMap.instantiateSequenced( INIT_COLL_SIZE );
+ collectionEntries = IdentityMap.instantiateSequenced( INIT_COLL_SIZE );
+ collectionsByKey = new HashMap( INIT_COLL_SIZE );
+ arrayHolders = IdentityMap.instantiate( INIT_COLL_SIZE );
+
+ nullifiableEntityKeys = new HashSet();
+
+ initTransientState();
+ }
+
+ private void initTransientState() {
+ nullAssociations = new HashSet( INIT_COLL_SIZE );
+ nonlazyCollections = new ArrayList( INIT_COLL_SIZE );
+ }
+
+ public boolean isStateless() {
+ return false;
+ }
+
+ public SessionImplementor getSession() {
+ return session;
+ }
+
+ public LoadContexts getLoadContexts() {
+ if ( loadContexts == null ) {
+ loadContexts = new LoadContexts( this );
+ }
+ return loadContexts;
+ }
+
+ public void addUnownedCollection(CollectionKey key, PersistentCollection collection) {
+ if (unownedCollections==null) {
+ unownedCollections = new HashMap(8);
+ }
+ unownedCollections.put(key, collection);
+ }
+
+ public PersistentCollection useUnownedCollection(CollectionKey key) {
+ if (unownedCollections==null) {
+ return null;
+ }
+ else {
+ return (PersistentCollection) unownedCollections.remove(key);
+ }
+ }
+
+ /**
+ * Get the <tt>BatchFetchQueue</tt>, instantiating one if
+ * necessary.
+ */
+ public BatchFetchQueue getBatchFetchQueue() {
+ if (batchFetchQueue==null) {
+ batchFetchQueue = new BatchFetchQueue(this);
+ }
+ return batchFetchQueue;
+ }
+
+ public void clear() {
+ Iterator itr = proxiesByKey.values().iterator();
+ while ( itr.hasNext() ) {
+ final LazyInitializer li = ( ( HibernateProxy ) itr.next() ).getHibernateLazyInitializer();
+ li.setSession( null );
+ }
+ Map.Entry[] collectionEntryArray = IdentityMap.concurrentEntries( collectionEntries );
+ for ( int i = 0; i < collectionEntryArray.length; i++ ) {
+ ( ( PersistentCollection ) collectionEntryArray[i].getKey() ).unsetSession( getSession() );
+ }
+ arrayHolders.clear();
+ entitiesByKey.clear();
+ entitiesByUniqueKey.clear();
+ entityEntries.clear();
+ entitySnapshotsByKey.clear();
+ collectionsByKey.clear();
+ collectionEntries.clear();
+ if ( unownedCollections != null ) {
+ unownedCollections.clear();
+ }
+ proxiesByKey.clear();
+ nullifiableEntityKeys.clear();
+ if ( batchFetchQueue != null ) {
+ batchFetchQueue.clear();
+ }
+ hasNonReadOnlyEntities = false;
+ if ( loadContexts != null ) {
+ loadContexts.cleanup();
+ }
+ }
+
+ public boolean hasNonReadOnlyEntities() {
+ return hasNonReadOnlyEntities;
+ }
+
+ public void setEntryStatus(EntityEntry entry, Status status) {
+ entry.setStatus(status);
+ setHasNonReadOnlyEnties(status);
+ }
+
+ private void setHasNonReadOnlyEnties(Status status) {
+ if ( status==Status.DELETED || status==Status.MANAGED || status==Status.SAVING ) {
+ hasNonReadOnlyEntities = true;
+ }
+ }
+
+ public void afterTransactionCompletion() {
+ // Downgrade locks
+ Iterator iter = entityEntries.values().iterator();
+ while ( iter.hasNext() ) {
+ ( (EntityEntry) iter.next() ).setLockMode(LockMode.NONE);
+ }
+ }
+
+ /**
+ * Get the current state of the entity as known to the underlying
+ * database, or null if there is no corresponding row
+ */
+ public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister)
+ throws HibernateException {
+ EntityKey key = new EntityKey( id, persister, session.getEntityMode() );
+ Object cached = entitySnapshotsByKey.get(key);
+ if (cached!=null) {
+ return cached==NO_ROW ? null : (Object[]) cached;
+ }
+ else {
+ Object[] snapshot = persister.getDatabaseSnapshot( id, session );
+ entitySnapshotsByKey.put( key, snapshot==null ? NO_ROW : snapshot );
+ return snapshot;
+ }
+ }
+
+ public Object[] getNaturalIdSnapshot(Serializable id, EntityPersister persister)
+ throws HibernateException {
+ if ( !persister.hasNaturalIdentifier() ) {
+ return null;
+ }
+
+ // if the natural-id is marked as non-mutable, it is not retrieved during a
+ // normal database-snapshot operation...
+ int[] props = persister.getNaturalIdentifierProperties();
+ boolean[] updateable = persister.getPropertyUpdateability();
+ boolean allNatualIdPropsAreUpdateable = true;
+ for ( int i = 0; i < props.length; i++ ) {
+ if ( !updateable[ props[i] ] ) {
+ allNatualIdPropsAreUpdateable = false;
+ break;
+ }
+ }
+
+ if ( allNatualIdPropsAreUpdateable ) {
+ // do this when all the properties are updateable since there is
+ // a certain likelihood that the information will already be
+ // snapshot-cached.
+ Object[] entitySnapshot = getDatabaseSnapshot( id, persister );
+ if ( entitySnapshot == NO_ROW ) {
+ return null;
+ }
+ Object[] naturalIdSnapshot = new Object[ props.length ];
+ for ( int i = 0; i < props.length; i++ ) {
+ naturalIdSnapshot[i] = entitySnapshot[ props[i] ];
+ }
+ return naturalIdSnapshot;
+ }
+ else {
+ return persister.getNaturalIdentifierSnapshot( id, session );
+ }
+ }
+
+ /**
+ * Retrieve the cached database snapshot for the requested entity key.
+ * <p/>
+ * This differs from {@link #getDatabaseSnapshot} is two important respects:<ol>
+ * <li>no snapshot is obtained from the database if not already cached</li>
+ * <li>an entry of {@link #NO_ROW} here is interpretet as an exception</li>
+ * </ol>
+ * @param key The entity key for which to retrieve the cached snapshot
+ * @return The cached snapshot
+ * @throws IllegalStateException if the cached snapshot was == {@link #NO_ROW}.
+ */
+ public Object[] getCachedDatabaseSnapshot(EntityKey key) {
+ Object snapshot = entitySnapshotsByKey.get( key );
+ if ( snapshot == NO_ROW ) {
+ throw new IllegalStateException( "persistence context reported no row snapshot for " + MessageHelper.infoString( key.getEntityName(), key.getIdentifier() ) );
+ }
+ return ( Object[] ) snapshot;
+ }
+
+ /*public void removeDatabaseSnapshot(EntityKey key) {
+ entitySnapshotsByKey.remove(key);
+ }*/
+
+ public void addEntity(EntityKey key, Object entity) {
+ entitiesByKey.put(key, entity);
+ getBatchFetchQueue().removeBatchLoadableEntityKey(key);
+ }
+
+ /**
+ * Get the entity instance associated with the given
+ * <tt>EntityKey</tt>
+ */
+ public Object getEntity(EntityKey key) {
+ return entitiesByKey.get(key);
+ }
+
+ public boolean containsEntity(EntityKey key) {
+ return entitiesByKey.containsKey(key);
+ }
+
+ /**
+ * Remove an entity from the session cache, also clear
+ * up other state associated with the entity, all except
+ * for the <tt>EntityEntry</tt>
+ */
+ public Object removeEntity(EntityKey key) {
+ Object entity = entitiesByKey.remove(key);
+ Iterator iter = entitiesByUniqueKey.values().iterator();
+ while ( iter.hasNext() ) {
+ if ( iter.next()==entity ) iter.remove();
+ }
+ entitySnapshotsByKey.remove(key);
+ nullifiableEntityKeys.remove(key);
+ getBatchFetchQueue().removeBatchLoadableEntityKey(key);
+ getBatchFetchQueue().removeSubselect(key);
+ return entity;
+ }
+
+ /**
+ * Get an entity cached by unique key
+ */
+ public Object getEntity(EntityUniqueKey euk) {
+ return entitiesByUniqueKey.get(euk);
+ }
+
+ /**
+ * Add an entity to the cache by unique key
+ */
+ public void addEntity(EntityUniqueKey euk, Object entity) {
+ entitiesByUniqueKey.put(euk, entity);
+ }
+
+ /**
+ * Retreive the EntityEntry representation of the given entity.
+ *
+ * @param entity The entity for which to locate the EntityEntry.
+ * @return The EntityEntry for the given entity.
+ */
+ public EntityEntry getEntry(Object entity) {
+ return (EntityEntry) entityEntries.get(entity);
+ }
+
+ /**
+ * Remove an entity entry from the session cache
+ */
+ public EntityEntry removeEntry(Object entity) {
+ return (EntityEntry) entityEntries.remove(entity);
+ }
+
+ /**
+ * Is there an EntityEntry for this instance?
+ */
+ public boolean isEntryFor(Object entity) {
+ return entityEntries.containsKey(entity);
+ }
+
+ /**
+ * Get the collection entry for a persistent collection
+ */
+ public CollectionEntry getCollectionEntry(PersistentCollection coll) {
+ return (CollectionEntry) collectionEntries.get(coll);
+ }
+
+ /**
+ * Adds an entity to the internal caches.
+ */
+ public EntityEntry addEntity(
+ final Object entity,
+ final Status status,
+ final Object[] loadedState,
+ final EntityKey entityKey,
+ final Object version,
+ final LockMode lockMode,
+ final boolean existsInDatabase,
+ final EntityPersister persister,
+ final boolean disableVersionIncrement,
+ boolean lazyPropertiesAreUnfetched
+ ) {
+
+ addEntity( entityKey, entity );
+
+ return addEntry(
+ entity,
+ status,
+ loadedState,
+ null,
+ entityKey.getIdentifier(),
+ version,
+ lockMode,
+ existsInDatabase,
+ persister,
+ disableVersionIncrement,
+ lazyPropertiesAreUnfetched
+ );
+ }
+
+
+ /**
+ * Generates an appropriate EntityEntry instance and adds it
+ * to the event source's internal caches.
+ */
+ public EntityEntry addEntry(
+ final Object entity,
+ final Status status,
+ final Object[] loadedState,
+ final Object rowId,
+ final Serializable id,
+ final Object version,
+ final LockMode lockMode,
+ final boolean existsInDatabase,
+ final EntityPersister persister,
+ final boolean disableVersionIncrement,
+ boolean lazyPropertiesAreUnfetched) {
+
+ EntityEntry e = new EntityEntry(
+ status,
+ loadedState,
+ rowId,
+ id,
+ version,
+ lockMode,
+ existsInDatabase,
+ persister,
+ session.getEntityMode(),
+ disableVersionIncrement,
+ lazyPropertiesAreUnfetched
+ );
+ entityEntries.put(entity, e);
+
+ setHasNonReadOnlyEnties(status);
+ return e;
+ }
+
+ public boolean containsCollection(PersistentCollection collection) {
+ return collectionEntries.containsKey(collection);
+ }
+
+ public boolean containsProxy(Object entity) {
+ return proxiesByKey.containsValue( entity );
+ }
+
+ /**
+ * Takes the given object and, if it represents a proxy, reassociates it with this event source.
+ *
+ * @param value The possible proxy to be reassociated.
+ * @return Whether the passed value represented an actual proxy which got initialized.
+ * @throws MappingException
+ */
+ public boolean reassociateIfUninitializedProxy(Object value) throws MappingException {
+ if ( value instanceof ElementWrapper ) {
+ value = ( (ElementWrapper) value ).getElement();
+ }
+
+ if ( !Hibernate.isInitialized(value) ) {
+ HibernateProxy proxy = (HibernateProxy) value;
+ LazyInitializer li = proxy.getHibernateLazyInitializer();
+ reassociateProxy(li, proxy);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * If a deleted entity instance is re-saved, and it has a proxy, we need to
+ * reset the identifier of the proxy
+ */
+ public void reassociateProxy(Object value, Serializable id) throws MappingException {
+ if ( value instanceof ElementWrapper ) {
+ value = ( (ElementWrapper) value ).getElement();
+ }
+
+ if ( value instanceof HibernateProxy ) {
+ if ( log.isDebugEnabled() ) log.debug("setting proxy identifier: " + id);
+ HibernateProxy proxy = (HibernateProxy) value;
+ LazyInitializer li = proxy.getHibernateLazyInitializer();
+ li.setIdentifier(id);
+ reassociateProxy(li, proxy);
+ }
+ }
+
+ /**
+ * Associate a proxy that was instantiated by another session with this session
+ *
+ * @param li The proxy initializer.
+ * @param proxy The proxy to reassociate.
+ */
+ private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
+ if ( li.getSession() != this.getSession() ) {
+ EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() );
+ EntityKey key = new EntityKey( li.getIdentifier(), persister, session.getEntityMode() );
+ // any earlier proxy takes precedence
+ if ( !proxiesByKey.containsKey( key ) ) {
+ proxiesByKey.put( key, proxy );
+ }
+ proxy.getHibernateLazyInitializer().setSession( session );
+ }
+ }
+
+ /**
+ * Get the entity instance underlying the given proxy, throwing
+ * an exception if the proxy is uninitialized. If the given object
+ * is not a proxy, simply return the argument.
+ */
+ public Object unproxy(Object maybeProxy) throws HibernateException {
+ if ( maybeProxy instanceof ElementWrapper ) {
+ maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
+ }
+
+ if ( maybeProxy instanceof HibernateProxy ) {
+ HibernateProxy proxy = (HibernateProxy) maybeProxy;
+ LazyInitializer li = proxy.getHibernateLazyInitializer();
+ if ( li.isUninitialized() ) {
+ throw new PersistentObjectException(
+ "object was an uninitialized proxy for " +
+ li.getEntityName()
+ );
+ }
+ return li.getImplementation(); //unwrap the object
+ }
+ else {
+ return maybeProxy;
+ }
+ }
+
+ /**
+ * Possibly unproxy the given reference and reassociate it with the current session.
+ *
+ * @param maybeProxy The reference to be unproxied if it currently represents a proxy.
+ * @return The unproxied instance.
+ * @throws HibernateException
+ */
+ public Object unproxyAndReassociate(Object maybeProxy) throws HibernateException {
+ if ( maybeProxy instanceof ElementWrapper ) {
+ maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
+ }
+
+ if ( maybeProxy instanceof HibernateProxy ) {
+ HibernateProxy proxy = (HibernateProxy) maybeProxy;
+ LazyInitializer li = proxy.getHibernateLazyInitializer();
+ reassociateProxy(li, proxy);
+ return li.getImplementation(); //initialize + unwrap the object
+ }
+ else {
+ return maybeProxy;
+ }
+ }
+
+ /**
+ * Attempts to check whether the given key represents an entity already loaded within the
+ * current session.
+ * @param object The entity reference against which to perform the uniqueness check.
+ * @throws HibernateException
+ */
+ public void checkUniqueness(EntityKey key, Object object) throws HibernateException {
+ Object entity = getEntity(key);
+ if ( entity == object ) {
+ throw new AssertionFailure( "object already associated, but no entry was found" );
+ }
+ if ( entity != null ) {
+ throw new NonUniqueObjectException( key.getIdentifier(), key.getEntityName() );
+ }
+ }
+
+ /**
+ * If the existing proxy is insufficiently "narrow" (derived), instantiate a new proxy
+ * and overwrite the registration of the old one. This breaks == and occurs only for
+ * "class" proxies rather than "interface" proxies. Also init the proxy to point to
+ * the given target implementation if necessary.
+ *
+ * @param proxy The proxy instance to be narrowed.
+ * @param persister The persister for the proxied entity.
+ * @param key The internal cache key for the proxied entity.
+ * @param object (optional) the actual proxied entity instance.
+ * @return An appropriately narrowed instance.
+ * @throws HibernateException
+ */
+ public Object narrowProxy(Object proxy, EntityPersister persister, EntityKey key, Object object)
+ throws HibernateException {
+
+ boolean alreadyNarrow = persister.getConcreteProxyClass( session.getEntityMode() )
+ .isAssignableFrom( proxy.getClass() );
+
+ if ( !alreadyNarrow ) {
+ if ( PROXY_WARN_LOG.isWarnEnabled() ) {
+ PROXY_WARN_LOG.warn(
+ "Narrowing proxy to " +
+ persister.getConcreteProxyClass( session.getEntityMode() ) +
+ " - this operation breaks =="
+ );
+ }
+
+ if ( object != null ) {
+ proxiesByKey.remove(key);
+ return object; //return the proxied object
+ }
+ else {
+ proxy = persister.createProxy( key.getIdentifier(), session );
+ proxiesByKey.put(key, proxy); //overwrite old proxy
+ return proxy;
+ }
+
+ }
+ else {
+
+ if ( object != null ) {
+ LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
+ li.setImplementation(object);
+ }
+
+ return proxy;
+
+ }
+
+ }
+
+ /**
+ * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
+ * third argument (the entity associated with the key) if no proxy exists. Init
+ * the proxy to the target implementation, if necessary.
+ */
+ public Object proxyFor(EntityPersister persister, EntityKey key, Object impl)
+ throws HibernateException {
+ if ( !persister.hasProxy() ) return impl;
+ Object proxy = proxiesByKey.get(key);
+ if ( proxy != null ) {
+ return narrowProxy(proxy, persister, key, impl);
+ }
+ else {
+ return impl;
+ }
+ }
+
+ /**
+ * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the
+ * argument (the entity associated with the key) if no proxy exists.
+ * (slower than the form above)
+ */
+ public Object proxyFor(Object impl) throws HibernateException {
+ EntityEntry e = getEntry(impl);
+ EntityPersister p = e.getPersister();
+ return proxyFor( p, new EntityKey( e.getId(), p, session.getEntityMode() ), impl );
+ }
+
+ /**
+ * Get the entity that owns this persistent collection
+ */
+ public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException {
+ return getEntity( new EntityKey( key, collectionPersister.getOwnerEntityPersister(), session.getEntityMode() ) );
+ }
+
+ /**
+ * Get the entity that owned this persistent collection when it was loaded
+ *
+ * @param collection The persistent collection
+ * @return the owner, if its entity ID is available from the collection's loaded key
+ * and the owner entity is in the persistence context; otherwise, returns null
+ */
+ public Object getLoadedCollectionOwnerOrNull(PersistentCollection collection) {
+ CollectionEntry ce = getCollectionEntry( collection );
+ if ( ce.getLoadedPersister() == null ) {
+ return null; // early exit...
+ }
+ Object loadedOwner = null;
+ // TODO: an alternative is to check if the owner has changed; if it hasn't then
+ // return collection.getOwner()
+ Serializable entityId = getLoadedCollectionOwnerIdOrNull( ce );
+ if ( entityId != null ) {
+ loadedOwner = getCollectionOwner( entityId, ce.getLoadedPersister() );
+ }
+ return loadedOwner;
+ }
+
+ /**
+ * Get the ID for the entity that owned this persistent collection when it was loaded
+ *
+ * @param collection The persistent collection
+ * @return the owner ID if available from the collection's loaded key; otherwise, returns null
+ */
+ public Serializable getLoadedCollectionOwnerIdOrNull(PersistentCollection collection) {
+ return getLoadedCollectionOwnerIdOrNull( getCollectionEntry( collection ) );
+ }
+
+ /**
+ * Get the ID for the entity that owned this persistent collection when it was loaded
+ *
+ * @param ce The collection entry
+ * @return the owner ID if available from the collection's loaded key; otherwise, returns null
+ */
+ private Serializable getLoadedCollectionOwnerIdOrNull(CollectionEntry ce) {
+ if ( ce == null || ce.getLoadedKey() == null || ce.getLoadedPersister() == null ) {
+ return null;
+ }
+ // TODO: an alternative is to check if the owner has changed; if it hasn't then
+ // get the ID from collection.getOwner()
+ return ce.getLoadedPersister().getCollectionType().getIdOfOwnerOrNull( ce.getLoadedKey(), session );
+ }
+
+ /**
+ * add a collection we just loaded up (still needs initializing)
+ */
+ public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) {
+ CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing);
+ addCollection(collection, ce, id);
+ }
+
+ /**
+ * add a detached uninitialized collection
+ */
+ public void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection) {
+ CollectionEntry ce = new CollectionEntry( persister, collection.getKey() );
+ addCollection( collection, ce, collection.getKey() );
+ }
+
+ /**
+ * Add a new collection (ie. a newly created one, just instantiated by the
+ * application, with no database state or snapshot)
+ * @param collection The collection to be associated with the persistence context
+ */
+ public void addNewCollection(CollectionPersister persister, PersistentCollection collection)
+ throws HibernateException {
+ addCollection(collection, persister);
+ }
+
+ /**
+ * Add an collection to the cache, with a given collection entry.
+ *
+ * @param coll The collection for which we are adding an entry.
+ * @param entry The entry representing the collection.
+ * @param key The key of the collection's entry.
+ */
+ private void addCollection(PersistentCollection coll, CollectionEntry entry, Serializable key) {
+ collectionEntries.put( coll, entry );
+ CollectionKey collectionKey = new CollectionKey( entry.getLoadedPersister(), key, session.getEntityMode() );
+ PersistentCollection old = ( PersistentCollection ) collectionsByKey.put( collectionKey, coll );
+ if ( old != null ) {
+ if ( old == coll ) {
+ throw new AssertionFailure("bug adding collection twice");
+ }
+ // or should it actually throw an exception?
+ old.unsetSession( session );
+ collectionEntries.remove( old );
+ // watch out for a case where old is still referenced
+ // somewhere in the object graph! (which is a user error)
+ }
+ }
+
+ /**
+ * Add a collection to the cache, creating a new collection entry for it
+ *
+ * @param collection The collection for which we are adding an entry.
+ * @param persister The collection persister
+ */
+ private void addCollection(PersistentCollection collection, CollectionPersister persister) {
+ CollectionEntry ce = new CollectionEntry( persister, collection );
+ collectionEntries.put( collection, ce );
+ }
+
+ /**
+ * add an (initialized) collection that was created by another session and passed
+ * into update() (ie. one with a snapshot and existing state on the database)
+ */
+ public void addInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection)
+ throws HibernateException {
+ if ( collection.isUnreferenced() ) {
+ //treat it just like a new collection
+ addCollection( collection, collectionPersister );
+ }
+ else {
+ CollectionEntry ce = new CollectionEntry( collection, session.getFactory() );
+ addCollection( collection, ce, collection.getKey() );
+ }
+ }
+
+ /**
+ * add a collection we just pulled out of the cache (does not need initializing)
+ */
+ public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
+ throws HibernateException {
+ CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing);
+ ce.postInitialize(collection);
+ addCollection(collection, ce, id);
+ return ce;
+ }
+
+ /**
+ * Get the collection instance associated with the <tt>CollectionKey</tt>
+ */
+ public PersistentCollection getCollection(CollectionKey collectionKey) {
+ return (PersistentCollection) collectionsByKey.get(collectionKey);
+ }
+
+ /**
+ * Register a collection for non-lazy loading at the end of the
+ * two-phase load
+ */
+ public void addNonLazyCollection(PersistentCollection collection) {
+ nonlazyCollections.add(collection);
+ }
+
+ /**
+ * Force initialization of all non-lazy collections encountered during
+ * the current two-phase load (actually, this is a no-op, unless this
+ * is the "outermost" load)
+ */
+ public void initializeNonLazyCollections() throws HibernateException {
+ if ( loadCounter == 0 ) {
+ log.debug( "initializing non-lazy collections" );
+ //do this work only at the very highest level of the load
+ loadCounter++; //don't let this method be called recursively
+ try {
+ int size;
+ while ( ( size = nonlazyCollections.size() ) > 0 ) {
+ //note that each iteration of the loop may add new elements
+ ( (PersistentCollection) nonlazyCollections.remove( size - 1 ) ).forceInitialization();
+ }
+ }
+ finally {
+ loadCounter--;
+ clearNullProperties();
+ }
+ }
+ }
+
+
+ /**
+ * Get the <tt>PersistentCollection</tt> object for an array
+ */
+ public PersistentCollection getCollectionHolder(Object array) {
+ return (PersistentCollection) arrayHolders.get(array);
+ }
+
+ /**
+ * Register a <tt>PersistentCollection</tt> object for an array.
+ * Associates a holder with an array - MUST be called after loading
+ * array, since the array instance is not created until endLoad().
+ */
+ public void addCollectionHolder(PersistentCollection holder) {
+ //TODO:refactor + make this method private
+ arrayHolders.put( holder.getValue(), holder );
+ }
+
+ public PersistentCollection removeCollectionHolder(Object array) {
+ return (PersistentCollection) arrayHolders.remove(array);
+ }
+
+ /**
+ * Get the snapshot of the pre-flush collection state
+ */
+ public Serializable getSnapshot(PersistentCollection coll) {
+ return getCollectionEntry(coll).getSnapshot();
+ }
+
+ /**
+ * Get the collection entry for a collection passed to filter,
+ * which might be a collection wrapper, an array, or an unwrapped
+ * collection. Return null if there is no entry.
+ */
+ public CollectionEntry getCollectionEntryOrNull(Object collection) {
+ PersistentCollection coll;
+ if ( collection instanceof PersistentCollection ) {
+ coll = (PersistentCollection) collection;
+ //if (collection==null) throw new TransientObjectException("Collection was not yet persistent");
+ }
+ else {
+ coll = getCollectionHolder(collection);
+ if ( coll == null ) {
+ //it might be an unwrapped collection reference!
+ //try to find a wrapper (slowish)
+ Iterator wrappers = IdentityMap.keyIterator(collectionEntries);
+ while ( wrappers.hasNext() ) {
+ PersistentCollection pc = (PersistentCollection) wrappers.next();
+ if ( pc.isWrapper(collection) ) {
+ coll = pc;
+ break;
+ }
+ }
+ }
+ }
+
+ return (coll == null) ? null : getCollectionEntry(coll);
+ }
+
+ /**
+ * Get an existing proxy by key
+ */
+ public Object getProxy(EntityKey key) {
+ return proxiesByKey.get(key);
+ }
+
+ /**
+ * Add a proxy to the session cache
+ */
+ public void addProxy(EntityKey key, Object proxy) {
+ proxiesByKey.put(key, proxy);
+ }
+
+ /**
+ * Remove a proxy from the session cache.
+ * <p/>
+ * Additionally, ensure that any load optimization references
+ * such as batch or subselect loading get cleaned up as well.
+ *
+ * @param key The key of the entity proxy to be removed
+ * @return The proxy reference.
+ */
+ public Object removeProxy(EntityKey key) {
+ if ( batchFetchQueue != null ) {
+ batchFetchQueue.removeBatchLoadableEntityKey( key );
+ batchFetchQueue.removeSubselect( key );
+ }
+ return proxiesByKey.remove( key );
+ }
+
+ /**
+ * Record the fact that an entity does not exist in the database
+ *
+ * @param key the primary key of the entity
+ */
+ /*public void addNonExistantEntityKey(EntityKey key) {
+ nonExistantEntityKeys.add(key);
+ }*/
+
+ /**
+ * Record the fact that an entity does not exist in the database
+ *
+ * @param key a unique key of the entity
+ */
+ /*public void addNonExistantEntityUniqueKey(EntityUniqueKey key) {
+ nonExistentEntityUniqueKeys.add(key);
+ }*/
+
+ /*public void removeNonExist(EntityKey key) {
+ nonExistantEntityKeys.remove(key);
+ }*/
+
+ /**
+ * Retrieve the set of EntityKeys representing nullifiable references
+ */
+ public HashSet getNullifiableEntityKeys() {
+ return nullifiableEntityKeys;
+ }
+
+ public Map getEntitiesByKey() {
+ return entitiesByKey;
+ }
+
+ public Map getEntityEntries() {
+ return entityEntries;
+ }
+
+ public Map getCollectionEntries() {
+ return collectionEntries;
+ }
+
+ public Map getCollectionsByKey() {
+ return collectionsByKey;
+ }
+
+ /**
+ * Do we already know that the entity does not exist in the
+ * database?
+ */
+ /*public boolean isNonExistant(EntityKey key) {
+ return nonExistantEntityKeys.contains(key);
+ }*/
+
+ /**
+ * Do we already know that the entity does not exist in the
+ * database?
+ */
+ /*public boolean isNonExistant(EntityUniqueKey key) {
+ return nonExistentEntityUniqueKeys.contains(key);
+ }*/
+
+ public int getCascadeLevel() {
+ return cascading;
+ }
+
+ public int incrementCascadeLevel() {
+ return ++cascading;
+ }
+
+ public int decrementCascadeLevel() {
+ return --cascading;
+ }
+
+ public boolean isFlushing() {
+ return flushing;
+ }
+
+ public void setFlushing(boolean flushing) {
+ this.flushing = flushing;
+ }
+
+ /**
+ * Call this before begining a two-phase load
+ */
+ public void beforeLoad() {
+ loadCounter++;
+ }
+
+ /**
+ * Call this after finishing a two-phase load
+ */
+ public void afterLoad() {
+ loadCounter--;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return a string representation of the object.
+ */
+ public String toString() {
+ return new StringBuffer()
+ .append("PersistenceContext[entityKeys=")
+ .append(entitiesByKey.keySet())
+ .append(",collectionKeys=")
+ .append(collectionsByKey.keySet())
+ .append("]")
+ .toString();
+ }
+
+ /**
+ * Search <tt>this</tt> persistence context for an associated entity instance which is considered the "owner" of
+ * the given <tt>childEntity</tt>, and return that owner's id value. This is performed in the scenario of a
+ * uni-directional, non-inverse one-to-many collection (which means that the collection elements do not maintain
+ * a direct reference to the owner).
+ * <p/>
+ * As such, the processing here is basically to loop over every entity currently associated with this persistence
+ * context and for those of the correct entity (sub) type to extract its collection role property value and see
+ * if the child is contained within that collection. If so, we have found the owner; if not, we go on.
+ * <p/>
+ * Also need to account for <tt>mergeMap</tt> which acts as a local copy cache managed for the duration of a merge
+ * operation. It represents a map of the detached entity instances pointing to the corresponding managed instance.
+ *
+ * @param entityName The entity name for the entity type which would own the child
+ * @param propertyName The name of the property on the owning entity type which would name this child association.
+ * @param childEntity The child entity instance for which to locate the owner instance id.
+ * @param mergeMap A map of non-persistent instances from an on-going merge operation (possibly null).
+ *
+ * @return The id of the entityName instance which is said to own the child; null if an appropriate owner not
+ * located.
+ */
+ public Serializable getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap) {
+ final String collectionRole = entityName + '.' + propertyName;
+ final EntityPersister persister = session.getFactory().getEntityPersister( entityName );
+ final CollectionPersister collectionPersister = session.getFactory().getCollectionPersister( collectionRole );
+
+ // iterate all the entities currently associated with the persistence context.
+ Iterator entities = entityEntries.entrySet().iterator();
+ while ( entities.hasNext() ) {
+ final Map.Entry me = ( Map.Entry ) entities.next();
+ final EntityEntry entityEntry = ( EntityEntry ) me.getValue();
+ // does this entity entry pertain to the entity persister in which we are interested (owner)?
+ if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) {
+ final Object entityEntryInstance = me.getKey();
+
+ //check if the managed object is the parent
+ boolean found = isFoundInParent(
+ propertyName,
+ childEntity,
+ persister,
+ collectionPersister,
+ entityEntryInstance
+ );
+
+ if ( !found && mergeMap != null ) {
+ //check if the detached object being merged is the parent
+ Object unmergedInstance = mergeMap.get( entityEntryInstance );
+ Object unmergedChild = mergeMap.get( childEntity );
+ if ( unmergedInstance != null && unmergedChild != null ) {
+ found = isFoundInParent(
+ propertyName,
+ unmergedChild,
+ persister,
+ collectionPersister,
+ unmergedInstance
+ );
+ }
+ }
+
+ if ( found ) {
+ return entityEntry.getId();
+ }
+
+ }
+ }
+
+ // if we get here, it is possible that we have a proxy 'in the way' of the merge map resolution...
+ // NOTE: decided to put this here rather than in the above loop as I was nervous about the performance
+ // of the loop-in-loop especially considering this is far more likely the 'edge case'
+ if ( mergeMap != null ) {
+ Iterator mergeMapItr = mergeMap.entrySet().iterator();
+ while ( mergeMapItr.hasNext() ) {
+ final Map.Entry mergeMapEntry = ( Map.Entry ) mergeMapItr.next();
+ if ( mergeMapEntry.getKey() instanceof HibernateProxy ) {
+ final HibernateProxy proxy = ( HibernateProxy ) mergeMapEntry.getKey();
+ if ( persister.isSubclassEntityName( proxy.getHibernateLazyInitializer().getEntityName() ) ) {
+ boolean found = isFoundInParent(
+ propertyName,
+ childEntity,
+ persister,
+ collectionPersister,
+ mergeMap.get( proxy )
+ );
+ if ( !found ) {
+ found = isFoundInParent(
+ propertyName,
+ mergeMap.get( childEntity ),
+ persister,
+ collectionPersister,
+ mergeMap.get( proxy )
+ );
+ }
+ if ( found ) {
+ return proxy.getHibernateLazyInitializer().getIdentifier();
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private boolean isFoundInParent(
+ String property,
+ Object childEntity,
+ EntityPersister persister,
+ CollectionPersister collectionPersister,
+ Object potentialParent) {
+ Object collection = persister.getPropertyValue(
+ potentialParent,
+ property,
+ session.getEntityMode()
+ );
+ return collection != null
+ && Hibernate.isInitialized( collection )
+ && collectionPersister.getCollectionType().contains( collection, childEntity, session );
+ }
+
+ /**
+ * Search the persistence context for an index of the child object,
+ * given a collection role
+ */
+ public Object getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap) {
+
+ EntityPersister persister = session.getFactory()
+ .getEntityPersister(entity);
+ CollectionPersister cp = session.getFactory()
+ .getCollectionPersister(entity + '.' + property);
+ Iterator entities = entityEntries.entrySet().iterator();
+ while ( entities.hasNext() ) {
+ Map.Entry me = (Map.Entry) entities.next();
+ EntityEntry ee = (EntityEntry) me.getValue();
+ if ( persister.isSubclassEntityName( ee.getEntityName() ) ) {
+ Object instance = me.getKey();
+
+ Object index = getIndexInParent(property, childEntity, persister, cp, instance);
+
+ if (index==null && mergeMap!=null) {
+ Object unmergedInstance = mergeMap.get(instance);
+ Object unmergedChild = mergeMap.get(childEntity);
+ if ( unmergedInstance!=null && unmergedChild!=null ) {
+ index = getIndexInParent(property, unmergedChild, persister, cp, unmergedInstance);
+ }
+ }
+
+ if (index!=null) return index;
+ }
+ }
+ return null;
+ }
+
+ private Object getIndexInParent(
+ String property,
+ Object childEntity,
+ EntityPersister persister,
+ CollectionPersister collectionPersister,
+ Object potentialParent
+ ){
+ Object collection = persister.getPropertyValue( potentialParent, property, session.getEntityMode() );
+ if ( collection!=null && Hibernate.isInitialized(collection) ) {
+ return collectionPersister.getCollectionType().indexOf(collection, childEntity);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Record the fact that the association belonging to the keyed
+ * entity is null.
+ */
+ public void addNullProperty(EntityKey ownerKey, String propertyName) {
+ nullAssociations.add( new AssociationKey(ownerKey, propertyName) );
+ }
+
+ /**
+ * Is the association property belonging to the keyed entity null?
+ */
+ public boolean isPropertyNull(EntityKey ownerKey, String propertyName) {
+ return nullAssociations.contains( new AssociationKey(ownerKey, propertyName) );
+ }
+
+ private void clearNullProperties() {
+ nullAssociations.clear();
+ }
+
+ public void setReadOnly(Object entity, boolean readOnly) {
+ EntityEntry entry = getEntry(entity);
+ if (entry==null) {
+ throw new TransientObjectException("Instance was not associated with the session");
+ }
+ entry.setReadOnly(readOnly, entity);
+ hasNonReadOnlyEntities = hasNonReadOnlyEntities || !readOnly;
+ }
+
+ public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId) {
+ Object entity = entitiesByKey.remove( oldKey );
+ EntityEntry oldEntry = ( EntityEntry ) entityEntries.remove( entity );
+
+ EntityKey newKey = new EntityKey( generatedId, oldEntry.getPersister(), getSession().getEntityMode() );
+ addEntity( newKey, entity );
+ addEntry(
+ entity,
+ oldEntry.getStatus(),
+ oldEntry.getLoadedState(),
+ oldEntry.getRowId(),
+ generatedId,
+ oldEntry.getVersion(),
+ oldEntry.getLockMode(),
+ oldEntry.isExistsInDatabase(),
+ oldEntry.getPersister(),
+ oldEntry.isBeingReplicated(),
+ oldEntry.isLoadedWithLazyPropertiesUnfetched()
+ );
+ }
+
+ /**
+ * Used by the owning session to explicitly control serialization of the
+ * persistence context.
+ *
+ * @param oos The stream to which the persistence context should get written
+ * @throws IOException serialization errors.
+ */
+ public void serialize(ObjectOutputStream oos) throws IOException {
+ log.trace( "serializing persistent-context" );
+
+ oos.writeBoolean( hasNonReadOnlyEntities );
+
+ oos.writeInt( entitiesByKey.size() );
+ log.trace( "starting serialization of [" + entitiesByKey.size() + "] entitiesByKey entries" );
+ Iterator itr = entitiesByKey.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ ( ( EntityKey ) entry.getKey() ).serialize( oos );
+ oos.writeObject( entry.getValue() );
+ }
+
+ oos.writeInt( entitiesByUniqueKey.size() );
+ log.trace( "starting serialization of [" + entitiesByUniqueKey.size() + "] entitiesByUniqueKey entries" );
+ itr = entitiesByUniqueKey.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ ( ( EntityUniqueKey ) entry.getKey() ).serialize( oos );
+ oos.writeObject( entry.getValue() );
+ }
+
+ oos.writeInt( proxiesByKey.size() );
+ log.trace( "starting serialization of [" + proxiesByKey.size() + "] proxiesByKey entries" );
+ itr = proxiesByKey.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ ( ( EntityKey ) entry.getKey() ).serialize( oos );
+ oos.writeObject( entry.getValue() );
+ }
+
+ oos.writeInt( entitySnapshotsByKey.size() );
+ log.trace( "starting serialization of [" + entitySnapshotsByKey.size() + "] entitySnapshotsByKey entries" );
+ itr = entitySnapshotsByKey.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ ( ( EntityKey ) entry.getKey() ).serialize( oos );
+ oos.writeObject( entry.getValue() );
+ }
+
+ oos.writeInt( entityEntries.size() );
+ log.trace( "starting serialization of [" + entityEntries.size() + "] entityEntries entries" );
+ itr = entityEntries.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ oos.writeObject( entry.getKey() );
+ ( ( EntityEntry ) entry.getValue() ).serialize( oos );
+ }
+
+ oos.writeInt( collectionsByKey.size() );
+ log.trace( "starting serialization of [" + collectionsByKey.size() + "] collectionsByKey entries" );
+ itr = collectionsByKey.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ ( ( CollectionKey ) entry.getKey() ).serialize( oos );
+ oos.writeObject( entry.getValue() );
+ }
+
+ oos.writeInt( collectionEntries.size() );
+ log.trace( "starting serialization of [" + collectionEntries.size() + "] collectionEntries entries" );
+ itr = collectionEntries.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ oos.writeObject( entry.getKey() );
+ ( ( CollectionEntry ) entry.getValue() ).serialize( oos );
+ }
+
+ oos.writeInt( arrayHolders.size() );
+ log.trace( "starting serialization of [" + arrayHolders.size() + "] arrayHolders entries" );
+ itr = arrayHolders.entrySet().iterator();
+ while ( itr.hasNext() ) {
+ Map.Entry entry = ( Map.Entry ) itr.next();
+ oos.writeObject( entry.getKey() );
+ oos.writeObject( entry.getValue() );
+ }
+
+ oos.writeInt( nullifiableEntityKeys.size() );
+ log.trace( "starting serialization of [" + nullifiableEntityKeys.size() + "] nullifiableEntityKeys entries" );
+ itr = nullifiableEntityKeys.iterator();
+ while ( itr.hasNext() ) {
+ EntityKey entry = ( EntityKey ) itr.next();
+ entry.serialize( oos );
+ }
+ }
+
+ public static StatefulPersistenceContext deserialize(
+ ObjectInputStream ois,
+ SessionImplementor session) throws IOException, ClassNotFoundException {
+ log.trace( "deserializing persistent-context" );
+ StatefulPersistenceContext rtn = new StatefulPersistenceContext( session );
+
+ // during deserialization, we need to reconnect all proxies and
+ // collections to this session, as well as the EntityEntry and
+ // CollectionEntry instances; these associations are transient
+ // because serialization is used for different things.
+
+ try {
+ // todo : we can actually just determine this from the incoming EntityEntry-s
+ rtn.hasNonReadOnlyEntities = ois.readBoolean();
+
+ int count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] entitiesByKey entries" );
+ rtn.entitiesByKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ rtn.entitiesByKey.put( EntityKey.deserialize( ois, session ), ois.readObject() );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] entitiesByUniqueKey entries" );
+ rtn.entitiesByUniqueKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ rtn.entitiesByUniqueKey.put( EntityUniqueKey.deserialize( ois, session ), ois.readObject() );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] proxiesByKey entries" );
+ rtn.proxiesByKey = new ReferenceMap( ReferenceMap.HARD, ReferenceMap.WEAK, count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count, .75f );
+ for ( int i = 0; i < count; i++ ) {
+ EntityKey ek = EntityKey.deserialize( ois, session );
+ Object proxy = ois.readObject();
+ if ( proxy instanceof HibernateProxy ) {
+ ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer().setSession( session );
+ rtn.proxiesByKey.put( ek, proxy );
+ }
+ else {
+ log.trace( "encountered prunded proxy" );
+ }
+ // otherwise, the proxy was pruned during the serialization process
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] entitySnapshotsByKey entries" );
+ rtn.entitySnapshotsByKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ rtn.entitySnapshotsByKey.put( EntityKey.deserialize( ois, session ), ois.readObject() );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] entityEntries entries" );
+ rtn.entityEntries = IdentityMap.instantiateSequenced( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ Object entity = ois.readObject();
+ EntityEntry entry = EntityEntry.deserialize( ois, session );
+ rtn.entityEntries.put( entity, entry );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] collectionsByKey entries" );
+ rtn.collectionsByKey = new HashMap( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ rtn.collectionsByKey.put( CollectionKey.deserialize( ois, session ), ois.readObject() );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] collectionEntries entries" );
+ rtn.collectionEntries = IdentityMap.instantiateSequenced( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ final PersistentCollection pc = ( PersistentCollection ) ois.readObject();
+ final CollectionEntry ce = CollectionEntry.deserialize( ois, session );
+ pc.setCurrentSession( session );
+ rtn.collectionEntries.put( pc, ce );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] arrayHolders entries" );
+ rtn.arrayHolders = IdentityMap.instantiate( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
+ for ( int i = 0; i < count; i++ ) {
+ rtn.arrayHolders.put( ois.readObject(), ois.readObject() );
+ }
+
+ count = ois.readInt();
+ log.trace( "staring deserialization of [" + count + "] nullifiableEntityKeys entries" );
+ rtn.nullifiableEntityKeys = new HashSet();
+ for ( int i = 0; i < count; i++ ) {
+ rtn.nullifiableEntityKeys.add( EntityKey.deserialize( ois, session ) );
+ }
+
+ }
+ catch ( HibernateException he ) {
+ throw new InvalidObjectException( he.getMessage() );
+ }
+
+ return rtn;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/Status.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,46 +0,0 @@
-//$Id: Status.java 9194 2006-02-01 19:59:07Z steveebersole $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.io.ObjectStreamException;
-import java.io.InvalidObjectException;
-
-/**
- * Represents the status of an entity with respect to
- * this session. These statuses are for internal
- * book-keeping only and are not intended to represent
- * any notion that is visible to the _application_.
- */
-public final class Status implements Serializable {
-
- public static final Status MANAGED = new Status( "MANAGED" );
- public static final Status READ_ONLY = new Status( "READ_ONLY" );
- public static final Status DELETED = new Status( "DELETED" );
- public static final Status GONE = new Status( "GONE" );
- public static final Status LOADING = new Status( "LOADING" );
- public static final Status SAVING = new Status( "SAVING" );
-
- private String name;
-
- private Status(String name) {
- this.name = name;
- }
-
- public String toString() {
- return name;
- }
-
- private Object readResolve() throws ObjectStreamException {
- return parse( name );
- }
-
- public static Status parse(String name) throws InvalidObjectException {
- if ( name.equals(MANAGED.name) ) return MANAGED;
- if ( name.equals(READ_ONLY.name) ) return READ_ONLY;
- if ( name.equals(DELETED.name) ) return DELETED;
- if ( name.equals(GONE.name) ) return GONE;
- if ( name.equals(LOADING.name) ) return LOADING;
- if ( name.equals(SAVING.name) ) return SAVING;
- throw new InvalidObjectException( "invalid Status" );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/Status.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Status.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.io.ObjectStreamException;
+import java.io.InvalidObjectException;
+
+/**
+ * Represents the status of an entity with respect to
+ * this session. These statuses are for internal
+ * book-keeping only and are not intended to represent
+ * any notion that is visible to the _application_.
+ */
+public final class Status implements Serializable {
+
+ public static final Status MANAGED = new Status( "MANAGED" );
+ public static final Status READ_ONLY = new Status( "READ_ONLY" );
+ public static final Status DELETED = new Status( "DELETED" );
+ public static final Status GONE = new Status( "GONE" );
+ public static final Status LOADING = new Status( "LOADING" );
+ public static final Status SAVING = new Status( "SAVING" );
+
+ private String name;
+
+ private Status(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ return parse( name );
+ }
+
+ public static Status parse(String name) throws InvalidObjectException {
+ if ( name.equals(MANAGED.name) ) return MANAGED;
+ if ( name.equals(READ_ONLY.name) ) return READ_ONLY;
+ if ( name.equals(DELETED.name) ) return DELETED;
+ if ( name.equals(GONE.name) ) return GONE;
+ if ( name.equals(LOADING.name) ) return LOADING;
+ if ( name.equals(SAVING.name) ) return SAVING;
+ throw new InvalidObjectException( "invalid Status" );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/SubselectFetch.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,78 +0,0 @@
-//$Id: SubselectFetch.java 7670 2005-07-29 05:36:14Z oneovthafew $
-package org.hibernate.engine;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.persister.entity.Loadable;
-import org.hibernate.persister.entity.PropertyMapping;
-import org.hibernate.util.StringHelper;
-
-/**
- * @author Gavin King
- */
-public class SubselectFetch {
- private final Set resultingEntityKeys;
- private final String queryString;
- private final String alias;
- private final Loadable loadable;
- private final QueryParameters queryParameters;
- private final Map namedParameterLocMap;
-
- public SubselectFetch(
- //final String queryString,
- final String alias,
- final Loadable loadable,
- final QueryParameters queryParameters,
- final Set resultingEntityKeys,
- final Map namedParameterLocMap
- ) {
- this.resultingEntityKeys = resultingEntityKeys;
- this.queryParameters = queryParameters;
- this.namedParameterLocMap = namedParameterLocMap;
- this.loadable = loadable;
- this.alias = alias;
-
- //TODO: ugly here:
- final String queryString = queryParameters.getFilteredSQL();
- int fromIndex = queryString.indexOf(" from ");
- int orderByIndex = queryString.lastIndexOf("order by");
- this.queryString = orderByIndex>0 ?
- queryString.substring(fromIndex, orderByIndex) :
- queryString.substring(fromIndex);
-
- }
-
- public QueryParameters getQueryParameters() {
- return queryParameters;
- }
-
- /**
- * Get the Set of EntityKeys
- */
- public Set getResult() {
- return resultingEntityKeys;
- }
-
- public String toSubselectString(String ukname) {
-
- String[] joinColumns = ukname==null ?
- StringHelper.qualify( alias, loadable.getIdentifierColumnNames() ) :
- ( (PropertyMapping) loadable ).toColumns(alias, ukname);
-
- return new StringBuffer()
- .append("select ")
- .append( StringHelper.join(", ", joinColumns) )
- .append(queryString)
- .toString();
- }
-
- public String toString() {
- return "SubselectFetch(" + queryString + ')';
- }
-
- public Map getNamedParameterLocMap() {
- return namedParameterLocMap;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/SubselectFetch.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/SubselectFetch.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.persister.entity.Loadable;
+import org.hibernate.persister.entity.PropertyMapping;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Gavin King
+ */
+public class SubselectFetch {
+ private final Set resultingEntityKeys;
+ private final String queryString;
+ private final String alias;
+ private final Loadable loadable;
+ private final QueryParameters queryParameters;
+ private final Map namedParameterLocMap;
+
+ public SubselectFetch(
+ //final String queryString,
+ final String alias,
+ final Loadable loadable,
+ final QueryParameters queryParameters,
+ final Set resultingEntityKeys,
+ final Map namedParameterLocMap
+ ) {
+ this.resultingEntityKeys = resultingEntityKeys;
+ this.queryParameters = queryParameters;
+ this.namedParameterLocMap = namedParameterLocMap;
+ this.loadable = loadable;
+ this.alias = alias;
+
+ //TODO: ugly here:
+ final String queryString = queryParameters.getFilteredSQL();
+ int fromIndex = queryString.indexOf(" from ");
+ int orderByIndex = queryString.lastIndexOf("order by");
+ this.queryString = orderByIndex>0 ?
+ queryString.substring(fromIndex, orderByIndex) :
+ queryString.substring(fromIndex);
+
+ }
+
+ public QueryParameters getQueryParameters() {
+ return queryParameters;
+ }
+
+ /**
+ * Get the Set of EntityKeys
+ */
+ public Set getResult() {
+ return resultingEntityKeys;
+ }
+
+ public String toSubselectString(String ukname) {
+
+ String[] joinColumns = ukname==null ?
+ StringHelper.qualify( alias, loadable.getIdentifierColumnNames() ) :
+ ( (PropertyMapping) loadable ).toColumns(alias, ukname);
+
+ return new StringBuffer()
+ .append("select ")
+ .append( StringHelper.join(", ", joinColumns) )
+ .append(queryString)
+ .toString();
+ }
+
+ public String toString() {
+ return "SubselectFetch(" + queryString + ')';
+ }
+
+ public Map getNamedParameterLocMap() {
+ return namedParameterLocMap;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/TransactionHelper.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,54 +0,0 @@
-//$Id: TransactionHelper.java 9056 2006-01-13 19:40:15Z steveebersole $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-import org.hibernate.HibernateException;
-import org.hibernate.engine.transaction.IsolatedWork;
-import org.hibernate.engine.transaction.Isolater;
-import org.hibernate.exception.JDBCExceptionHelper;
-
-/**
- * Allows work to be done outside the current transaction, by suspending it,
- * and performing work in a new transaction
- *
- * @author Emmanuel Bernard
- */
-public abstract class TransactionHelper {
-
- // todo : remove this and just have subclasses use Isolater/IsolatedWork directly...
-
- /**
- * The work to be done
- */
- protected abstract Serializable doWorkInCurrentTransaction(Connection conn, String sql) throws SQLException;
-
- /**
- * Suspend the current transaction and perform work in a new transaction
- */
- public Serializable doWorkInNewTransaction(final SessionImplementor session)
- throws HibernateException {
- class Work implements IsolatedWork {
- Serializable generatedValue;
- public void doWork(Connection connection) throws HibernateException {
- String sql = null;
- try {
- generatedValue = doWorkInCurrentTransaction( connection, sql );
- }
- catch( SQLException sqle ) {
- throw JDBCExceptionHelper.convert(
- session.getFactory().getSQLExceptionConverter(),
- sqle,
- "could not get or update next value",
- sql
- );
- }
- }
- }
- Work work = new Work();
- Isolater.doIsolatedWork( work, session );
- return work.generatedValue;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/TransactionHelper.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TransactionHelper.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,77 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.hibernate.HibernateException;
+import org.hibernate.engine.transaction.IsolatedWork;
+import org.hibernate.engine.transaction.Isolater;
+import org.hibernate.exception.JDBCExceptionHelper;
+
+/**
+ * Allows work to be done outside the current transaction, by suspending it,
+ * and performing work in a new transaction
+ *
+ * @author Emmanuel Bernard
+ */
+public abstract class TransactionHelper {
+
+ // todo : remove this and just have subclasses use Isolater/IsolatedWork directly...
+
+ /**
+ * The work to be done
+ */
+ protected abstract Serializable doWorkInCurrentTransaction(Connection conn, String sql) throws SQLException;
+
+ /**
+ * Suspend the current transaction and perform work in a new transaction
+ */
+ public Serializable doWorkInNewTransaction(final SessionImplementor session)
+ throws HibernateException {
+ class Work implements IsolatedWork {
+ Serializable generatedValue;
+ public void doWork(Connection connection) throws HibernateException {
+ String sql = null;
+ try {
+ generatedValue = doWorkInCurrentTransaction( connection, sql );
+ }
+ catch( SQLException sqle ) {
+ throw JDBCExceptionHelper.convert(
+ session.getFactory().getSQLExceptionConverter(),
+ sqle,
+ "could not get or update next value",
+ sql
+ );
+ }
+ }
+ }
+ Work work = new Work();
+ Isolater.doIsolatedWork( work, session );
+ return work.generatedValue;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,273 +0,0 @@
-//$Id: TwoPhaseLoad.java 11398 2007-04-10 14:54:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.CacheMode;
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.cache.entry.CacheEntry;
-import org.hibernate.event.PostLoadEvent;
-import org.hibernate.event.PostLoadEventListener;
-import org.hibernate.event.PreLoadEvent;
-import org.hibernate.event.PreLoadEventListener;
-import org.hibernate.intercept.LazyPropertyInitializer;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.property.BackrefPropertyAccessor;
-import org.hibernate.type.Type;
-import org.hibernate.type.TypeFactory;
-
-/**
- * Functionality relating to Hibernate's two-phase loading process,
- * that may be reused by persisters that do not use the Loader
- * framework
- *
- * @author Gavin King
- */
-public final class TwoPhaseLoad {
-
- private static final Logger log = LoggerFactory.getLogger(TwoPhaseLoad.class);
-
- private TwoPhaseLoad() {}
-
- /**
- * Register the "hydrated" state of an entity instance, after the first step of 2-phase loading.
- *
- * Add the "hydrated state" (an array) of an uninitialized entity to the session. We don't try
- * to resolve any associations yet, because there might be other entities waiting to be
- * read from the JDBC result set we are currently processing
- */
- public static void postHydrate(
- final EntityPersister persister,
- final Serializable id,
- final Object[] values,
- final Object rowId,
- final Object object,
- final LockMode lockMode,
- final boolean lazyPropertiesAreUnfetched,
- final SessionImplementor session)
- throws HibernateException {
-
- Object version = Versioning.getVersion(values, persister);
- session.getPersistenceContext().addEntry(
- object,
- Status.LOADING,
- values,
- rowId,
- id,
- version,
- lockMode,
- true,
- persister,
- false,
- lazyPropertiesAreUnfetched
- );
-
- if ( log.isTraceEnabled() && version!=null ) {
- String versionStr = persister.isVersioned()
- ? persister.getVersionType().toLoggableString( version, session.getFactory() )
- : "null";
- log.trace( "Version: " + versionStr );
- }
-
- }
-
- /**
- * Perform the second step of 2-phase load. Fully initialize the entity
- * instance.
- *
- * After processing a JDBC result set, we "resolve" all the associations
- * between the entities which were instantiated and had their state
- * "hydrated" into an array
- */
- public static void initializeEntity(
- final Object entity,
- final boolean readOnly,
- final SessionImplementor session,
- final PreLoadEvent preLoadEvent,
- final PostLoadEvent postLoadEvent) throws HibernateException {
-
- //TODO: Should this be an InitializeEntityEventListener??? (watch out for performance!)
-
- final PersistenceContext persistenceContext = session.getPersistenceContext();
- EntityEntry entityEntry = persistenceContext.getEntry(entity);
- if ( entityEntry == null ) {
- throw new AssertionFailure( "possible non-threadsafe access to the session" );
- }
- EntityPersister persister = entityEntry.getPersister();
- Serializable id = entityEntry.getId();
- Object[] hydratedState = entityEntry.getLoadedState();
-
- if ( log.isDebugEnabled() )
- log.debug(
- "resolving associations for " +
- MessageHelper.infoString(persister, id, session.getFactory())
- );
-
- Type[] types = persister.getPropertyTypes();
- for ( int i = 0; i < hydratedState.length; i++ ) {
- final Object value = hydratedState[i];
- if ( value!=LazyPropertyInitializer.UNFETCHED_PROPERTY && value!=BackrefPropertyAccessor.UNKNOWN ) {
- hydratedState[i] = types[i].resolve( value, session, entity );
- }
- }
-
- //Must occur after resolving identifiers!
- if ( session.isEventSource() ) {
- preLoadEvent.setEntity(entity).setState(hydratedState).setId(id).setPersister(persister);
- PreLoadEventListener[] listeners = session.getListeners().getPreLoadEventListeners();
- for ( int i = 0; i < listeners.length; i++ ) {
- listeners[i].onPreLoad(preLoadEvent);
- }
- }
-
- persister.setPropertyValues( entity, hydratedState, session.getEntityMode() );
-
- final SessionFactoryImplementor factory = session.getFactory();
- if ( persister.hasCache() && session.getCacheMode().isPutEnabled() ) {
-
- if ( log.isDebugEnabled() )
- log.debug(
- "adding entity to second-level cache: " +
- MessageHelper.infoString( persister, id, session.getFactory() )
- );
-
- Object version = Versioning.getVersion(hydratedState, persister);
- CacheEntry entry = new CacheEntry(
- hydratedState,
- persister,
- entityEntry.isLoadedWithLazyPropertiesUnfetched(),
- version,
- session,
- entity
- );
- CacheKey cacheKey = new CacheKey(
- id,
- persister.getIdentifierType(),
- persister.getRootEntityName(),
- session.getEntityMode(),
- session.getFactory()
- );
- boolean put = persister.getCacheAccessStrategy().putFromLoad(
- cacheKey,
- persister.getCacheEntryStructure().structure( entry ),
- session.getTimestamp(),
- version,
- useMinimalPuts( session, entityEntry )
- );
-
- if ( put && factory.getStatistics().isStatisticsEnabled() ) {
- factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
- }
- }
-
- if ( readOnly || !persister.isMutable() ) {
- //no need to take a snapshot - this is a
- //performance optimization, but not really
- //important, except for entities with huge
- //mutable property values
- persistenceContext.setEntryStatus(entityEntry, Status.READ_ONLY);
- }
- else {
- //take a snapshot
- TypeFactory.deepCopy(
- hydratedState,
- persister.getPropertyTypes(),
- persister.getPropertyUpdateability(),
- hydratedState, //after setting values to object, entityMode
- session
- );
- persistenceContext.setEntryStatus(entityEntry, Status.MANAGED);
- }
-
- persister.afterInitialize(
- entity,
- entityEntry.isLoadedWithLazyPropertiesUnfetched(),
- session
- );
-
- if ( session.isEventSource() ) {
- postLoadEvent.setEntity(entity).setId(id).setPersister(persister);
- PostLoadEventListener[] listeners = session.getListeners().getPostLoadEventListeners();
- for ( int i = 0; i < listeners.length; i++ ) {
- listeners[i].onPostLoad(postLoadEvent);
- }
- }
-
- if ( log.isDebugEnabled() )
- log.debug(
- "done materializing entity " +
- MessageHelper.infoString( persister, id, session.getFactory() )
- );
-
- if ( factory.getStatistics().isStatisticsEnabled() ) {
- factory.getStatisticsImplementor().loadEntity( persister.getEntityName() );
- }
-
- }
-
- private static boolean useMinimalPuts(SessionImplementor session, EntityEntry entityEntry) {
- return ( session.getFactory().getSettings().isMinimalPutsEnabled() &&
- session.getCacheMode()!=CacheMode.REFRESH ) ||
- ( entityEntry.getPersister().hasLazyProperties() &&
- entityEntry.isLoadedWithLazyPropertiesUnfetched() &&
- entityEntry.getPersister().isLazyPropertiesCacheable() );
- }
-
- /**
- * Add an uninitialized instance of an entity class, as a placeholder to ensure object
- * identity. Must be called before <tt>postHydrate()</tt>.
- *
- * Create a "temporary" entry for a newly instantiated entity. The entity is uninitialized,
- * but we need the mapping from id to instance in order to guarantee uniqueness.
- */
- public static void addUninitializedEntity(
- final EntityKey key,
- final Object object,
- final EntityPersister persister,
- final LockMode lockMode,
- final boolean lazyPropertiesAreUnfetched,
- final SessionImplementor session
- ) {
- session.getPersistenceContext().addEntity(
- object,
- Status.LOADING,
- null,
- key,
- null,
- lockMode,
- true,
- persister,
- false,
- lazyPropertiesAreUnfetched
- );
- }
-
- public static void addUninitializedCachedEntity(
- final EntityKey key,
- final Object object,
- final EntityPersister persister,
- final LockMode lockMode,
- final boolean lazyPropertiesAreUnfetched,
- final Object version,
- final SessionImplementor session
- ) {
- session.getPersistenceContext().addEntity(
- object,
- Status.LOADING,
- null,
- key,
- version,
- lockMode,
- true,
- persister,
- false,
- lazyPropertiesAreUnfetched
- );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,296 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.AssertionFailure;
+import org.hibernate.CacheMode;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.cache.entry.CacheEntry;
+import org.hibernate.event.PostLoadEvent;
+import org.hibernate.event.PostLoadEventListener;
+import org.hibernate.event.PreLoadEvent;
+import org.hibernate.event.PreLoadEventListener;
+import org.hibernate.intercept.LazyPropertyInitializer;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.property.BackrefPropertyAccessor;
+import org.hibernate.type.Type;
+import org.hibernate.type.TypeFactory;
+
+/**
+ * Functionality relating to Hibernate's two-phase loading process,
+ * that may be reused by persisters that do not use the Loader
+ * framework
+ *
+ * @author Gavin King
+ */
+public final class TwoPhaseLoad {
+
+ private static final Logger log = LoggerFactory.getLogger(TwoPhaseLoad.class);
+
+ private TwoPhaseLoad() {}
+
+ /**
+ * Register the "hydrated" state of an entity instance, after the first step of 2-phase loading.
+ *
+ * Add the "hydrated state" (an array) of an uninitialized entity to the session. We don't try
+ * to resolve any associations yet, because there might be other entities waiting to be
+ * read from the JDBC result set we are currently processing
+ */
+ public static void postHydrate(
+ final EntityPersister persister,
+ final Serializable id,
+ final Object[] values,
+ final Object rowId,
+ final Object object,
+ final LockMode lockMode,
+ final boolean lazyPropertiesAreUnfetched,
+ final SessionImplementor session)
+ throws HibernateException {
+
+ Object version = Versioning.getVersion(values, persister);
+ session.getPersistenceContext().addEntry(
+ object,
+ Status.LOADING,
+ values,
+ rowId,
+ id,
+ version,
+ lockMode,
+ true,
+ persister,
+ false,
+ lazyPropertiesAreUnfetched
+ );
+
+ if ( log.isTraceEnabled() && version!=null ) {
+ String versionStr = persister.isVersioned()
+ ? persister.getVersionType().toLoggableString( version, session.getFactory() )
+ : "null";
+ log.trace( "Version: " + versionStr );
+ }
+
+ }
+
+ /**
+ * Perform the second step of 2-phase load. Fully initialize the entity
+ * instance.
+ *
+ * After processing a JDBC result set, we "resolve" all the associations
+ * between the entities which were instantiated and had their state
+ * "hydrated" into an array
+ */
+ public static void initializeEntity(
+ final Object entity,
+ final boolean readOnly,
+ final SessionImplementor session,
+ final PreLoadEvent preLoadEvent,
+ final PostLoadEvent postLoadEvent) throws HibernateException {
+
+ //TODO: Should this be an InitializeEntityEventListener??? (watch out for performance!)
+
+ final PersistenceContext persistenceContext = session.getPersistenceContext();
+ EntityEntry entityEntry = persistenceContext.getEntry(entity);
+ if ( entityEntry == null ) {
+ throw new AssertionFailure( "possible non-threadsafe access to the session" );
+ }
+ EntityPersister persister = entityEntry.getPersister();
+ Serializable id = entityEntry.getId();
+ Object[] hydratedState = entityEntry.getLoadedState();
+
+ if ( log.isDebugEnabled() )
+ log.debug(
+ "resolving associations for " +
+ MessageHelper.infoString(persister, id, session.getFactory())
+ );
+
+ Type[] types = persister.getPropertyTypes();
+ for ( int i = 0; i < hydratedState.length; i++ ) {
+ final Object value = hydratedState[i];
+ if ( value!=LazyPropertyInitializer.UNFETCHED_PROPERTY && value!=BackrefPropertyAccessor.UNKNOWN ) {
+ hydratedState[i] = types[i].resolve( value, session, entity );
+ }
+ }
+
+ //Must occur after resolving identifiers!
+ if ( session.isEventSource() ) {
+ preLoadEvent.setEntity(entity).setState(hydratedState).setId(id).setPersister(persister);
+ PreLoadEventListener[] listeners = session.getListeners().getPreLoadEventListeners();
+ for ( int i = 0; i < listeners.length; i++ ) {
+ listeners[i].onPreLoad(preLoadEvent);
+ }
+ }
+
+ persister.setPropertyValues( entity, hydratedState, session.getEntityMode() );
+
+ final SessionFactoryImplementor factory = session.getFactory();
+ if ( persister.hasCache() && session.getCacheMode().isPutEnabled() ) {
+
+ if ( log.isDebugEnabled() )
+ log.debug(
+ "adding entity to second-level cache: " +
+ MessageHelper.infoString( persister, id, session.getFactory() )
+ );
+
+ Object version = Versioning.getVersion(hydratedState, persister);
+ CacheEntry entry = new CacheEntry(
+ hydratedState,
+ persister,
+ entityEntry.isLoadedWithLazyPropertiesUnfetched(),
+ version,
+ session,
+ entity
+ );
+ CacheKey cacheKey = new CacheKey(
+ id,
+ persister.getIdentifierType(),
+ persister.getRootEntityName(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ boolean put = persister.getCacheAccessStrategy().putFromLoad(
+ cacheKey,
+ persister.getCacheEntryStructure().structure( entry ),
+ session.getTimestamp(),
+ version,
+ useMinimalPuts( session, entityEntry )
+ );
+
+ if ( put && factory.getStatistics().isStatisticsEnabled() ) {
+ factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
+ }
+ }
+
+ if ( readOnly || !persister.isMutable() ) {
+ //no need to take a snapshot - this is a
+ //performance optimization, but not really
+ //important, except for entities with huge
+ //mutable property values
+ persistenceContext.setEntryStatus(entityEntry, Status.READ_ONLY);
+ }
+ else {
+ //take a snapshot
+ TypeFactory.deepCopy(
+ hydratedState,
+ persister.getPropertyTypes(),
+ persister.getPropertyUpdateability(),
+ hydratedState, //after setting values to object, entityMode
+ session
+ );
+ persistenceContext.setEntryStatus(entityEntry, Status.MANAGED);
+ }
+
+ persister.afterInitialize(
+ entity,
+ entityEntry.isLoadedWithLazyPropertiesUnfetched(),
+ session
+ );
+
+ if ( session.isEventSource() ) {
+ postLoadEvent.setEntity(entity).setId(id).setPersister(persister);
+ PostLoadEventListener[] listeners = session.getListeners().getPostLoadEventListeners();
+ for ( int i = 0; i < listeners.length; i++ ) {
+ listeners[i].onPostLoad(postLoadEvent);
+ }
+ }
+
+ if ( log.isDebugEnabled() )
+ log.debug(
+ "done materializing entity " +
+ MessageHelper.infoString( persister, id, session.getFactory() )
+ );
+
+ if ( factory.getStatistics().isStatisticsEnabled() ) {
+ factory.getStatisticsImplementor().loadEntity( persister.getEntityName() );
+ }
+
+ }
+
+ private static boolean useMinimalPuts(SessionImplementor session, EntityEntry entityEntry) {
+ return ( session.getFactory().getSettings().isMinimalPutsEnabled() &&
+ session.getCacheMode()!=CacheMode.REFRESH ) ||
+ ( entityEntry.getPersister().hasLazyProperties() &&
+ entityEntry.isLoadedWithLazyPropertiesUnfetched() &&
+ entityEntry.getPersister().isLazyPropertiesCacheable() );
+ }
+
+ /**
+ * Add an uninitialized instance of an entity class, as a placeholder to ensure object
+ * identity. Must be called before <tt>postHydrate()</tt>.
+ *
+ * Create a "temporary" entry for a newly instantiated entity. The entity is uninitialized,
+ * but we need the mapping from id to instance in order to guarantee uniqueness.
+ */
+ public static void addUninitializedEntity(
+ final EntityKey key,
+ final Object object,
+ final EntityPersister persister,
+ final LockMode lockMode,
+ final boolean lazyPropertiesAreUnfetched,
+ final SessionImplementor session
+ ) {
+ session.getPersistenceContext().addEntity(
+ object,
+ Status.LOADING,
+ null,
+ key,
+ null,
+ lockMode,
+ true,
+ persister,
+ false,
+ lazyPropertiesAreUnfetched
+ );
+ }
+
+ public static void addUninitializedCachedEntity(
+ final EntityKey key,
+ final Object object,
+ final EntityPersister persister,
+ final LockMode lockMode,
+ final boolean lazyPropertiesAreUnfetched,
+ final Object version,
+ final SessionImplementor session
+ ) {
+ session.getPersistenceContext().addEntity(
+ object,
+ Status.LOADING,
+ null,
+ key,
+ version,
+ lockMode,
+ true,
+ persister,
+ false,
+ lazyPropertiesAreUnfetched
+ );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/TypedValue.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,60 +0,0 @@
-//$Id: TypedValue.java 6638 2005-05-02 14:34:17Z oneovthafew $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-
-import org.hibernate.EntityMode;
-import org.hibernate.type.Type;
-
-/**
- * An ordered pair of a value and its Hibernate type.
- *
- * @see org.hibernate.type.Type
- * @author Gavin King
- */
-public final class TypedValue implements Serializable {
- private final Type type;
- private final Object value;
- private final EntityMode entityMode;
-
- public TypedValue(Type type, Object value, EntityMode entityMode) {
- this.type = type;
- this.value=value;
- this.entityMode = entityMode;
- }
-
- public Object getValue() {
- return value;
- }
-
- public Type getType() {
- return type;
- }
-
- public String toString() {
- return value==null ? "null" : value.toString();
- }
-
- public int hashCode() {
- //int result = 17;
- //result = 37 * result + type.hashCode();
- //result = 37 * result + ( value==null ? 0 : value.hashCode() );
- //return result;
- return value==null ? 0 : type.getHashCode(value, entityMode);
- }
-
- public boolean equals(Object other) {
- if ( !(other instanceof TypedValue) ) return false;
- TypedValue that = (TypedValue) other;
- /*return that.type.equals(type) &&
- EqualsHelper.equals(that.value, value);*/
- return type.getReturnedClass() == that.type.getReturnedClass() &&
- type.isEqual(that.value, value, entityMode);
- }
-
-}
-
-
-
-
-
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/TypedValue.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/TypedValue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+
+import org.hibernate.EntityMode;
+import org.hibernate.type.Type;
+
+/**
+ * An ordered pair of a value and its Hibernate type.
+ *
+ * @see org.hibernate.type.Type
+ * @author Gavin King
+ */
+public final class TypedValue implements Serializable {
+ private final Type type;
+ private final Object value;
+ private final EntityMode entityMode;
+
+ public TypedValue(Type type, Object value, EntityMode entityMode) {
+ this.type = type;
+ this.value=value;
+ this.entityMode = entityMode;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String toString() {
+ return value==null ? "null" : value.toString();
+ }
+
+ public int hashCode() {
+ //int result = 17;
+ //result = 37 * result + type.hashCode();
+ //result = 37 * result + ( value==null ? 0 : value.hashCode() );
+ //return result;
+ return value==null ? 0 : type.getHashCode(value, entityMode);
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof TypedValue) ) return false;
+ TypedValue that = (TypedValue) other;
+ /*return that.type.equals(type) &&
+ EqualsHelper.equals(that.value, value);*/
+ return type.getReturnedClass() == that.type.getReturnedClass() &&
+ type.isEqual(that.value, value, entityMode);
+ }
+
+}
+
+
+
+
+
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,115 +0,0 @@
-//$Id: UnsavedValueFactory.java 7736 2005-08-03 20:03:34Z steveebersole $
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-
-import org.hibernate.InstantiationException;
-import org.hibernate.MappingException;
-import org.hibernate.property.Getter;
-import org.hibernate.type.IdentifierType;
-import org.hibernate.type.PrimitiveType;
-import org.hibernate.type.Type;
-import org.hibernate.type.VersionType;
-
-/**
- * @author Gavin King
- */
-public class UnsavedValueFactory {
-
- private static Object instantiate(Constructor constructor) {
- try {
- return constructor.newInstance(null);
- }
- catch (Exception e) {
- throw new InstantiationException( "could not instantiate test object", constructor.getDeclaringClass(), e );
- }
- }
-
- /**
- * Return an IdentifierValue for the specified unsaved-value. If none is specified,
- * guess the unsaved value by instantiating a test instance of the class and
- * reading it's id property, or if that is not possible, using the java default
- * value for the type
- */
- public static IdentifierValue getUnsavedIdentifierValue(
- String unsavedValue,
- Getter identifierGetter,
- Type identifierType,
- Constructor constructor) {
-
- if ( unsavedValue == null ) {
- if ( identifierGetter!=null && constructor!=null ) {
- // use the id value of a newly instantiated instance as the unsaved-value
- Serializable defaultValue = (Serializable) identifierGetter.get( instantiate(constructor) );
- return new IdentifierValue( defaultValue );
- }
- else if ( identifierGetter != null && (identifierType instanceof PrimitiveType) ) {
- Serializable defaultValue = ( ( PrimitiveType ) identifierType ).getDefaultValue();
- return new IdentifierValue( defaultValue );
- }
- else {
- return IdentifierValue.NULL;
- }
- }
- else if ( "null".equals( unsavedValue ) ) {
- return IdentifierValue.NULL;
- }
- else if ( "undefined".equals( unsavedValue ) ) {
- return IdentifierValue.UNDEFINED;
- }
- else if ( "none".equals( unsavedValue ) ) {
- return IdentifierValue.NONE;
- }
- else if ( "any".equals( unsavedValue ) ) {
- return IdentifierValue.ANY;
- }
- else {
- try {
- return new IdentifierValue( ( Serializable ) ( ( IdentifierType ) identifierType ).stringToObject( unsavedValue ) );
- }
- catch ( ClassCastException cce ) {
- throw new MappingException( "Bad identifier type: " + identifierType.getName() );
- }
- catch ( Exception e ) {
- throw new MappingException( "Could not parse identifier unsaved-value: " + unsavedValue );
- }
- }
- }
-
- public static VersionValue getUnsavedVersionValue(
- String versionUnsavedValue,
- Getter versionGetter,
- VersionType versionType,
- Constructor constructor) {
-
- if ( versionUnsavedValue == null ) {
- if ( constructor!=null ) {
- Object defaultValue = versionGetter.get( instantiate(constructor) );
- // if the version of a newly instantiated object is not the same
- // as the version seed value, use that as the unsaved-value
- return versionType.isEqual( versionType.seed( null ), defaultValue ) ?
- VersionValue.UNDEFINED :
- new VersionValue( defaultValue );
- }
- else {
- return VersionValue.UNDEFINED;
- }
- }
- else if ( "undefined".equals( versionUnsavedValue ) ) {
- return VersionValue.UNDEFINED;
- }
- else if ( "null".equals( versionUnsavedValue ) ) {
- return VersionValue.NULL;
- }
- else if ( "negative".equals( versionUnsavedValue ) ) {
- return VersionValue.NEGATIVE;
- }
- else {
- // this should not happen since the DTD prevents it
- throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
- }
-
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/UnsavedValueFactory.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,138 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+
+import org.hibernate.InstantiationException;
+import org.hibernate.MappingException;
+import org.hibernate.property.Getter;
+import org.hibernate.type.IdentifierType;
+import org.hibernate.type.PrimitiveType;
+import org.hibernate.type.Type;
+import org.hibernate.type.VersionType;
+
+/**
+ * @author Gavin King
+ */
+public class UnsavedValueFactory {
+
+ private static Object instantiate(Constructor constructor) {
+ try {
+ return constructor.newInstance(null);
+ }
+ catch (Exception e) {
+ throw new InstantiationException( "could not instantiate test object", constructor.getDeclaringClass(), e );
+ }
+ }
+
+ /**
+ * Return an IdentifierValue for the specified unsaved-value. If none is specified,
+ * guess the unsaved value by instantiating a test instance of the class and
+ * reading it's id property, or if that is not possible, using the java default
+ * value for the type
+ */
+ public static IdentifierValue getUnsavedIdentifierValue(
+ String unsavedValue,
+ Getter identifierGetter,
+ Type identifierType,
+ Constructor constructor) {
+
+ if ( unsavedValue == null ) {
+ if ( identifierGetter!=null && constructor!=null ) {
+ // use the id value of a newly instantiated instance as the unsaved-value
+ Serializable defaultValue = (Serializable) identifierGetter.get( instantiate(constructor) );
+ return new IdentifierValue( defaultValue );
+ }
+ else if ( identifierGetter != null && (identifierType instanceof PrimitiveType) ) {
+ Serializable defaultValue = ( ( PrimitiveType ) identifierType ).getDefaultValue();
+ return new IdentifierValue( defaultValue );
+ }
+ else {
+ return IdentifierValue.NULL;
+ }
+ }
+ else if ( "null".equals( unsavedValue ) ) {
+ return IdentifierValue.NULL;
+ }
+ else if ( "undefined".equals( unsavedValue ) ) {
+ return IdentifierValue.UNDEFINED;
+ }
+ else if ( "none".equals( unsavedValue ) ) {
+ return IdentifierValue.NONE;
+ }
+ else if ( "any".equals( unsavedValue ) ) {
+ return IdentifierValue.ANY;
+ }
+ else {
+ try {
+ return new IdentifierValue( ( Serializable ) ( ( IdentifierType ) identifierType ).stringToObject( unsavedValue ) );
+ }
+ catch ( ClassCastException cce ) {
+ throw new MappingException( "Bad identifier type: " + identifierType.getName() );
+ }
+ catch ( Exception e ) {
+ throw new MappingException( "Could not parse identifier unsaved-value: " + unsavedValue );
+ }
+ }
+ }
+
+ public static VersionValue getUnsavedVersionValue(
+ String versionUnsavedValue,
+ Getter versionGetter,
+ VersionType versionType,
+ Constructor constructor) {
+
+ if ( versionUnsavedValue == null ) {
+ if ( constructor!=null ) {
+ Object defaultValue = versionGetter.get( instantiate(constructor) );
+ // if the version of a newly instantiated object is not the same
+ // as the version seed value, use that as the unsaved-value
+ return versionType.isEqual( versionType.seed( null ), defaultValue ) ?
+ VersionValue.UNDEFINED :
+ new VersionValue( defaultValue );
+ }
+ else {
+ return VersionValue.UNDEFINED;
+ }
+ }
+ else if ( "undefined".equals( versionUnsavedValue ) ) {
+ return VersionValue.UNDEFINED;
+ }
+ else if ( "null".equals( versionUnsavedValue ) ) {
+ return VersionValue.NULL;
+ }
+ else if ( "negative".equals( versionUnsavedValue ) ) {
+ return VersionValue.NEGATIVE;
+ }
+ else {
+ // this should not happen since the DTD prevents it
+ throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
+ }
+
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/ValueInclusion.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,51 +0,0 @@
-package org.hibernate.engine;
-
-import java.io.Serializable;
-import java.io.ObjectStreamException;
-import java.io.StreamCorruptedException;
-
-/**
- * An enum of the different ways a value might be "included".
- * <p/>
- * This is really an expanded true/false notion with "PARTIAL" being the
- * expansion. PARTIAL deals with components in the cases where
- * parts of the referenced component might define inclusion, but the
- * component overall does not.
- *
- * @author Steve Ebersole
- */
-public class ValueInclusion implements Serializable {
-
- public static final ValueInclusion NONE = new ValueInclusion( "none" );
- public static final ValueInclusion FULL = new ValueInclusion( "full" );
- public static final ValueInclusion PARTIAL = new ValueInclusion( "partial" );
-
- private final String name;
-
- public ValueInclusion(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String toString() {
- return "ValueInclusion[" + name + "]";
- }
-
- private Object readResolve() throws ObjectStreamException {
- if ( name.equals( NONE.name ) ) {
- return NONE;
- }
- else if ( name.equals( FULL.name ) ) {
- return FULL;
- }
- else if ( name.equals( PARTIAL.name ) ) {
- return PARTIAL;
- }
- else {
- throw new StreamCorruptedException( "unrecognized value inclusion [" + name + "]" );
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/ValueInclusion.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/ValueInclusion.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,75 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import java.io.Serializable;
+import java.io.ObjectStreamException;
+import java.io.StreamCorruptedException;
+
+/**
+ * An enum of the different ways a value might be "included".
+ * <p/>
+ * This is really an expanded true/false notion with "PARTIAL" being the
+ * expansion. PARTIAL deals with components in the cases where
+ * parts of the referenced component might define inclusion, but the
+ * component overall does not.
+ *
+ * @author Steve Ebersole
+ */
+public class ValueInclusion implements Serializable {
+
+ public static final ValueInclusion NONE = new ValueInclusion( "none" );
+ public static final ValueInclusion FULL = new ValueInclusion( "full" );
+ public static final ValueInclusion PARTIAL = new ValueInclusion( "partial" );
+
+ private final String name;
+
+ public ValueInclusion(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ return "ValueInclusion[" + name + "]";
+ }
+
+ private Object readResolve() throws ObjectStreamException {
+ if ( name.equals( NONE.name ) ) {
+ return NONE;
+ }
+ else if ( name.equals( FULL.name ) ) {
+ return FULL;
+ }
+ else if ( name.equals( PARTIAL.name ) ) {
+ return PARTIAL;
+ }
+ else {
+ throw new StreamCorruptedException( "unrecognized value inclusion [" + name + "]" );
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/VersionValue.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,109 +0,0 @@
-//$Id: VersionValue.java 7017 2005-06-05 04:31:34Z oneovthafew $
-package org.hibernate.engine;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.MappingException;
-import org.hibernate.id.IdentifierGeneratorFactory;
-
-/**
- * A strategy for determining if a version value is an version of
- * a new transient instance or a previously persistent transient instance.
- * The strategy is determined by the <tt>unsaved-value</tt> attribute in
- * the mapping file.
- *
- * @author Gavin King
- */
-public class VersionValue {
-
- private static final Logger log = LoggerFactory.getLogger(VersionValue.class);
-
- private final Object value;
- /**
- * Assume the transient instance is newly instantiated if the version
- * is null, otherwise assume it is a detached instance.
- */
- public static final VersionValue NULL = new VersionValue() {
- public final Boolean isUnsaved(Object version) {
- log.trace("version unsaved-value strategy NULL");
- return version==null ? Boolean.TRUE : Boolean.FALSE;
- }
- public Object getDefaultValue(Object currentValue) {
- return null;
- }
- public String toString() {
- return "VERSION_SAVE_NULL";
- }
- };
- /**
- * Assume the transient instance is newly instantiated if the version
- * is null, otherwise defer to the identifier unsaved-value.
- */
- public static final VersionValue UNDEFINED = new VersionValue() {
- public final Boolean isUnsaved(Object version) {
- log.trace("version unsaved-value strategy UNDEFINED");
- return version==null ? Boolean.TRUE : null;
- }
- public Object getDefaultValue(Object currentValue) {
- return currentValue;
- }
- public String toString() {
- return "VERSION_UNDEFINED";
- }
- };
- /**
- * Assume the transient instance is newly instantiated if the version
- * is negative, otherwise assume it is a detached instance.
- */
- public static final VersionValue NEGATIVE = new VersionValue() {
-
- public final Boolean isUnsaved(Object version) throws MappingException {
- log.trace("version unsaved-value strategy NEGATIVE");
- if (version==null) return Boolean.TRUE;
- if (version instanceof Number) {
- return ( (Number) version ).longValue() < 0l ? Boolean.TRUE : Boolean.FALSE;
- }
- else {
- throw new MappingException("unsaved-value NEGATIVE may only be used with short, int and long types");
- }
- }
- public Object getDefaultValue(Object currentValue) {
- return IdentifierGeneratorFactory.createNumber( -1l, currentValue.getClass() );
- }
- public String toString() {
- return "VERSION_NEGATIVE";
- }
- };
-
- protected VersionValue() {
- this.value = null;
- }
-
- /**
- * Assume the transient instance is newly instantiated if
- * its version is null or equal to <tt>value</tt>
- * @param value value to compare to
- */
- public VersionValue(Object value) {
- this.value = value;
- }
-
- /**
- * Does the given version belong to a new instance?
- *
- * @param version version to check
- * @return true is unsaved, false is saved, null is undefined
- */
- public Boolean isUnsaved(Object version) throws MappingException {
- if ( log.isTraceEnabled() ) log.trace("version unsaved-value: " + value);
- return version==null || version.equals(value) ? Boolean.TRUE : Boolean.FALSE;
- }
-
- public Object getDefaultValue(Object currentValue) {
- return value;
- }
-
- public String toString() {
- return "version unsaved-value: " + value;
- }
-}
\ No newline at end of file
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/VersionValue.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/VersionValue.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,132 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.MappingException;
+import org.hibernate.id.IdentifierGeneratorFactory;
+
+/**
+ * A strategy for determining if a version value is an version of
+ * a new transient instance or a previously persistent transient instance.
+ * The strategy is determined by the <tt>unsaved-value</tt> attribute in
+ * the mapping file.
+ *
+ * @author Gavin King
+ */
+public class VersionValue {
+
+ private static final Logger log = LoggerFactory.getLogger(VersionValue.class);
+
+ private final Object value;
+ /**
+ * Assume the transient instance is newly instantiated if the version
+ * is null, otherwise assume it is a detached instance.
+ */
+ public static final VersionValue NULL = new VersionValue() {
+ public final Boolean isUnsaved(Object version) {
+ log.trace("version unsaved-value strategy NULL");
+ return version==null ? Boolean.TRUE : Boolean.FALSE;
+ }
+ public Object getDefaultValue(Object currentValue) {
+ return null;
+ }
+ public String toString() {
+ return "VERSION_SAVE_NULL";
+ }
+ };
+ /**
+ * Assume the transient instance is newly instantiated if the version
+ * is null, otherwise defer to the identifier unsaved-value.
+ */
+ public static final VersionValue UNDEFINED = new VersionValue() {
+ public final Boolean isUnsaved(Object version) {
+ log.trace("version unsaved-value strategy UNDEFINED");
+ return version==null ? Boolean.TRUE : null;
+ }
+ public Object getDefaultValue(Object currentValue) {
+ return currentValue;
+ }
+ public String toString() {
+ return "VERSION_UNDEFINED";
+ }
+ };
+ /**
+ * Assume the transient instance is newly instantiated if the version
+ * is negative, otherwise assume it is a detached instance.
+ */
+ public static final VersionValue NEGATIVE = new VersionValue() {
+
+ public final Boolean isUnsaved(Object version) throws MappingException {
+ log.trace("version unsaved-value strategy NEGATIVE");
+ if (version==null) return Boolean.TRUE;
+ if (version instanceof Number) {
+ return ( (Number) version ).longValue() < 0l ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else {
+ throw new MappingException("unsaved-value NEGATIVE may only be used with short, int and long types");
+ }
+ }
+ public Object getDefaultValue(Object currentValue) {
+ return IdentifierGeneratorFactory.createNumber( -1l, currentValue.getClass() );
+ }
+ public String toString() {
+ return "VERSION_NEGATIVE";
+ }
+ };
+
+ protected VersionValue() {
+ this.value = null;
+ }
+
+ /**
+ * Assume the transient instance is newly instantiated if
+ * its version is null or equal to <tt>value</tt>
+ * @param value value to compare to
+ */
+ public VersionValue(Object value) {
+ this.value = value;
+ }
+
+ /**
+ * Does the given version belong to a new instance?
+ *
+ * @param version version to check
+ * @return true is unsaved, false is saved, null is undefined
+ */
+ public Boolean isUnsaved(Object version) throws MappingException {
+ if ( log.isTraceEnabled() ) log.trace("version unsaved-value: " + value);
+ return version==null || version.equals(value) ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public Object getDefaultValue(Object currentValue) {
+ return value;
+ }
+
+ public String toString() {
+ return "version unsaved-value: " + value;
+ }
+}
\ No newline at end of file
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/Versioning.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,172 +0,0 @@
-//$Id: Versioning.java 10857 2006-11-21 23:28:07Z steve.ebersole(a)jboss.com $
-package org.hibernate.engine;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.type.VersionType;
-
-/**
- * Utilities for dealing with optimisitic locking values.
- *
- * @author Gavin King
- */
-public final class Versioning {
- /**
- * Apply no optimistic locking
- */
- public static final int OPTIMISTIC_LOCK_NONE = -1;
-
- /**
- * Apply optimisitc locking based on the defined version or timestamp
- * property.
- */
- public static final int OPTIMISTIC_LOCK_VERSION = 0;
-
- /**
- * Apply optimisitc locking based on the a current vs. snapshot comparison
- * of <b>all</b> properties.
- */
- public static final int OPTIMISTIC_LOCK_ALL = 2;
-
- /**
- * Apply optimisitc locking based on the a current vs. snapshot comparison
- * of <b>dirty</b> properties.
- */
- public static final int OPTIMISTIC_LOCK_DIRTY = 1;
-
- private static final Logger log = LoggerFactory.getLogger( Versioning.class );
-
- /**
- * Private constructor disallowing instantiation.
- */
- private Versioning() {}
-
- /**
- * Create an initial optimisitc locking value according the {@link VersionType}
- * contract for the version property.
- *
- * @param versionType The version type.
- * @param session The originating session
- * @return The initial optimisitc locking value
- */
- private static Object seed(VersionType versionType, SessionImplementor session) {
- Object seed = versionType.seed( session );
- if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
- return seed;
- }
-
- /**
- * Create an initial optimisitc locking value according the {@link VersionType}
- * contract for the version property <b>if required</b> and inject it into
- * the snapshot state.
- *
- * @param fields The current snapshot state
- * @param versionProperty The index of the version property
- * @param versionType The version type
- * @param session The orginating session
- * @return True if we injected a new version value into the fields array; false
- * otherwise.
- */
- public static boolean seedVersion(
- Object[] fields,
- int versionProperty,
- VersionType versionType,
- SessionImplementor session) {
- Object initialVersion = fields[versionProperty];
- if (
- initialVersion==null ||
- // This next bit is to allow for both unsaved-value="negative"
- // and for "older" behavior where version number did not get
- // seeded if it was already set in the object
- // TODO: shift it into unsaved-value strategy
- ( (initialVersion instanceof Number) && ( (Number) initialVersion ).longValue()<0 )
- ) {
- fields[versionProperty] = seed( versionType, session );
- return true;
- }
- else {
- if ( log.isTraceEnabled() ) {
- log.trace( "using initial version: " + initialVersion );
- }
- return false;
- }
- }
-
-
- /**
- * Generate the next increment in the optimisitc locking value according
- * the {@link VersionType} contract for the version property.
- *
- * @param version The current version
- * @param versionType The version type
- * @param session The originating session
- * @return The incremented optimistic locking value.
- */
- public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
- Object next = versionType.next( version, session );
- if ( log.isTraceEnabled() ) {
- log.trace(
- "Incrementing: " +
- versionType.toLoggableString( version, session.getFactory() ) +
- " to " +
- versionType.toLoggableString( next, session.getFactory() )
- );
- }
- return next;
- }
-
- /**
- * Inject the optimisitc locking value into the entity state snapshot.
- *
- * @param fields The state snapshot
- * @param version The optimisitc locking value
- * @param persister The entity persister
- */
- public static void setVersion(Object[] fields, Object version, EntityPersister persister) {
- if ( !persister.isVersioned() ) {
- return;
- }
- fields[ persister.getVersionProperty() ] = version;
- }
-
- /**
- * Extract the optimisitc locking value out of the entity state snapshot.
- *
- * @param fields The state snapshot
- * @param persister The entity persister
- * @return The extracted optimisitc locking value
- */
- public static Object getVersion(Object[] fields, EntityPersister persister) {
- if ( !persister.isVersioned() ) {
- return null;
- }
- return fields[ persister.getVersionProperty() ];
- }
-
- /**
- * Do we need to increment the version number, given the dirty properties?
- *
- * @param dirtyProperties The array of property indexes which were deemed dirty
- * @param hasDirtyCollections Were any collections found to be dirty (structurally changed)
- * @param propertyVersionability An array indicating versionability of each property.
- * @return True if a version increment is required; false otherwise.
- */
- public static boolean isVersionIncrementRequired(
- final int[] dirtyProperties,
- final boolean hasDirtyCollections,
- final boolean[] propertyVersionability) {
- if ( hasDirtyCollections ) {
- return true;
- }
- for ( int i = 0; i < dirtyProperties.length; i++ ) {
- if ( propertyVersionability[ dirtyProperties[i] ] ) {
- return true;
- }
- }
- return false;
- }
-
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/Versioning.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/Versioning.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,195 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.type.VersionType;
+
+/**
+ * Utilities for dealing with optimisitic locking values.
+ *
+ * @author Gavin King
+ */
+public final class Versioning {
+ /**
+ * Apply no optimistic locking
+ */
+ public static final int OPTIMISTIC_LOCK_NONE = -1;
+
+ /**
+ * Apply optimisitc locking based on the defined version or timestamp
+ * property.
+ */
+ public static final int OPTIMISTIC_LOCK_VERSION = 0;
+
+ /**
+ * Apply optimisitc locking based on the a current vs. snapshot comparison
+ * of <b>all</b> properties.
+ */
+ public static final int OPTIMISTIC_LOCK_ALL = 2;
+
+ /**
+ * Apply optimisitc locking based on the a current vs. snapshot comparison
+ * of <b>dirty</b> properties.
+ */
+ public static final int OPTIMISTIC_LOCK_DIRTY = 1;
+
+ private static final Logger log = LoggerFactory.getLogger( Versioning.class );
+
+ /**
+ * Private constructor disallowing instantiation.
+ */
+ private Versioning() {}
+
+ /**
+ * Create an initial optimisitc locking value according the {@link VersionType}
+ * contract for the version property.
+ *
+ * @param versionType The version type.
+ * @param session The originating session
+ * @return The initial optimisitc locking value
+ */
+ private static Object seed(VersionType versionType, SessionImplementor session) {
+ Object seed = versionType.seed( session );
+ if ( log.isTraceEnabled() ) log.trace("Seeding: " + seed);
+ return seed;
+ }
+
+ /**
+ * Create an initial optimisitc locking value according the {@link VersionType}
+ * contract for the version property <b>if required</b> and inject it into
+ * the snapshot state.
+ *
+ * @param fields The current snapshot state
+ * @param versionProperty The index of the version property
+ * @param versionType The version type
+ * @param session The orginating session
+ * @return True if we injected a new version value into the fields array; false
+ * otherwise.
+ */
+ public static boolean seedVersion(
+ Object[] fields,
+ int versionProperty,
+ VersionType versionType,
+ SessionImplementor session) {
+ Object initialVersion = fields[versionProperty];
+ if (
+ initialVersion==null ||
+ // This next bit is to allow for both unsaved-value="negative"
+ // and for "older" behavior where version number did not get
+ // seeded if it was already set in the object
+ // TODO: shift it into unsaved-value strategy
+ ( (initialVersion instanceof Number) && ( (Number) initialVersion ).longValue()<0 )
+ ) {
+ fields[versionProperty] = seed( versionType, session );
+ return true;
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "using initial version: " + initialVersion );
+ }
+ return false;
+ }
+ }
+
+
+ /**
+ * Generate the next increment in the optimisitc locking value according
+ * the {@link VersionType} contract for the version property.
+ *
+ * @param version The current version
+ * @param versionType The version type
+ * @param session The originating session
+ * @return The incremented optimistic locking value.
+ */
+ public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
+ Object next = versionType.next( version, session );
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ "Incrementing: " +
+ versionType.toLoggableString( version, session.getFactory() ) +
+ " to " +
+ versionType.toLoggableString( next, session.getFactory() )
+ );
+ }
+ return next;
+ }
+
+ /**
+ * Inject the optimisitc locking value into the entity state snapshot.
+ *
+ * @param fields The state snapshot
+ * @param version The optimisitc locking value
+ * @param persister The entity persister
+ */
+ public static void setVersion(Object[] fields, Object version, EntityPersister persister) {
+ if ( !persister.isVersioned() ) {
+ return;
+ }
+ fields[ persister.getVersionProperty() ] = version;
+ }
+
+ /**
+ * Extract the optimisitc locking value out of the entity state snapshot.
+ *
+ * @param fields The state snapshot
+ * @param persister The entity persister
+ * @return The extracted optimisitc locking value
+ */
+ public static Object getVersion(Object[] fields, EntityPersister persister) {
+ if ( !persister.isVersioned() ) {
+ return null;
+ }
+ return fields[ persister.getVersionProperty() ];
+ }
+
+ /**
+ * Do we need to increment the version number, given the dirty properties?
+ *
+ * @param dirtyProperties The array of property indexes which were deemed dirty
+ * @param hasDirtyCollections Were any collections found to be dirty (structurally changed)
+ * @param propertyVersionability An array indicating versionability of each property.
+ * @return True if a version increment is required; false otherwise.
+ */
+ public static boolean isVersionIncrementRequired(
+ final int[] dirtyProperties,
+ final boolean hasDirtyCollections,
+ final boolean[] propertyVersionability) {
+ if ( hasDirtyCollections ) {
+ return true;
+ }
+ for ( int i = 0; i < dirtyProperties.length; i++ ) {
+ if ( propertyVersionability[ dirtyProperties[i] ] ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,334 +0,0 @@
-package org.hibernate.engine.loading;
-
-import java.sql.ResultSet;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.HashSet;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.EntityMode;
-import org.hibernate.CacheMode;
-import org.hibernate.cache.entry.CollectionCacheEntry;
-import org.hibernate.cache.CacheKey;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.engine.CollectionKey;
-import org.hibernate.engine.Status;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.CollectionEntry;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-/**
- * Represents state associated with the processing of a given {@link ResultSet}
- * in regards to loading collections.
- * <p/>
- * Another implementation option to consider is to not expose {@link ResultSet}s
- * directly (in the JDBC redesign) but to always "wrap" them and apply a
- * [series of] context[s] to that wrapper.
- *
- * @author Steve Ebersole
- */
-public class CollectionLoadContext {
- private static final Logger log = LoggerFactory.getLogger( CollectionLoadContext.class );
-
- private final LoadContexts loadContexts;
- private final ResultSet resultSet;
- private Set localLoadingCollectionKeys = new HashSet();
-
- /**
- * Creates a collection load context for the given result set.
- *
- * @param loadContexts Callback to other collection load contexts.
- * @param resultSet The result set this is "wrapping".
- */
- public CollectionLoadContext(LoadContexts loadContexts, ResultSet resultSet) {
- this.loadContexts = loadContexts;
- this.resultSet = resultSet;
- }
-
- public ResultSet getResultSet() {
- return resultSet;
- }
-
- public LoadContexts getLoadContext() {
- return loadContexts;
- }
-
- /**
- * Retrieve the collection that is being loaded as part of processing this
- * result set.
- * <p/>
- * Basically, there are two valid return values from this method:<ul>
- * <li>an instance of {@link PersistentCollection} which indicates to
- * continue loading the result set row data into that returned collection
- * instance; this may be either an instance already associated and in the
- * midst of being loaded, or a newly instantiated instance as a matching
- * associated collection was not found.</li>
- * <li><i>null</i> indicates to ignore the corresponding result set row
- * data relating to the requested collection; this indicates that either
- * the collection was found to already be associated with the persistence
- * context in a fully loaded state, or it was found in a loading state
- * associated with another result set processing context.</li>
- * </ul>
- *
- * @param persister The persister for the collection being requested.
- * @param key The key of the collection being requested.
- *
- * @return The loading collection (see discussion above).
- */
- public PersistentCollection getLoadingCollection(final CollectionPersister persister, final Serializable key) {
- final EntityMode em = loadContexts.getPersistenceContext().getSession().getEntityMode();
- final CollectionKey collectionKey = new CollectionKey( persister, key, em );
- if ( log.isTraceEnabled() ) {
- log.trace( "starting attempt to find loading collection [" + MessageHelper.collectionInfoString( persister.getRole(), key ) + "]" );
- }
- final LoadingCollectionEntry loadingCollectionEntry = loadContexts.locateLoadingCollectionEntry( collectionKey );
- if ( loadingCollectionEntry == null ) {
- // look for existing collection as part of the persistence context
- PersistentCollection collection = loadContexts.getPersistenceContext().getCollection( collectionKey );
- if ( collection != null ) {
- if ( collection.wasInitialized() ) {
- log.trace( "collection already initialized; ignoring" );
- return null; // ignore this row of results! Note the early exit
- }
- else {
- // initialize this collection
- log.trace( "collection not yet initialized; initializing" );
- }
- }
- else {
- Object owner = loadContexts.getPersistenceContext().getCollectionOwner( key, persister );
- final boolean newlySavedEntity = owner != null
- && loadContexts.getPersistenceContext().getEntry( owner ).getStatus() != Status.LOADING
- && em != EntityMode.DOM4J;
- if ( newlySavedEntity ) {
- // important, to account for newly saved entities in query
- // todo : some kind of check for new status...
- log.trace( "owning entity already loaded; ignoring" );
- return null;
- }
- else {
- // create one
- if ( log.isTraceEnabled() ) {
- log.trace( "instantiating new collection [key=" + key + ", rs=" + resultSet + "]" );
- }
- collection = persister.getCollectionType()
- .instantiate( loadContexts.getPersistenceContext().getSession(), persister, key );
- }
- }
- collection.beforeInitialize( persister, -1 );
- collection.beginRead();
- localLoadingCollectionKeys.add( collectionKey );
- loadContexts.registerLoadingCollectionXRef( collectionKey, new LoadingCollectionEntry( resultSet, persister, key, collection ) );
- return collection;
- }
- else {
- if ( loadingCollectionEntry.getResultSet() == resultSet ) {
- log.trace( "found loading collection bound to current result set processing; reading row" );
- return loadingCollectionEntry.getCollection();
- }
- else {
- // ignore this row, the collection is in process of
- // being loaded somewhere further "up" the stack
- log.trace( "collection is already being initialized; ignoring row" );
- return null;
- }
- }
- }
-
- /**
- * Finish the process of collection-loading for this bound result set. Mainly this
- * involves cleaning up resources and notifying the collections that loading is
- * complete.
- *
- * @param persister The persister for which to complete loading.
- */
- public void endLoadingCollections(CollectionPersister persister) {
- SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
- if ( !loadContexts.hasLoadingCollectionEntries()
- && localLoadingCollectionKeys.isEmpty() ) {
- return;
- }
-
- // in an effort to avoid concurrent-modification-exceptions (from
- // potential recursive calls back through here as a result of the
- // eventual call to PersistentCollection#endRead), we scan the
- // internal loadingCollections map for matches and store those matches
- // in a temp collection. the temp collection is then used to "drive"
- // the #endRead processing.
- List matches = null;
- Iterator iter = localLoadingCollectionKeys.iterator();
- while ( iter.hasNext() ) {
- final CollectionKey collectionKey = (CollectionKey) iter.next();
- final LoadingCollectionEntry lce = loadContexts.locateLoadingCollectionEntry( collectionKey );
- if ( lce == null) {
- log.warn( "In CollectionLoadContext#endLoadingCollections, localLoadingCollectionKeys contained [" + collectionKey + "], but no LoadingCollectionEntry was found in loadContexts" );
- }
- else if ( lce.getResultSet() == resultSet && lce.getPersister() == persister ) {
- if ( matches == null ) {
- matches = new ArrayList();
- }
- matches.add( lce );
- if ( lce.getCollection().getOwner() == null ) {
- session.getPersistenceContext().addUnownedCollection(
- new CollectionKey( persister, lce.getKey(), session.getEntityMode() ),
- lce.getCollection()
- );
- }
- if ( log.isTraceEnabled() ) {
- log.trace( "removing collection load entry [" + lce + "]" );
- }
-
- // todo : i'd much rather have this done from #endLoadingCollection(CollectionPersister,LoadingCollectionEntry)...
- loadContexts.unregisterLoadingCollectionXRef( collectionKey );
- iter.remove();
- }
- }
-
- endLoadingCollections( persister, matches );
- if ( localLoadingCollectionKeys.isEmpty() ) {
- // todo : hack!!!
- // NOTE : here we cleanup the load context when we have no more local
- // LCE entries. This "works" for the time being because really
- // only the collection load contexts are implemented. Long term,
- // this cleanup should become part of the "close result set"
- // processing from the (sandbox/jdbc) jdbc-container code.
- loadContexts.cleanup( resultSet );
- }
- }
-
- private void endLoadingCollections(CollectionPersister persister, List matchedCollectionEntries) {
- if ( matchedCollectionEntries == null ) {
- if ( log.isDebugEnabled() ) {
- log.debug( "no collections were found in result set for role: " + persister.getRole() );
- }
- return;
- }
-
- final int count = matchedCollectionEntries.size();
- if ( log.isDebugEnabled() ) {
- log.debug( count + " collections were found in result set for role: " + persister.getRole() );
- }
-
- for ( int i = 0; i < count; i++ ) {
- LoadingCollectionEntry lce = ( LoadingCollectionEntry ) matchedCollectionEntries.get( i );
- endLoadingCollection( lce, persister );
- }
-
- if ( log.isDebugEnabled() ) {
- log.debug( count + " collections initialized for role: " + persister.getRole() );
- }
- }
-
- private void endLoadingCollection(LoadingCollectionEntry lce, CollectionPersister persister) {
- if ( log.isTraceEnabled() ) {
- log.debug( "ending loading collection [" + lce + "]" );
- }
- final SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
- final EntityMode em = session.getEntityMode();
-
- boolean hasNoQueuedAdds = lce.getCollection().endRead(); // warning: can cause a recursive calls! (proxy initialization)
-
- if ( persister.getCollectionType().hasHolder( em ) ) {
- getLoadContext().getPersistenceContext().addCollectionHolder( lce.getCollection() );
- }
-
- CollectionEntry ce = getLoadContext().getPersistenceContext().getCollectionEntry( lce.getCollection() );
- if ( ce == null ) {
- ce = getLoadContext().getPersistenceContext().addInitializedCollection( persister, lce.getCollection(), lce.getKey() );
- }
- else {
- ce.postInitialize( lce.getCollection() );
- }
-
- boolean addToCache = hasNoQueuedAdds && // there were no queued additions
- persister.hasCache() && // and the role has a cache
- session.getCacheMode().isPutEnabled() &&
- !ce.isDoremove(); // and this is not a forced initialization during flush
- if ( addToCache ) {
- addCollectionToCache( lce, persister );
- }
-
- if ( log.isDebugEnabled() ) {
- log.debug( "collection fully initialized: " + MessageHelper.collectionInfoString(persister, lce.getKey(), session.getFactory() ) );
- }
-
- if ( session.getFactory().getStatistics().isStatisticsEnabled() ) {
- session.getFactory().getStatisticsImplementor().loadCollection( persister.getRole() );
- }
- }
-
- /**
- * Add the collection to the second-level cache
- *
- * @param lce The entry representing the collection to add
- * @param persister The persister
- */
- private void addCollectionToCache(LoadingCollectionEntry lce, CollectionPersister persister) {
- final SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
- final SessionFactoryImplementor factory = session.getFactory();
-
- if ( log.isDebugEnabled() ) {
- log.debug( "Caching collection: " + MessageHelper.collectionInfoString( persister, lce.getKey(), factory ) );
- }
-
- if ( !session.getEnabledFilters().isEmpty() && persister.isAffectedByEnabledFilters( session ) ) {
- // some filters affecting the collection are enabled on the session, so do not do the put into the cache.
- log.debug( "Refusing to add to cache due to enabled filters" );
- // todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;
- // but CacheKey is currently used for both collections and entities; would ideally need to define two seperate ones;
- // currently this works in conjuction with the check on
- // DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from
- // cache with enabled filters).
- return; // EARLY EXIT!!!!!
- }
-
- final Object version;
- if ( persister.isVersioned() ) {
- final Object collectionOwner = getLoadContext().getPersistenceContext().getCollectionOwner( lce.getKey(), persister );
- version = getLoadContext().getPersistenceContext().getEntry( collectionOwner ).getVersion();
- }
- else {
- version = null;
- }
-
- CollectionCacheEntry entry = new CollectionCacheEntry( lce.getCollection(), persister );
- CacheKey cacheKey = new CacheKey(
- lce.getKey(),
- persister.getKeyType(),
- persister.getRole(),
- session.getEntityMode(),
- session.getFactory()
- );
- boolean put = persister.getCacheAccessStrategy().putFromLoad(
- cacheKey,
- persister.getCacheEntryStructure().structure(entry),
- session.getTimestamp(),
- version,
- factory.getSettings().isMinimalPutsEnabled() && session.getCacheMode()!= CacheMode.REFRESH
- );
-
- if ( put && factory.getStatistics().isStatisticsEnabled() ) {
- factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
- }
- }
-
- void cleanup() {
- if ( !localLoadingCollectionKeys.isEmpty() ) {
- log.warn( "On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [" + localLoadingCollectionKeys.size() + "] entries" );
- }
- loadContexts.cleanupCollectionXRefs( localLoadingCollectionKeys );
- localLoadingCollectionKeys.clear();
- }
-
-
- public String toString() {
- return super.toString() + "<rs=" + resultSet + ">";
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/CollectionLoadContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,358 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.loading;
+
+import java.sql.ResultSet;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.EntityMode;
+import org.hibernate.CacheMode;
+import org.hibernate.cache.entry.CollectionCacheEntry;
+import org.hibernate.cache.CacheKey;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.engine.CollectionKey;
+import org.hibernate.engine.Status;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.CollectionEntry;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * Represents state associated with the processing of a given {@link ResultSet}
+ * in regards to loading collections.
+ * <p/>
+ * Another implementation option to consider is to not expose {@link ResultSet}s
+ * directly (in the JDBC redesign) but to always "wrap" them and apply a
+ * [series of] context[s] to that wrapper.
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionLoadContext {
+ private static final Logger log = LoggerFactory.getLogger( CollectionLoadContext.class );
+
+ private final LoadContexts loadContexts;
+ private final ResultSet resultSet;
+ private Set localLoadingCollectionKeys = new HashSet();
+
+ /**
+ * Creates a collection load context for the given result set.
+ *
+ * @param loadContexts Callback to other collection load contexts.
+ * @param resultSet The result set this is "wrapping".
+ */
+ public CollectionLoadContext(LoadContexts loadContexts, ResultSet resultSet) {
+ this.loadContexts = loadContexts;
+ this.resultSet = resultSet;
+ }
+
+ public ResultSet getResultSet() {
+ return resultSet;
+ }
+
+ public LoadContexts getLoadContext() {
+ return loadContexts;
+ }
+
+ /**
+ * Retrieve the collection that is being loaded as part of processing this
+ * result set.
+ * <p/>
+ * Basically, there are two valid return values from this method:<ul>
+ * <li>an instance of {@link PersistentCollection} which indicates to
+ * continue loading the result set row data into that returned collection
+ * instance; this may be either an instance already associated and in the
+ * midst of being loaded, or a newly instantiated instance as a matching
+ * associated collection was not found.</li>
+ * <li><i>null</i> indicates to ignore the corresponding result set row
+ * data relating to the requested collection; this indicates that either
+ * the collection was found to already be associated with the persistence
+ * context in a fully loaded state, or it was found in a loading state
+ * associated with another result set processing context.</li>
+ * </ul>
+ *
+ * @param persister The persister for the collection being requested.
+ * @param key The key of the collection being requested.
+ *
+ * @return The loading collection (see discussion above).
+ */
+ public PersistentCollection getLoadingCollection(final CollectionPersister persister, final Serializable key) {
+ final EntityMode em = loadContexts.getPersistenceContext().getSession().getEntityMode();
+ final CollectionKey collectionKey = new CollectionKey( persister, key, em );
+ if ( log.isTraceEnabled() ) {
+ log.trace( "starting attempt to find loading collection [" + MessageHelper.collectionInfoString( persister.getRole(), key ) + "]" );
+ }
+ final LoadingCollectionEntry loadingCollectionEntry = loadContexts.locateLoadingCollectionEntry( collectionKey );
+ if ( loadingCollectionEntry == null ) {
+ // look for existing collection as part of the persistence context
+ PersistentCollection collection = loadContexts.getPersistenceContext().getCollection( collectionKey );
+ if ( collection != null ) {
+ if ( collection.wasInitialized() ) {
+ log.trace( "collection already initialized; ignoring" );
+ return null; // ignore this row of results! Note the early exit
+ }
+ else {
+ // initialize this collection
+ log.trace( "collection not yet initialized; initializing" );
+ }
+ }
+ else {
+ Object owner = loadContexts.getPersistenceContext().getCollectionOwner( key, persister );
+ final boolean newlySavedEntity = owner != null
+ && loadContexts.getPersistenceContext().getEntry( owner ).getStatus() != Status.LOADING
+ && em != EntityMode.DOM4J;
+ if ( newlySavedEntity ) {
+ // important, to account for newly saved entities in query
+ // todo : some kind of check for new status...
+ log.trace( "owning entity already loaded; ignoring" );
+ return null;
+ }
+ else {
+ // create one
+ if ( log.isTraceEnabled() ) {
+ log.trace( "instantiating new collection [key=" + key + ", rs=" + resultSet + "]" );
+ }
+ collection = persister.getCollectionType()
+ .instantiate( loadContexts.getPersistenceContext().getSession(), persister, key );
+ }
+ }
+ collection.beforeInitialize( persister, -1 );
+ collection.beginRead();
+ localLoadingCollectionKeys.add( collectionKey );
+ loadContexts.registerLoadingCollectionXRef( collectionKey, new LoadingCollectionEntry( resultSet, persister, key, collection ) );
+ return collection;
+ }
+ else {
+ if ( loadingCollectionEntry.getResultSet() == resultSet ) {
+ log.trace( "found loading collection bound to current result set processing; reading row" );
+ return loadingCollectionEntry.getCollection();
+ }
+ else {
+ // ignore this row, the collection is in process of
+ // being loaded somewhere further "up" the stack
+ log.trace( "collection is already being initialized; ignoring row" );
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Finish the process of collection-loading for this bound result set. Mainly this
+ * involves cleaning up resources and notifying the collections that loading is
+ * complete.
+ *
+ * @param persister The persister for which to complete loading.
+ */
+ public void endLoadingCollections(CollectionPersister persister) {
+ SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
+ if ( !loadContexts.hasLoadingCollectionEntries()
+ && localLoadingCollectionKeys.isEmpty() ) {
+ return;
+ }
+
+ // in an effort to avoid concurrent-modification-exceptions (from
+ // potential recursive calls back through here as a result of the
+ // eventual call to PersistentCollection#endRead), we scan the
+ // internal loadingCollections map for matches and store those matches
+ // in a temp collection. the temp collection is then used to "drive"
+ // the #endRead processing.
+ List matches = null;
+ Iterator iter = localLoadingCollectionKeys.iterator();
+ while ( iter.hasNext() ) {
+ final CollectionKey collectionKey = (CollectionKey) iter.next();
+ final LoadingCollectionEntry lce = loadContexts.locateLoadingCollectionEntry( collectionKey );
+ if ( lce == null) {
+ log.warn( "In CollectionLoadContext#endLoadingCollections, localLoadingCollectionKeys contained [" + collectionKey + "], but no LoadingCollectionEntry was found in loadContexts" );
+ }
+ else if ( lce.getResultSet() == resultSet && lce.getPersister() == persister ) {
+ if ( matches == null ) {
+ matches = new ArrayList();
+ }
+ matches.add( lce );
+ if ( lce.getCollection().getOwner() == null ) {
+ session.getPersistenceContext().addUnownedCollection(
+ new CollectionKey( persister, lce.getKey(), session.getEntityMode() ),
+ lce.getCollection()
+ );
+ }
+ if ( log.isTraceEnabled() ) {
+ log.trace( "removing collection load entry [" + lce + "]" );
+ }
+
+ // todo : i'd much rather have this done from #endLoadingCollection(CollectionPersister,LoadingCollectionEntry)...
+ loadContexts.unregisterLoadingCollectionXRef( collectionKey );
+ iter.remove();
+ }
+ }
+
+ endLoadingCollections( persister, matches );
+ if ( localLoadingCollectionKeys.isEmpty() ) {
+ // todo : hack!!!
+ // NOTE : here we cleanup the load context when we have no more local
+ // LCE entries. This "works" for the time being because really
+ // only the collection load contexts are implemented. Long term,
+ // this cleanup should become part of the "close result set"
+ // processing from the (sandbox/jdbc) jdbc-container code.
+ loadContexts.cleanup( resultSet );
+ }
+ }
+
+ private void endLoadingCollections(CollectionPersister persister, List matchedCollectionEntries) {
+ if ( matchedCollectionEntries == null ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "no collections were found in result set for role: " + persister.getRole() );
+ }
+ return;
+ }
+
+ final int count = matchedCollectionEntries.size();
+ if ( log.isDebugEnabled() ) {
+ log.debug( count + " collections were found in result set for role: " + persister.getRole() );
+ }
+
+ for ( int i = 0; i < count; i++ ) {
+ LoadingCollectionEntry lce = ( LoadingCollectionEntry ) matchedCollectionEntries.get( i );
+ endLoadingCollection( lce, persister );
+ }
+
+ if ( log.isDebugEnabled() ) {
+ log.debug( count + " collections initialized for role: " + persister.getRole() );
+ }
+ }
+
+ private void endLoadingCollection(LoadingCollectionEntry lce, CollectionPersister persister) {
+ if ( log.isTraceEnabled() ) {
+ log.debug( "ending loading collection [" + lce + "]" );
+ }
+ final SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
+ final EntityMode em = session.getEntityMode();
+
+ boolean hasNoQueuedAdds = lce.getCollection().endRead(); // warning: can cause a recursive calls! (proxy initialization)
+
+ if ( persister.getCollectionType().hasHolder( em ) ) {
+ getLoadContext().getPersistenceContext().addCollectionHolder( lce.getCollection() );
+ }
+
+ CollectionEntry ce = getLoadContext().getPersistenceContext().getCollectionEntry( lce.getCollection() );
+ if ( ce == null ) {
+ ce = getLoadContext().getPersistenceContext().addInitializedCollection( persister, lce.getCollection(), lce.getKey() );
+ }
+ else {
+ ce.postInitialize( lce.getCollection() );
+ }
+
+ boolean addToCache = hasNoQueuedAdds && // there were no queued additions
+ persister.hasCache() && // and the role has a cache
+ session.getCacheMode().isPutEnabled() &&
+ !ce.isDoremove(); // and this is not a forced initialization during flush
+ if ( addToCache ) {
+ addCollectionToCache( lce, persister );
+ }
+
+ if ( log.isDebugEnabled() ) {
+ log.debug( "collection fully initialized: " + MessageHelper.collectionInfoString(persister, lce.getKey(), session.getFactory() ) );
+ }
+
+ if ( session.getFactory().getStatistics().isStatisticsEnabled() ) {
+ session.getFactory().getStatisticsImplementor().loadCollection( persister.getRole() );
+ }
+ }
+
+ /**
+ * Add the collection to the second-level cache
+ *
+ * @param lce The entry representing the collection to add
+ * @param persister The persister
+ */
+ private void addCollectionToCache(LoadingCollectionEntry lce, CollectionPersister persister) {
+ final SessionImplementor session = getLoadContext().getPersistenceContext().getSession();
+ final SessionFactoryImplementor factory = session.getFactory();
+
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Caching collection: " + MessageHelper.collectionInfoString( persister, lce.getKey(), factory ) );
+ }
+
+ if ( !session.getEnabledFilters().isEmpty() && persister.isAffectedByEnabledFilters( session ) ) {
+ // some filters affecting the collection are enabled on the session, so do not do the put into the cache.
+ log.debug( "Refusing to add to cache due to enabled filters" );
+ // todo : add the notion of enabled filters to the CacheKey to differentiate filtered collections from non-filtered;
+ // but CacheKey is currently used for both collections and entities; would ideally need to define two seperate ones;
+ // currently this works in conjuction with the check on
+ // DefaultInitializeCollectionEventHandler.initializeCollectionFromCache() (which makes sure to not read from
+ // cache with enabled filters).
+ return; // EARLY EXIT!!!!!
+ }
+
+ final Object version;
+ if ( persister.isVersioned() ) {
+ final Object collectionOwner = getLoadContext().getPersistenceContext().getCollectionOwner( lce.getKey(), persister );
+ version = getLoadContext().getPersistenceContext().getEntry( collectionOwner ).getVersion();
+ }
+ else {
+ version = null;
+ }
+
+ CollectionCacheEntry entry = new CollectionCacheEntry( lce.getCollection(), persister );
+ CacheKey cacheKey = new CacheKey(
+ lce.getKey(),
+ persister.getKeyType(),
+ persister.getRole(),
+ session.getEntityMode(),
+ session.getFactory()
+ );
+ boolean put = persister.getCacheAccessStrategy().putFromLoad(
+ cacheKey,
+ persister.getCacheEntryStructure().structure(entry),
+ session.getTimestamp(),
+ version,
+ factory.getSettings().isMinimalPutsEnabled() && session.getCacheMode()!= CacheMode.REFRESH
+ );
+
+ if ( put && factory.getStatistics().isStatisticsEnabled() ) {
+ factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
+ }
+ }
+
+ void cleanup() {
+ if ( !localLoadingCollectionKeys.isEmpty() ) {
+ log.warn( "On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [" + localLoadingCollectionKeys.size() + "] entries" );
+ }
+ loadContexts.cleanupCollectionXRefs( localLoadingCollectionKeys );
+ localLoadingCollectionKeys.clear();
+ }
+
+
+ public String toString() {
+ return super.toString() + "<rs=" + resultSet + ">";
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,39 +0,0 @@
-package org.hibernate.engine.loading;
-
-import java.sql.ResultSet;
-import java.util.List;
-import java.util.ArrayList;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@inheritDoc}
- *
- * @author Steve Ebersole
- */
-public class EntityLoadContext {
- private static final Logger log = LoggerFactory.getLogger( EntityLoadContext.class );
-
- private final LoadContexts loadContexts;
- private final ResultSet resultSet;
- private final List hydratingEntities = new ArrayList( 20 ); // todo : need map? the prob is a proper key, right?
-
- public EntityLoadContext(LoadContexts loadContexts, ResultSet resultSet) {
- this.loadContexts = loadContexts;
- this.resultSet = resultSet;
- }
-
- void cleanup() {
- if ( !hydratingEntities.isEmpty() ) {
- log.warn( "On EntityLoadContext#clear, hydratingEntities contained [" + hydratingEntities.size() + "] entries" );
- }
- hydratingEntities.clear();
- }
-
-
- public String toString() {
- return super.toString() + "<rs=" + resultSet + ">";
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/EntityLoadContext.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,63 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.loading;
+
+import java.sql.ResultSet;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class EntityLoadContext {
+ private static final Logger log = LoggerFactory.getLogger( EntityLoadContext.class );
+
+ private final LoadContexts loadContexts;
+ private final ResultSet resultSet;
+ private final List hydratingEntities = new ArrayList( 20 ); // todo : need map? the prob is a proper key, right?
+
+ public EntityLoadContext(LoadContexts loadContexts, ResultSet resultSet) {
+ this.loadContexts = loadContexts;
+ this.resultSet = resultSet;
+ }
+
+ void cleanup() {
+ if ( !hydratingEntities.isEmpty() ) {
+ log.warn( "On EntityLoadContext#clear, hydratingEntities contained [" + hydratingEntities.size() + "] entries" );
+ }
+ hydratingEntities.clear();
+ }
+
+
+ public String toString() {
+ return super.toString() + "<rs=" + resultSet + ">";
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,307 +0,0 @@
-package org.hibernate.engine.loading;
-
-import java.sql.ResultSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.io.Serializable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.util.IdentityMap;
-import org.hibernate.engine.PersistenceContext;
-import org.hibernate.engine.CollectionKey;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-import org.hibernate.EntityMode;
-
-/**
- * Maps {@link ResultSet result-sets} to specific contextual data
- * related to processing that {@link ResultSet result-sets}.
- * <p/>
- * Implementation note: internally an {@link IdentityMap} is used to maintain
- * the mappings; {@link IdentityMap} was chosen because I'd rather not be
- * dependent upon potentially bad {@link ResultSet#equals} and {ResultSet#hashCode}
- * implementations.
- * <p/>
- * Considering the JDBC-redesign work, would further like this contextual info
- * not mapped seperately, but available based on the result set being processed.
- * This would also allow maintaining a single mapping as we could reliably get
- * notification of the result-set closing...
- *
- * @author Steve Ebersole
- */
-public class LoadContexts {
- private static final Logger log = LoggerFactory.getLogger( LoadContexts.class );
-
- private final PersistenceContext persistenceContext;
- private Map collectionLoadContexts;
- private Map entityLoadContexts;
-
- private Map xrefLoadingCollectionEntries;
-
- /**
- * Creates and binds this to the given persistence context.
- *
- * @param persistenceContext The persistence context to which this
- * will be bound.
- */
- public LoadContexts(PersistenceContext persistenceContext) {
- this.persistenceContext = persistenceContext;
- }
-
- /**
- * Retrieves the persistence context to which this is bound.
- *
- * @return The persistence context to which this is bound.
- */
- public PersistenceContext getPersistenceContext() {
- return persistenceContext;
- }
-
- private SessionImplementor getSession() {
- return getPersistenceContext().getSession();
- }
-
- private EntityMode getEntityMode() {
- return getSession().getEntityMode();
- }
-
-
- // cleanup code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Release internal state associated with the given result set.
- * <p/>
- * This should be called when we are done with processing said result set,
- * ideally as the result set is being closed.
- *
- * @param resultSet The result set for which it is ok to release
- * associated resources.
- */
- public void cleanup(ResultSet resultSet) {
- if ( collectionLoadContexts != null ) {
- CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) collectionLoadContexts.remove( resultSet );
- collectionLoadContext.cleanup();
- }
- if ( entityLoadContexts != null ) {
- EntityLoadContext entityLoadContext = ( EntityLoadContext ) entityLoadContexts.remove( resultSet );
- entityLoadContext.cleanup();
- }
- }
-
- /**
- * Release internal state associated with *all* result sets.
- * <p/>
- * This is intended as a "failsafe" process to make sure we get everything
- * cleaned up and released.
- */
- public void cleanup() {
- if ( collectionLoadContexts != null ) {
- Iterator itr = collectionLoadContexts.values().iterator();
- while ( itr.hasNext() ) {
- CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next();
- log.warn( "fail-safe cleanup (collections) : " + collectionLoadContext );
- collectionLoadContext.cleanup();
- }
- collectionLoadContexts.clear();
- }
- if ( entityLoadContexts != null ) {
- Iterator itr = entityLoadContexts.values().iterator();
- while ( itr.hasNext() ) {
- EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next();
- log.warn( "fail-safe cleanup (entities) : " + entityLoadContext );
- entityLoadContext.cleanup();
- }
- entityLoadContexts.clear();
- }
- }
-
-
- // Collection load contexts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Do we currently have any internal entries corresponding to loading
- * collections?
- *
- * @return True if we currently hold state pertaining to loading collections;
- * false otherwise.
- */
- public boolean hasLoadingCollectionEntries() {
- return ( collectionLoadContexts != null && !collectionLoadContexts.isEmpty() );
- }
-
- /**
- * Do we currently have any registered internal entries corresponding to loading
- * collections?
- *
- * @return True if we currently hold state pertaining to a registered loading collections;
- * false otherwise.
- */
- public boolean hasRegisteredLoadingCollectionEntries() {
- return ( xrefLoadingCollectionEntries != null && !xrefLoadingCollectionEntries.isEmpty() );
- }
-
-
- /**
- * Get the {@link CollectionLoadContext} associated with the given
- * {@link ResultSet}, creating one if needed.
- *
- * @param resultSet The result set for which to retrieve the context.
- * @return The processing context.
- */
- public CollectionLoadContext getCollectionLoadContext(ResultSet resultSet) {
- CollectionLoadContext context = null;
- if ( collectionLoadContexts == null ) {
- collectionLoadContexts = IdentityMap.instantiate( 8 );
- }
- else {
- context = ( CollectionLoadContext ) collectionLoadContexts.get( resultSet );
- }
- if ( context == null ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "constructing collection load context for result set [" + resultSet + "]" );
- }
- context = new CollectionLoadContext( this, resultSet );
- collectionLoadContexts.put( resultSet, context );
- }
- return context;
- }
-
- /**
- * Attempt to locate the loading collection given the owner's key. The lookup here
- * occurs against all result-set contexts...
- *
- * @param persister The collection persister
- * @param ownerKey The owner key
- * @return The loading collection, or null if not found.
- */
- public PersistentCollection locateLoadingCollection(CollectionPersister persister, Serializable ownerKey) {
- LoadingCollectionEntry lce = locateLoadingCollectionEntry( new CollectionKey( persister, ownerKey, getEntityMode() ) );
- if ( lce != null ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "returning loading collection:" + MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) );
- }
- return lce.getCollection();
- }
- else {
- // todo : should really move this log statement to CollectionType, where this is used from...
- if ( log.isTraceEnabled() ) {
- log.trace( "creating collection wrapper:" + MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) );
- }
- return null;
- }
- }
-
- // loading collection xrefs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Register a loading collection xref.
- * <p/>
- * This xref map is used because sometimes a collection is in process of
- * being loaded from one result set, but needs to be accessed from the
- * context of another "nested" result set processing.
- * <p/>
- * Implementation note: package protected, as this is meant solely for use
- * by {@link CollectionLoadContext} to be able to locate collections
- * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
- *
- * @param entryKey The xref collection key
- * @param entry The corresponding loading collection entry
- */
- void registerLoadingCollectionXRef(CollectionKey entryKey, LoadingCollectionEntry entry) {
- if ( xrefLoadingCollectionEntries == null ) {
- xrefLoadingCollectionEntries = new HashMap();
- }
- xrefLoadingCollectionEntries.put( entryKey, entry );
- }
-
- /**
- * The inverse of {@link #registerLoadingCollectionXRef}. Here, we are done
- * processing the said collection entry, so we remove it from the
- * load context.
- * <p/>
- * The idea here is that other loading collections can now reference said
- * collection directly from the {@link PersistenceContext} because it
- * has completed its load cycle.
- * <p/>
- * Implementation note: package protected, as this is meant solely for use
- * by {@link CollectionLoadContext} to be able to locate collections
- * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
- *
- * @param key The key of the collection we are done processing.
- */
- void unregisterLoadingCollectionXRef(CollectionKey key) {
- if ( !hasRegisteredLoadingCollectionEntries() ) {
- return;
- }
- xrefLoadingCollectionEntries.remove(key);
- }
-
- /*package*/Map getLoadingCollectionXRefs() {
- return xrefLoadingCollectionEntries;
- }
-
-
- /**
- * Locate the LoadingCollectionEntry within *any* of the tracked
- * {@link CollectionLoadContext}s.
- * <p/>
- * Implementation note: package protected, as this is meant solely for use
- * by {@link CollectionLoadContext} to be able to locate collections
- * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
- *
- * @param key The collection key.
- * @return The located entry; or null.
- */
- LoadingCollectionEntry locateLoadingCollectionEntry(CollectionKey key) {
- if ( xrefLoadingCollectionEntries == null ) {
- return null;
- }
- if ( log.isTraceEnabled() ) {
- log.trace( "attempting to locate loading collection entry [" + key + "] in any result-set context" );
- }
- LoadingCollectionEntry rtn = ( LoadingCollectionEntry ) xrefLoadingCollectionEntries.get( key );
- if ( log.isTraceEnabled() ) {
- if ( rtn == null ) {
- log.trace( "collection [" + key + "] not located in load context" );
- }
- else {
- log.trace( "collection [" + key + "] located in load context" );
- }
- }
- return rtn;
- }
-
- /*package*/void cleanupCollectionXRefs(Set entryKeys) {
- Iterator itr = entryKeys.iterator();
- while ( itr.hasNext() ) {
- final CollectionKey entryKey = ( CollectionKey ) itr.next();
- xrefLoadingCollectionEntries.remove( entryKey );
- }
- }
-
-
- // Entity load contexts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // * currently, not yet used...
-
- public EntityLoadContext getEntityLoadContext(ResultSet resultSet) {
- EntityLoadContext context = null;
- if ( entityLoadContexts == null ) {
- entityLoadContexts = IdentityMap.instantiate( 8 );
- }
- else {
- context = ( EntityLoadContext ) entityLoadContexts.get( resultSet );
- }
- if ( context == null ) {
- context = new EntityLoadContext( this, resultSet );
- entityLoadContexts.put( resultSet, context );
- }
- return context;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadContexts.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,331 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.loading;
+
+import java.sql.ResultSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.io.Serializable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.util.IdentityMap;
+import org.hibernate.engine.PersistenceContext;
+import org.hibernate.engine.CollectionKey;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+import org.hibernate.EntityMode;
+
+/**
+ * Maps {@link ResultSet result-sets} to specific contextual data
+ * related to processing that {@link ResultSet result-sets}.
+ * <p/>
+ * Implementation note: internally an {@link IdentityMap} is used to maintain
+ * the mappings; {@link IdentityMap} was chosen because I'd rather not be
+ * dependent upon potentially bad {@link ResultSet#equals} and {ResultSet#hashCode}
+ * implementations.
+ * <p/>
+ * Considering the JDBC-redesign work, would further like this contextual info
+ * not mapped seperately, but available based on the result set being processed.
+ * This would also allow maintaining a single mapping as we could reliably get
+ * notification of the result-set closing...
+ *
+ * @author Steve Ebersole
+ */
+public class LoadContexts {
+ private static final Logger log = LoggerFactory.getLogger( LoadContexts.class );
+
+ private final PersistenceContext persistenceContext;
+ private Map collectionLoadContexts;
+ private Map entityLoadContexts;
+
+ private Map xrefLoadingCollectionEntries;
+
+ /**
+ * Creates and binds this to the given persistence context.
+ *
+ * @param persistenceContext The persistence context to which this
+ * will be bound.
+ */
+ public LoadContexts(PersistenceContext persistenceContext) {
+ this.persistenceContext = persistenceContext;
+ }
+
+ /**
+ * Retrieves the persistence context to which this is bound.
+ *
+ * @return The persistence context to which this is bound.
+ */
+ public PersistenceContext getPersistenceContext() {
+ return persistenceContext;
+ }
+
+ private SessionImplementor getSession() {
+ return getPersistenceContext().getSession();
+ }
+
+ private EntityMode getEntityMode() {
+ return getSession().getEntityMode();
+ }
+
+
+ // cleanup code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Release internal state associated with the given result set.
+ * <p/>
+ * This should be called when we are done with processing said result set,
+ * ideally as the result set is being closed.
+ *
+ * @param resultSet The result set for which it is ok to release
+ * associated resources.
+ */
+ public void cleanup(ResultSet resultSet) {
+ if ( collectionLoadContexts != null ) {
+ CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) collectionLoadContexts.remove( resultSet );
+ collectionLoadContext.cleanup();
+ }
+ if ( entityLoadContexts != null ) {
+ EntityLoadContext entityLoadContext = ( EntityLoadContext ) entityLoadContexts.remove( resultSet );
+ entityLoadContext.cleanup();
+ }
+ }
+
+ /**
+ * Release internal state associated with *all* result sets.
+ * <p/>
+ * This is intended as a "failsafe" process to make sure we get everything
+ * cleaned up and released.
+ */
+ public void cleanup() {
+ if ( collectionLoadContexts != null ) {
+ Iterator itr = collectionLoadContexts.values().iterator();
+ while ( itr.hasNext() ) {
+ CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next();
+ log.warn( "fail-safe cleanup (collections) : " + collectionLoadContext );
+ collectionLoadContext.cleanup();
+ }
+ collectionLoadContexts.clear();
+ }
+ if ( entityLoadContexts != null ) {
+ Iterator itr = entityLoadContexts.values().iterator();
+ while ( itr.hasNext() ) {
+ EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next();
+ log.warn( "fail-safe cleanup (entities) : " + entityLoadContext );
+ entityLoadContext.cleanup();
+ }
+ entityLoadContexts.clear();
+ }
+ }
+
+
+ // Collection load contexts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Do we currently have any internal entries corresponding to loading
+ * collections?
+ *
+ * @return True if we currently hold state pertaining to loading collections;
+ * false otherwise.
+ */
+ public boolean hasLoadingCollectionEntries() {
+ return ( collectionLoadContexts != null && !collectionLoadContexts.isEmpty() );
+ }
+
+ /**
+ * Do we currently have any registered internal entries corresponding to loading
+ * collections?
+ *
+ * @return True if we currently hold state pertaining to a registered loading collections;
+ * false otherwise.
+ */
+ public boolean hasRegisteredLoadingCollectionEntries() {
+ return ( xrefLoadingCollectionEntries != null && !xrefLoadingCollectionEntries.isEmpty() );
+ }
+
+
+ /**
+ * Get the {@link CollectionLoadContext} associated with the given
+ * {@link ResultSet}, creating one if needed.
+ *
+ * @param resultSet The result set for which to retrieve the context.
+ * @return The processing context.
+ */
+ public CollectionLoadContext getCollectionLoadContext(ResultSet resultSet) {
+ CollectionLoadContext context = null;
+ if ( collectionLoadContexts == null ) {
+ collectionLoadContexts = IdentityMap.instantiate( 8 );
+ }
+ else {
+ context = ( CollectionLoadContext ) collectionLoadContexts.get( resultSet );
+ }
+ if ( context == null ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "constructing collection load context for result set [" + resultSet + "]" );
+ }
+ context = new CollectionLoadContext( this, resultSet );
+ collectionLoadContexts.put( resultSet, context );
+ }
+ return context;
+ }
+
+ /**
+ * Attempt to locate the loading collection given the owner's key. The lookup here
+ * occurs against all result-set contexts...
+ *
+ * @param persister The collection persister
+ * @param ownerKey The owner key
+ * @return The loading collection, or null if not found.
+ */
+ public PersistentCollection locateLoadingCollection(CollectionPersister persister, Serializable ownerKey) {
+ LoadingCollectionEntry lce = locateLoadingCollectionEntry( new CollectionKey( persister, ownerKey, getEntityMode() ) );
+ if ( lce != null ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "returning loading collection:" + MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) );
+ }
+ return lce.getCollection();
+ }
+ else {
+ // todo : should really move this log statement to CollectionType, where this is used from...
+ if ( log.isTraceEnabled() ) {
+ log.trace( "creating collection wrapper:" + MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) );
+ }
+ return null;
+ }
+ }
+
+ // loading collection xrefs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Register a loading collection xref.
+ * <p/>
+ * This xref map is used because sometimes a collection is in process of
+ * being loaded from one result set, but needs to be accessed from the
+ * context of another "nested" result set processing.
+ * <p/>
+ * Implementation note: package protected, as this is meant solely for use
+ * by {@link CollectionLoadContext} to be able to locate collections
+ * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
+ *
+ * @param entryKey The xref collection key
+ * @param entry The corresponding loading collection entry
+ */
+ void registerLoadingCollectionXRef(CollectionKey entryKey, LoadingCollectionEntry entry) {
+ if ( xrefLoadingCollectionEntries == null ) {
+ xrefLoadingCollectionEntries = new HashMap();
+ }
+ xrefLoadingCollectionEntries.put( entryKey, entry );
+ }
+
+ /**
+ * The inverse of {@link #registerLoadingCollectionXRef}. Here, we are done
+ * processing the said collection entry, so we remove it from the
+ * load context.
+ * <p/>
+ * The idea here is that other loading collections can now reference said
+ * collection directly from the {@link PersistenceContext} because it
+ * has completed its load cycle.
+ * <p/>
+ * Implementation note: package protected, as this is meant solely for use
+ * by {@link CollectionLoadContext} to be able to locate collections
+ * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
+ *
+ * @param key The key of the collection we are done processing.
+ */
+ void unregisterLoadingCollectionXRef(CollectionKey key) {
+ if ( !hasRegisteredLoadingCollectionEntries() ) {
+ return;
+ }
+ xrefLoadingCollectionEntries.remove(key);
+ }
+
+ /*package*/Map getLoadingCollectionXRefs() {
+ return xrefLoadingCollectionEntries;
+ }
+
+
+ /**
+ * Locate the LoadingCollectionEntry within *any* of the tracked
+ * {@link CollectionLoadContext}s.
+ * <p/>
+ * Implementation note: package protected, as this is meant solely for use
+ * by {@link CollectionLoadContext} to be able to locate collections
+ * being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
+ *
+ * @param key The collection key.
+ * @return The located entry; or null.
+ */
+ LoadingCollectionEntry locateLoadingCollectionEntry(CollectionKey key) {
+ if ( xrefLoadingCollectionEntries == null ) {
+ return null;
+ }
+ if ( log.isTraceEnabled() ) {
+ log.trace( "attempting to locate loading collection entry [" + key + "] in any result-set context" );
+ }
+ LoadingCollectionEntry rtn = ( LoadingCollectionEntry ) xrefLoadingCollectionEntries.get( key );
+ if ( log.isTraceEnabled() ) {
+ if ( rtn == null ) {
+ log.trace( "collection [" + key + "] not located in load context" );
+ }
+ else {
+ log.trace( "collection [" + key + "] located in load context" );
+ }
+ }
+ return rtn;
+ }
+
+ /*package*/void cleanupCollectionXRefs(Set entryKeys) {
+ Iterator itr = entryKeys.iterator();
+ while ( itr.hasNext() ) {
+ final CollectionKey entryKey = ( CollectionKey ) itr.next();
+ xrefLoadingCollectionEntries.remove( entryKey );
+ }
+ }
+
+
+ // Entity load contexts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ // * currently, not yet used...
+
+ public EntityLoadContext getEntityLoadContext(ResultSet resultSet) {
+ EntityLoadContext context = null;
+ if ( entityLoadContexts == null ) {
+ entityLoadContexts = IdentityMap.instantiate( 8 );
+ }
+ else {
+ context = ( EntityLoadContext ) entityLoadContexts.get( resultSet );
+ }
+ if ( context == null ) {
+ context = new EntityLoadContext( this, resultSet );
+ entityLoadContexts.put( resultSet, context );
+ }
+ return context;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,51 +0,0 @@
-package org.hibernate.engine.loading;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.pretty.MessageHelper;
-
-/**
- * Represents a collection currently being loaded.
- *
- * @author Steve Ebersole
- */
-public class LoadingCollectionEntry {
- private final ResultSet resultSet;
- private final CollectionPersister persister;
- private final Serializable key;
- private final PersistentCollection collection;
-
- public LoadingCollectionEntry(
- ResultSet resultSet,
- CollectionPersister persister,
- Serializable key,
- PersistentCollection collection) {
- this.resultSet = resultSet;
- this.persister = persister;
- this.key = key;
- this.collection = collection;
- }
-
- public ResultSet getResultSet() {
- return resultSet;
- }
-
- public CollectionPersister getPersister() {
- return persister;
- }
-
- public Serializable getKey() {
- return key;
- }
-
- public PersistentCollection getCollection() {
- return collection;
- }
-
- public String toString() {
- return getClass().getName() + "<rs=" + resultSet + ", coll=" + MessageHelper.collectionInfoString( persister.getRole(), key ) + ">@" + Integer.toHexString( hashCode() );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/loading/LoadingCollectionEntry.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,75 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.loading;
+
+import java.io.Serializable;
+import java.sql.ResultSet;
+
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.pretty.MessageHelper;
+
+/**
+ * Represents a collection currently being loaded.
+ *
+ * @author Steve Ebersole
+ */
+public class LoadingCollectionEntry {
+ private final ResultSet resultSet;
+ private final CollectionPersister persister;
+ private final Serializable key;
+ private final PersistentCollection collection;
+
+ public LoadingCollectionEntry(
+ ResultSet resultSet,
+ CollectionPersister persister,
+ Serializable key,
+ PersistentCollection collection) {
+ this.resultSet = resultSet;
+ this.persister = persister;
+ this.key = key;
+ this.collection = collection;
+ }
+
+ public ResultSet getResultSet() {
+ return resultSet;
+ }
+
+ public CollectionPersister getPersister() {
+ return persister;
+ }
+
+ public Serializable getKey() {
+ return key;
+ }
+
+ public PersistentCollection getCollection() {
+ return collection;
+ }
+
+ public String toString() {
+ return getClass().getName() + "<rs=" + resultSet + ", coll=" + MessageHelper.collectionInfoString( persister.getRole(), key ) + ">@" + Integer.toHexString( hashCode() );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/package.html 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,9 +0,0 @@
-<html>
-<head></head>
-<body>
-<p>
- This package contains classes that are "shared" by other packages,
- and implementations of some key algorithms.
-</p>
-</body>
-</html>
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/package.html)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/package.html 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,34 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<html>
+<head></head>
+<body>
+<p>
+ This package contains classes that are "shared" by other packages,
+ and implementations of some key algorithms.
+</p>
+</body>
+</html>
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,31 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.engine.SessionFactoryImplementor;
-
-import java.io.Serializable;
-import java.util.Map;
-
-/**
- * Extends an HQLQueryPlan to maintain a reference to the collection-role name
- * being filtered.
- *
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class FilterQueryPlan extends HQLQueryPlan implements Serializable {
-
- private final String collectionRole;
-
- public FilterQueryPlan(
- String hql,
- String collectionRole,
- boolean shallow,
- Map enabledFilters,
- SessionFactoryImplementor factory) {
- super( hql, collectionRole, shallow, enabledFilters, factory );
- this.collectionRole = collectionRole;
- }
-
- public String getCollectionRole() {
- return collectionRole;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/FilterQueryPlan.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Extends an HQLQueryPlan to maintain a reference to the collection-role name
+ * being filtered.
+ *
+ * @author Steve Ebersole
+ */
+public class FilterQueryPlan extends HQLQueryPlan implements Serializable {
+
+ private final String collectionRole;
+
+ public FilterQueryPlan(
+ String hql,
+ String collectionRole,
+ boolean shallow,
+ Map enabledFilters,
+ SessionFactoryImplementor factory) {
+ super( hql, collectionRole, shallow, enabledFilters, factory );
+ this.collectionRole = collectionRole;
+ }
+
+ public String getCollectionRole() {
+ return collectionRole;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,315 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.hql.QuerySplitter;
-import org.hibernate.hql.QueryTranslator;
-import org.hibernate.hql.ParameterTranslations;
-import org.hibernate.hql.FilterTranslator;
-import org.hibernate.util.ArrayHelper;
-import org.hibernate.util.EmptyIterator;
-import org.hibernate.util.JoinedIterator;
-import org.hibernate.util.IdentitySet;
-import org.hibernate.HibernateException;
-import org.hibernate.ScrollableResults;
-import org.hibernate.QueryException;
-import org.hibernate.type.Type;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.QueryParameters;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.RowSelection;
-import org.hibernate.event.EventSource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.HashMap;
-
-/**
- * Defines a query execution plan for an HQL query (or filter).
- *
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class HQLQueryPlan implements Serializable {
-
- // TODO : keep seperate notions of QT[] here for shallow/non-shallow queries...
-
- private static final Logger log = LoggerFactory.getLogger( HQLQueryPlan.class );
-
- private final String sourceQuery;
- private final QueryTranslator[] translators;
- private final String[] sqlStrings;
-
- private final ParameterMetadata parameterMetadata;
- private final ReturnMetadata returnMetadata;
- private final Set querySpaces;
-
- private final Set enabledFilterNames;
- private final boolean shallow;
-
-
- public HQLQueryPlan(String hql, boolean shallow, Map enabledFilters, SessionFactoryImplementor factory) {
- this( hql, null, shallow, enabledFilters, factory );
- }
-
- protected HQLQueryPlan(String hql, String collectionRole, boolean shallow, Map enabledFilters, SessionFactoryImplementor factory) {
- this.sourceQuery = hql;
- this.shallow = shallow;
-
- Set copy = new HashSet();
- copy.addAll( enabledFilters.keySet() );
- this.enabledFilterNames = java.util.Collections.unmodifiableSet( copy );
-
- Set combinedQuerySpaces = new HashSet();
- String[] concreteQueryStrings = QuerySplitter.concreteQueries( hql, factory );
- final int length = concreteQueryStrings.length;
- translators = new QueryTranslator[length];
- List sqlStringList = new ArrayList();
- for ( int i=0; i<length; i++ ) {
- if ( collectionRole == null ) {
- translators[i] = factory.getSettings()
- .getQueryTranslatorFactory()
- .createQueryTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
- translators[i].compile( factory.getSettings().getQuerySubstitutions(), shallow );
- }
- else {
- translators[i] = factory.getSettings()
- .getQueryTranslatorFactory()
- .createFilterTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
- ( ( FilterTranslator ) translators[i] ).compile( collectionRole, factory.getSettings().getQuerySubstitutions(), shallow );
- }
- combinedQuerySpaces.addAll( translators[i].getQuerySpaces() );
- sqlStringList.addAll( translators[i].collectSqlStrings() );
- }
-
- this.sqlStrings = ArrayHelper.toStringArray( sqlStringList );
- this.querySpaces = combinedQuerySpaces;
-
- if ( length == 0 ) {
- parameterMetadata = new ParameterMetadata( null, null );
- returnMetadata = null;
- }
- else {
- this.parameterMetadata = buildParameterMetadata( translators[0].getParameterTranslations(), hql );
- if ( translators[0].isManipulationStatement() ) {
- returnMetadata = null;
- }
- else {
- if ( length > 1 ) {
- final int returns = translators[0].getReturnTypes().length;
- returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), new Type[returns] );
- }
- else {
- returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), translators[0].getReturnTypes() );
- }
- }
- }
- }
-
- public String getSourceQuery() {
- return sourceQuery;
- }
-
- public Set getQuerySpaces() {
- return querySpaces;
- }
-
- public ParameterMetadata getParameterMetadata() {
- return parameterMetadata;
- }
-
- public ReturnMetadata getReturnMetadata() {
- return returnMetadata;
- }
-
- public Set getEnabledFilterNames() {
- return enabledFilterNames;
- }
-
- public String[] getSqlStrings() {
- return sqlStrings;
- }
-
- public Set getUtilizedFilterNames() {
- // TODO : add this info to the translator and aggregate it here...
- return null;
- }
-
- public boolean isShallow() {
- return shallow;
- }
-
- public List performList(
- QueryParameters queryParameters,
- SessionImplementor session) throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "find: " + getSourceQuery() );
- queryParameters.traceParameters( session.getFactory() );
- }
- boolean hasLimit = queryParameters.getRowSelection() != null &&
- queryParameters.getRowSelection().definesLimits();
- boolean needsLimit = hasLimit && translators.length > 1;
- QueryParameters queryParametersToUse;
- if ( needsLimit ) {
- log.warn( "firstResult/maxResults specified on polymorphic query; applying in memory!" );
- RowSelection selection = new RowSelection();
- selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() );
- selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
- queryParametersToUse = queryParameters.createCopyUsing( selection );
- }
- else {
- queryParametersToUse = queryParameters;
- }
-
- List combinedResults = new ArrayList();
- IdentitySet distinction = new IdentitySet();
- int includedCount = -1;
- translator_loop: for ( int i = 0; i < translators.length; i++ ) {
- List tmp = translators[i].list( session, queryParametersToUse );
- if ( needsLimit ) {
- // NOTE : firstRow is zero-based
- int first = queryParameters.getRowSelection().getFirstRow() == null
- ? 0
- : queryParameters.getRowSelection().getFirstRow().intValue();
- int max = queryParameters.getRowSelection().getMaxRows() == null
- ? -1
- : queryParameters.getRowSelection().getMaxRows().intValue();
- final int size = tmp.size();
- for ( int x = 0; x < size; x++ ) {
- final Object result = tmp.get( x );
- if ( distinction.add( result ) ) {
- continue;
- }
- includedCount++;
- if ( includedCount < first ) {
- continue;
- }
- combinedResults.add( result );
- if ( max >= 0 && includedCount > max ) {
- // break the outer loop !!!
- break translator_loop;
- }
- }
- }
- else {
- combinedResults.addAll( tmp );
- }
- }
- return combinedResults;
- }
-
- public Iterator performIterate(
- QueryParameters queryParameters,
- EventSource session) throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "iterate: " + getSourceQuery() );
- queryParameters.traceParameters( session.getFactory() );
- }
- if ( translators.length == 0 ) {
- return EmptyIterator.INSTANCE;
- }
-
- Iterator[] results = null;
- boolean many = translators.length > 1;
- if (many) {
- results = new Iterator[translators.length];
- }
-
- Iterator result = null;
- for ( int i = 0; i < translators.length; i++ ) {
- result = translators[i].iterate( queryParameters, session );
- if (many) results[i] = result;
- }
-
- return many ? new JoinedIterator(results) : result;
- }
-
- public ScrollableResults performScroll(
- QueryParameters queryParameters,
- SessionImplementor session) throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "iterate: " + getSourceQuery() );
- queryParameters.traceParameters( session.getFactory() );
- }
- if ( translators.length != 1 ) {
- throw new QueryException( "implicit polymorphism not supported for scroll() queries" );
- }
- if ( queryParameters.getRowSelection().definesLimits() && translators[0].containsCollectionFetches() ) {
- throw new QueryException( "firstResult/maxResults not supported in conjunction with scroll() of a query containing collection fetches" );
- }
-
- return translators[0].scroll( queryParameters, session );
- }
-
- public int performExecuteUpdate(QueryParameters queryParameters, SessionImplementor session)
- throws HibernateException {
- if ( log.isTraceEnabled() ) {
- log.trace( "executeUpdate: " + getSourceQuery() );
- queryParameters.traceParameters( session.getFactory() );
- }
- if ( translators.length != 1 ) {
- log.warn( "manipulation query [" + getSourceQuery() + "] resulted in [" + translators.length + "] split queries" );
- }
- int result = 0;
- for ( int i = 0; i < translators.length; i++ ) {
- result += translators[i].executeUpdate( queryParameters, session );
- }
- return result;
- }
-
- private ParameterMetadata buildParameterMetadata(ParameterTranslations parameterTranslations, String hql) {
- long start = System.currentTimeMillis();
- ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations( hql );
- long end = System.currentTimeMillis();
- if ( log.isTraceEnabled() ) {
- log.trace( "HQL param location recognition took " + (end - start) + " mills (" + hql + ")" );
- }
-
- int ordinalParamCount = parameterTranslations.getOrdinalParameterCount();
- int[] locations = ArrayHelper.toIntArray( recognizer.getOrdinalParameterLocationList() );
- if ( parameterTranslations.supportsOrdinalParameterMetadata() && locations.length != ordinalParamCount ) {
- throw new HibernateException( "ordinal parameter mismatch" );
- }
- ordinalParamCount = locations.length;
- OrdinalParameterDescriptor[] ordinalParamDescriptors = new OrdinalParameterDescriptor[ordinalParamCount];
- for ( int i = 1; i <= ordinalParamCount; i++ ) {
- ordinalParamDescriptors[ i - 1 ] = new OrdinalParameterDescriptor(
- i,
- parameterTranslations.supportsOrdinalParameterMetadata()
- ? parameterTranslations.getOrdinalParameterExpectedType( i )
- : null,
- locations[ i - 1 ]
- );
- }
-
- Iterator itr = recognizer.getNamedParameterDescriptionMap().entrySet().iterator();
- Map namedParamDescriptorMap = new HashMap();
- while( itr.hasNext() ) {
- final Map.Entry entry = ( Map.Entry ) itr.next();
- final String name = ( String ) entry.getKey();
- final ParamLocationRecognizer.NamedParameterDescription description =
- ( ParamLocationRecognizer.NamedParameterDescription ) entry.getValue();
- namedParamDescriptorMap.put(
- name,
- new NamedParameterDescriptor(
- name,
- parameterTranslations.getNamedParameterExpectedType( name ),
- description.buildPositionsArray(),
- description.isJpaStyle()
- )
- );
- }
-
- return new ParameterMetadata( ordinalParamDescriptors, namedParamDescriptorMap );
- }
-
- public QueryTranslator[] getTranslators() {
- QueryTranslator[] copy = new QueryTranslator[translators.length];
- System.arraycopy(translators, 0, copy, 0, copy.length);
- return copy;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/HQLQueryPlan.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,339 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.hql.QuerySplitter;
+import org.hibernate.hql.QueryTranslator;
+import org.hibernate.hql.ParameterTranslations;
+import org.hibernate.hql.FilterTranslator;
+import org.hibernate.util.ArrayHelper;
+import org.hibernate.util.EmptyIterator;
+import org.hibernate.util.JoinedIterator;
+import org.hibernate.util.IdentitySet;
+import org.hibernate.HibernateException;
+import org.hibernate.ScrollableResults;
+import org.hibernate.QueryException;
+import org.hibernate.type.Type;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.QueryParameters;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.RowSelection;
+import org.hibernate.event.EventSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.HashMap;
+
+/**
+ * Defines a query execution plan for an HQL query (or filter).
+ *
+ * @author Steve Ebersole
+ */
+public class HQLQueryPlan implements Serializable {
+
+ // TODO : keep seperate notions of QT[] here for shallow/non-shallow queries...
+
+ private static final Logger log = LoggerFactory.getLogger( HQLQueryPlan.class );
+
+ private final String sourceQuery;
+ private final QueryTranslator[] translators;
+ private final String[] sqlStrings;
+
+ private final ParameterMetadata parameterMetadata;
+ private final ReturnMetadata returnMetadata;
+ private final Set querySpaces;
+
+ private final Set enabledFilterNames;
+ private final boolean shallow;
+
+
+ public HQLQueryPlan(String hql, boolean shallow, Map enabledFilters, SessionFactoryImplementor factory) {
+ this( hql, null, shallow, enabledFilters, factory );
+ }
+
+ protected HQLQueryPlan(String hql, String collectionRole, boolean shallow, Map enabledFilters, SessionFactoryImplementor factory) {
+ this.sourceQuery = hql;
+ this.shallow = shallow;
+
+ Set copy = new HashSet();
+ copy.addAll( enabledFilters.keySet() );
+ this.enabledFilterNames = java.util.Collections.unmodifiableSet( copy );
+
+ Set combinedQuerySpaces = new HashSet();
+ String[] concreteQueryStrings = QuerySplitter.concreteQueries( hql, factory );
+ final int length = concreteQueryStrings.length;
+ translators = new QueryTranslator[length];
+ List sqlStringList = new ArrayList();
+ for ( int i=0; i<length; i++ ) {
+ if ( collectionRole == null ) {
+ translators[i] = factory.getSettings()
+ .getQueryTranslatorFactory()
+ .createQueryTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
+ translators[i].compile( factory.getSettings().getQuerySubstitutions(), shallow );
+ }
+ else {
+ translators[i] = factory.getSettings()
+ .getQueryTranslatorFactory()
+ .createFilterTranslator( hql, concreteQueryStrings[i], enabledFilters, factory );
+ ( ( FilterTranslator ) translators[i] ).compile( collectionRole, factory.getSettings().getQuerySubstitutions(), shallow );
+ }
+ combinedQuerySpaces.addAll( translators[i].getQuerySpaces() );
+ sqlStringList.addAll( translators[i].collectSqlStrings() );
+ }
+
+ this.sqlStrings = ArrayHelper.toStringArray( sqlStringList );
+ this.querySpaces = combinedQuerySpaces;
+
+ if ( length == 0 ) {
+ parameterMetadata = new ParameterMetadata( null, null );
+ returnMetadata = null;
+ }
+ else {
+ this.parameterMetadata = buildParameterMetadata( translators[0].getParameterTranslations(), hql );
+ if ( translators[0].isManipulationStatement() ) {
+ returnMetadata = null;
+ }
+ else {
+ if ( length > 1 ) {
+ final int returns = translators[0].getReturnTypes().length;
+ returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), new Type[returns] );
+ }
+ else {
+ returnMetadata = new ReturnMetadata( translators[0].getReturnAliases(), translators[0].getReturnTypes() );
+ }
+ }
+ }
+ }
+
+ public String getSourceQuery() {
+ return sourceQuery;
+ }
+
+ public Set getQuerySpaces() {
+ return querySpaces;
+ }
+
+ public ParameterMetadata getParameterMetadata() {
+ return parameterMetadata;
+ }
+
+ public ReturnMetadata getReturnMetadata() {
+ return returnMetadata;
+ }
+
+ public Set getEnabledFilterNames() {
+ return enabledFilterNames;
+ }
+
+ public String[] getSqlStrings() {
+ return sqlStrings;
+ }
+
+ public Set getUtilizedFilterNames() {
+ // TODO : add this info to the translator and aggregate it here...
+ return null;
+ }
+
+ public boolean isShallow() {
+ return shallow;
+ }
+
+ public List performList(
+ QueryParameters queryParameters,
+ SessionImplementor session) throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "find: " + getSourceQuery() );
+ queryParameters.traceParameters( session.getFactory() );
+ }
+ boolean hasLimit = queryParameters.getRowSelection() != null &&
+ queryParameters.getRowSelection().definesLimits();
+ boolean needsLimit = hasLimit && translators.length > 1;
+ QueryParameters queryParametersToUse;
+ if ( needsLimit ) {
+ log.warn( "firstResult/maxResults specified on polymorphic query; applying in memory!" );
+ RowSelection selection = new RowSelection();
+ selection.setFetchSize( queryParameters.getRowSelection().getFetchSize() );
+ selection.setTimeout( queryParameters.getRowSelection().getTimeout() );
+ queryParametersToUse = queryParameters.createCopyUsing( selection );
+ }
+ else {
+ queryParametersToUse = queryParameters;
+ }
+
+ List combinedResults = new ArrayList();
+ IdentitySet distinction = new IdentitySet();
+ int includedCount = -1;
+ translator_loop: for ( int i = 0; i < translators.length; i++ ) {
+ List tmp = translators[i].list( session, queryParametersToUse );
+ if ( needsLimit ) {
+ // NOTE : firstRow is zero-based
+ int first = queryParameters.getRowSelection().getFirstRow() == null
+ ? 0
+ : queryParameters.getRowSelection().getFirstRow().intValue();
+ int max = queryParameters.getRowSelection().getMaxRows() == null
+ ? -1
+ : queryParameters.getRowSelection().getMaxRows().intValue();
+ final int size = tmp.size();
+ for ( int x = 0; x < size; x++ ) {
+ final Object result = tmp.get( x );
+ if ( distinction.add( result ) ) {
+ continue;
+ }
+ includedCount++;
+ if ( includedCount < first ) {
+ continue;
+ }
+ combinedResults.add( result );
+ if ( max >= 0 && includedCount > max ) {
+ // break the outer loop !!!
+ break translator_loop;
+ }
+ }
+ }
+ else {
+ combinedResults.addAll( tmp );
+ }
+ }
+ return combinedResults;
+ }
+
+ public Iterator performIterate(
+ QueryParameters queryParameters,
+ EventSource session) throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "iterate: " + getSourceQuery() );
+ queryParameters.traceParameters( session.getFactory() );
+ }
+ if ( translators.length == 0 ) {
+ return EmptyIterator.INSTANCE;
+ }
+
+ Iterator[] results = null;
+ boolean many = translators.length > 1;
+ if (many) {
+ results = new Iterator[translators.length];
+ }
+
+ Iterator result = null;
+ for ( int i = 0; i < translators.length; i++ ) {
+ result = translators[i].iterate( queryParameters, session );
+ if (many) results[i] = result;
+ }
+
+ return many ? new JoinedIterator(results) : result;
+ }
+
+ public ScrollableResults performScroll(
+ QueryParameters queryParameters,
+ SessionImplementor session) throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "iterate: " + getSourceQuery() );
+ queryParameters.traceParameters( session.getFactory() );
+ }
+ if ( translators.length != 1 ) {
+ throw new QueryException( "implicit polymorphism not supported for scroll() queries" );
+ }
+ if ( queryParameters.getRowSelection().definesLimits() && translators[0].containsCollectionFetches() ) {
+ throw new QueryException( "firstResult/maxResults not supported in conjunction with scroll() of a query containing collection fetches" );
+ }
+
+ return translators[0].scroll( queryParameters, session );
+ }
+
+ public int performExecuteUpdate(QueryParameters queryParameters, SessionImplementor session)
+ throws HibernateException {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "executeUpdate: " + getSourceQuery() );
+ queryParameters.traceParameters( session.getFactory() );
+ }
+ if ( translators.length != 1 ) {
+ log.warn( "manipulation query [" + getSourceQuery() + "] resulted in [" + translators.length + "] split queries" );
+ }
+ int result = 0;
+ for ( int i = 0; i < translators.length; i++ ) {
+ result += translators[i].executeUpdate( queryParameters, session );
+ }
+ return result;
+ }
+
+ private ParameterMetadata buildParameterMetadata(ParameterTranslations parameterTranslations, String hql) {
+ long start = System.currentTimeMillis();
+ ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations( hql );
+ long end = System.currentTimeMillis();
+ if ( log.isTraceEnabled() ) {
+ log.trace( "HQL param location recognition took " + (end - start) + " mills (" + hql + ")" );
+ }
+
+ int ordinalParamCount = parameterTranslations.getOrdinalParameterCount();
+ int[] locations = ArrayHelper.toIntArray( recognizer.getOrdinalParameterLocationList() );
+ if ( parameterTranslations.supportsOrdinalParameterMetadata() && locations.length != ordinalParamCount ) {
+ throw new HibernateException( "ordinal parameter mismatch" );
+ }
+ ordinalParamCount = locations.length;
+ OrdinalParameterDescriptor[] ordinalParamDescriptors = new OrdinalParameterDescriptor[ordinalParamCount];
+ for ( int i = 1; i <= ordinalParamCount; i++ ) {
+ ordinalParamDescriptors[ i - 1 ] = new OrdinalParameterDescriptor(
+ i,
+ parameterTranslations.supportsOrdinalParameterMetadata()
+ ? parameterTranslations.getOrdinalParameterExpectedType( i )
+ : null,
+ locations[ i - 1 ]
+ );
+ }
+
+ Iterator itr = recognizer.getNamedParameterDescriptionMap().entrySet().iterator();
+ Map namedParamDescriptorMap = new HashMap();
+ while( itr.hasNext() ) {
+ final Map.Entry entry = ( Map.Entry ) itr.next();
+ final String name = ( String ) entry.getKey();
+ final ParamLocationRecognizer.NamedParameterDescription description =
+ ( ParamLocationRecognizer.NamedParameterDescription ) entry.getValue();
+ namedParamDescriptorMap.put(
+ name,
+ new NamedParameterDescriptor(
+ name,
+ parameterTranslations.getNamedParameterExpectedType( name ),
+ description.buildPositionsArray(),
+ description.isJpaStyle()
+ )
+ );
+ }
+
+ return new ParameterMetadata( ordinalParamDescriptors, namedParamDescriptorMap );
+ }
+
+ public QueryTranslator[] getTranslators() {
+ QueryTranslator[] copy = new QueryTranslator[translators.length];
+ System.arraycopy(translators, 0, copy, 0, copy.length);
+ return copy;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,40 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.type.Type;
-
-import java.io.Serializable;
-
-/**
- * Descriptor regarding a named parameter.
- *
- * @author Steve Ebersole
- */
-public class NamedParameterDescriptor implements Serializable {
- private final String name;
- private final Type expectedType;
- private final int[] sourceLocations;
- private final boolean jpaStyle;
-
- public NamedParameterDescriptor(String name, Type expectedType, int[] sourceLocations, boolean jpaStyle) {
- this.name = name;
- this.expectedType = expectedType;
- this.sourceLocations = sourceLocations;
- this.jpaStyle = jpaStyle;
- }
-
- public String getName() {
- return name;
- }
-
- public Type getExpectedType() {
- return expectedType;
- }
-
- public int[] getSourceLocations() {
- return sourceLocations;
- }
-
- public boolean isJpaStyle() {
- return jpaStyle;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NamedParameterDescriptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,64 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+
+/**
+ * Descriptor regarding a named parameter.
+ *
+ * @author Steve Ebersole
+ */
+public class NamedParameterDescriptor implements Serializable {
+ private final String name;
+ private final Type expectedType;
+ private final int[] sourceLocations;
+ private final boolean jpaStyle;
+
+ public NamedParameterDescriptor(String name, Type expectedType, int[] sourceLocations, boolean jpaStyle) {
+ this.name = name;
+ this.expectedType = expectedType;
+ this.sourceLocations = sourceLocations;
+ this.jpaStyle = jpaStyle;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Type getExpectedType() {
+ return expectedType;
+ }
+
+ public int[] getSourceLocations() {
+ return sourceLocations;
+ }
+
+ public boolean isJpaStyle() {
+ return jpaStyle;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,182 +0,0 @@
-package org.hibernate.engine.query;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.QueryException;
-import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
-import org.hibernate.action.BulkOperationCleanupAction;
-import org.hibernate.engine.QueryParameters;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.TypedValue;
-import org.hibernate.event.EventSource;
-import org.hibernate.exception.JDBCExceptionHelper;
-import org.hibernate.loader.custom.sql.SQLCustomQuery;
-import org.hibernate.type.Type;
-import org.hibernate.util.ArrayHelper;
-
-/**
- * Defines a query execution plan for a native-SQL query.
- *
- * @author Steve Ebersole
- */
-public class NativeSQLQueryPlan implements Serializable {
- private final String sourceQuery;
-
- private final SQLCustomQuery customQuery;
-
- private static final Logger log = LoggerFactory.getLogger(NativeSQLQueryPlan.class);
-
- public NativeSQLQueryPlan(
- NativeSQLQuerySpecification specification,
- SessionFactoryImplementor factory) {
- this.sourceQuery = specification.getQueryString();
-
- customQuery = new SQLCustomQuery(
- specification.getQueryString(),
- specification.getQueryReturns(),
- specification.getQuerySpaces(),
- factory );
- }
-
- public String getSourceQuery() {
- return sourceQuery;
- }
-
- public SQLCustomQuery getCustomQuery() {
- return customQuery;
- }
-
- private int[] getNamedParameterLocs(String name) throws QueryException {
- Object loc = customQuery.getNamedParameterBindPoints().get( name );
- if ( loc == null ) {
- throw new QueryException(
- "Named parameter does not appear in Query: " + name,
- customQuery.getSQL() );
- }
- if ( loc instanceof Integer ) {
- return new int[] { ((Integer) loc ).intValue() };
- }
- else {
- return ArrayHelper.toIntArray( (List) loc );
- }
- }
-
- /**
- * Bind positional parameter values to the <tt>PreparedStatement</tt>
- * (these are parameters specified by a JDBC-style ?).
- */
- private int bindPositionalParameters(final PreparedStatement st,
- final QueryParameters queryParameters, final int start,
- final SessionImplementor session) throws SQLException,
- HibernateException {
-
- final Object[] values = queryParameters
- .getFilteredPositionalParameterValues();
- final Type[] types = queryParameters
- .getFilteredPositionalParameterTypes();
- int span = 0;
- for (int i = 0; i < values.length; i++) {
- types[i].nullSafeSet( st, values[i], start + span, session );
- span += types[i].getColumnSpan( session.getFactory() );
- }
- return span;
- }
-
- /**
- * Bind named parameters to the <tt>PreparedStatement</tt>. This has an
- * empty implementation on this superclass and should be implemented by
- * subclasses (queries) which allow named parameters.
- */
- private int bindNamedParameters(final PreparedStatement ps,
- final Map namedParams, final int start,
- final SessionImplementor session) throws SQLException,
- HibernateException {
-
- if ( namedParams != null ) {
- // assumes that types are all of span 1
- Iterator iter = namedParams.entrySet().iterator();
- int result = 0;
- while ( iter.hasNext() ) {
- Map.Entry e = (Map.Entry) iter.next();
- String name = (String) e.getKey();
- TypedValue typedval = (TypedValue) e.getValue();
- int[] locs = getNamedParameterLocs( name );
- for (int i = 0; i < locs.length; i++) {
- if ( log.isDebugEnabled() ) {
- log.debug( "bindNamedParameters() "
- + typedval.getValue() + " -> " + name + " ["
- + (locs[i] + start ) + "]" );
- }
- typedval.getType().nullSafeSet( ps, typedval.getValue(),
- locs[i] + start, session );
- }
- result += locs.length;
- }
- return result;
- }
- else {
- return 0;
- }
- }
-
- protected void coordinateSharedCacheCleanup(SessionImplementor session) {
- BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, getCustomQuery().getQuerySpaces() );
-
- action.init();
-
- if ( session.isEventSource() ) {
- ( ( EventSource ) session ).getActionQueue().addAction( action );
- }
- }
-
- public int performExecuteUpdate(QueryParameters queryParameters,
- SessionImplementor session) throws HibernateException {
-
- coordinateSharedCacheCleanup( session );
-
- if(queryParameters.isCallable()) {
- throw new IllegalArgumentException("callable not yet supported for native queries");
- }
-
- int result = 0;
- PreparedStatement ps;
- try {
- queryParameters.processFilters( this.customQuery.getSQL(),
- session );
- String sql = queryParameters.getFilteredSQL();
-
- ps = session.getBatcher().prepareStatement( sql );
-
- try {
- int col = 1;
- col += bindPositionalParameters( ps, queryParameters, col,
- session );
- col += bindNamedParameters( ps, queryParameters
- .getNamedParameters(), col, session );
- result = ps.executeUpdate();
- }
- finally {
- if ( ps != null ) {
- session.getBatcher().closeStatement( ps );
- }
- }
- }
- catch (SQLException sqle) {
- throw JDBCExceptionHelper.convert( session.getFactory()
- .getSQLExceptionConverter(), sqle,
- "could not execute native bulk manipulation query", this.sourceQuery );
- }
-
- return result;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/NativeSQLQueryPlan.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,206 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.QueryException;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
+import org.hibernate.action.BulkOperationCleanupAction;
+import org.hibernate.engine.QueryParameters;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.TypedValue;
+import org.hibernate.event.EventSource;
+import org.hibernate.exception.JDBCExceptionHelper;
+import org.hibernate.loader.custom.sql.SQLCustomQuery;
+import org.hibernate.type.Type;
+import org.hibernate.util.ArrayHelper;
+
+/**
+ * Defines a query execution plan for a native-SQL query.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryPlan implements Serializable {
+ private final String sourceQuery;
+
+ private final SQLCustomQuery customQuery;
+
+ private static final Logger log = LoggerFactory.getLogger(NativeSQLQueryPlan.class);
+
+ public NativeSQLQueryPlan(
+ NativeSQLQuerySpecification specification,
+ SessionFactoryImplementor factory) {
+ this.sourceQuery = specification.getQueryString();
+
+ customQuery = new SQLCustomQuery(
+ specification.getQueryString(),
+ specification.getQueryReturns(),
+ specification.getQuerySpaces(),
+ factory );
+ }
+
+ public String getSourceQuery() {
+ return sourceQuery;
+ }
+
+ public SQLCustomQuery getCustomQuery() {
+ return customQuery;
+ }
+
+ private int[] getNamedParameterLocs(String name) throws QueryException {
+ Object loc = customQuery.getNamedParameterBindPoints().get( name );
+ if ( loc == null ) {
+ throw new QueryException(
+ "Named parameter does not appear in Query: " + name,
+ customQuery.getSQL() );
+ }
+ if ( loc instanceof Integer ) {
+ return new int[] { ((Integer) loc ).intValue() };
+ }
+ else {
+ return ArrayHelper.toIntArray( (List) loc );
+ }
+ }
+
+ /**
+ * Bind positional parameter values to the <tt>PreparedStatement</tt>
+ * (these are parameters specified by a JDBC-style ?).
+ */
+ private int bindPositionalParameters(final PreparedStatement st,
+ final QueryParameters queryParameters, final int start,
+ final SessionImplementor session) throws SQLException,
+ HibernateException {
+
+ final Object[] values = queryParameters
+ .getFilteredPositionalParameterValues();
+ final Type[] types = queryParameters
+ .getFilteredPositionalParameterTypes();
+ int span = 0;
+ for (int i = 0; i < values.length; i++) {
+ types[i].nullSafeSet( st, values[i], start + span, session );
+ span += types[i].getColumnSpan( session.getFactory() );
+ }
+ return span;
+ }
+
+ /**
+ * Bind named parameters to the <tt>PreparedStatement</tt>. This has an
+ * empty implementation on this superclass and should be implemented by
+ * subclasses (queries) which allow named parameters.
+ */
+ private int bindNamedParameters(final PreparedStatement ps,
+ final Map namedParams, final int start,
+ final SessionImplementor session) throws SQLException,
+ HibernateException {
+
+ if ( namedParams != null ) {
+ // assumes that types are all of span 1
+ Iterator iter = namedParams.entrySet().iterator();
+ int result = 0;
+ while ( iter.hasNext() ) {
+ Map.Entry e = (Map.Entry) iter.next();
+ String name = (String) e.getKey();
+ TypedValue typedval = (TypedValue) e.getValue();
+ int[] locs = getNamedParameterLocs( name );
+ for (int i = 0; i < locs.length; i++) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "bindNamedParameters() "
+ + typedval.getValue() + " -> " + name + " ["
+ + (locs[i] + start ) + "]" );
+ }
+ typedval.getType().nullSafeSet( ps, typedval.getValue(),
+ locs[i] + start, session );
+ }
+ result += locs.length;
+ }
+ return result;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ protected void coordinateSharedCacheCleanup(SessionImplementor session) {
+ BulkOperationCleanupAction action = new BulkOperationCleanupAction( session, getCustomQuery().getQuerySpaces() );
+
+ action.init();
+
+ if ( session.isEventSource() ) {
+ ( ( EventSource ) session ).getActionQueue().addAction( action );
+ }
+ }
+
+ public int performExecuteUpdate(QueryParameters queryParameters,
+ SessionImplementor session) throws HibernateException {
+
+ coordinateSharedCacheCleanup( session );
+
+ if(queryParameters.isCallable()) {
+ throw new IllegalArgumentException("callable not yet supported for native queries");
+ }
+
+ int result = 0;
+ PreparedStatement ps;
+ try {
+ queryParameters.processFilters( this.customQuery.getSQL(),
+ session );
+ String sql = queryParameters.getFilteredSQL();
+
+ ps = session.getBatcher().prepareStatement( sql );
+
+ try {
+ int col = 1;
+ col += bindPositionalParameters( ps, queryParameters, col,
+ session );
+ col += bindNamedParameters( ps, queryParameters
+ .getNamedParameters(), col, session );
+ result = ps.executeUpdate();
+ }
+ finally {
+ if ( ps != null ) {
+ session.getBatcher().closeStatement( ps );
+ }
+ }
+ }
+ catch (SQLException sqle) {
+ throw JDBCExceptionHelper.convert( session.getFactory()
+ .getSQLExceptionConverter(), sqle,
+ "could not execute native bulk manipulation query", this.sourceQuery );
+ }
+
+ return result;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,32 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.type.Type;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class OrdinalParameterDescriptor implements Serializable {
- private final int ordinalPosition;
- private final Type expectedType;
- private final int sourceLocation;
-
- public OrdinalParameterDescriptor(int ordinalPosition, Type expectedType, int sourceLocation) {
- this.ordinalPosition = ordinalPosition;
- this.expectedType = expectedType;
- this.sourceLocation = sourceLocation;
- }
-
- public int getOrdinalPosition() {
- return ordinalPosition;
- }
-
- public Type getExpectedType() {
- return expectedType;
- }
-
- public int getSourceLocation() {
- return sourceLocation;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/OrdinalParameterDescriptor.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,56 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+
+/**
+ * @author Steve Ebersole
+ */
+public class OrdinalParameterDescriptor implements Serializable {
+ private final int ordinalPosition;
+ private final Type expectedType;
+ private final int sourceLocation;
+
+ public OrdinalParameterDescriptor(int ordinalPosition, Type expectedType, int sourceLocation) {
+ this.ordinalPosition = ordinalPosition;
+ this.expectedType = expectedType;
+ this.sourceLocation = sourceLocation;
+ }
+
+ public int getOrdinalPosition() {
+ return ordinalPosition;
+ }
+
+ public Type getExpectedType() {
+ return expectedType;
+ }
+
+ public int getSourceLocation() {
+ return sourceLocation;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,108 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.util.ArrayHelper;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * Implements a parameter parser recognizer specifically for the purpose
- * of journaling parameter locations.
- *
- * @author Steve Ebersole
- */
-public class ParamLocationRecognizer implements ParameterParser.Recognizer {
-
- public static class NamedParameterDescription {
- private final boolean jpaStyle;
- private final List positions = new ArrayList();
-
- public NamedParameterDescription(boolean jpaStyle) {
- this.jpaStyle = jpaStyle;
- }
-
- public boolean isJpaStyle() {
- return jpaStyle;
- }
-
- private void add(int position) {
- positions.add( new Integer( position ) );
- }
-
- public int[] buildPositionsArray() {
- return ArrayHelper.toIntArray( positions );
- }
- }
-
- private Map namedParameterDescriptions = new HashMap();
- private List ordinalParameterLocationList = new ArrayList();
-
- /**
- * Convenience method for creating a param location recognizer and
- * initiating the parse.
- *
- * @param query The query to be parsed for parameter locations.
- * @return The generated recognizer, with journaled location info.
- */
- public static ParamLocationRecognizer parseLocations(String query) {
- ParamLocationRecognizer recognizer = new ParamLocationRecognizer();
- ParameterParser.parse( query, recognizer );
- return recognizer;
- }
-
- /**
- * Returns the map of named parameter locations. The map is keyed by
- * parameter name; the corresponding value is a (@link NamedParameterDescription}.
- *
- * @return The map of named parameter locations.
- */
- public Map getNamedParameterDescriptionMap() {
- return namedParameterDescriptions;
- }
-
- /**
- * Returns the list of ordinal parameter locations. The list elements
- * are Integers, representing the location for that given ordinal. Thus
- * {@link #getOrdinalParameterLocationList()}.elementAt(n) represents the
- * location for the nth parameter.
- *
- * @return The list of ordinal parameter locations.
- */
- public List getOrdinalParameterLocationList() {
- return ordinalParameterLocationList;
- }
-
-
- // Recognition code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public void ordinalParameter(int position) {
- ordinalParameterLocationList.add( new Integer( position ) );
- }
-
- public void namedParameter(String name, int position) {
- getOrBuildNamedParameterDescription( name, false ).add( position );
- }
-
- public void jpaPositionalParameter(String name, int position) {
- getOrBuildNamedParameterDescription( name, true ).add( position );
- }
-
- private NamedParameterDescription getOrBuildNamedParameterDescription(String name, boolean jpa) {
- NamedParameterDescription desc = ( NamedParameterDescription ) namedParameterDescriptions.get( name );
- if ( desc == null ) {
- desc = new NamedParameterDescription( jpa );
- namedParameterDescriptions.put( name, desc );
- }
- return desc;
- }
-
- public void other(char character) {
- // don't care...
- }
-
- public void outParameter(int position) {
- // don't care...
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParamLocationRecognizer.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,132 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.util.ArrayHelper;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Implements a parameter parser recognizer specifically for the purpose
+ * of journaling parameter locations.
+ *
+ * @author Steve Ebersole
+ */
+public class ParamLocationRecognizer implements ParameterParser.Recognizer {
+
+ public static class NamedParameterDescription {
+ private final boolean jpaStyle;
+ private final List positions = new ArrayList();
+
+ public NamedParameterDescription(boolean jpaStyle) {
+ this.jpaStyle = jpaStyle;
+ }
+
+ public boolean isJpaStyle() {
+ return jpaStyle;
+ }
+
+ private void add(int position) {
+ positions.add( new Integer( position ) );
+ }
+
+ public int[] buildPositionsArray() {
+ return ArrayHelper.toIntArray( positions );
+ }
+ }
+
+ private Map namedParameterDescriptions = new HashMap();
+ private List ordinalParameterLocationList = new ArrayList();
+
+ /**
+ * Convenience method for creating a param location recognizer and
+ * initiating the parse.
+ *
+ * @param query The query to be parsed for parameter locations.
+ * @return The generated recognizer, with journaled location info.
+ */
+ public static ParamLocationRecognizer parseLocations(String query) {
+ ParamLocationRecognizer recognizer = new ParamLocationRecognizer();
+ ParameterParser.parse( query, recognizer );
+ return recognizer;
+ }
+
+ /**
+ * Returns the map of named parameter locations. The map is keyed by
+ * parameter name; the corresponding value is a (@link NamedParameterDescription}.
+ *
+ * @return The map of named parameter locations.
+ */
+ public Map getNamedParameterDescriptionMap() {
+ return namedParameterDescriptions;
+ }
+
+ /**
+ * Returns the list of ordinal parameter locations. The list elements
+ * are Integers, representing the location for that given ordinal. Thus
+ * {@link #getOrdinalParameterLocationList()}.elementAt(n) represents the
+ * location for the nth parameter.
+ *
+ * @return The list of ordinal parameter locations.
+ */
+ public List getOrdinalParameterLocationList() {
+ return ordinalParameterLocationList;
+ }
+
+
+ // Recognition code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public void ordinalParameter(int position) {
+ ordinalParameterLocationList.add( new Integer( position ) );
+ }
+
+ public void namedParameter(String name, int position) {
+ getOrBuildNamedParameterDescription( name, false ).add( position );
+ }
+
+ public void jpaPositionalParameter(String name, int position) {
+ getOrBuildNamedParameterDescription( name, true ).add( position );
+ }
+
+ private NamedParameterDescription getOrBuildNamedParameterDescription(String name, boolean jpa) {
+ NamedParameterDescription desc = ( NamedParameterDescription ) namedParameterDescriptions.get( name );
+ if ( desc == null ) {
+ desc = new NamedParameterDescription( jpa );
+ namedParameterDescriptions.put( name, desc );
+ }
+ return desc;
+ }
+
+ public void other(char character) {
+ // don't care...
+ }
+
+ public void outParameter(int position) {
+ // don't care...
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,88 +0,0 @@
-package org.hibernate.engine.query;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.QueryParameterException;
-import org.hibernate.type.Type;
-
-/**
- * Encapsulates metadata about parameters encountered within a query.
- *
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class ParameterMetadata implements Serializable {
-
- private static final OrdinalParameterDescriptor[] EMPTY_ORDINALS = new OrdinalParameterDescriptor[0];
-
- private final OrdinalParameterDescriptor[] ordinalDescriptors;
- private final Map namedDescriptorMap;
-
- /**
- * Instantiates a ParameterMetadata container.
- *
- * @param ordinalDescriptors
- * @param namedDescriptorMap
- */
- public ParameterMetadata(OrdinalParameterDescriptor[] ordinalDescriptors, Map namedDescriptorMap) {
- if ( ordinalDescriptors == null ) {
- this.ordinalDescriptors = EMPTY_ORDINALS;
- }
- else {
- OrdinalParameterDescriptor[] copy = new OrdinalParameterDescriptor[ ordinalDescriptors.length ];
- System.arraycopy( ordinalDescriptors, 0, copy, 0, ordinalDescriptors.length );
- this.ordinalDescriptors = copy;
- }
- if ( namedDescriptorMap == null ) {
- this.namedDescriptorMap = java.util.Collections.EMPTY_MAP;
- }
- else {
- int size = ( int ) ( ( namedDescriptorMap.size() / .75 ) + 1 );
- Map copy = new HashMap( size );
- copy.putAll( namedDescriptorMap );
- this.namedDescriptorMap = java.util.Collections.unmodifiableMap( copy );
- }
- }
-
- public int getOrdinalParameterCount() {
- return ordinalDescriptors.length;
- }
-
- public OrdinalParameterDescriptor getOrdinalParameterDescriptor(int position) {
- if ( position < 1 || position > ordinalDescriptors.length ) {
- throw new IndexOutOfBoundsException( "Remember that ordinal parameters are 1-based!" );
- }
- return ordinalDescriptors[position - 1];
- }
-
- public Type getOrdinalParameterExpectedType(int position) {
- return getOrdinalParameterDescriptor( position ).getExpectedType();
- }
-
- public int getOrdinalParameterSourceLocation(int position) {
- return getOrdinalParameterDescriptor( position ).getSourceLocation();
- }
-
- public Set getNamedParameterNames() {
- return namedDescriptorMap.keySet();
- }
-
- public NamedParameterDescriptor getNamedParameterDescriptor(String name) {
- NamedParameterDescriptor meta = ( NamedParameterDescriptor ) namedDescriptorMap.get( name );
- if ( meta == null ) {
- throw new QueryParameterException( "could not locate named parameter [" + name + "]" );
- }
- return meta;
- }
-
- public Type getNamedParameterExpectedType(String name) {
- return getNamedParameterDescriptor( name ).getExpectedType();
- }
-
- public int[] getNamedParameterSourceLocations(String name) {
- return getNamedParameterDescriptor( name ).getSourceLocations();
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterMetadata.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,112 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.QueryParameterException;
+import org.hibernate.type.Type;
+
+/**
+ * Encapsulates metadata about parameters encountered within a query.
+ *
+ * @author Steve Ebersole
+ */
+public class ParameterMetadata implements Serializable {
+
+ private static final OrdinalParameterDescriptor[] EMPTY_ORDINALS = new OrdinalParameterDescriptor[0];
+
+ private final OrdinalParameterDescriptor[] ordinalDescriptors;
+ private final Map namedDescriptorMap;
+
+ /**
+ * Instantiates a ParameterMetadata container.
+ *
+ * @param ordinalDescriptors
+ * @param namedDescriptorMap
+ */
+ public ParameterMetadata(OrdinalParameterDescriptor[] ordinalDescriptors, Map namedDescriptorMap) {
+ if ( ordinalDescriptors == null ) {
+ this.ordinalDescriptors = EMPTY_ORDINALS;
+ }
+ else {
+ OrdinalParameterDescriptor[] copy = new OrdinalParameterDescriptor[ ordinalDescriptors.length ];
+ System.arraycopy( ordinalDescriptors, 0, copy, 0, ordinalDescriptors.length );
+ this.ordinalDescriptors = copy;
+ }
+ if ( namedDescriptorMap == null ) {
+ this.namedDescriptorMap = java.util.Collections.EMPTY_MAP;
+ }
+ else {
+ int size = ( int ) ( ( namedDescriptorMap.size() / .75 ) + 1 );
+ Map copy = new HashMap( size );
+ copy.putAll( namedDescriptorMap );
+ this.namedDescriptorMap = java.util.Collections.unmodifiableMap( copy );
+ }
+ }
+
+ public int getOrdinalParameterCount() {
+ return ordinalDescriptors.length;
+ }
+
+ public OrdinalParameterDescriptor getOrdinalParameterDescriptor(int position) {
+ if ( position < 1 || position > ordinalDescriptors.length ) {
+ throw new IndexOutOfBoundsException( "Remember that ordinal parameters are 1-based!" );
+ }
+ return ordinalDescriptors[position - 1];
+ }
+
+ public Type getOrdinalParameterExpectedType(int position) {
+ return getOrdinalParameterDescriptor( position ).getExpectedType();
+ }
+
+ public int getOrdinalParameterSourceLocation(int position) {
+ return getOrdinalParameterDescriptor( position ).getSourceLocation();
+ }
+
+ public Set getNamedParameterNames() {
+ return namedDescriptorMap.keySet();
+ }
+
+ public NamedParameterDescriptor getNamedParameterDescriptor(String name) {
+ NamedParameterDescriptor meta = ( NamedParameterDescriptor ) namedDescriptorMap.get( name );
+ if ( meta == null ) {
+ throw new QueryParameterException( "could not locate named parameter [" + name + "]" );
+ }
+ return meta;
+ }
+
+ public Type getNamedParameterExpectedType(String name) {
+ return getNamedParameterDescriptor( name ).getExpectedType();
+ }
+
+ public int[] getNamedParameterSourceLocations(String name) {
+ return getNamedParameterDescriptor( name ).getSourceLocations();
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/ParameterParser.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,108 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.QueryException;
-import org.hibernate.hql.classic.ParserHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * The single available method {@link #parse} is responsible for parsing a
- * query string and recognizing tokens in relation to parameters (either
- * named, JPA-style, or ordinal) and providing callbacks about such
- * recognitions.
- *
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class ParameterParser {
-
- public static interface Recognizer {
- public void outParameter(int position);
- public void ordinalParameter(int position);
- public void namedParameter(String name, int position);
- public void jpaPositionalParameter(String name, int position);
- public void other(char character);
- }
-
- private ParameterParser() {
- // disallow instantiation
- }
-
- /**
- * Performs the actual parsing and tokenizing of the query string making appropriate
- * callbacks to the given recognizer upon recognition of the various tokens.
- * <p/>
- * Note that currently, this only knows how to deal with a single output
- * parameter (for callable statements). If we later add support for
- * multiple output params, this, obviously, needs to change.
- *
- * @param sqlString The string to be parsed/tokenized.
- * @param recognizer The thing which handles recognition events.
- * @throws QueryException
- */
- public static void parse(String sqlString, Recognizer recognizer) throws QueryException {
- boolean hasMainOutputParameter = sqlString.indexOf( "call" ) > 0 &&
- sqlString.indexOf( "?" ) < sqlString.indexOf( "call" ) &&
- sqlString.indexOf( "=" ) < sqlString.indexOf( "call" );
- boolean foundMainOutputParam = false;
-
- int stringLength = sqlString.length();
- boolean inQuote = false;
- for ( int indx = 0; indx < stringLength; indx++ ) {
- char c = sqlString.charAt( indx );
- if ( inQuote ) {
- if ( '\'' == c ) {
- inQuote = false;
- }
- recognizer.other( c );
- }
- else if ( '\'' == c ) {
- inQuote = true;
- recognizer.other( c );
- }
- else {
- if ( c == ':' ) {
- // named parameter
- int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS, indx + 1 );
- int chopLocation = right < 0 ? sqlString.length() : right;
- String param = sqlString.substring( indx + 1, chopLocation );
- if ( StringHelper.isEmpty( param ) ) {
- throw new QueryException("Space is not allowed after parameter prefix ':' '"
- + sqlString + "'");
- }
- recognizer.namedParameter( param, indx );
- indx = chopLocation - 1;
- }
- else if ( c == '?' ) {
- // could be either an ordinal or JPA-positional parameter
- if ( indx < stringLength - 1 && Character.isDigit( sqlString.charAt( indx + 1 ) ) ) {
- // a peek ahead showed this as an JPA-positional parameter
- int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS, indx + 1 );
- int chopLocation = right < 0 ? sqlString.length() : right;
- String param = sqlString.substring( indx + 1, chopLocation );
- // make sure this "name" is an integral
- try {
- new Integer( param );
- }
- catch( NumberFormatException e ) {
- throw new QueryException( "JPA-style positional param was not an integral ordinal" );
- }
- recognizer.jpaPositionalParameter( param, indx );
- indx = chopLocation - 1;
- }
- else {
- if ( hasMainOutputParameter && !foundMainOutputParam ) {
- foundMainOutputParam = true;
- recognizer.outParameter( indx );
- }
- else {
- recognizer.ordinalParameter( indx );
- }
- }
- }
- else {
- recognizer.other( c );
- }
- }
- }
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/ParameterParser.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ParameterParser.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,132 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.QueryException;
+import org.hibernate.hql.classic.ParserHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * The single available method {@link #parse} is responsible for parsing a
+ * query string and recognizing tokens in relation to parameters (either
+ * named, JPA-style, or ordinal) and providing callbacks about such
+ * recognitions.
+ *
+ * @author Steve Ebersole
+ */
+public class ParameterParser {
+
+ public static interface Recognizer {
+ public void outParameter(int position);
+ public void ordinalParameter(int position);
+ public void namedParameter(String name, int position);
+ public void jpaPositionalParameter(String name, int position);
+ public void other(char character);
+ }
+
+ private ParameterParser() {
+ // disallow instantiation
+ }
+
+ /**
+ * Performs the actual parsing and tokenizing of the query string making appropriate
+ * callbacks to the given recognizer upon recognition of the various tokens.
+ * <p/>
+ * Note that currently, this only knows how to deal with a single output
+ * parameter (for callable statements). If we later add support for
+ * multiple output params, this, obviously, needs to change.
+ *
+ * @param sqlString The string to be parsed/tokenized.
+ * @param recognizer The thing which handles recognition events.
+ * @throws QueryException
+ */
+ public static void parse(String sqlString, Recognizer recognizer) throws QueryException {
+ boolean hasMainOutputParameter = sqlString.indexOf( "call" ) > 0 &&
+ sqlString.indexOf( "?" ) < sqlString.indexOf( "call" ) &&
+ sqlString.indexOf( "=" ) < sqlString.indexOf( "call" );
+ boolean foundMainOutputParam = false;
+
+ int stringLength = sqlString.length();
+ boolean inQuote = false;
+ for ( int indx = 0; indx < stringLength; indx++ ) {
+ char c = sqlString.charAt( indx );
+ if ( inQuote ) {
+ if ( '\'' == c ) {
+ inQuote = false;
+ }
+ recognizer.other( c );
+ }
+ else if ( '\'' == c ) {
+ inQuote = true;
+ recognizer.other( c );
+ }
+ else {
+ if ( c == ':' ) {
+ // named parameter
+ int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS, indx + 1 );
+ int chopLocation = right < 0 ? sqlString.length() : right;
+ String param = sqlString.substring( indx + 1, chopLocation );
+ if ( StringHelper.isEmpty( param ) ) {
+ throw new QueryException("Space is not allowed after parameter prefix ':' '"
+ + sqlString + "'");
+ }
+ recognizer.namedParameter( param, indx );
+ indx = chopLocation - 1;
+ }
+ else if ( c == '?' ) {
+ // could be either an ordinal or JPA-positional parameter
+ if ( indx < stringLength - 1 && Character.isDigit( sqlString.charAt( indx + 1 ) ) ) {
+ // a peek ahead showed this as an JPA-positional parameter
+ int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS, indx + 1 );
+ int chopLocation = right < 0 ? sqlString.length() : right;
+ String param = sqlString.substring( indx + 1, chopLocation );
+ // make sure this "name" is an integral
+ try {
+ new Integer( param );
+ }
+ catch( NumberFormatException e ) {
+ throw new QueryException( "JPA-style positional param was not an integral ordinal" );
+ }
+ recognizer.jpaPositionalParameter( param, indx );
+ indx = chopLocation - 1;
+ }
+ else {
+ if ( hasMainOutputParameter && !foundMainOutputParam ) {
+ foundMainOutputParam = true;
+ recognizer.outParameter( indx );
+ }
+ else {
+ recognizer.ordinalParameter( indx );
+ }
+ }
+ }
+ else {
+ recognizer.other( c );
+ }
+ }
+ }
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,72 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.type.Type;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * Defines metadata regarding a translated HQL or native-SQL query.
- *
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class QueryMetadata implements Serializable {
- private final String sourceQuery;
- private final ParameterMetadata parameterMetadata;
- private final String[] returnAliases;
- private final Type[] returnTypes;
- private final Set querySpaces;
-
- public QueryMetadata(
- String sourceQuery,
- ParameterMetadata parameterMetadata,
- String[] returnAliases,
- Type[] returnTypes,
- Set querySpaces) {
- this.sourceQuery = sourceQuery;
- this.parameterMetadata = parameterMetadata;
- this.returnAliases = returnAliases;
- this.returnTypes = returnTypes;
- this.querySpaces = querySpaces;
- }
-
- /**
- * Get the source HQL or native-SQL query.
- *
- * @return The source query.
- */
- public String getSourceQuery() {
- return sourceQuery;
- }
-
- public ParameterMetadata getParameterMetadata() {
- return parameterMetadata;
- }
-
- /**
- * Return source query select clause aliases (if any)
- *
- * @return an array of aliases as strings.
- */
- public String[] getReturnAliases() {
- return returnAliases;
- }
-
- /**
- * An array of types describing the returns of the source query.
- *
- * @return The return type array.
- */
- public Type[] getReturnTypes() {
- return returnTypes;
- }
-
- /**
- * The set of query spaces affected by this source query.
- *
- * @return The set of query spaces.
- */
- public Set getQuerySpaces() {
- return querySpaces;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryMetadata.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,96 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * Defines metadata regarding a translated HQL or native-SQL query.
+ *
+ * @author Steve Ebersole
+ */
+public class QueryMetadata implements Serializable {
+ private final String sourceQuery;
+ private final ParameterMetadata parameterMetadata;
+ private final String[] returnAliases;
+ private final Type[] returnTypes;
+ private final Set querySpaces;
+
+ public QueryMetadata(
+ String sourceQuery,
+ ParameterMetadata parameterMetadata,
+ String[] returnAliases,
+ Type[] returnTypes,
+ Set querySpaces) {
+ this.sourceQuery = sourceQuery;
+ this.parameterMetadata = parameterMetadata;
+ this.returnAliases = returnAliases;
+ this.returnTypes = returnTypes;
+ this.querySpaces = querySpaces;
+ }
+
+ /**
+ * Get the source HQL or native-SQL query.
+ *
+ * @return The source query.
+ */
+ public String getSourceQuery() {
+ return sourceQuery;
+ }
+
+ public ParameterMetadata getParameterMetadata() {
+ return parameterMetadata;
+ }
+
+ /**
+ * Return source query select clause aliases (if any)
+ *
+ * @return an array of aliases as strings.
+ */
+ public String[] getReturnAliases() {
+ return returnAliases;
+ }
+
+ /**
+ * An array of types describing the returns of the source query.
+ *
+ * @return The return type array.
+ */
+ public Type[] getReturnTypes() {
+ return returnTypes;
+ }
+
+ /**
+ * The set of query spaces affected by this source query.
+ *
+ * @return The set of query spaces.
+ */
+ public Set getQuerySpaces() {
+ return querySpaces;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,263 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.util.ArrayHelper;
-import org.hibernate.util.SimpleMRUCache;
-import org.hibernate.util.SoftLimitMRUCache;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
-import org.hibernate.QueryException;
-import org.hibernate.MappingException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-
-/**
- * Acts as a cache for compiled query plans, as well as query-parameter metadata.
- *
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class QueryPlanCache implements Serializable {
-
- private static final Logger log = LoggerFactory.getLogger( QueryPlanCache.class );
-
- private SessionFactoryImplementor factory;
-
- public QueryPlanCache(SessionFactoryImplementor factory) {
- this.factory = factory;
- }
-
- // simple cache of param metadata based on query string. Ideally, the
- // original "user-supplied query" string should be used to retreive this
- // metadata (i.e., not the para-list-expanded query string) to avoid
- // unnecessary cache entries.
- // Used solely for caching param metadata for native-sql queries, see
- // getSQLParameterMetadata() for a discussion as to why...
- private final SimpleMRUCache sqlParamMetadataCache = new SimpleMRUCache();
-
- // the cache of the actual plans...
- private final SoftLimitMRUCache planCache = new SoftLimitMRUCache( 128 );
-
-
- public ParameterMetadata getSQLParameterMetadata(String query) {
- ParameterMetadata metadata = ( ParameterMetadata ) sqlParamMetadataCache.get( query );
- if ( metadata == null ) {
- // for native-sql queries, the param metadata is determined outside
- // any relation to a query plan, because query plan creation and/or
- // retreival for a native-sql query depends on all of the return
- // types having been set, which might not be the case up-front when
- // param metadata would be most useful
- metadata = buildNativeSQLParameterMetadata( query );
- sqlParamMetadataCache.put( query, metadata );
- }
- return metadata;
- }
-
- public HQLQueryPlan getHQLQueryPlan(String queryString, boolean shallow, Map enabledFilters)
- throws QueryException, MappingException {
- HQLQueryPlanKey key = new HQLQueryPlanKey( queryString, shallow, enabledFilters );
- HQLQueryPlan plan = ( HQLQueryPlan ) planCache.get ( key );
-
- if ( plan == null ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "unable to locate HQL query plan in cache; generating (" + queryString + ")" );
- }
- plan = new HQLQueryPlan(queryString, shallow, enabledFilters, factory );
- }
- else {
- if ( log.isTraceEnabled() ) {
- log.trace( "located HQL query plan in cache (" + queryString + ")" );
- }
- }
-
- planCache.put( key, plan );
-
- return plan;
- }
-
- public FilterQueryPlan getFilterQueryPlan(String filterString, String collectionRole, boolean shallow, Map enabledFilters)
- throws QueryException, MappingException {
- FilterQueryPlanKey key = new FilterQueryPlanKey( filterString, collectionRole, shallow, enabledFilters );
- FilterQueryPlan plan = ( FilterQueryPlan ) planCache.get ( key );
-
- if ( plan == null ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "unable to locate collection-filter query plan in cache; generating (" + collectionRole + " : " + filterString + ")" );
- }
- plan = new FilterQueryPlan( filterString, collectionRole, shallow, enabledFilters, factory );
- }
- else {
- if ( log.isTraceEnabled() ) {
- log.trace( "located collection-filter query plan in cache (" + collectionRole + " : " + filterString + ")" );
- }
- }
-
- planCache.put( key, plan );
-
- return plan;
- }
-
- public NativeSQLQueryPlan getNativeSQLQueryPlan(NativeSQLQuerySpecification spec) {
- NativeSQLQueryPlan plan = ( NativeSQLQueryPlan ) planCache.get( spec );
-
- if ( plan == null ) {
- if ( log.isTraceEnabled() ) {
- log.trace( "unable to locate native-sql query plan in cache; generating (" + spec.getQueryString() + ")" );
- }
- plan = new NativeSQLQueryPlan( spec, factory );
- }
- else {
- if ( log.isTraceEnabled() ) {
- log.trace( "located native-sql query plan in cache (" + spec.getQueryString() + ")" );
- }
- }
-
- planCache.put( spec, plan );
- return plan;
- }
-
- private ParameterMetadata buildNativeSQLParameterMetadata(String sqlString) {
- ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations( sqlString );
-
- OrdinalParameterDescriptor[] ordinalDescriptors =
- new OrdinalParameterDescriptor[ recognizer.getOrdinalParameterLocationList().size() ];
- for ( int i = 0; i < recognizer.getOrdinalParameterLocationList().size(); i++ ) {
- final Integer position = ( Integer ) recognizer.getOrdinalParameterLocationList().get( i );
- ordinalDescriptors[i] = new OrdinalParameterDescriptor( i, null, position.intValue() );
- }
-
- Iterator itr = recognizer.getNamedParameterDescriptionMap().entrySet().iterator();
- Map namedParamDescriptorMap = new HashMap();
- while( itr.hasNext() ) {
- final Map.Entry entry = ( Map.Entry ) itr.next();
- final String name = ( String ) entry.getKey();
- final ParamLocationRecognizer.NamedParameterDescription description =
- ( ParamLocationRecognizer.NamedParameterDescription ) entry.getValue();
- namedParamDescriptorMap.put(
- name ,
- new NamedParameterDescriptor( name, null, description.buildPositionsArray(), description.isJpaStyle() )
- );
- }
-
- return new ParameterMetadata( ordinalDescriptors, namedParamDescriptorMap );
- }
-
- private static class HQLQueryPlanKey implements Serializable {
- private final String query;
- private final boolean shallow;
- private final Set filterNames;
- private final int hashCode;
-
- public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters) {
- this.query = query;
- this.shallow = shallow;
-
- if ( enabledFilters == null || enabledFilters.isEmpty() ) {
- filterNames = Collections.EMPTY_SET;
- }
- else {
- Set tmp = new HashSet();
- tmp.addAll( enabledFilters.keySet() );
- this.filterNames = Collections.unmodifiableSet( tmp );
- }
-
- int hash = query.hashCode();
- hash = 29 * hash + ( shallow ? 1 : 0 );
- hash = 29 * hash + filterNames.hashCode();
- this.hashCode = hash;
- }
-
- public boolean equals(Object o) {
- if ( this == o ) {
- return true;
- }
- if ( o == null || getClass() != o.getClass() ) {
- return false;
- }
-
- final HQLQueryPlanKey that = ( HQLQueryPlanKey ) o;
-
- if ( shallow != that.shallow ) {
- return false;
- }
- if ( !filterNames.equals( that.filterNames ) ) {
- return false;
- }
- if ( !query.equals( that.query ) ) {
- return false;
- }
-
- return true;
- }
-
- public int hashCode() {
- return hashCode;
- }
- }
-
- private static class FilterQueryPlanKey implements Serializable {
- private final String query;
- private final String collectionRole;
- private final boolean shallow;
- private final Set filterNames;
- private final int hashCode;
-
- public FilterQueryPlanKey(String query, String collectionRole, boolean shallow, Map enabledFilters) {
- this.query = query;
- this.collectionRole = collectionRole;
- this.shallow = shallow;
-
- if ( enabledFilters == null || enabledFilters.isEmpty() ) {
- filterNames = Collections.EMPTY_SET;
- }
- else {
- Set tmp = new HashSet();
- tmp.addAll( enabledFilters.keySet() );
- this.filterNames = Collections.unmodifiableSet( tmp );
- }
-
- int hash = query.hashCode();
- hash = 29 * hash + collectionRole.hashCode();
- hash = 29 * hash + ( shallow ? 1 : 0 );
- hash = 29 * hash + filterNames.hashCode();
- this.hashCode = hash;
- }
-
- public boolean equals(Object o) {
- if ( this == o ) {
- return true;
- }
- if ( o == null || getClass() != o.getClass() ) {
- return false;
- }
-
- final FilterQueryPlanKey that = ( FilterQueryPlanKey ) o;
-
- if ( shallow != that.shallow ) {
- return false;
- }
- if ( !filterNames.equals( that.filterNames ) ) {
- return false;
- }
- if ( !query.equals( that.query ) ) {
- return false;
- }
- if ( !collectionRole.equals( that.collectionRole ) ) {
- return false;
- }
-
- return true;
- }
-
- public int hashCode() {
- return hashCode;
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/QueryPlanCache.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,285 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.util.SimpleMRUCache;
+import org.hibernate.util.SoftLimitMRUCache;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
+import org.hibernate.QueryException;
+import org.hibernate.MappingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * Acts as a cache for compiled query plans, as well as query-parameter metadata.
+ *
+ * @author Steve Ebersole
+ */
+public class QueryPlanCache implements Serializable {
+
+ private static final Logger log = LoggerFactory.getLogger( QueryPlanCache.class );
+
+ private SessionFactoryImplementor factory;
+
+ public QueryPlanCache(SessionFactoryImplementor factory) {
+ this.factory = factory;
+ }
+
+ // simple cache of param metadata based on query string. Ideally, the
+ // original "user-supplied query" string should be used to retreive this
+ // metadata (i.e., not the para-list-expanded query string) to avoid
+ // unnecessary cache entries.
+ // Used solely for caching param metadata for native-sql queries, see
+ // getSQLParameterMetadata() for a discussion as to why...
+ private final SimpleMRUCache sqlParamMetadataCache = new SimpleMRUCache();
+
+ // the cache of the actual plans...
+ private final SoftLimitMRUCache planCache = new SoftLimitMRUCache( 128 );
+
+
+ public ParameterMetadata getSQLParameterMetadata(String query) {
+ ParameterMetadata metadata = ( ParameterMetadata ) sqlParamMetadataCache.get( query );
+ if ( metadata == null ) {
+ // for native-sql queries, the param metadata is determined outside
+ // any relation to a query plan, because query plan creation and/or
+ // retreival for a native-sql query depends on all of the return
+ // types having been set, which might not be the case up-front when
+ // param metadata would be most useful
+ metadata = buildNativeSQLParameterMetadata( query );
+ sqlParamMetadataCache.put( query, metadata );
+ }
+ return metadata;
+ }
+
+ public HQLQueryPlan getHQLQueryPlan(String queryString, boolean shallow, Map enabledFilters)
+ throws QueryException, MappingException {
+ HQLQueryPlanKey key = new HQLQueryPlanKey( queryString, shallow, enabledFilters );
+ HQLQueryPlan plan = ( HQLQueryPlan ) planCache.get ( key );
+
+ if ( plan == null ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "unable to locate HQL query plan in cache; generating (" + queryString + ")" );
+ }
+ plan = new HQLQueryPlan(queryString, shallow, enabledFilters, factory );
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "located HQL query plan in cache (" + queryString + ")" );
+ }
+ }
+
+ planCache.put( key, plan );
+
+ return plan;
+ }
+
+ public FilterQueryPlan getFilterQueryPlan(String filterString, String collectionRole, boolean shallow, Map enabledFilters)
+ throws QueryException, MappingException {
+ FilterQueryPlanKey key = new FilterQueryPlanKey( filterString, collectionRole, shallow, enabledFilters );
+ FilterQueryPlan plan = ( FilterQueryPlan ) planCache.get ( key );
+
+ if ( plan == null ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "unable to locate collection-filter query plan in cache; generating (" + collectionRole + " : " + filterString + ")" );
+ }
+ plan = new FilterQueryPlan( filterString, collectionRole, shallow, enabledFilters, factory );
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "located collection-filter query plan in cache (" + collectionRole + " : " + filterString + ")" );
+ }
+ }
+
+ planCache.put( key, plan );
+
+ return plan;
+ }
+
+ public NativeSQLQueryPlan getNativeSQLQueryPlan(NativeSQLQuerySpecification spec) {
+ NativeSQLQueryPlan plan = ( NativeSQLQueryPlan ) planCache.get( spec );
+
+ if ( plan == null ) {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "unable to locate native-sql query plan in cache; generating (" + spec.getQueryString() + ")" );
+ }
+ plan = new NativeSQLQueryPlan( spec, factory );
+ }
+ else {
+ if ( log.isTraceEnabled() ) {
+ log.trace( "located native-sql query plan in cache (" + spec.getQueryString() + ")" );
+ }
+ }
+
+ planCache.put( spec, plan );
+ return plan;
+ }
+
+ private ParameterMetadata buildNativeSQLParameterMetadata(String sqlString) {
+ ParamLocationRecognizer recognizer = ParamLocationRecognizer.parseLocations( sqlString );
+
+ OrdinalParameterDescriptor[] ordinalDescriptors =
+ new OrdinalParameterDescriptor[ recognizer.getOrdinalParameterLocationList().size() ];
+ for ( int i = 0; i < recognizer.getOrdinalParameterLocationList().size(); i++ ) {
+ final Integer position = ( Integer ) recognizer.getOrdinalParameterLocationList().get( i );
+ ordinalDescriptors[i] = new OrdinalParameterDescriptor( i, null, position.intValue() );
+ }
+
+ Iterator itr = recognizer.getNamedParameterDescriptionMap().entrySet().iterator();
+ Map namedParamDescriptorMap = new HashMap();
+ while( itr.hasNext() ) {
+ final Map.Entry entry = ( Map.Entry ) itr.next();
+ final String name = ( String ) entry.getKey();
+ final ParamLocationRecognizer.NamedParameterDescription description =
+ ( ParamLocationRecognizer.NamedParameterDescription ) entry.getValue();
+ namedParamDescriptorMap.put(
+ name ,
+ new NamedParameterDescriptor( name, null, description.buildPositionsArray(), description.isJpaStyle() )
+ );
+ }
+
+ return new ParameterMetadata( ordinalDescriptors, namedParamDescriptorMap );
+ }
+
+ private static class HQLQueryPlanKey implements Serializable {
+ private final String query;
+ private final boolean shallow;
+ private final Set filterNames;
+ private final int hashCode;
+
+ public HQLQueryPlanKey(String query, boolean shallow, Map enabledFilters) {
+ this.query = query;
+ this.shallow = shallow;
+
+ if ( enabledFilters == null || enabledFilters.isEmpty() ) {
+ filterNames = Collections.EMPTY_SET;
+ }
+ else {
+ Set tmp = new HashSet();
+ tmp.addAll( enabledFilters.keySet() );
+ this.filterNames = Collections.unmodifiableSet( tmp );
+ }
+
+ int hash = query.hashCode();
+ hash = 29 * hash + ( shallow ? 1 : 0 );
+ hash = 29 * hash + filterNames.hashCode();
+ this.hashCode = hash;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ final HQLQueryPlanKey that = ( HQLQueryPlanKey ) o;
+
+ if ( shallow != that.shallow ) {
+ return false;
+ }
+ if ( !filterNames.equals( that.filterNames ) ) {
+ return false;
+ }
+ if ( !query.equals( that.query ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+ }
+
+ private static class FilterQueryPlanKey implements Serializable {
+ private final String query;
+ private final String collectionRole;
+ private final boolean shallow;
+ private final Set filterNames;
+ private final int hashCode;
+
+ public FilterQueryPlanKey(String query, String collectionRole, boolean shallow, Map enabledFilters) {
+ this.query = query;
+ this.collectionRole = collectionRole;
+ this.shallow = shallow;
+
+ if ( enabledFilters == null || enabledFilters.isEmpty() ) {
+ filterNames = Collections.EMPTY_SET;
+ }
+ else {
+ Set tmp = new HashSet();
+ tmp.addAll( enabledFilters.keySet() );
+ this.filterNames = Collections.unmodifiableSet( tmp );
+ }
+
+ int hash = query.hashCode();
+ hash = 29 * hash + collectionRole.hashCode();
+ hash = 29 * hash + ( shallow ? 1 : 0 );
+ hash = 29 * hash + filterNames.hashCode();
+ this.hashCode = hash;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ final FilterQueryPlanKey that = ( FilterQueryPlanKey ) o;
+
+ if ( shallow != that.shallow ) {
+ return false;
+ }
+ if ( !filterNames.equals( that.filterNames ) ) {
+ return false;
+ }
+ if ( !query.equals( that.query ) ) {
+ return false;
+ }
+ if ( !collectionRole.equals( that.collectionRole ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return hashCode;
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,26 +0,0 @@
-package org.hibernate.engine.query;
-
-import org.hibernate.type.Type;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
- */
-public class ReturnMetadata implements Serializable {
- private final String[] returnAliases;
- private final Type[] returnTypes;
-
- public ReturnMetadata(String[] returnAliases, Type[] returnTypes) {
- this.returnAliases = returnAliases;
- this.returnTypes = returnTypes;
- }
-
- public String[] getReturnAliases() {
- return returnAliases;
- }
-
- public Type[] getReturnTypes() {
- return returnTypes;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/ReturnMetadata.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query;
+
+import org.hibernate.type.Type;
+
+import java.io.Serializable;
+
+/**
+ * @author Steve Ebersole
+ */
+public class ReturnMetadata implements Serializable {
+ private final String[] returnAliases;
+ private final Type[] returnTypes;
+
+ public ReturnMetadata(String[] returnAliases, Type[] returnTypes) {
+ this.returnAliases = returnAliases;
+ this.returnTypes = returnTypes;
+ }
+
+ public String[] getReturnAliases() {
+ return returnAliases;
+ }
+
+ public Type[] getReturnTypes() {
+ return returnTypes;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,60 +0,0 @@
-// $Id: NativeSQLQueryCollectionReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
-package org.hibernate.engine.query.sql;
-
-import java.util.Map;
-
-import org.hibernate.LockMode;
-
-/**
- * Represents a return defined as part of a native sql query which
- * names a collection role in the form {classname}.{collectionrole}; it
- * is used in defining a custom sql query for loading an entity's
- * collection in non-fetching scenarios (i.e., loading the collection
- * itself as the "root" of the result).
- *
- * @author Steve Ebersole
- */
-public class NativeSQLQueryCollectionReturn extends NativeSQLQueryNonScalarReturn {
- private String ownerEntityName;
- private String ownerProperty;
-
- /**
- * Construct a native-sql return representing a collection initializer
- *
- * @param alias The result alias
- * @param ownerEntityName The entity-name of the entity owning the collection
- * to be initialized.
- * @param ownerProperty The property name (on the owner) which represents
- * the collection to be initialized.
- * @param propertyResults Any user-supplied column->property mappings
- * @param lockMode The lock mode to apply to the collection.
- */
- public NativeSQLQueryCollectionReturn(
- String alias,
- String ownerEntityName,
- String ownerProperty,
- Map propertyResults,
- LockMode lockMode) {
- super( alias, propertyResults, lockMode );
- this.ownerEntityName = ownerEntityName;
- this.ownerProperty = ownerProperty;
- }
-
- /**
- * Returns the class owning the collection.
- *
- * @return The class owning the collection.
- */
- public String getOwnerEntityName() {
- return ownerEntityName;
- }
-
- /**
- * Returns the name of the property representing the collection from the {@link #getOwnerEntityName}.
- *
- * @return The name of the property representing the collection on the owner class.
- */
- public String getOwnerProperty() {
- return ownerProperty;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryCollectionReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+import java.util.Map;
+
+import org.hibernate.LockMode;
+
+/**
+ * Represents a return defined as part of a native sql query which
+ * names a collection role in the form {classname}.{collectionrole}; it
+ * is used in defining a custom sql query for loading an entity's
+ * collection in non-fetching scenarios (i.e., loading the collection
+ * itself as the "root" of the result).
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryCollectionReturn extends NativeSQLQueryNonScalarReturn {
+ private String ownerEntityName;
+ private String ownerProperty;
+
+ /**
+ * Construct a native-sql return representing a collection initializer
+ *
+ * @param alias The result alias
+ * @param ownerEntityName The entity-name of the entity owning the collection
+ * to be initialized.
+ * @param ownerProperty The property name (on the owner) which represents
+ * the collection to be initialized.
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply to the collection.
+ */
+ public NativeSQLQueryCollectionReturn(
+ String alias,
+ String ownerEntityName,
+ String ownerProperty,
+ Map propertyResults,
+ LockMode lockMode) {
+ super( alias, propertyResults, lockMode );
+ this.ownerEntityName = ownerEntityName;
+ this.ownerProperty = ownerProperty;
+ }
+
+ /**
+ * Returns the class owning the collection.
+ *
+ * @return The class owning the collection.
+ */
+ public String getOwnerEntityName() {
+ return ownerEntityName;
+ }
+
+ /**
+ * Returns the name of the property representing the collection from the {@link #getOwnerEntityName}.
+ *
+ * @return The name of the property representing the collection on the owner class.
+ */
+ public String getOwnerProperty() {
+ return ownerProperty;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,56 +0,0 @@
-// $Id: NativeSQLQueryJoinReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
-package org.hibernate.engine.query.sql;
-
-import java.util.Map;
-
-import org.hibernate.LockMode;
-
-/**
- * Represents a return defined as part of a native sql query which
- * names a fetched role.
- *
- * @author Steve Ebersole
- */
-public class NativeSQLQueryJoinReturn extends NativeSQLQueryNonScalarReturn {
- private String ownerAlias;
- private String ownerProperty;
-
- /**
- * Construct a return descriptor representing some form of fetch.
- *
- * @param alias The result alias
- * @param ownerAlias The owner's result alias
- * @param ownerProperty The owner's property representing the thing to be fetched
- * @param propertyResults Any user-supplied column->property mappings
- * @param lockMode The lock mode to apply
- */
- public NativeSQLQueryJoinReturn(
- String alias,
- String ownerAlias,
- String ownerProperty,
- Map propertyResults,
- LockMode lockMode) {
- super( alias, propertyResults, lockMode );
- this.ownerAlias = ownerAlias;
- this.ownerProperty = ownerProperty;
- }
-
- /**
- * Retrieve the alias of the owner of this fetched association.
- *
- * @return The owner's alias.
- */
- public String getOwnerAlias() {
- return ownerAlias;
- }
-
- /**
- * Retrieve the property name (relative to the owner) which maps to
- * the association to be fetched.
- *
- * @return The property name.
- */
- public String getOwnerProperty() {
- return ownerProperty;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryJoinReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,79 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+import java.util.Map;
+
+import org.hibernate.LockMode;
+
+/**
+ * Represents a return defined as part of a native sql query which
+ * names a fetched role.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryJoinReturn extends NativeSQLQueryNonScalarReturn {
+ private String ownerAlias;
+ private String ownerProperty;
+
+ /**
+ * Construct a return descriptor representing some form of fetch.
+ *
+ * @param alias The result alias
+ * @param ownerAlias The owner's result alias
+ * @param ownerProperty The owner's property representing the thing to be fetched
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply
+ */
+ public NativeSQLQueryJoinReturn(
+ String alias,
+ String ownerAlias,
+ String ownerProperty,
+ Map propertyResults,
+ LockMode lockMode) {
+ super( alias, propertyResults, lockMode );
+ this.ownerAlias = ownerAlias;
+ this.ownerProperty = ownerProperty;
+ }
+
+ /**
+ * Retrieve the alias of the owner of this fetched association.
+ *
+ * @return The owner's alias.
+ */
+ public String getOwnerAlias() {
+ return ownerAlias;
+ }
+
+ /**
+ * Retrieve the property name (relative to the owner) which maps to
+ * the association to be fetched.
+ *
+ * @return The property name.
+ */
+ public String getOwnerProperty() {
+ return ownerProperty;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,67 +0,0 @@
-// $Id: NativeSQLQueryNonScalarReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
-package org.hibernate.engine.query.sql;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.HibernateException;
-import org.hibernate.LockMode;
-
-/**
- * Represents the base information for a non-scalar return defined as part of
- * a native sql query.
- *
- * @author Steve Ebersole
- */
-public abstract class NativeSQLQueryNonScalarReturn implements NativeSQLQueryReturn, Serializable {
- private final String alias;
- private final LockMode lockMode;
- private final Map propertyResults = new HashMap();
-
- /**
- * Constructs some form of non-scalar return descriptor
- *
- * @param alias The result alias
- * @param propertyResults Any user-supplied column->property mappings
- * @param lockMode The lock mode to apply to the return.
- */
- protected NativeSQLQueryNonScalarReturn(String alias, Map propertyResults, LockMode lockMode) {
- this.alias = alias;
- if ( alias == null ) {
- throw new HibernateException("alias must be specified");
- }
- this.lockMode = lockMode;
- if ( propertyResults != null ) {
- this.propertyResults.putAll( propertyResults );
- }
- }
-
- /**
- * Retrieve the defined result alias
- *
- * @return The result alias.
- */
- public String getAlias() {
- return alias;
- }
-
- /**
- * Retrieve the lock-mode to apply to this return
- *
- * @return The lock mode
- */
- public LockMode getLockMode() {
- return lockMode;
- }
-
- /**
- * Retrieve the user-supplied column->property mappings.
- *
- * @return The property mappings.
- */
- public Map getPropertyResultsMap() {
- return Collections.unmodifiableMap( propertyResults );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryNonScalarReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,90 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+
+/**
+ * Represents the base information for a non-scalar return defined as part of
+ * a native sql query.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class NativeSQLQueryNonScalarReturn implements NativeSQLQueryReturn, Serializable {
+ private final String alias;
+ private final LockMode lockMode;
+ private final Map propertyResults = new HashMap();
+
+ /**
+ * Constructs some form of non-scalar return descriptor
+ *
+ * @param alias The result alias
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply to the return.
+ */
+ protected NativeSQLQueryNonScalarReturn(String alias, Map propertyResults, LockMode lockMode) {
+ this.alias = alias;
+ if ( alias == null ) {
+ throw new HibernateException("alias must be specified");
+ }
+ this.lockMode = lockMode;
+ if ( propertyResults != null ) {
+ this.propertyResults.putAll( propertyResults );
+ }
+ }
+
+ /**
+ * Retrieve the defined result alias
+ *
+ * @return The result alias.
+ */
+ public String getAlias() {
+ return alias;
+ }
+
+ /**
+ * Retrieve the lock-mode to apply to this return
+ *
+ * @return The lock mode
+ */
+ public LockMode getLockMode() {
+ return lockMode;
+ }
+
+ /**
+ * Retrieve the user-supplied column->property mappings.
+ *
+ * @return The property mappings.
+ */
+ public Map getPropertyResultsMap() {
+ return Collections.unmodifiableMap( propertyResults );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,9 +0,0 @@
-package org.hibernate.engine.query.sql;
-
-/**
- * Describes a return in a native SQL query.
- *
- * @author Steve Ebersole
- */
-public interface NativeSQLQueryReturn {
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,33 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+/**
+ * Describes a return in a native SQL query.
+ *
+ * @author Steve Ebersole
+ */
+public interface NativeSQLQueryReturn {
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,52 +0,0 @@
-// $Id: NativeSQLQueryRootReturn.java 7232 2005-06-19 17:16:40 -0500 (Sun, 19 Jun 2005) maxcsaucdk $
-package org.hibernate.engine.query.sql;
-
-import java.util.Map;
-
-import org.hibernate.LockMode;
-
-/**
- * Represents a return defined as part of a native sql query which
- * names a "root" entity. A root entity means it is explicitly a
- * "column" in the result, as opposed to a fetched relationship or role.
- *
- * @author Steve Ebersole
- */
-public class NativeSQLQueryRootReturn extends NativeSQLQueryNonScalarReturn {
- private String returnEntityName;
-
- /**
- * Construct a return representing an entity returned at the root
- * of the result.
- *
- * @param alias The result alias
- * @param entityName The entity name.
- * @param lockMode The lock mode to apply
- */
- public NativeSQLQueryRootReturn(String alias, String entityName, LockMode lockMode) {
- this(alias, entityName, null, lockMode);
- }
-
- /**
- *
- * @param alias The result alias
- * @param entityName The entity name.
- * @param propertyResults Any user-supplied column->property mappings
- * @param lockMode The lock mode to apply
- */
- public NativeSQLQueryRootReturn(String alias, String entityName, Map propertyResults, LockMode lockMode) {
- super( alias, propertyResults, lockMode );
- this.returnEntityName = entityName;
-
- }
-
- /**
- * The name of the entity to be returned.
- *
- * @return The entity name
- */
- public String getReturnEntityName() {
- return returnEntityName;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryRootReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,75 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+import java.util.Map;
+
+import org.hibernate.LockMode;
+
+/**
+ * Represents a return defined as part of a native sql query which
+ * names a "root" entity. A root entity means it is explicitly a
+ * "column" in the result, as opposed to a fetched relationship or role.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQueryRootReturn extends NativeSQLQueryNonScalarReturn {
+ private String returnEntityName;
+
+ /**
+ * Construct a return representing an entity returned at the root
+ * of the result.
+ *
+ * @param alias The result alias
+ * @param entityName The entity name.
+ * @param lockMode The lock mode to apply
+ */
+ public NativeSQLQueryRootReturn(String alias, String entityName, LockMode lockMode) {
+ this(alias, entityName, null, lockMode);
+ }
+
+ /**
+ *
+ * @param alias The result alias
+ * @param entityName The entity name.
+ * @param propertyResults Any user-supplied column->property mappings
+ * @param lockMode The lock mode to apply
+ */
+ public NativeSQLQueryRootReturn(String alias, String entityName, Map propertyResults, LockMode lockMode) {
+ super( alias, propertyResults, lockMode );
+ this.returnEntityName = entityName;
+
+ }
+
+ /**
+ * The name of the entity to be returned.
+ *
+ * @return The entity name
+ */
+ public String getReturnEntityName() {
+ return returnEntityName;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,27 +0,0 @@
-package org.hibernate.engine.query.sql;
-
-import org.hibernate.type.Type;
-
-/**
- * Describes a scalar return in a native SQL query.
- *
- * @author gloegl
- */
-public class NativeSQLQueryScalarReturn implements NativeSQLQueryReturn {
- private Type type;
- private String columnAlias;
-
- public NativeSQLQueryScalarReturn(String alias, Type type) {
- this.type = type;
- this.columnAlias = alias;
- }
-
- public String getColumnAlias() {
- return columnAlias;
- }
-
- public Type getType() {
- return type;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQueryScalarReturn.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+import org.hibernate.type.Type;
+
+/**
+ * Describes a scalar return in a native SQL query.
+ *
+ * @author gloegl
+ */
+public class NativeSQLQueryScalarReturn implements NativeSQLQueryReturn {
+ private Type type;
+ private String columnAlias;
+
+ public NativeSQLQueryScalarReturn(String alias, Type type) {
+ this.type = type;
+ this.columnAlias = alias;
+ }
+
+ public String getColumnAlias() {
+ return columnAlias;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,80 +0,0 @@
-package org.hibernate.engine.query.sql;
-
-import org.hibernate.util.ArrayHelper;
-
-import java.util.Set;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Defines the specification or blue-print for a native-sql query.
- * Essentially a simple struct containing the information needed to "translate"
- * a native-sql query and cache that translated representation. Also used as
- * the key by which the native-sql query plans are cached.
- *
- * @author Steve Ebersole
- */
-public class NativeSQLQuerySpecification {
- private final String queryString;
- private final NativeSQLQueryReturn[] queryReturns;
- private final Set querySpaces;
- private final int hashCode;
-
- public NativeSQLQuerySpecification(
- String queryString,
- NativeSQLQueryReturn[] queryReturns,
- Collection querySpaces) {
- this.queryString = queryString;
- this.queryReturns = queryReturns;
- if ( querySpaces == null ) {
- this.querySpaces = Collections.EMPTY_SET;
- }
- else {
- Set tmp = new HashSet();
- tmp.addAll( querySpaces );
- this.querySpaces = Collections.unmodifiableSet( tmp );
- }
-
- // pre-determine and cache the hashcode
- int hashCode = queryString.hashCode();
- hashCode = 29 * hashCode + this.querySpaces.hashCode();
- if ( this.queryReturns != null ) {
- hashCode = 29 * hashCode + ArrayHelper.toList( this.queryReturns ).hashCode();
- }
- this.hashCode = hashCode;
- }
-
- public String getQueryString() {
- return queryString;
- }
-
- public NativeSQLQueryReturn[] getQueryReturns() {
- return queryReturns;
- }
-
- public Set getQuerySpaces() {
- return querySpaces;
- }
-
- public boolean equals(Object o) {
- if ( this == o ) {
- return true;
- }
- if ( o == null || getClass() != o.getClass() ) {
- return false;
- }
-
- final NativeSQLQuerySpecification that = ( NativeSQLQuerySpecification ) o;
-
- return querySpaces.equals( that.querySpaces ) &&
- queryString.equals( that.queryString ) &&
- Arrays.equals( queryReturns, that.queryReturns );
- }
-
-
- public int hashCode() {
- return hashCode;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/query/sql/NativeSQLQuerySpecification.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,104 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.query.sql;
+
+import org.hibernate.util.ArrayHelper;
+
+import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Collections;
+
+/**
+ * Defines the specification or blue-print for a native-sql query.
+ * Essentially a simple struct containing the information needed to "translate"
+ * a native-sql query and cache that translated representation. Also used as
+ * the key by which the native-sql query plans are cached.
+ *
+ * @author Steve Ebersole
+ */
+public class NativeSQLQuerySpecification {
+ private final String queryString;
+ private final NativeSQLQueryReturn[] queryReturns;
+ private final Set querySpaces;
+ private final int hashCode;
+
+ public NativeSQLQuerySpecification(
+ String queryString,
+ NativeSQLQueryReturn[] queryReturns,
+ Collection querySpaces) {
+ this.queryString = queryString;
+ this.queryReturns = queryReturns;
+ if ( querySpaces == null ) {
+ this.querySpaces = Collections.EMPTY_SET;
+ }
+ else {
+ Set tmp = new HashSet();
+ tmp.addAll( querySpaces );
+ this.querySpaces = Collections.unmodifiableSet( tmp );
+ }
+
+ // pre-determine and cache the hashcode
+ int hashCode = queryString.hashCode();
+ hashCode = 29 * hashCode + this.querySpaces.hashCode();
+ if ( this.queryReturns != null ) {
+ hashCode = 29 * hashCode + ArrayHelper.toList( this.queryReturns ).hashCode();
+ }
+ this.hashCode = hashCode;
+ }
+
+ public String getQueryString() {
+ return queryString;
+ }
+
+ public NativeSQLQueryReturn[] getQueryReturns() {
+ return queryReturns;
+ }
+
+ public Set getQuerySpaces() {
+ return querySpaces;
+ }
+
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ final NativeSQLQuerySpecification that = ( NativeSQLQuerySpecification ) o;
+
+ return querySpaces.equals( that.querySpaces ) &&
+ queryString.equals( that.queryString ) &&
+ Arrays.equals( queryReturns, that.queryReturns );
+ }
+
+
+ public int hashCode() {
+ return hashCode;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-package org.hibernate.engine.transaction;
-
-import org.hibernate.HibernateException;
-
-import java.sql.Connection;
-
-/**
- * Represents work that needs to be performed in a manner
- * which isolates it from any current application unit of
- * work transaction.
- *
- * @author Steve Ebersole
- */
-public interface IsolatedWork {
- /**
- * Perform the actual work to be done.
- *
- * @param connection The JDBC connection to use.
- * @throws HibernateException
- */
- public void doWork(Connection connection) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/IsolatedWork.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.transaction;
+
+import org.hibernate.HibernateException;
+
+import java.sql.Connection;
+
+/**
+ * Represents work that needs to be performed in a manner
+ * which isolates it from any current application unit of
+ * work transaction.
+ *
+ * @author Steve Ebersole
+ */
+public interface IsolatedWork {
+ /**
+ * Perform the actual work to be done.
+ *
+ * @param connection The JDBC connection to use.
+ * @throws HibernateException
+ */
+ public void doWork(Connection connection) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,230 +0,0 @@
-package org.hibernate.engine.transaction;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.exception.JDBCExceptionHelper;
-
-/**
- * Class which provides the isolation semantics required by
- * an {@link IsolatedWork}. Processing comes in two flavors:<ul>
- * <li>{@link #doIsolatedWork} : makes sure the work to be done is
- * performed in a seperate, distinct transaction</li>
- * <li>{@link #doNonTransactedWork} : makes sure the work to be
- * done is performed outside the scope of any transaction</li>
- * </ul>
- *
- * @author Steve Ebersole
- */
-public class Isolater {
-
- private static final Logger log = LoggerFactory.getLogger( Isolater.class );
-
- /**
- * Ensures that all processing actually performed by the given work will
- * occur on a seperate transaction.
- *
- * @param work The work to be performed.
- * @param session The session from which this request is originating.
- * @throws HibernateException
- */
- public static void doIsolatedWork(IsolatedWork work, SessionImplementor session) throws HibernateException {
- boolean isJta = session.getFactory().getTransactionManager() != null;
- if ( isJta ) {
- new JtaDelegate( session ).delegateWork( work, true );
- }
- else {
- new JdbcDelegate( session ).delegateWork( work, true );
- }
- }
-
- /**
- * Ensures that all processing actually performed by the given work will
- * occur outside of a transaction.
- *
- * @param work The work to be performed.
- * @param session The session from which this request is originating.
- * @throws HibernateException
- */
- public static void doNonTransactedWork(IsolatedWork work, SessionImplementor session) throws HibernateException {
- boolean isJta = session.getFactory().getTransactionManager() != null;
- if ( isJta ) {
- new JtaDelegate( session ).delegateWork( work, false );
- }
- else {
- new JdbcDelegate( session ).delegateWork( work, false );
- }
- }
-
- // should be ok performance-wise to generate new delegate instances for each
- // request since these are locally stack-scoped. Besides, it makes the code
- // much easier to read than the old TransactionHelper stuff...
-
- private static interface Delegate {
- public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException;
- }
-
- /**
- * An isolation delegate for JTA-based transactions. Essentially susepnds
- * any current transaction, does the work in a new transaction, and then
- * resumes the initial transaction (if there was one).
- */
- public static class JtaDelegate implements Delegate {
- private final SessionImplementor session;
-
- public JtaDelegate(SessionImplementor session) {
- this.session = session;
- }
-
- public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException {
- TransactionManager transactionManager = session.getFactory().getTransactionManager();
- Transaction surroundingTransaction = null;
- Connection connection = null;
- boolean caughtException = false;
-
- try {
- // First we need to suspend any current JTA transaction and obtain
- // a JDBC connection
- surroundingTransaction = transactionManager.suspend();
- if ( log.isDebugEnabled() ) {
- log.debug( "surrounding JTA transaction suspended [" + surroundingTransaction + "]" );
- }
-
- if ( transacted ) {
- transactionManager.begin();
- }
-
- connection = session.getBatcher().openConnection();
-
- // perform the actual work
- work.doWork( connection );
-
- // if everything went ok, commit the transaction and close the obtained
- // connection handle...
- session.getBatcher().closeConnection( connection );
-
- if ( transacted ) {
- transactionManager.commit();
- }
- }
- catch( Throwable t ) {
- // at some point the processing went bad, so we need to:
- // 1) make sure the connection handle gets released
- // 2) try to cleanup the JTA context as much as possible
- caughtException = true;
- try {
- if ( connection != null && !connection.isClosed() ) {
- session.getBatcher().closeConnection( connection );
- }
- }
- catch( Throwable ignore ) {
- log.trace( "unable to release connection on exception [" + ignore + "]" );
- }
- if ( transacted ) {
- try {
- transactionManager.rollback();
- }
- catch( Throwable ignore ) {
- log.trace( "unable to rollback new transaction on exception [" + ignore + "]" );
- }
- }
- // finally handle the exception
- if ( t instanceof HibernateException ) {
- throw ( HibernateException ) t;
- }
- else {
- throw new HibernateException( "error performing isolated work", t );
- }
- }
- finally {
- if ( surroundingTransaction != null ) {
- try {
- transactionManager.resume( surroundingTransaction );
- if ( log.isDebugEnabled() ) {
- log.debug( "surrounding JTA transaction resumed [" + surroundingTransaction + "]" );
- }
- }
- catch( Throwable t ) {
- if ( !caughtException ) {
- throw new HibernateException( "unable to resume previously suspended transaction", t );
- }
- }
- }
- }
- }
- }
-
- /**
- * An isolation delegate for JDBC-based transactions. Basically just
- * grabs a new connection and does the work on that.
- */
- public static class JdbcDelegate implements Delegate {
- private final SessionImplementor session;
-
- public JdbcDelegate(SessionImplementor session) {
- this.session = session;
- }
-
- public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException {
- Connection connection = null;
- boolean wasAutoCommit = false;
- try {
- connection = session.getBatcher().openConnection();
-
- if ( transacted ) {
- if ( connection.getAutoCommit() ) {
- wasAutoCommit = true;
- connection.setAutoCommit( false );
- }
- }
-
- work.doWork( connection );
-
- if ( transacted ) {
- connection.commit();
- }
- }
- catch( Throwable t ) {
- try {
- if ( transacted && connection != null && !connection.isClosed() ) {
- connection.rollback();
- }
- }
- catch( Throwable ignore ) {
- log.trace( "unable to release connection on exception [" + ignore + "]" );
- }
-
- if ( t instanceof HibernateException ) {
- throw ( HibernateException ) t;
- }
- else if ( t instanceof SQLException ) {
- throw JDBCExceptionHelper.convert(
- session.getFactory().getSQLExceptionConverter(),
- ( SQLException ) t,
- "error performing isolated work"
- );
- }
- else {
- throw new HibernateException( "error performing isolated work", t );
- }
- }
- finally {
- if ( transacted && wasAutoCommit ) {
- try {
- connection.setAutoCommit( true );
- }
- catch( Throwable ignore ) {
- log.trace( "was unable to reset connection back to auto-commit" );
- }
- }
- session.getBatcher().closeConnection( connection );
- }
- }
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java (from rev 14998, core/trunk/core/src/main/java/org/hibernate/engine/transaction/Isolater.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/engine/transaction/Isolater.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,256 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.engine.transaction;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.exception.JDBCExceptionHelper;
+
+/**
+ * Class which provides the isolation semantics required by
+ * an {@link IsolatedWork}. Processing comes in two flavors:<ul>
+ * <li>{@link #doIsolatedWork} : makes sure the work to be done is
+ * performed in a seperate, distinct transaction</li>
+ * <li>{@link #doNonTransactedWork} : makes sure the work to be
+ * done is performed outside the scope of any transaction</li>
+ * </ul>
+ *
+ * @author Steve Ebersole
+ */
+public class Isolater {
+
+ private static final Logger log = LoggerFactory.getLogger( Isolater.class );
+
+ /**
+ * Ensures that all processing actually performed by the given work will
+ * occur on a seperate transaction.
+ *
+ * @param work The work to be performed.
+ * @param session The session from which this request is originating.
+ * @throws HibernateException
+ */
+ public static void doIsolatedWork(IsolatedWork work, SessionImplementor session) throws HibernateException {
+ boolean isJta = session.getFactory().getTransactionManager() != null;
+ if ( isJta ) {
+ new JtaDelegate( session ).delegateWork( work, true );
+ }
+ else {
+ new JdbcDelegate( session ).delegateWork( work, true );
+ }
+ }
+
+ /**
+ * Ensures that all processing actually performed by the given work will
+ * occur outside of a transaction.
+ *
+ * @param work The work to be performed.
+ * @param session The session from which this request is originating.
+ * @throws HibernateException
+ */
+ public static void doNonTransactedWork(IsolatedWork work, SessionImplementor session) throws HibernateException {
+ boolean isJta = session.getFactory().getTransactionManager() != null;
+ if ( isJta ) {
+ new JtaDelegate( session ).delegateWork( work, false );
+ }
+ else {
+ new JdbcDelegate( session ).delegateWork( work, false );
+ }
+ }
+
+ // should be ok performance-wise to generate new delegate instances for each
+ // request since these are locally stack-scoped. Besides, it makes the code
+ // much easier to read than the old TransactionHelper stuff...
+
+ private static interface Delegate {
+ public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException;
+ }
+
+ /**
+ * An isolation delegate for JTA-based transactions. Essentially susepnds
+ * any current transaction, does the work in a new transaction, and then
+ * resumes the initial transaction (if there was one).
+ */
+ public static class JtaDelegate implements Delegate {
+ private final SessionImplementor session;
+
+ public JtaDelegate(SessionImplementor session) {
+ this.session = session;
+ }
+
+ public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException {
+ TransactionManager transactionManager = session.getFactory().getTransactionManager();
+ Transaction surroundingTransaction = null;
+ Connection connection = null;
+ boolean caughtException = false;
+
+ try {
+ // First we need to suspend any current JTA transaction and obtain
+ // a JDBC connection
+ surroundingTransaction = transactionManager.suspend();
+ if ( log.isDebugEnabled() ) {
+ log.debug( "surrounding JTA transaction suspended [" + surroundingTransaction + "]" );
+ }
+
+ if ( transacted ) {
+ transactionManager.begin();
+ }
+
+ connection = session.getBatcher().openConnection();
+
+ // perform the actual work
+ work.doWork( connection );
+
+ // if everything went ok, commit the transaction and close the obtained
+ // connection handle...
+ session.getBatcher().closeConnection( connection );
+
+ if ( transacted ) {
+ transactionManager.commit();
+ }
+ }
+ catch( Throwable t ) {
+ // at some point the processing went bad, so we need to:
+ // 1) make sure the connection handle gets released
+ // 2) try to cleanup the JTA context as much as possible
+ caughtException = true;
+ try {
+ if ( connection != null && !connection.isClosed() ) {
+ session.getBatcher().closeConnection( connection );
+ }
+ }
+ catch( Throwable ignore ) {
+ log.trace( "unable to release connection on exception [" + ignore + "]" );
+ }
+ if ( transacted ) {
+ try {
+ transactionManager.rollback();
+ }
+ catch( Throwable ignore ) {
+ log.trace( "unable to rollback new transaction on exception [" + ignore + "]" );
+ }
+ }
+ // finally handle the exception
+ if ( t instanceof HibernateException ) {
+ throw ( HibernateException ) t;
+ }
+ else {
+ throw new HibernateException( "error performing isolated work", t );
+ }
+ }
+ finally {
+ if ( surroundingTransaction != null ) {
+ try {
+ transactionManager.resume( surroundingTransaction );
+ if ( log.isDebugEnabled() ) {
+ log.debug( "surrounding JTA transaction resumed [" + surroundingTransaction + "]" );
+ }
+ }
+ catch( Throwable t ) {
+ if ( !caughtException ) {
+ throw new HibernateException( "unable to resume previously suspended transaction", t );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * An isolation delegate for JDBC-based transactions. Basically just
+ * grabs a new connection and does the work on that.
+ */
+ public static class JdbcDelegate implements Delegate {
+ private final SessionImplementor session;
+
+ public JdbcDelegate(SessionImplementor session) {
+ this.session = session;
+ }
+
+ public void delegateWork(IsolatedWork work, boolean transacted) throws HibernateException {
+ Connection connection = null;
+ boolean wasAutoCommit = false;
+ try {
+ connection = session.getBatcher().openConnection();
+
+ if ( transacted ) {
+ if ( connection.getAutoCommit() ) {
+ wasAutoCommit = true;
+ connection.setAutoCommit( false );
+ }
+ }
+
+ work.doWork( connection );
+
+ if ( transacted ) {
+ connection.commit();
+ }
+ }
+ catch( Throwable t ) {
+ try {
+ if ( transacted && connection != null && !connection.isClosed() ) {
+ connection.rollback();
+ }
+ }
+ catch( Throwable ignore ) {
+ log.trace( "unable to release connection on exception [" + ignore + "]" );
+ }
+
+ if ( t instanceof HibernateException ) {
+ throw ( HibernateException ) t;
+ }
+ else if ( t instanceof SQLException ) {
+ throw JDBCExceptionHelper.convert(
+ session.getFactory().getSQLExceptionConverter(),
+ ( SQLException ) t,
+ "error performing isolated work"
+ );
+ }
+ else {
+ throw new HibernateException( "error performing isolated work", t );
+ }
+ }
+ finally {
+ if ( connection != null ) {
+ if ( transacted && wasAutoCommit ) {
+ try {
+ connection.setAutoCommit( true );
+ }
+ catch( Throwable ignore ) {
+ log.trace( "was unable to reset connection back to auto-commit" );
+ }
+ }
+ session.getBatcher().closeConnection( connection );
+ }
+ }
+ }
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,115 +0,0 @@
-//$Id: $
-package org.hibernate.event;
-
-import java.io.Serializable;
-
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.CollectionEntry;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.persister.collection.CollectionPersister;
-
-/**
- * Defines a base class for events involving collections.
- *
- * @author Gail Badner
- */
-public abstract class AbstractCollectionEvent extends AbstractEvent {
-
- private final PersistentCollection collection;
- private final Object affectedOwner;
- private final Serializable affectedOwnerId;
- private final String affectedOwnerEntityName;
-
- /**
- * Constructs an AbstractCollectionEvent object.
- *
- * @param collection - the collection
- * @param source - the Session source
- * @param affectedOwner - the owner that is affected by this event;
- * can be null if unavailable
- * @param affectedOwnerId - the ID for the owner that is affected
- * by this event; can be null if unavailable
- * that is affected by this event; can be null if unavailable
- */
- public AbstractCollectionEvent( CollectionPersister collectionPersister,
- PersistentCollection collection,
- EventSource source,
- Object affectedOwner,
- Serializable affectedOwnerId) {
- super(source);
- this.collection = collection;
- this.affectedOwner = affectedOwner;
- this.affectedOwnerId = affectedOwnerId;
- this.affectedOwnerEntityName =
- getAffectedOwnerEntityName( collectionPersister, affectedOwner, source );
- }
-
- protected static CollectionPersister getLoadedCollectionPersister( PersistentCollection collection, EventSource source ) {
- CollectionEntry ce = source.getPersistenceContext().getCollectionEntry( collection );
- return ( ce == null ? null : ce.getLoadedPersister() );
- }
-
- protected static Object getLoadedOwnerOrNull( PersistentCollection collection, EventSource source ) {
- return source.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
- }
-
- protected static Serializable getLoadedOwnerIdOrNull( PersistentCollection collection, EventSource source ) {
- return source.getPersistenceContext().getLoadedCollectionOwnerIdOrNull( collection );
- }
-
- protected static Serializable getOwnerIdOrNull( Object owner, EventSource source ) {
- EntityEntry ownerEntry = source.getPersistenceContext().getEntry( owner );
- return ( ownerEntry == null ? null : ownerEntry.getId() );
- }
-
- protected static String getAffectedOwnerEntityName(CollectionPersister collectionPersister, Object affectedOwner, EventSource source ) {
-
- // collectionPersister should not be null, but we don't want to throw
- // an exception if it is null
- String entityName =
- ( collectionPersister == null ? null : collectionPersister.getOwnerEntityPersister().getEntityName() );
- if ( affectedOwner != null ) {
- EntityEntry ee = source.getPersistenceContext().getEntry( affectedOwner );
- if ( ee != null && ee.getEntityName() != null) {
- entityName = ee.getEntityName();
- }
- }
- return entityName;
- }
-
- public PersistentCollection getCollection() {
- return collection;
- }
-
- /**
- * Get the collection owner entity that is affected by this event.
- *
- * @return the affected owner; returns null if the entity is not in the persistence context
- * (e.g., because the collection from a detached entity was moved to a new owner)
- */
- public Object getAffectedOwnerOrNull() {
- return affectedOwner;
- }
-
- /**
- * Get the ID for the collection owner entity that is affected by this event.
- *
- * @return the affected owner ID; returns null if the ID cannot be obtained
- * from the collection's loaded key (e.g., a property-ref is used for the
- * collection and does not include the entity's ID)
- */
- public Serializable getAffectedOwnerIdOrNull() {
- return affectedOwnerId;
- }
-
- /**
- * Get the entity name for the collection owner entity that is affected by this event.
- *
- * @return the entity name; if the owner is not in the PersistenceContext, the
- * returned value may be a superclass name, instead of the actual class name
- */
- public String getAffectedOwnerEntityName() {
- return affectedOwnerEntityName;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractCollectionEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,138 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import java.io.Serializable;
+
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.CollectionEntry;
+import org.hibernate.engine.EntityEntry;
+import org.hibernate.persister.collection.CollectionPersister;
+
+/**
+ * Defines a base class for events involving collections.
+ *
+ * @author Gail Badner
+ */
+public abstract class AbstractCollectionEvent extends AbstractEvent {
+
+ private final PersistentCollection collection;
+ private final Object affectedOwner;
+ private final Serializable affectedOwnerId;
+ private final String affectedOwnerEntityName;
+
+ /**
+ * Constructs an AbstractCollectionEvent object.
+ *
+ * @param collection - the collection
+ * @param source - the Session source
+ * @param affectedOwner - the owner that is affected by this event;
+ * can be null if unavailable
+ * @param affectedOwnerId - the ID for the owner that is affected
+ * by this event; can be null if unavailable
+ * that is affected by this event; can be null if unavailable
+ */
+ public AbstractCollectionEvent( CollectionPersister collectionPersister,
+ PersistentCollection collection,
+ EventSource source,
+ Object affectedOwner,
+ Serializable affectedOwnerId) {
+ super(source);
+ this.collection = collection;
+ this.affectedOwner = affectedOwner;
+ this.affectedOwnerId = affectedOwnerId;
+ this.affectedOwnerEntityName =
+ getAffectedOwnerEntityName( collectionPersister, affectedOwner, source );
+ }
+
+ protected static CollectionPersister getLoadedCollectionPersister( PersistentCollection collection, EventSource source ) {
+ CollectionEntry ce = source.getPersistenceContext().getCollectionEntry( collection );
+ return ( ce == null ? null : ce.getLoadedPersister() );
+ }
+
+ protected static Object getLoadedOwnerOrNull( PersistentCollection collection, EventSource source ) {
+ return source.getPersistenceContext().getLoadedCollectionOwnerOrNull( collection );
+ }
+
+ protected static Serializable getLoadedOwnerIdOrNull( PersistentCollection collection, EventSource source ) {
+ return source.getPersistenceContext().getLoadedCollectionOwnerIdOrNull( collection );
+ }
+
+ protected static Serializable getOwnerIdOrNull( Object owner, EventSource source ) {
+ EntityEntry ownerEntry = source.getPersistenceContext().getEntry( owner );
+ return ( ownerEntry == null ? null : ownerEntry.getId() );
+ }
+
+ protected static String getAffectedOwnerEntityName(CollectionPersister collectionPersister, Object affectedOwner, EventSource source ) {
+
+ // collectionPersister should not be null, but we don't want to throw
+ // an exception if it is null
+ String entityName =
+ ( collectionPersister == null ? null : collectionPersister.getOwnerEntityPersister().getEntityName() );
+ if ( affectedOwner != null ) {
+ EntityEntry ee = source.getPersistenceContext().getEntry( affectedOwner );
+ if ( ee != null && ee.getEntityName() != null) {
+ entityName = ee.getEntityName();
+ }
+ }
+ return entityName;
+ }
+
+ public PersistentCollection getCollection() {
+ return collection;
+ }
+
+ /**
+ * Get the collection owner entity that is affected by this event.
+ *
+ * @return the affected owner; returns null if the entity is not in the persistence context
+ * (e.g., because the collection from a detached entity was moved to a new owner)
+ */
+ public Object getAffectedOwnerOrNull() {
+ return affectedOwner;
+ }
+
+ /**
+ * Get the ID for the collection owner entity that is affected by this event.
+ *
+ * @return the affected owner ID; returns null if the ID cannot be obtained
+ * from the collection's loaded key (e.g., a property-ref is used for the
+ * collection and does not include the entity's ID)
+ */
+ public Serializable getAffectedOwnerIdOrNull() {
+ return affectedOwnerId;
+ }
+
+ /**
+ * Get the entity name for the collection owner entity that is affected by this event.
+ *
+ * @return the entity name; if the owner is not in the PersistenceContext, the
+ * returned value may be a superclass name, instead of the actual class name
+ */
+ public String getAffectedOwnerEntityName() {
+ return affectedOwnerEntityName;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/AbstractEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,35 +0,0 @@
-//$Id: AbstractEvent.java 6929 2005-05-27 03:54:08Z oneovthafew $
-package org.hibernate.event;
-
-import java.io.Serializable;
-
-
-/**
- * Defines a base class for Session generated events.
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractEvent implements Serializable {
-
- private final EventSource session;
-
- /**
- * Constructs an event from the given event session.
- *
- * @param source The session event source.
- */
- public AbstractEvent(EventSource source) {
- this.session = source;
- }
-
- /**
- * Returns the session event source for this event. This is the underlying
- * session from which this event was generated.
- *
- * @return The session event source.
- */
- public final EventSource getSession() {
- return session;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/AbstractEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AbstractEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import java.io.Serializable;
+
+
+/**
+ * Defines a base class for Session generated events.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractEvent implements Serializable {
+
+ private final EventSource session;
+
+ /**
+ * Constructs an event from the given event session.
+ *
+ * @param source The session event source.
+ */
+ public AbstractEvent(EventSource source) {
+ this.session = source;
+ }
+
+ /**
+ * Returns the session event source for this event. This is the underlying
+ * session from which this event was generated.
+ *
+ * @return The session event source.
+ */
+ public final EventSource getSession() {
+ return session;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/AutoFlushEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,36 +0,0 @@
-///$Id: AutoFlushEvent.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.event;
-
-import java.util.Set;
-
-
-/** Defines an event class for the auto-flushing of a session.
- *
- * @author Steve Ebersole
- */
-public class AutoFlushEvent extends FlushEvent {
-
- private Set querySpaces;
- private boolean flushRequired;
-
- public AutoFlushEvent(Set querySpaces, EventSource source) {
- super(source);
- this.querySpaces = querySpaces;
- }
-
- public Set getQuerySpaces() {
- return querySpaces;
- }
-
- public void setQuerySpaces(Set querySpaces) {
- this.querySpaces = querySpaces;
- }
-
- public boolean isFlushRequired() {
- return flushRequired;
- }
-
- public void setFlushRequired(boolean dirty) {
- this.flushRequired = dirty;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/AutoFlushEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,59 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import java.util.Set;
+
+
+/** Defines an event class for the auto-flushing of a session.
+ *
+ * @author Steve Ebersole
+ */
+public class AutoFlushEvent extends FlushEvent {
+
+ private Set querySpaces;
+ private boolean flushRequired;
+
+ public AutoFlushEvent(Set querySpaces, EventSource source) {
+ super(source);
+ this.querySpaces = querySpaces;
+ }
+
+ public Set getQuerySpaces() {
+ return querySpaces;
+ }
+
+ public void setQuerySpaces(Set querySpaces) {
+ this.querySpaces = querySpaces;
+ }
+
+ public boolean isFlushRequired() {
+ return flushRequired;
+ }
+
+ public void setFlushRequired(boolean dirty) {
+ this.flushRequired = dirty;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: AutoFlushEventListener.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.event;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * Defines the contract for handling of session auto-flush events.
- *
- * @author Steve Ebersole
- */
-public interface AutoFlushEventListener extends Serializable {
-
- /** Handle the given auto-flush event.
- *
- * @param event The auto-flush event to be handled.
- * @throws HibernateException
- */
- public void onAutoFlush(AutoFlushEvent event) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/AutoFlushEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * Defines the contract for handling of session auto-flush events.
+ *
+ * @author Steve Ebersole
+ */
+public interface AutoFlushEventListener extends Serializable {
+
+ /** Handle the given auto-flush event.
+ *
+ * @param event The auto-flush event to be handled.
+ * @throws HibernateException
+ */
+ public void onAutoFlush(AutoFlushEvent event) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/DeleteEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,59 +0,0 @@
-//$Id: DeleteEvent.java 7450 2005-07-11 20:33:59Z steveebersole $
-package org.hibernate.event;
-
-
-/** Defines an event class for the deletion of an entity.
- *
- * @author Steve Ebersole
- */
-public class DeleteEvent extends AbstractEvent {
-
- private Object object;
- private String entityName;
- private boolean cascadeDeleteEnabled;
-
- /**
- * Constructs a new DeleteEvent instance.
- *
- * @param object The entity to be deleted.
- * @param source The session from which the delete event was generated.
- */
- public DeleteEvent(Object object, EventSource source) {
- super(source);
- if (object == null) {
- throw new IllegalArgumentException(
- "attempt to create delete event with null entity"
- );
- }
- this.object = object;
- }
-
- public DeleteEvent(String entityName, Object object, EventSource source) {
- this(object, source);
- this.entityName = entityName;
- }
-
- public DeleteEvent(String entityName, Object object, boolean isCascadeDeleteEnabled, EventSource source) {
- this(object, source);
- this.entityName = entityName;
- cascadeDeleteEnabled = isCascadeDeleteEnabled;
- }
-
- /**
- * Returns the encapsulated entity to be deleed.
- *
- * @return The entity to be deleted.
- */
- public Object getObject() {
- return object;
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public boolean isCascadeDeleteEnabled() {
- return cascadeDeleteEnabled;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/DeleteEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,82 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+
+/** Defines an event class for the deletion of an entity.
+ *
+ * @author Steve Ebersole
+ */
+public class DeleteEvent extends AbstractEvent {
+
+ private Object object;
+ private String entityName;
+ private boolean cascadeDeleteEnabled;
+
+ /**
+ * Constructs a new DeleteEvent instance.
+ *
+ * @param object The entity to be deleted.
+ * @param source The session from which the delete event was generated.
+ */
+ public DeleteEvent(Object object, EventSource source) {
+ super(source);
+ if (object == null) {
+ throw new IllegalArgumentException(
+ "attempt to create delete event with null entity"
+ );
+ }
+ this.object = object;
+ }
+
+ public DeleteEvent(String entityName, Object object, EventSource source) {
+ this(object, source);
+ this.entityName = entityName;
+ }
+
+ public DeleteEvent(String entityName, Object object, boolean isCascadeDeleteEnabled, EventSource source) {
+ this(object, source);
+ this.entityName = entityName;
+ cascadeDeleteEnabled = isCascadeDeleteEnabled;
+ }
+
+ /**
+ * Returns the encapsulated entity to be deleed.
+ *
+ * @return The entity to be deleted.
+ */
+ public Object getObject() {
+ return object;
+ }
+
+ public String getEntityName() {
+ return entityName;
+ }
+
+ public boolean isCascadeDeleteEnabled() {
+ return cascadeDeleteEnabled;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/DeleteEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,24 +0,0 @@
-//$Id: DeleteEventListener.java 9944 2006-05-24 21:14:56Z steve.ebersole(a)jboss.com $
-package org.hibernate.event;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-import java.util.Set;
-
-/**
- * Defines the contract for handling of deletion events generated from a session.
- *
- * @author Steve Ebersole
- */
-public interface DeleteEventListener extends Serializable {
-
- /** Handle the given delete event.
- *
- * @param event The delete event to be handled.
- * @throws HibernateException
- */
- public void onDelete(DeleteEvent event) throws HibernateException;
-
- public void onDelete(DeleteEvent event, Set transientEntities) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/DeleteEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DeleteEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * Defines the contract for handling of deletion events generated from a session.
+ *
+ * @author Steve Ebersole
+ */
+public interface DeleteEventListener extends Serializable {
+
+ /** Handle the given delete event.
+ *
+ * @param event The delete event to be handled.
+ * @throws HibernateException
+ */
+ public void onDelete(DeleteEvent event) throws HibernateException;
+
+ public void onDelete(DeleteEvent event, Set transientEntities) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/Destructible.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,37 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.event;
-
-/**
- * Contract for listeners which require notification of SessionFactory closing,
- * presumably to destroy internal state.
- *
- * @author Steve Ebersole
- */
-public interface Destructible {
- /**
- * Notification of {@link org.hibernate.SessionFactory} shutdown.
- */
- public void cleanup();
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/Destructible.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Destructible.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+/**
+ * Contract for listeners which require notification of SessionFactory closing,
+ * presumably to destroy internal state.
+ *
+ * @author Steve Ebersole
+ */
+public interface Destructible {
+ /**
+ * Notification of {@link org.hibernate.SessionFactory} shutdown.
+ */
+ public void cleanup();
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,25 +0,0 @@
-//$Id: DirtyCheckEvent.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.event;
-
-
-/** Defines an event class for the dirty-checking of a session.
- *
- * @author Steve Ebersole
- */
-public class DirtyCheckEvent extends FlushEvent {
-
- private boolean dirty;
-
- public DirtyCheckEvent(EventSource source) {
- super(source);
- }
-
- public boolean isDirty() {
- return dirty;
- }
-
- public void setDirty(boolean dirty) {
- this.dirty = dirty;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,48 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+
+/** Defines an event class for the dirty-checking of a session.
+ *
+ * @author Steve Ebersole
+ */
+public class DirtyCheckEvent extends FlushEvent {
+
+ private boolean dirty;
+
+ public DirtyCheckEvent(EventSource source) {
+ super(source);
+ }
+
+ public boolean isDirty() {
+ return dirty;
+ }
+
+ public void setDirty(boolean dirty) {
+ this.dirty = dirty;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-//$Id: DirtyCheckEventListener.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.event;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * Defines the contract for handling of session dirty-check events.
- *
- * @author Steve Ebersole
- */
-public interface DirtyCheckEventListener extends Serializable {
-
- /** Handle the given dirty-check event.
- *
- * @param event The dirty-check event to be handled.
- * @throws HibernateException
- */
- public void onDirtyCheck(DirtyCheckEvent event) throws HibernateException;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/DirtyCheckEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * Defines the contract for handling of session dirty-check events.
+ *
+ * @author Steve Ebersole
+ */
+public interface DirtyCheckEventListener extends Serializable {
+
+ /** Handle the given dirty-check event.
+ *
+ * @param event The dirty-check event to be handled.
+ * @throws HibernateException
+ */
+ public void onDirtyCheck(DirtyCheckEvent event) throws HibernateException;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/EventListeners.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,512 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.event;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.MappingException;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.event.def.DefaultAutoFlushEventListener;
-import org.hibernate.event.def.DefaultDeleteEventListener;
-import org.hibernate.event.def.DefaultDirtyCheckEventListener;
-import org.hibernate.event.def.DefaultEvictEventListener;
-import org.hibernate.event.def.DefaultFlushEntityEventListener;
-import org.hibernate.event.def.DefaultFlushEventListener;
-import org.hibernate.event.def.DefaultInitializeCollectionEventListener;
-import org.hibernate.event.def.DefaultLoadEventListener;
-import org.hibernate.event.def.DefaultLockEventListener;
-import org.hibernate.event.def.DefaultMergeEventListener;
-import org.hibernate.event.def.DefaultPersistEventListener;
-import org.hibernate.event.def.DefaultPostLoadEventListener;
-import org.hibernate.event.def.DefaultPreLoadEventListener;
-import org.hibernate.event.def.DefaultRefreshEventListener;
-import org.hibernate.event.def.DefaultReplicateEventListener;
-import org.hibernate.event.def.DefaultSaveEventListener;
-import org.hibernate.event.def.DefaultSaveOrUpdateCopyEventListener;
-import org.hibernate.event.def.DefaultSaveOrUpdateEventListener;
-import org.hibernate.event.def.DefaultUpdateEventListener;
-import org.hibernate.event.def.DefaultPersistOnFlushEventListener;
-import org.hibernate.util.Cloneable;
-
-/**
- * A convience holder for all defined session event listeners.
- *
- * @author Steve Ebersole
- */
-public class EventListeners extends Cloneable implements Serializable {
-
- private LoadEventListener[] loadEventListeners = { new DefaultLoadEventListener() };
- private SaveOrUpdateEventListener[] saveOrUpdateEventListeners = { new DefaultSaveOrUpdateEventListener() };
- private MergeEventListener[] mergeEventListeners = { new DefaultMergeEventListener() };
- private PersistEventListener[] persistEventListeners = { new DefaultPersistEventListener() };
- private PersistEventListener[] persistOnFlushEventListeners = { new DefaultPersistOnFlushEventListener() };
- private ReplicateEventListener[] replicateEventListeners = { new DefaultReplicateEventListener() };
- private DeleteEventListener[] deleteEventListeners = { new DefaultDeleteEventListener() };
- private AutoFlushEventListener[] autoFlushEventListeners = { new DefaultAutoFlushEventListener() };
- private DirtyCheckEventListener[] dirtyCheckEventListeners = { new DefaultDirtyCheckEventListener() };
- private FlushEventListener[] flushEventListeners = { new DefaultFlushEventListener() };
- private EvictEventListener[] evictEventListeners = { new DefaultEvictEventListener() };
- private LockEventListener[] lockEventListeners = { new DefaultLockEventListener() };
- private RefreshEventListener[] refreshEventListeners = { new DefaultRefreshEventListener() };
- private FlushEntityEventListener[] flushEntityEventListeners = { new DefaultFlushEntityEventListener() };
- private InitializeCollectionEventListener[] initializeCollectionEventListeners =
- { new DefaultInitializeCollectionEventListener() };
-
- private PostLoadEventListener[] postLoadEventListeners = { new DefaultPostLoadEventListener() };
- private PreLoadEventListener[] preLoadEventListeners = { new DefaultPreLoadEventListener() };
-
- private PreDeleteEventListener[] preDeleteEventListeners = {};
- private PreUpdateEventListener[] preUpdateEventListeners = {};
- private PreInsertEventListener[] preInsertEventListeners = {};
- private PostDeleteEventListener[] postDeleteEventListeners = {};
- private PostUpdateEventListener[] postUpdateEventListeners = {};
- private PostInsertEventListener[] postInsertEventListeners = {};
- private PostDeleteEventListener[] postCommitDeleteEventListeners = {};
- private PostUpdateEventListener[] postCommitUpdateEventListeners = {};
- private PostInsertEventListener[] postCommitInsertEventListeners = {};
-
- private PreCollectionRecreateEventListener[] preCollectionRecreateEventListeners = {};
- private PostCollectionRecreateEventListener[] postCollectionRecreateEventListeners = {};
- private PreCollectionRemoveEventListener[] preCollectionRemoveEventListeners = {};
- private PostCollectionRemoveEventListener[] postCollectionRemoveEventListeners = {};
- private PreCollectionUpdateEventListener[] preCollectionUpdateEventListeners = {};
- private PostCollectionUpdateEventListener[] postCollectionUpdateEventListeners = {};
-
- private SaveOrUpdateEventListener[] saveEventListeners = { new DefaultSaveEventListener() };
- private SaveOrUpdateEventListener[] updateEventListeners = { new DefaultUpdateEventListener() };
- private MergeEventListener[] saveOrUpdateCopyEventListeners = { new DefaultSaveOrUpdateCopyEventListener() };//saveOrUpdateCopy() is deprecated!
-
- private static Map eventInterfaceFromType;
-
- static {
- eventInterfaceFromType = new HashMap();
-
- eventInterfaceFromType.put("auto-flush", AutoFlushEventListener.class);
- eventInterfaceFromType.put("merge", MergeEventListener.class);
- eventInterfaceFromType.put("create", PersistEventListener.class);
- eventInterfaceFromType.put("create-onflush", PersistEventListener.class);
- eventInterfaceFromType.put("delete", DeleteEventListener.class);
- eventInterfaceFromType.put("dirty-check", DirtyCheckEventListener.class);
- eventInterfaceFromType.put("evict", EvictEventListener.class);
- eventInterfaceFromType.put("flush", FlushEventListener.class);
- eventInterfaceFromType.put("flush-entity", FlushEntityEventListener.class);
- eventInterfaceFromType.put("load", LoadEventListener.class);
- eventInterfaceFromType.put("load-collection", InitializeCollectionEventListener.class);
- eventInterfaceFromType.put("lock", LockEventListener.class);
- eventInterfaceFromType.put("refresh", RefreshEventListener.class);
- eventInterfaceFromType.put("replicate", ReplicateEventListener.class);
- eventInterfaceFromType.put("save-update", SaveOrUpdateEventListener.class);
- eventInterfaceFromType.put("save", SaveOrUpdateEventListener.class);
- eventInterfaceFromType.put("update", SaveOrUpdateEventListener.class);
- eventInterfaceFromType.put("pre-load", PreLoadEventListener.class);
- eventInterfaceFromType.put("pre-update", PreUpdateEventListener.class);
- eventInterfaceFromType.put("pre-delete", PreDeleteEventListener.class);
- eventInterfaceFromType.put("pre-insert", PreInsertEventListener.class);
- eventInterfaceFromType.put("pre-collection-recreate", PreCollectionRecreateEventListener.class);
- eventInterfaceFromType.put("pre-collection-remove", PreCollectionRemoveEventListener.class);
- eventInterfaceFromType.put("pre-collection-update", PreCollectionUpdateEventListener.class);
- eventInterfaceFromType.put("post-load", PostLoadEventListener.class);
- eventInterfaceFromType.put("post-update", PostUpdateEventListener.class);
- eventInterfaceFromType.put("post-delete", PostDeleteEventListener.class);
- eventInterfaceFromType.put("post-insert", PostInsertEventListener.class);
- eventInterfaceFromType.put("post-commit-update", PostUpdateEventListener.class);
- eventInterfaceFromType.put("post-commit-delete", PostDeleteEventListener.class);
- eventInterfaceFromType.put("post-commit-insert", PostInsertEventListener.class);
- eventInterfaceFromType.put("post-collection-recreate", PostCollectionRecreateEventListener.class);
- eventInterfaceFromType.put("post-collection-remove", PostCollectionRemoveEventListener.class);
- eventInterfaceFromType.put("post-collection-update", PostCollectionUpdateEventListener.class);
- eventInterfaceFromType = Collections.unmodifiableMap( eventInterfaceFromType );
- }
-
- public Class getListenerClassFor(String type) {
- Class clazz = (Class) eventInterfaceFromType.get(type);
-
- if (clazz == null) {
- throw new MappingException("Unrecognized listener type [" + type + "]");
- }
-
- return clazz;
- }
-
- private static interface ListenerProcesser {
- public void processListener(Object listener);
- }
-
- private void processListeners(ListenerProcesser processer) {
- Field[] fields = getClass().getDeclaredFields();
- for ( int i = 0; i < fields.length; i++ ) {
- final Object[] listeners;
- try {
- Object fieldValue = fields[i].get(this);
- if ( fieldValue instanceof Object[] ) {
- listeners = ( Object[] ) fieldValue;
- }
- else {
- continue;
- }
- }
- catch ( Throwable t ) {
- throw new HibernateException( "could not init listeners", t );
- }
-
- int length = listeners.length;
- for ( int index = 0 ; index < length ; index++ ) {
- processer.processListener( listeners[index ] );
- }
- }
- }
-
- /**
- * Call {@link Initializable#initialize} on any listeners that implement the
- * {@link Initializable} interface.
- *
- * @param cfg The configuration.
- */
- public void initializeListeners(final Configuration cfg) {
- try {
- processListeners(
- new ListenerProcesser() {
- public void processListener(Object listener) {
- if ( listener instanceof Initializable ) {
- ( ( Initializable ) listener ).initialize( cfg );
- }
- }
- }
- );
- }
- catch ( Exception e ) {
- throw new HibernateException("could not init listeners", e);
- }
- }
-
- /**
- * Call {@link Destructible#cleanup} on any listeners that implement the
- * {@link Destructible} interface.
- */
- public void destroyListeners() {
- try {
- processListeners(
- new ListenerProcesser() {
- public void processListener(Object listener) {
- if ( listener instanceof Destructible ) {
- ( ( Destructible ) listener ).cleanup();
- }
- }
- }
- );
- }
- catch ( Exception e ) {
- throw new HibernateException("could not destruct listeners", e);
- }
- }
-
- public LoadEventListener[] getLoadEventListeners() {
- return loadEventListeners;
- }
-
- public void setLoadEventListeners(LoadEventListener[] loadEventListener) {
- this.loadEventListeners = loadEventListener;
- }
-
- public ReplicateEventListener[] getReplicateEventListeners() {
- return replicateEventListeners;
- }
-
- public void setReplicateEventListeners(ReplicateEventListener[] replicateEventListener) {
- this.replicateEventListeners = replicateEventListener;
- }
-
- public DeleteEventListener[] getDeleteEventListeners() {
- return deleteEventListeners;
- }
-
- public void setDeleteEventListeners(DeleteEventListener[] deleteEventListener) {
- this.deleteEventListeners = deleteEventListener;
- }
-
- public AutoFlushEventListener[] getAutoFlushEventListeners() {
- return autoFlushEventListeners;
- }
-
- public void setAutoFlushEventListeners(AutoFlushEventListener[] autoFlushEventListener) {
- this.autoFlushEventListeners = autoFlushEventListener;
- }
-
- public DirtyCheckEventListener[] getDirtyCheckEventListeners() {
- return dirtyCheckEventListeners;
- }
-
- public void setDirtyCheckEventListeners(DirtyCheckEventListener[] dirtyCheckEventListener) {
- this.dirtyCheckEventListeners = dirtyCheckEventListener;
- }
-
- public FlushEventListener[] getFlushEventListeners() {
- return flushEventListeners;
- }
-
- public void setFlushEventListeners(FlushEventListener[] flushEventListener) {
- this.flushEventListeners = flushEventListener;
- }
-
- public EvictEventListener[] getEvictEventListeners() {
- return evictEventListeners;
- }
-
- public void setEvictEventListeners(EvictEventListener[] evictEventListener) {
- this.evictEventListeners = evictEventListener;
- }
-
- public LockEventListener[] getLockEventListeners() {
- return lockEventListeners;
- }
-
- public void setLockEventListeners(LockEventListener[] lockEventListener) {
- this.lockEventListeners = lockEventListener;
- }
-
- public RefreshEventListener[] getRefreshEventListeners() {
- return refreshEventListeners;
- }
-
- public void setRefreshEventListeners(RefreshEventListener[] refreshEventListener) {
- this.refreshEventListeners = refreshEventListener;
- }
-
- public InitializeCollectionEventListener[] getInitializeCollectionEventListeners() {
- return initializeCollectionEventListeners;
- }
-
- public void setInitializeCollectionEventListeners(InitializeCollectionEventListener[] initializeCollectionEventListener) {
- this.initializeCollectionEventListeners = initializeCollectionEventListener;
- }
-
- public FlushEntityEventListener[] getFlushEntityEventListeners() {
- return flushEntityEventListeners;
- }
-
- public void setFlushEntityEventListeners(FlushEntityEventListener[] flushEntityEventListener) {
- this.flushEntityEventListeners = flushEntityEventListener;
- }
-
- public SaveOrUpdateEventListener[] getSaveOrUpdateEventListeners() {
- return saveOrUpdateEventListeners;
- }
-
- public void setSaveOrUpdateEventListeners(SaveOrUpdateEventListener[] saveOrUpdateEventListener) {
- this.saveOrUpdateEventListeners = saveOrUpdateEventListener;
- }
-
- public MergeEventListener[] getMergeEventListeners() {
- return mergeEventListeners;
- }
-
- public void setMergeEventListeners(MergeEventListener[] mergeEventListener) {
- this.mergeEventListeners = mergeEventListener;
- }
-
- public PersistEventListener[] getPersistEventListeners() {
- return persistEventListeners;
- }
-
- public void setPersistEventListeners(PersistEventListener[] createEventListener) {
- this.persistEventListeners = createEventListener;
- }
-
- public PersistEventListener[] getPersistOnFlushEventListeners() {
- return persistOnFlushEventListeners;
- }
-
- public void setPersistOnFlushEventListeners(PersistEventListener[] createEventListener) {
- this.persistOnFlushEventListeners = createEventListener;
- }
-
- public MergeEventListener[] getSaveOrUpdateCopyEventListeners() {
- return saveOrUpdateCopyEventListeners;
- }
-
- public void setSaveOrUpdateCopyEventListeners(MergeEventListener[] saveOrUpdateCopyEventListener) {
- this.saveOrUpdateCopyEventListeners = saveOrUpdateCopyEventListener;
- }
-
- public SaveOrUpdateEventListener[] getSaveEventListeners() {
- return saveEventListeners;
- }
-
- public void setSaveEventListeners(SaveOrUpdateEventListener[] saveEventListener) {
- this.saveEventListeners = saveEventListener;
- }
-
- public SaveOrUpdateEventListener[] getUpdateEventListeners() {
- return updateEventListeners;
- }
-
- public void setUpdateEventListeners(SaveOrUpdateEventListener[] updateEventListener) {
- this.updateEventListeners = updateEventListener;
- }
-
- public PostLoadEventListener[] getPostLoadEventListeners() {
- return postLoadEventListeners;
- }
-
- public void setPostLoadEventListeners(PostLoadEventListener[] postLoadEventListener) {
- this.postLoadEventListeners = postLoadEventListener;
- }
-
- public PreLoadEventListener[] getPreLoadEventListeners() {
- return preLoadEventListeners;
- }
-
- public void setPreLoadEventListeners(PreLoadEventListener[] preLoadEventListener) {
- this.preLoadEventListeners = preLoadEventListener;
- }
-
- public PreCollectionRecreateEventListener[] getPreCollectionRecreateEventListeners() {
- return preCollectionRecreateEventListeners;
- }
-
- public void setPreCollectionRecreateEventListeners(PreCollectionRecreateEventListener[] preCollectionRecreateEventListener) {
- this.preCollectionRecreateEventListeners = preCollectionRecreateEventListener;
- }
-
- public PreCollectionRemoveEventListener[] getPreCollectionRemoveEventListeners() {
- return preCollectionRemoveEventListeners;
- }
-
- public void setPreCollectionRemoveEventListeners(PreCollectionRemoveEventListener[] preCollectionRemoveEventListener) {
- this.preCollectionRemoveEventListeners = preCollectionRemoveEventListener;
- }
-
- public PreCollectionUpdateEventListener[] getPreCollectionUpdateEventListeners() {
- return preCollectionUpdateEventListeners;
- }
-
- public void setPreCollectionUpdateEventListeners(PreCollectionUpdateEventListener[] preCollectionUpdateEventListeners) {
- this.preCollectionUpdateEventListeners = preCollectionUpdateEventListeners;
- }
-
- public PostDeleteEventListener[] getPostDeleteEventListeners() {
- return postDeleteEventListeners;
- }
-
- public PostInsertEventListener[] getPostInsertEventListeners() {
- return postInsertEventListeners;
- }
-
- public PostUpdateEventListener[] getPostUpdateEventListeners() {
- return postUpdateEventListeners;
- }
-
- public void setPostDeleteEventListeners(PostDeleteEventListener[] postDeleteEventListener) {
- this.postDeleteEventListeners = postDeleteEventListener;
- }
-
- public void setPostInsertEventListeners(PostInsertEventListener[] postInsertEventListener) {
- this.postInsertEventListeners = postInsertEventListener;
- }
-
- public void setPostUpdateEventListeners(PostUpdateEventListener[] postUpdateEventListener) {
- this.postUpdateEventListeners = postUpdateEventListener;
- }
-
- public PostCollectionRecreateEventListener[] getPostCollectionRecreateEventListeners() {
- return postCollectionRecreateEventListeners;
- }
-
- public void setPostCollectionRecreateEventListeners(PostCollectionRecreateEventListener[] postCollectionRecreateEventListener) {
- this.postCollectionRecreateEventListeners = postCollectionRecreateEventListener;
- }
-
- public PostCollectionRemoveEventListener[] getPostCollectionRemoveEventListeners() {
- return postCollectionRemoveEventListeners;
- }
-
- public void setPostCollectionRemoveEventListeners(PostCollectionRemoveEventListener[] postCollectionRemoveEventListener) {
- this.postCollectionRemoveEventListeners = postCollectionRemoveEventListener;
- }
-
- public PostCollectionUpdateEventListener[] getPostCollectionUpdateEventListeners() {
- return postCollectionUpdateEventListeners;
- }
-
- public void setPostCollectionUpdateEventListeners(PostCollectionUpdateEventListener[] postCollectionUpdateEventListeners) {
- this.postCollectionUpdateEventListeners = postCollectionUpdateEventListeners;
- }
-
- public PreDeleteEventListener[] getPreDeleteEventListeners() {
- return preDeleteEventListeners;
- }
-
- public void setPreDeleteEventListeners(PreDeleteEventListener[] preDeleteEventListener) {
- this.preDeleteEventListeners = preDeleteEventListener;
- }
-
- public PreInsertEventListener[] getPreInsertEventListeners() {
- return preInsertEventListeners;
- }
-
- public void setPreInsertEventListeners(PreInsertEventListener[] preInsertEventListener) {
- this.preInsertEventListeners = preInsertEventListener;
- }
-
- public PreUpdateEventListener[] getPreUpdateEventListeners() {
- return preUpdateEventListeners;
- }
-
- public void setPreUpdateEventListeners(PreUpdateEventListener[] preUpdateEventListener) {
- this.preUpdateEventListeners = preUpdateEventListener;
- }
-
- public PostDeleteEventListener[] getPostCommitDeleteEventListeners() {
- return postCommitDeleteEventListeners;
- }
-
- public void setPostCommitDeleteEventListeners(
- PostDeleteEventListener[] postCommitDeleteEventListeners) {
- this.postCommitDeleteEventListeners = postCommitDeleteEventListeners;
- }
-
- public PostInsertEventListener[] getPostCommitInsertEventListeners() {
- return postCommitInsertEventListeners;
- }
-
- public void setPostCommitInsertEventListeners(
- PostInsertEventListener[] postCommitInsertEventListeners) {
- this.postCommitInsertEventListeners = postCommitInsertEventListeners;
- }
-
- public PostUpdateEventListener[] getPostCommitUpdateEventListeners() {
- return postCommitUpdateEventListeners;
- }
-
- public void setPostCommitUpdateEventListeners(
- PostUpdateEventListener[] postCommitUpdateEventListeners) {
- this.postCommitUpdateEventListeners = postCommitUpdateEventListeners;
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/EventListeners.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventListeners.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,513 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.MappingException;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.event.def.DefaultAutoFlushEventListener;
+import org.hibernate.event.def.DefaultDeleteEventListener;
+import org.hibernate.event.def.DefaultDirtyCheckEventListener;
+import org.hibernate.event.def.DefaultEvictEventListener;
+import org.hibernate.event.def.DefaultFlushEntityEventListener;
+import org.hibernate.event.def.DefaultFlushEventListener;
+import org.hibernate.event.def.DefaultInitializeCollectionEventListener;
+import org.hibernate.event.def.DefaultLoadEventListener;
+import org.hibernate.event.def.DefaultLockEventListener;
+import org.hibernate.event.def.DefaultMergeEventListener;
+import org.hibernate.event.def.DefaultPersistEventListener;
+import org.hibernate.event.def.DefaultPostLoadEventListener;
+import org.hibernate.event.def.DefaultPreLoadEventListener;
+import org.hibernate.event.def.DefaultRefreshEventListener;
+import org.hibernate.event.def.DefaultReplicateEventListener;
+import org.hibernate.event.def.DefaultSaveEventListener;
+import org.hibernate.event.def.DefaultSaveOrUpdateCopyEventListener;
+import org.hibernate.event.def.DefaultSaveOrUpdateEventListener;
+import org.hibernate.event.def.DefaultUpdateEventListener;
+import org.hibernate.event.def.DefaultPersistOnFlushEventListener;
+import org.hibernate.util.Cloneable;
+
+/**
+ * A convience holder for all defined session event listeners.
+ *
+ * @author Steve Ebersole
+ */
+public class EventListeners extends Cloneable implements Serializable {
+
+ private LoadEventListener[] loadEventListeners = { new DefaultLoadEventListener() };
+ private SaveOrUpdateEventListener[] saveOrUpdateEventListeners = { new DefaultSaveOrUpdateEventListener() };
+ private MergeEventListener[] mergeEventListeners = { new DefaultMergeEventListener() };
+ private PersistEventListener[] persistEventListeners = { new DefaultPersistEventListener() };
+ private PersistEventListener[] persistOnFlushEventListeners = { new DefaultPersistOnFlushEventListener() };
+ private ReplicateEventListener[] replicateEventListeners = { new DefaultReplicateEventListener() };
+ private DeleteEventListener[] deleteEventListeners = { new DefaultDeleteEventListener() };
+ private AutoFlushEventListener[] autoFlushEventListeners = { new DefaultAutoFlushEventListener() };
+ private DirtyCheckEventListener[] dirtyCheckEventListeners = { new DefaultDirtyCheckEventListener() };
+ private FlushEventListener[] flushEventListeners = { new DefaultFlushEventListener() };
+ private EvictEventListener[] evictEventListeners = { new DefaultEvictEventListener() };
+ private LockEventListener[] lockEventListeners = { new DefaultLockEventListener() };
+ private RefreshEventListener[] refreshEventListeners = { new DefaultRefreshEventListener() };
+ private FlushEntityEventListener[] flushEntityEventListeners = { new DefaultFlushEntityEventListener() };
+ private InitializeCollectionEventListener[] initializeCollectionEventListeners =
+ { new DefaultInitializeCollectionEventListener() };
+
+ private PostLoadEventListener[] postLoadEventListeners = { new DefaultPostLoadEventListener() };
+ private PreLoadEventListener[] preLoadEventListeners = { new DefaultPreLoadEventListener() };
+
+ private PreDeleteEventListener[] preDeleteEventListeners = {};
+ private PreUpdateEventListener[] preUpdateEventListeners = {};
+ private PreInsertEventListener[] preInsertEventListeners = {};
+ private PostDeleteEventListener[] postDeleteEventListeners = {};
+ private PostUpdateEventListener[] postUpdateEventListeners = {};
+ private PostInsertEventListener[] postInsertEventListeners = {};
+ private PostDeleteEventListener[] postCommitDeleteEventListeners = {};
+ private PostUpdateEventListener[] postCommitUpdateEventListeners = {};
+ private PostInsertEventListener[] postCommitInsertEventListeners = {};
+
+ private PreCollectionRecreateEventListener[] preCollectionRecreateEventListeners = {};
+ private PostCollectionRecreateEventListener[] postCollectionRecreateEventListeners = {};
+ private PreCollectionRemoveEventListener[] preCollectionRemoveEventListeners = {};
+ private PostCollectionRemoveEventListener[] postCollectionRemoveEventListeners = {};
+ private PreCollectionUpdateEventListener[] preCollectionUpdateEventListeners = {};
+ private PostCollectionUpdateEventListener[] postCollectionUpdateEventListeners = {};
+
+ private SaveOrUpdateEventListener[] saveEventListeners = { new DefaultSaveEventListener() };
+ private SaveOrUpdateEventListener[] updateEventListeners = { new DefaultUpdateEventListener() };
+ private MergeEventListener[] saveOrUpdateCopyEventListeners = { new DefaultSaveOrUpdateCopyEventListener() };//saveOrUpdateCopy() is deprecated!
+
+ private static Map eventInterfaceFromType;
+
+ static {
+ eventInterfaceFromType = new HashMap();
+
+ eventInterfaceFromType.put("auto-flush", AutoFlushEventListener.class);
+ eventInterfaceFromType.put("merge", MergeEventListener.class);
+ eventInterfaceFromType.put("create", PersistEventListener.class);
+ eventInterfaceFromType.put("create-onflush", PersistEventListener.class);
+ eventInterfaceFromType.put("delete", DeleteEventListener.class);
+ eventInterfaceFromType.put("dirty-check", DirtyCheckEventListener.class);
+ eventInterfaceFromType.put("evict", EvictEventListener.class);
+ eventInterfaceFromType.put("flush", FlushEventListener.class);
+ eventInterfaceFromType.put("flush-entity", FlushEntityEventListener.class);
+ eventInterfaceFromType.put("load", LoadEventListener.class);
+ eventInterfaceFromType.put("load-collection", InitializeCollectionEventListener.class);
+ eventInterfaceFromType.put("lock", LockEventListener.class);
+ eventInterfaceFromType.put("refresh", RefreshEventListener.class);
+ eventInterfaceFromType.put("replicate", ReplicateEventListener.class);
+ eventInterfaceFromType.put("save-update", SaveOrUpdateEventListener.class);
+ eventInterfaceFromType.put("save", SaveOrUpdateEventListener.class);
+ eventInterfaceFromType.put("update", SaveOrUpdateEventListener.class);
+ eventInterfaceFromType.put("pre-load", PreLoadEventListener.class);
+ eventInterfaceFromType.put("pre-update", PreUpdateEventListener.class);
+ eventInterfaceFromType.put("pre-delete", PreDeleteEventListener.class);
+ eventInterfaceFromType.put("pre-insert", PreInsertEventListener.class);
+ eventInterfaceFromType.put("pre-collection-recreate", PreCollectionRecreateEventListener.class);
+ eventInterfaceFromType.put("pre-collection-remove", PreCollectionRemoveEventListener.class);
+ eventInterfaceFromType.put("pre-collection-update", PreCollectionUpdateEventListener.class);
+ eventInterfaceFromType.put("post-load", PostLoadEventListener.class);
+ eventInterfaceFromType.put("post-update", PostUpdateEventListener.class);
+ eventInterfaceFromType.put("post-delete", PostDeleteEventListener.class);
+ eventInterfaceFromType.put("post-insert", PostInsertEventListener.class);
+ eventInterfaceFromType.put("post-commit-update", PostUpdateEventListener.class);
+ eventInterfaceFromType.put("post-commit-delete", PostDeleteEventListener.class);
+ eventInterfaceFromType.put("post-commit-insert", PostInsertEventListener.class);
+ eventInterfaceFromType.put("post-collection-recreate", PostCollectionRecreateEventListener.class);
+ eventInterfaceFromType.put("post-collection-remove", PostCollectionRemoveEventListener.class);
+ eventInterfaceFromType.put("post-collection-update", PostCollectionUpdateEventListener.class);
+ eventInterfaceFromType = Collections.unmodifiableMap( eventInterfaceFromType );
+ }
+
+ public Class getListenerClassFor(String type) {
+ Class clazz = (Class) eventInterfaceFromType.get(type);
+
+ if (clazz == null) {
+ throw new MappingException("Unrecognized listener type [" + type + "]");
+ }
+
+ return clazz;
+ }
+
+ private static interface ListenerProcesser {
+ public void processListener(Object listener);
+ }
+
+ private void processListeners(ListenerProcesser processer) {
+ Field[] fields = getClass().getDeclaredFields();
+ for ( int i = 0; i < fields.length; i++ ) {
+ final Object[] listeners;
+ try {
+ Object fieldValue = fields[i].get(this);
+ if ( fieldValue instanceof Object[] ) {
+ listeners = ( Object[] ) fieldValue;
+ }
+ else {
+ continue;
+ }
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "could not init listeners", t );
+ }
+
+ int length = listeners.length;
+ for ( int index = 0 ; index < length ; index++ ) {
+ processer.processListener( listeners[index ] );
+ }
+ }
+ }
+
+ /**
+ * Call {@link Initializable#initialize} on any listeners that implement the
+ * {@link Initializable} interface.
+ *
+ * @param cfg The configuration.
+ */
+ public void initializeListeners(final Configuration cfg) {
+ try {
+ processListeners(
+ new ListenerProcesser() {
+ public void processListener(Object listener) {
+ if ( listener instanceof Initializable ) {
+ ( ( Initializable ) listener ).initialize( cfg );
+ }
+ }
+ }
+ );
+ }
+ catch ( Exception e ) {
+ throw new HibernateException("could not init listeners", e);
+ }
+ }
+
+ /**
+ * Call {@link Destructible#cleanup} on any listeners that implement the
+ * {@link Destructible} interface.
+ */
+ public void destroyListeners() {
+ try {
+ processListeners(
+ new ListenerProcesser() {
+ public void processListener(Object listener) {
+ if ( listener instanceof Destructible ) {
+ ( ( Destructible ) listener ).cleanup();
+ }
+ }
+ }
+ );
+ }
+ catch ( Exception e ) {
+ throw new HibernateException("could not destruct listeners", e);
+ }
+ }
+
+ public LoadEventListener[] getLoadEventListeners() {
+ return loadEventListeners;
+ }
+
+ public void setLoadEventListeners(LoadEventListener[] loadEventListener) {
+ this.loadEventListeners = loadEventListener;
+ }
+
+ public ReplicateEventListener[] getReplicateEventListeners() {
+ return replicateEventListeners;
+ }
+
+ public void setReplicateEventListeners(ReplicateEventListener[] replicateEventListener) {
+ this.replicateEventListeners = replicateEventListener;
+ }
+
+ public DeleteEventListener[] getDeleteEventListeners() {
+ return deleteEventListeners;
+ }
+
+ public void setDeleteEventListeners(DeleteEventListener[] deleteEventListener) {
+ this.deleteEventListeners = deleteEventListener;
+ }
+
+ public AutoFlushEventListener[] getAutoFlushEventListeners() {
+ return autoFlushEventListeners;
+ }
+
+ public void setAutoFlushEventListeners(AutoFlushEventListener[] autoFlushEventListener) {
+ this.autoFlushEventListeners = autoFlushEventListener;
+ }
+
+ public DirtyCheckEventListener[] getDirtyCheckEventListeners() {
+ return dirtyCheckEventListeners;
+ }
+
+ public void setDirtyCheckEventListeners(DirtyCheckEventListener[] dirtyCheckEventListener) {
+ this.dirtyCheckEventListeners = dirtyCheckEventListener;
+ }
+
+ public FlushEventListener[] getFlushEventListeners() {
+ return flushEventListeners;
+ }
+
+ public void setFlushEventListeners(FlushEventListener[] flushEventListener) {
+ this.flushEventListeners = flushEventListener;
+ }
+
+ public EvictEventListener[] getEvictEventListeners() {
+ return evictEventListeners;
+ }
+
+ public void setEvictEventListeners(EvictEventListener[] evictEventListener) {
+ this.evictEventListeners = evictEventListener;
+ }
+
+ public LockEventListener[] getLockEventListeners() {
+ return lockEventListeners;
+ }
+
+ public void setLockEventListeners(LockEventListener[] lockEventListener) {
+ this.lockEventListeners = lockEventListener;
+ }
+
+ public RefreshEventListener[] getRefreshEventListeners() {
+ return refreshEventListeners;
+ }
+
+ public void setRefreshEventListeners(RefreshEventListener[] refreshEventListener) {
+ this.refreshEventListeners = refreshEventListener;
+ }
+
+ public InitializeCollectionEventListener[] getInitializeCollectionEventListeners() {
+ return initializeCollectionEventListeners;
+ }
+
+ public void setInitializeCollectionEventListeners(InitializeCollectionEventListener[] initializeCollectionEventListener) {
+ this.initializeCollectionEventListeners = initializeCollectionEventListener;
+ }
+
+ public FlushEntityEventListener[] getFlushEntityEventListeners() {
+ return flushEntityEventListeners;
+ }
+
+ public void setFlushEntityEventListeners(FlushEntityEventListener[] flushEntityEventListener) {
+ this.flushEntityEventListeners = flushEntityEventListener;
+ }
+
+ public SaveOrUpdateEventListener[] getSaveOrUpdateEventListeners() {
+ return saveOrUpdateEventListeners;
+ }
+
+ public void setSaveOrUpdateEventListeners(SaveOrUpdateEventListener[] saveOrUpdateEventListener) {
+ this.saveOrUpdateEventListeners = saveOrUpdateEventListener;
+ }
+
+ public MergeEventListener[] getMergeEventListeners() {
+ return mergeEventListeners;
+ }
+
+ public void setMergeEventListeners(MergeEventListener[] mergeEventListener) {
+ this.mergeEventListeners = mergeEventListener;
+ }
+
+ public PersistEventListener[] getPersistEventListeners() {
+ return persistEventListeners;
+ }
+
+ public void setPersistEventListeners(PersistEventListener[] createEventListener) {
+ this.persistEventListeners = createEventListener;
+ }
+
+ public PersistEventListener[] getPersistOnFlushEventListeners() {
+ return persistOnFlushEventListeners;
+ }
+
+ public void setPersistOnFlushEventListeners(PersistEventListener[] createEventListener) {
+ this.persistOnFlushEventListeners = createEventListener;
+ }
+
+ public MergeEventListener[] getSaveOrUpdateCopyEventListeners() {
+ return saveOrUpdateCopyEventListeners;
+ }
+
+ public void setSaveOrUpdateCopyEventListeners(MergeEventListener[] saveOrUpdateCopyEventListener) {
+ this.saveOrUpdateCopyEventListeners = saveOrUpdateCopyEventListener;
+ }
+
+ public SaveOrUpdateEventListener[] getSaveEventListeners() {
+ return saveEventListeners;
+ }
+
+ public void setSaveEventListeners(SaveOrUpdateEventListener[] saveEventListener) {
+ this.saveEventListeners = saveEventListener;
+ }
+
+ public SaveOrUpdateEventListener[] getUpdateEventListeners() {
+ return updateEventListeners;
+ }
+
+ public void setUpdateEventListeners(SaveOrUpdateEventListener[] updateEventListener) {
+ this.updateEventListeners = updateEventListener;
+ }
+
+ public PostLoadEventListener[] getPostLoadEventListeners() {
+ return postLoadEventListeners;
+ }
+
+ public void setPostLoadEventListeners(PostLoadEventListener[] postLoadEventListener) {
+ this.postLoadEventListeners = postLoadEventListener;
+ }
+
+ public PreLoadEventListener[] getPreLoadEventListeners() {
+ return preLoadEventListeners;
+ }
+
+ public void setPreLoadEventListeners(PreLoadEventListener[] preLoadEventListener) {
+ this.preLoadEventListeners = preLoadEventListener;
+ }
+
+ public PreCollectionRecreateEventListener[] getPreCollectionRecreateEventListeners() {
+ return preCollectionRecreateEventListeners;
+ }
+
+ public void setPreCollectionRecreateEventListeners(PreCollectionRecreateEventListener[] preCollectionRecreateEventListener) {
+ this.preCollectionRecreateEventListeners = preCollectionRecreateEventListener;
+ }
+
+ public PreCollectionRemoveEventListener[] getPreCollectionRemoveEventListeners() {
+ return preCollectionRemoveEventListeners;
+ }
+
+ public void setPreCollectionRemoveEventListeners(PreCollectionRemoveEventListener[] preCollectionRemoveEventListener) {
+ this.preCollectionRemoveEventListeners = preCollectionRemoveEventListener;
+ }
+
+ public PreCollectionUpdateEventListener[] getPreCollectionUpdateEventListeners() {
+ return preCollectionUpdateEventListeners;
+ }
+
+ public void setPreCollectionUpdateEventListeners(PreCollectionUpdateEventListener[] preCollectionUpdateEventListeners) {
+ this.preCollectionUpdateEventListeners = preCollectionUpdateEventListeners;
+ }
+
+ public PostDeleteEventListener[] getPostDeleteEventListeners() {
+ return postDeleteEventListeners;
+ }
+
+ public PostInsertEventListener[] getPostInsertEventListeners() {
+ return postInsertEventListeners;
+ }
+
+ public PostUpdateEventListener[] getPostUpdateEventListeners() {
+ return postUpdateEventListeners;
+ }
+
+ public void setPostDeleteEventListeners(PostDeleteEventListener[] postDeleteEventListener) {
+ this.postDeleteEventListeners = postDeleteEventListener;
+ }
+
+ public void setPostInsertEventListeners(PostInsertEventListener[] postInsertEventListener) {
+ this.postInsertEventListeners = postInsertEventListener;
+ }
+
+ public void setPostUpdateEventListeners(PostUpdateEventListener[] postUpdateEventListener) {
+ this.postUpdateEventListeners = postUpdateEventListener;
+ }
+
+ public PostCollectionRecreateEventListener[] getPostCollectionRecreateEventListeners() {
+ return postCollectionRecreateEventListeners;
+ }
+
+ public void setPostCollectionRecreateEventListeners(PostCollectionRecreateEventListener[] postCollectionRecreateEventListener) {
+ this.postCollectionRecreateEventListeners = postCollectionRecreateEventListener;
+ }
+
+ public PostCollectionRemoveEventListener[] getPostCollectionRemoveEventListeners() {
+ return postCollectionRemoveEventListeners;
+ }
+
+ public void setPostCollectionRemoveEventListeners(PostCollectionRemoveEventListener[] postCollectionRemoveEventListener) {
+ this.postCollectionRemoveEventListeners = postCollectionRemoveEventListener;
+ }
+
+ public PostCollectionUpdateEventListener[] getPostCollectionUpdateEventListeners() {
+ return postCollectionUpdateEventListeners;
+ }
+
+ public void setPostCollectionUpdateEventListeners(PostCollectionUpdateEventListener[] postCollectionUpdateEventListeners) {
+ this.postCollectionUpdateEventListeners = postCollectionUpdateEventListeners;
+ }
+
+ public PreDeleteEventListener[] getPreDeleteEventListeners() {
+ return preDeleteEventListeners;
+ }
+
+ public void setPreDeleteEventListeners(PreDeleteEventListener[] preDeleteEventListener) {
+ this.preDeleteEventListeners = preDeleteEventListener;
+ }
+
+ public PreInsertEventListener[] getPreInsertEventListeners() {
+ return preInsertEventListeners;
+ }
+
+ public void setPreInsertEventListeners(PreInsertEventListener[] preInsertEventListener) {
+ this.preInsertEventListeners = preInsertEventListener;
+ }
+
+ public PreUpdateEventListener[] getPreUpdateEventListeners() {
+ return preUpdateEventListeners;
+ }
+
+ public void setPreUpdateEventListeners(PreUpdateEventListener[] preUpdateEventListener) {
+ this.preUpdateEventListeners = preUpdateEventListener;
+ }
+
+ public PostDeleteEventListener[] getPostCommitDeleteEventListeners() {
+ return postCommitDeleteEventListeners;
+ }
+
+ public void setPostCommitDeleteEventListeners(
+ PostDeleteEventListener[] postCommitDeleteEventListeners) {
+ this.postCommitDeleteEventListeners = postCommitDeleteEventListeners;
+ }
+
+ public PostInsertEventListener[] getPostCommitInsertEventListeners() {
+ return postCommitInsertEventListeners;
+ }
+
+ public void setPostCommitInsertEventListeners(
+ PostInsertEventListener[] postCommitInsertEventListeners) {
+ this.postCommitInsertEventListeners = postCommitInsertEventListeners;
+ }
+
+ public PostUpdateEventListener[] getPostCommitUpdateEventListeners() {
+ return postCommitUpdateEventListeners;
+ }
+
+ public void setPostCommitUpdateEventListeners(
+ PostUpdateEventListener[] postCommitUpdateEventListeners) {
+ this.postCommitUpdateEventListeners = postCommitUpdateEventListeners;
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/EventSource.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,63 +0,0 @@
-//$Id: EventSource.java 9944 2006-05-24 21:14:56Z steve.ebersole(a)jboss.com $
-package org.hibernate.event;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.engine.ActionQueue;
-import org.hibernate.engine.EntityEntry;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.entity.EntityPersister;
-
-/**
- * @author Gavin King
- */
-public interface EventSource extends SessionImplementor, Session {
-
- /**
- * Get the ActionQueue for this session
- */
- public ActionQueue getActionQueue();
-
- /**
- * Instantiate an entity instance, using either an interceptor,
- * or the given persister
- */
- public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException;
-
- /**
- * Force an immediate flush
- */
- public void forceFlush(EntityEntry e) throws HibernateException;
-
- /**
- * Cascade merge an entity instance
- */
- public void merge(String entityName, Object object, Map copiedAlready) throws HibernateException;
- /**
- * Cascade persist an entity instance
- */
- public void persist(String entityName, Object object, Map createdAlready) throws HibernateException;
-
- /**
- * Cascade persist an entity instance during the flush process
- */
- public void persistOnFlush(String entityName, Object object, Map copiedAlready);
- /**
- * Cascade refesh an entity instance
- */
- public void refresh(Object object, Map refreshedAlready) throws HibernateException;
- /**
- * Cascade copy an entity instance
- */
- public void saveOrUpdateCopy(String entityName, Object object, Map copiedAlready) throws HibernateException;
-
- /**
- * Cascade delete an entity instance
- */
- public void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, Set transientEntities);
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/EventSource.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EventSource.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,86 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.engine.ActionQueue;
+import org.hibernate.engine.EntityEntry;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * @author Gavin King
+ */
+public interface EventSource extends SessionImplementor, Session {
+
+ /**
+ * Get the ActionQueue for this session
+ */
+ public ActionQueue getActionQueue();
+
+ /**
+ * Instantiate an entity instance, using either an interceptor,
+ * or the given persister
+ */
+ public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException;
+
+ /**
+ * Force an immediate flush
+ */
+ public void forceFlush(EntityEntry e) throws HibernateException;
+
+ /**
+ * Cascade merge an entity instance
+ */
+ public void merge(String entityName, Object object, Map copiedAlready) throws HibernateException;
+ /**
+ * Cascade persist an entity instance
+ */
+ public void persist(String entityName, Object object, Map createdAlready) throws HibernateException;
+
+ /**
+ * Cascade persist an entity instance during the flush process
+ */
+ public void persistOnFlush(String entityName, Object object, Map copiedAlready);
+ /**
+ * Cascade refesh an entity instance
+ */
+ public void refresh(Object object, Map refreshedAlready) throws HibernateException;
+ /**
+ * Cascade copy an entity instance
+ */
+ public void saveOrUpdateCopy(String entityName, Object object, Map copiedAlready) throws HibernateException;
+
+ /**
+ * Cascade delete an entity instance
+ */
+ public void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, Set transientEntities);
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/EvictEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,26 +0,0 @@
-//$Id: EvictEvent.java 6929 2005-05-27 03:54:08Z oneovthafew $
-package org.hibernate.event;
-
-
-/**
- * Defines an event class for the evicting of an entity.
- *
- * @author Steve Ebersole
- */
-public class EvictEvent extends AbstractEvent {
-
- private Object object;
-
- public EvictEvent(Object object, EventSource source) {
- super(source);
- this.object = object;
- }
-
- public Object getObject() {
- return object;
- }
-
- public void setObject(Object object) {
- this.object = object;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/EvictEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+
+/**
+ * Defines an event class for the evicting of an entity.
+ *
+ * @author Steve Ebersole
+ */
+public class EvictEvent extends AbstractEvent {
+
+ private Object object;
+
+ public EvictEvent(Object object, EventSource source) {
+ super(source);
+ this.object = object;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+
+ public void setObject(Object object) {
+ this.object = object;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/EvictEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,22 +0,0 @@
-//$Id: EvictEventListener.java 4533 2004-09-12 03:02:54Z oneovthafew $
-package org.hibernate.event;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * Defines the contract for handling of evict events generated from a session.
- *
- * @author Steve Ebersole
- */
-public interface EvictEventListener extends Serializable {
-
- /**
- * Handle the given evict event.
- *
- * @param event The evict event to be handled.
- * @throws HibernateException
- */
- public void onEvict(EvictEvent event) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/EvictEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/EvictEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * Defines the contract for handling of evict events generated from a session.
+ *
+ * @author Steve Ebersole
+ */
+public interface EvictEventListener extends Serializable {
+
+ /**
+ * Handle the given evict event.
+ *
+ * @param event The evict event to be handled.
+ * @throws HibernateException
+ */
+ public void onEvict(EvictEvent event) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/FlushEntityEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,71 +0,0 @@
-//$Id: FlushEntityEvent.java 6929 2005-05-27 03:54:08Z oneovthafew $
-package org.hibernate.event;
-
-import org.hibernate.engine.EntityEntry;
-
-/**
- * @author Gavin King
- */
-public class FlushEntityEvent extends AbstractEvent {
-
- private Object entity;
- private Object[] propertyValues;
- private Object[] databaseSnapshot;
- private int[] dirtyProperties;
- private boolean hasDirtyCollection;
- private boolean dirtyCheckPossible;
- private boolean dirtyCheckHandledByInterceptor;
- private EntityEntry entityEntry;
-
- public FlushEntityEvent(EventSource source, Object entity, EntityEntry entry) {
- super(source);
- this.entity = entity;
- this.entityEntry = entry;
- }
-
- public EntityEntry getEntityEntry() {
- return entityEntry;
- }
- public Object[] getDatabaseSnapshot() {
- return databaseSnapshot;
- }
- public void setDatabaseSnapshot(Object[] databaseSnapshot) {
- this.databaseSnapshot = databaseSnapshot;
- }
- public boolean hasDatabaseSnapshot() {
- return databaseSnapshot!=null;
- }
- public boolean isDirtyCheckHandledByInterceptor() {
- return dirtyCheckHandledByInterceptor;
- }
- public void setDirtyCheckHandledByInterceptor(boolean dirtyCheckHandledByInterceptor) {
- this.dirtyCheckHandledByInterceptor = dirtyCheckHandledByInterceptor;
- }
- public boolean isDirtyCheckPossible() {
- return dirtyCheckPossible;
- }
- public void setDirtyCheckPossible(boolean dirtyCheckPossible) {
- this.dirtyCheckPossible = dirtyCheckPossible;
- }
- public int[] getDirtyProperties() {
- return dirtyProperties;
- }
- public void setDirtyProperties(int[] dirtyProperties) {
- this.dirtyProperties = dirtyProperties;
- }
- public boolean hasDirtyCollection() {
- return hasDirtyCollection;
- }
- public void setHasDirtyCollection(boolean hasDirtyCollection) {
- this.hasDirtyCollection = hasDirtyCollection;
- }
- public Object[] getPropertyValues() {
- return propertyValues;
- }
- public void setPropertyValues(Object[] propertyValues) {
- this.propertyValues = propertyValues;
- }
- public Object getEntity() {
- return entity;
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/FlushEntityEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,94 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.engine.EntityEntry;
+
+/**
+ * @author Gavin King
+ */
+public class FlushEntityEvent extends AbstractEvent {
+
+ private Object entity;
+ private Object[] propertyValues;
+ private Object[] databaseSnapshot;
+ private int[] dirtyProperties;
+ private boolean hasDirtyCollection;
+ private boolean dirtyCheckPossible;
+ private boolean dirtyCheckHandledByInterceptor;
+ private EntityEntry entityEntry;
+
+ public FlushEntityEvent(EventSource source, Object entity, EntityEntry entry) {
+ super(source);
+ this.entity = entity;
+ this.entityEntry = entry;
+ }
+
+ public EntityEntry getEntityEntry() {
+ return entityEntry;
+ }
+ public Object[] getDatabaseSnapshot() {
+ return databaseSnapshot;
+ }
+ public void setDatabaseSnapshot(Object[] databaseSnapshot) {
+ this.databaseSnapshot = databaseSnapshot;
+ }
+ public boolean hasDatabaseSnapshot() {
+ return databaseSnapshot!=null;
+ }
+ public boolean isDirtyCheckHandledByInterceptor() {
+ return dirtyCheckHandledByInterceptor;
+ }
+ public void setDirtyCheckHandledByInterceptor(boolean dirtyCheckHandledByInterceptor) {
+ this.dirtyCheckHandledByInterceptor = dirtyCheckHandledByInterceptor;
+ }
+ public boolean isDirtyCheckPossible() {
+ return dirtyCheckPossible;
+ }
+ public void setDirtyCheckPossible(boolean dirtyCheckPossible) {
+ this.dirtyCheckPossible = dirtyCheckPossible;
+ }
+ public int[] getDirtyProperties() {
+ return dirtyProperties;
+ }
+ public void setDirtyProperties(int[] dirtyProperties) {
+ this.dirtyProperties = dirtyProperties;
+ }
+ public boolean hasDirtyCollection() {
+ return hasDirtyCollection;
+ }
+ public void setHasDirtyCollection(boolean hasDirtyCollection) {
+ this.hasDirtyCollection = hasDirtyCollection;
+ }
+ public Object[] getPropertyValues() {
+ return propertyValues;
+ }
+ public void setPropertyValues(Object[] propertyValues) {
+ this.propertyValues = propertyValues;
+ }
+ public Object getEntity() {
+ return entity;
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,13 +0,0 @@
-//$Id: FlushEntityEventListener.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.event;
-
-import java.io.Serializable;
-
-import org.hibernate.HibernateException;
-
-/**
- * @author Gavin King
- */
-public interface FlushEntityEventListener extends Serializable {
- public void onFlushEntity(FlushEntityEvent event) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEntityEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import java.io.Serializable;
+
+import org.hibernate.HibernateException;
+
+/**
+ * @author Gavin King
+ */
+public interface FlushEntityEventListener extends Serializable {
+ public void onFlushEntity(FlushEntityEvent event) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/FlushEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,16 +0,0 @@
-//$Id: FlushEvent.java 6929 2005-05-27 03:54:08Z oneovthafew $
-package org.hibernate.event;
-
-
-/**
- * Defines an event class for the flushing of a session.
- *
- * @author Steve Ebersole
- */
-public class FlushEvent extends AbstractEvent {
-
- public FlushEvent(EventSource source) {
- super(source);
- }
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/FlushEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,39 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+
+/**
+ * Defines an event class for the flushing of a session.
+ *
+ * @author Steve Ebersole
+ */
+public class FlushEvent extends AbstractEvent {
+
+ public FlushEvent(EventSource source) {
+ super(source);
+ }
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/FlushEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: FlushEventListener.java 4185 2004-08-08 11:24:56Z oneovthafew $
-package org.hibernate.event;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * Defines the contract for handling of session flush events.
- *
- * @author Steve Ebersole
- */
-public interface FlushEventListener extends Serializable {
-
- /** Handle the given flush event.
- *
- * @param event The flush event to be handled.
- * @throws HibernateException
- */
- public void onFlush(FlushEvent event) throws HibernateException;
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/FlushEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/FlushEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * Defines the contract for handling of session flush events.
+ *
+ * @author Steve Ebersole
+ */
+public interface FlushEventListener extends Serializable {
+
+ /** Handle the given flush event.
+ *
+ * @param event The flush event to be handled.
+ * @throws HibernateException
+ */
+ public void onFlush(FlushEvent event) throws HibernateException;
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/Initializable.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,36 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.event;
-
-import org.hibernate.cfg.Configuration;
-
-/**
- * An event listener that requires access to mappings to initialize state at
- * initialization time.
- *
- * @author Gavin King
- */
-public interface Initializable {
- public void initialize(Configuration cfg);
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/Initializable.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/Initializable.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,37 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.cfg.Configuration;
+
+/**
+ * An event listener that requires access to mappings to initialize state at
+ * initialization time.
+ *
+ * @author Gavin King
+ */
+public interface Initializable {
+ public void initialize(Configuration cfg);
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,21 +0,0 @@
-//$Id: InitializeCollectionEvent.java 14313 2008-02-06 07:46:52Z gbadner $
-package org.hibernate.event;
-
-import org.hibernate.collection.PersistentCollection;
-
-/**
- * An event that occurs when a collection wants to be
- * initialized
- *
- * @author Gavin King
- */
-public class InitializeCollectionEvent extends AbstractCollectionEvent {
-
- public InitializeCollectionEvent(PersistentCollection collection, EventSource source ) {
- super( getLoadedCollectionPersister( collection, source ),
- collection,
- source,
- getLoadedOwnerOrNull( collection, source ),
- getLoadedOwnerIdOrNull( collection, source ) );
- }
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,44 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.collection.PersistentCollection;
+
+/**
+ * An event that occurs when a collection wants to be
+ * initialized
+ *
+ * @author Gavin King
+ */
+public class InitializeCollectionEvent extends AbstractCollectionEvent {
+
+ public InitializeCollectionEvent(PersistentCollection collection, EventSource source ) {
+ super( getLoadedCollectionPersister( collection, source ),
+ collection,
+ source,
+ getLoadedOwnerOrNull( collection, source ),
+ getLoadedOwnerIdOrNull( collection, source ) );
+ }
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,18 +0,0 @@
-//$Id: InitializeCollectionEventListener.java 4345 2004-08-16 12:12:12Z oneovthafew $
-package org.hibernate.event;
-
-import org.hibernate.HibernateException;
-
-import java.io.Serializable;
-
-/**
- * Defines the contract for handling of collection initialization events
- * generated by a session.
- *
- * @author Gavin King
- */
-public interface InitializeCollectionEventListener extends Serializable {
-
- public void onInitializeCollection(InitializeCollectionEvent event) throws HibernateException;
-
-}
Copied: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java (from rev 14993, core/trunk/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java)
===================================================================
--- core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java (rev 0)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/InitializeCollectionEventListener.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate.event;
+
+import org.hibernate.HibernateException;
+
+import java.io.Serializable;
+
+/**
+ * Defines the contract for handling of collection initialization events
+ * generated by a session.
+ *
+ * @author Gavin King
+ */
+public interface InitializeCollectionEventListener extends Serializable {
+
+ public void onInitializeCollection(InitializeCollectionEvent event) throws HibernateException;
+
+}
Deleted: core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LoadEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java 2008-07-29 18:50:51 UTC (rev 14992)
+++ core/tags/hibernate-3.3.0.CR2/core/src/main/java/org/hibernate/event/LoadEvent.java 2008-07-31 20:03:48 UTC (rev 15004)
@@ -1,107 +0,0 @@
-//$Id: LoadEvent.java 7785 2005-08-08 23:24:44Z oneovthafew $
-package org.hibernate.event;
-
-import java.io.Serializable;
-
-import org.hibernate.LockMode;
-
-/**
- * Defines an event class for the loading of an entity.
- *
- * @author Steve Ebersole
- */
-public class LoadEvent extends AbstractEvent {
-
- public static final LockMode DEFAULT_LOCK_MODE = LockMode.NONE;
-
- private Serializable entityId;
- private String entityClassName;
- private Object instanceToLoad;
- private LockMode lockMode;
- private boolean isAssociationFetch;
- private Object result;
-
- public LoadEvent(Serializable entityId, Object instanceToLoad, EventSource source) {
- this(entityId, null, instanceToLoad, null, false, source);
- }
-
- public LoadEvent(Serializable entityId, String entityClassName, LockMode lockMode, EventSource source) {
- this(entityId, entityClassName, null, lockMode, false, source);
- }
-
- public LoadEvent(Serializable entityId, String entityClassName, boolean isAssociationFetch, EventSource source) {
- this(entityId, entityClassName, null, null, isAssociationFetch, source);
- }
-
- public boolean isAssociationFetch() {
- return isAssociationFetch;
- }
-
- private LoadEvent(
- Serializable entityId,
- String entityClassName,
- Object instanceToLoad,
- LockMode lockMode,
- boolean isAssociationFetch,
- EventSource source) {
-
- super(source);
-
- if ( entityId == null ) {
- throw new IllegalArgumentException("id to load is required for loading");
- }
-
- if ( lockMode == LockMode.WRITE ) {
- throw new IllegalArgumentException("Invalid lock mode for loading");
- }
- else if ( lockMode == null ) {
- lockMode = DEFAULT_LOCK_MODE;
- }
-
- this.entityId = entityId;
- this.entityClassName = entityClassName;
- this.insta