Skip to content
Browse files

HHH-6297 remove legacy cache api

  • Loading branch information...
1 parent ad180ff commit 92ad3eed8080c63eb206665953cd050ba32373d5 @stliu stliu committed
Showing with 1,934 additions and 3,966 deletions.
  1. +29 −7 documentation/src/main/docbook/manual/en-US/content/performance.xml
  2. +5 −7 etc/hibernate.properties
  3. +487 −488 etc/hibernate.properties.template
  4. +12 −14 hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java
  5. +0 −114 hibernate-core/src/main/java/org/hibernate/cache/internal/HashtableCache.java
  6. +0 −86 hibernate-core/src/main/java/org/hibernate/cache/internal/NoCacheProvider.java
  7. +14 −15 hibernate-core/src/main/java/org/hibernate/cache/internal/Timestamper.java
  8. +0 −114 ...rnate-core/src/main/java/org/hibernate/cache/internal/bridge/CollectionAccessStrategyAdapter.java
  9. +0 −81 hibernate-core/src/main/java/org/hibernate/cache/internal/bridge/CollectionRegionAdapter.java
  10. +0 −132 hibernate-core/src/main/java/org/hibernate/cache/internal/bridge/EntityAccessStrategyAdapter.java
  11. +0 −80 hibernate-core/src/main/java/org/hibernate/cache/internal/bridge/EntityRegionAdapter.java
  12. +0 −125 ...nate-core/src/main/java/org/hibernate/cache/internal/bridge/RegionFactoryCacheProviderBridge.java
  13. +0 −39 hibernate-core/src/main/java/org/hibernate/cache/internal/bridge/TimestampsRegionAdapter.java
  14. +0 −111 hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractJndiBoundCacheProvider.java
  15. +0 −132 hibernate-core/src/main/java/org/hibernate/cache/spi/Cache.java
  16. +0 −197 hibernate-core/src/main/java/org/hibernate/cache/spi/CacheConcurrencyStrategy.java
  17. +0 −68 hibernate-core/src/main/java/org/hibernate/cache/spi/CacheProvider.java
  18. +0 −178 hibernate-core/src/main/java/org/hibernate/cache/spi/NonstrictReadWriteCache.java
  19. +0 −87 hibernate-core/src/main/java/org/hibernate/cache/spi/OptimisticCache.java
  20. +0 −165 hibernate-core/src/main/java/org/hibernate/cache/spi/ReadOnlyCache.java
  21. +0 −500 hibernate-core/src/main/java/org/hibernate/cache/spi/ReadWriteCache.java
  22. +1 −6 hibernate-core/src/main/java/org/hibernate/cache/spi/RegionFactory.java
  23. +0 −183 hibernate-core/src/main/java/org/hibernate/cache/spi/TransactionalCache.java
  24. +0 −33 hibernate-core/src/main/java/org/hibernate/cache/spi/access/EntityRegionAccessStrategy.java
  25. +0 −7 hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
  26. +0 −5 hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
  27. +6 −6 hibernate-core/src/main/java/org/hibernate/cfg/ExternalSessionFactoryConfig.java
  28. +20 −34 hibernate-core/src/main/java/org/hibernate/cfg/SettingsFactory.java
  29. +2 −2 hibernate-core/src/main/java/org/hibernate/jmx/HibernateServiceMBean.java
  30. +0 −159 hibernate-core/src/test/java/org/hibernate/test/legacy/CacheTest.java
  31. +2 −2 hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java
  32. +1 −1 hibernate-core/src/test/resources/hibernate.properties
  33. +1 −1 hibernate-core/src/test/resources/log4j.properties
  34. +0 −274 hibernate-ehcache/src/main/java/org/hibernate/cache/internal/EhCache.java
  35. +0 −171 hibernate-ehcache/src/main/java/org/hibernate/cache/internal/EhCacheProvider.java
  36. +0 −185 hibernate-ehcache/src/main/java/org/hibernate/cache/internal/SingletonEhCacheProvider.java
  37. +8 −8 hibernate-ehcache/src/test/java/org/hibernate/test/cache/ehcache/EhCacheRegionTest.java
  38. +5 −6 hibernate-ehcache/src/test/java/org/hibernate/test/cache/ehcache/EhCacheTest.java
  39. +1 −1 ...-entitymanager/src/test/bundles/cfgxmlpar/org/hibernate/ejb/test/pack/cfgxmlpar/hibernate.cfg.xml
  40. +1 −1 hibernate-entitymanager/src/test/bundles/defaultpar/META-INF/persistence.xml
  41. +1 −1 hibernate-entitymanager/src/test/bundles/defaultpar_1_0/META-INF/persistence.xml
  42. +1 −1 hibernate-entitymanager/src/test/bundles/excludehbmpar/META-INF/persistence.xml
  43. +1 −1 hibernate-entitymanager/src/test/bundles/explicitpar/META-INF/persistence.xml
  44. +1 −1 hibernate-entitymanager/src/test/bundles/explodedpar/META-INF/persistence.xml
  45. +1 −1 hibernate-entitymanager/src/test/bundles/overridenpar/META-INF/persistence.xml
  46. +1 −1 hibernate-entitymanager/src/test/bundles/space par/META-INF/persistence.xml
  47. +1 −1 hibernate-entitymanager/src/test/bundles/war/WEB-INF/classes/META-INF/persistence.xml
  48. +1 −1 hibernate-entitymanager/src/test/resources/hibernate.properties
  49. +1 −1 hibernate-entitymanager/src/test/resources/org/hibernate/ejb/test/hibernate.cfg.xml
  50. +2 −2 ...e-envers/src/test/java/org/hibernate/envers/test/integration/cache/HibernateSecLvlQueryCache.java
  51. +360 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/AbstractReadWriteAccessStrategy.java
  52. +18 −21 ...bernate-testing/src/main/java/org/hibernate/testing/cache/BaseCollectionRegionAccessStrategy.java
  53. +85 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseEntityRegionAccessStrategy.java
  54. +91 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseGeneralDataRegion.java
  55. +34 −29 ...eRegionAdapter.java → hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseRegion.java
  56. +109 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseRegionAccessStrategy.java
  57. +14 −19 ...va → hibernate-testing/src/main/java/org/hibernate/testing/cache/BaseTransactionalDataRegion.java
  58. +116 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/CachingRegionFactory.java
  59. +74 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/CollectionRegionImpl.java
  60. +78 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/EntityRegionImpl.java
  61. +17 −19 ...g/src/main/java/org/hibernate/testing/cache/NonstrictReadWriteCollectionRegionAccessStrategy.java
  62. +22 −29 ...sting/src/main/java/org/hibernate/testing/cache/NonstrictReadWriteEntityRegionAccessStrategy.java
  63. +59 −0 ...ate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyCollectionRegionAccessStrategy.java
  64. +86 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadOnlyEntityRegionAccessStrategy.java
  65. +36 −11 ...te-testing/src/main/java/org/hibernate/testing/cache/ReadWriteCollectionRegionAccessStrategy.java
  66. +127 −0 hibernate-testing/src/main/java/org/hibernate/testing/cache/ReadWriteEntityRegionAccessStrategy.java
  67. +2 −2 hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java
View
36 documentation/src/main/docbook/manual/en-US/content/performance.xml
@@ -750,9 +750,9 @@ Customer customer = (Customer) session.get( Customer.class, customerId );
<tbody>
<row>
- <entry>Hashtable (not intended for production use)</entry>
+ <entry>ConcurrentHashMap (only for testing purpose, in hibernate-testing module)</entry>
- <entry><literal>org.hibernate.cache.internal.HashtableCacheProvider</literal></entry>
+ <entry><literal>org.hibernate.testing.cache.CachingRegionFactory</literal></entry>
<entry>memory</entry>
@@ -764,7 +764,7 @@ Customer customer = (Customer) session.get( Customer.class, customerId );
<row>
<entry>EHCache</entry>
- <entry><literal>org.hibernate.cache.internal.EhCacheProvider</literal></entry>
+ <entry><literal>org.hibernate.cache.internal.EhCacheRegionFactory</literal></entry>
<entry>memory, disk</entry>
@@ -773,7 +773,7 @@ Customer customer = (Customer) session.get( Customer.class, customerId );
<entry>yes</entry>
</row>
- <row>
+<!-- <row>
<entry>OSCache</entry>
<entry><literal>org.hibernate.cache.OSCacheProvider</literal></entry>
@@ -819,6 +819,17 @@ Customer customer = (Customer) session.get( Customer.class, customerId );
<entry>yes (replication or invalidation)</entry>
<entry>yes (clock sync req.)</entry>
+ </row> -->
+ <row>
+ <entry>Infinispan</entry>
+
+ <entry><literal>org.hibernate.cache.infinispan.InfinispanRegionFactory</literal></entry>
+
+ <entry>clustered (ip multicast), transactional</entry>
+
+ <entry>yes (replication or invalidation)</entry>
+
+ <entry>yes (clock sync req.)</entry>
</row>
</tbody>
</tgroup>
@@ -1114,7 +1125,7 @@ public SortedSet&lt;Ticket&gt; getTickets() {
<tbody>
<row>
- <entry>Hashtable (not intended for production use)</entry>
+ <entry>ConcurrentHashMap (not intended for production use)</entry>
<entry>yes</entry>
@@ -1134,10 +1145,10 @@ public SortedSet&lt;Ticket&gt; getTickets() {
<entry>yes</entry>
- <entry></entry>
+ <entry>yes</entry>
</row>
- <row>
+ <!-- <row>
<entry>OSCache</entry>
<entry>yes</entry>
@@ -1183,6 +1194,17 @@ public SortedSet&lt;Ticket&gt; getTickets() {
<entry></entry>
<entry>yes</entry>
+ </row> -->
+ <row>
+ <entry>Infinispan</entry>
+
+ <entry>yes</entry>
+
+ <entry></entry>
+
+ <entry></entry>
+
+ <entry>yes</entry>
</row>
</tbody>
</tgroup>
View
12 etc/hibernate.properties
@@ -492,13 +492,11 @@ hibernate.cache.region_prefix hibernate.test
## choose a cache implementation
-#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider
-hibernate.cache.provider_class org.hibernate.cache.internal.HashtableCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.OSCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.SwarmCacheProvider
-
+#hibernate.cache.region.factory_class org.hibernate.cache.infinispan.InfinispanRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.infinispan.JndiInfinispanRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.internal.EhCacheRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.internal.SingletonEhCacheRegionFactory
+hibernate.cache.region.factory_class org.hibernate.cache.internal.NoCachingRegionFactory
## choose a custom query cache implementation
View
975 etc/hibernate.properties.template
@@ -1,488 +1,487 @@
-######################
-### Query Language ###
-######################
-
-## define query language constants / function names
-
-hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
-
-
-## Query translator factory class
-
-hibernate.query.factory_class @QUERY_TRANSLATOR_FACTORY@
-
-#################
-### Platforms ###
-#################
-
-hibernate.dialect @HIBERNATE_DIALECT@
-hibernate.connection.driver_class @DRIVER_CLASS@
-hibernate.connection.username @DB_USERNAME@
-hibernate.connection.password @DB_PASSWORD@
-hibernate.connection.url @DB_URL@
-
-## JNDI Datasource
-
-#hibernate.connection.datasource jdbc/test
-#hibernate.connection.username db2
-#hibernate.connection.password db2
-
-
-## HypersonicSQL
-
-#hibernate.dialect org.hibernate.dialect.HSQLDialect
-#hibernate.connection.driver_class org.hsqldb.jdbcDriver
-#hibernate.connection.username sa
-#hibernate.connection.password
-#hibernate.connection.url jdbc:hsqldb:hsql://localhost
-#hibernate.connection.url jdbc:hsqldb:test
-#hibernate.connection.url jdbc:hsqldb:.
-
-
-## MySQL
-
-
-#hibernate.dialect org.hibernate.dialect.MySQLDialect
-#hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
-#hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
-#hibernate.connection.driver_class org.gjt.mm.mysql.Driver
-#hibernate.connection.driver_class com.mysql.jdbc.Driver
-#hibernate.connection.url jdbc:mysql:///test
-#hibernate.connection.username gavin
-#hibernate.connection.password
-
-
-## Oracle
-
-#hibernate.dialect org.hibernate.dialect.OracleDialect
-#hibernate.dialect org.hibernate.dialect.Oracle9Dialect
-#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
-#hibernate.connection.username ora
-#hibernate.connection.password ora
-#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:test
-
-
-## PostgreSQL
-
-#hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
-#hibernate.connection.driver_class org.postgresql.Driver
-#hibernate.connection.url jdbc:postgresql:template1
-#hibernate.connection.username pg
-#hibernate.connection.password
-#hibernate.query.substitutions yes 'Y', no 'N'
-
-
-## DB2
-
-#hibernate.dialect org.hibernate.dialect.DB2Dialect
-#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
-#hibernate.connection.url jdbc:db2:test
-#hibernate.connection.username db2
-#hibernate.connection.password db2
-
-## TimesTen (not supported yet)
-
-#hibernate.dialect org.hibernate.dialect.TimesTenDialect
-#hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver
-#hibernate.connection.url jdbc:timesten:direct:test
-#hibernate.connection.username
-#hibernate.connection.password
-
-## DB2/400
-
-#hibernate.dialect org.hibernate.dialect.DB2400Dialect
-#hibernate.connection.username user
-#hibernate.connection.password password
-
-## Native driver
-#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
-#hibernate.connection.url jdbc:db2://systemname
-
-## Toolbox driver
-#hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
-#hibernate.connection.url jdbc:as400://systemname
-
-
-## Derby (Not supported!)
-
-#hibernate.dialect org.hibernate.dialect.DerbyDialect
-#hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver
-#hibernate.connection.username
-#hibernate.connection.password
-#hibernate.connection.url jdbc:derby:/test;create=true
-
-
-## Sybase
-
-#hibernate.dialect org.hibernate.dialect.SybaseDialect
-#hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver
-#hibernate.connection.username sa
-#hibernate.connection.password sasasa
-#hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb
-
-
-## Mckoi SQL
-
-#hibernate.dialect org.hibernate.dialect.MckoiDialect
-#hibernate.connection.driver_class com.mckoi.JDBCDriver
-#hibernate.connection.url jdbc:mckoi:///
-#hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.00/db.conf
-#hibernate.connection.username admin
-#hibernate.connection.password nimda
-
-
-## SAP DB
-
-#hibernate.dialect org.hibernate.dialect.SAPDBDialect
-#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
-#hibernate.connection.url jdbc:sapdb://localhost/TST
-#hibernate.connection.username TEST
-#hibernate.connection.password TEST
-#hibernate.query.substitutions yes 'Y', no 'N'
-
-
-## MS SQL Server
-
-#hibernate.dialect org.hibernate.dialect.SQLServerDialect
-#hibernate.connection.username sa
-#hibernate.connection.password sa
-
-## JSQL Driver
-#hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver
-#hibernate.connection.url jdbc:JSQLConnect://1E1/test
-
-## JTURBO Driver
-#hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver
-#hibernate.connection.url jdbc:JTurbo://1E1:1433/test
-
-## WebLogic Driver
-#hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver
-#hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433
-
-## Microsoft Driver (not recommended!)
-#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
-#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor
-
-## jTDS (since version 0.9)
-#hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver
-#hibernate.connection.url jdbc:jtds:sqlserver://1E1/test
-
-## Interbase
-
-#hibernate.dialect org.hibernate.dialect.InterbaseDialect
-#hibernate.connection.username sysdba
-#hibernate.connection.password masterkey
-
-## DO NOT specify hibernate.connection.sqlDialect
-
-## InterClient
-
-#hibernate.connection.driver_class interbase.interclient.Driver
-#hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb
-
-## Pure Java
-
-#hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver
-#hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb
-
-
-## Pointbase
-
-#hibernate.dialect org.hibernate.dialect.PointbaseDialect
-#hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver
-#hibernate.connection.url jdbc:pointbase:embedded:sample
-#hibernate.connection.username PBPUBLIC
-#hibernate.connection.password PBPUBLIC
-
-
-## Ingres
-
-#hibernate.dialect org.hibernate.dialect.IngresDialect
-#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
-#hibernate.connection.url jdbc:edbc://localhost:II7/database
-#hibernate.connection.username user
-#hibernate.connection.password password
-
-
-## Mimer SQL
-
-#hibernate.dialect org.hibernate.dialect.MimerSQLDialect
-#hibernate.connection.driver_class com.mimer.jdbc.Driver
-#hibernate.connection.url jdbc:mimer:multi1
-#hibernate.connection.username hibernate
-#hibernate.connection.password hibernate
-
-
-
-#################################
-### Hibernate Connection Pool ###
-#################################
-
-hibernate.connection.pool_size 1
-
-
-
-###########################
-### C3P0 Connection Pool###
-###########################
-
-#hibernate.c3p0.max_size 2
-#hibernate.c3p0.min_size 2
-#hibernate.c3p0.timeout 5000
-#hibernate.c3p0.max_statements 100
-#hibernate.c3p0.idle_test_period 3000
-#hibernate.c3p0.acquire_increment 2
-#hibernate.c3p0.validate false
-
-
-
-##############################
-### Proxool Connection Pool###
-##############################
-
-## Properties for external configuration of Proxool
-
-hibernate.proxool.pool_alias pool1
-
-## Only need one of the following
-
-#hibernate.proxool.existing_pool true
-#hibernate.proxool.xml proxool.xml
-#hibernate.proxool.properties proxool.properties
-
-
-
-#################################
-### Plugin ConnectionProvider ###
-#################################
-
-## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)
-
-#hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.DBCPConnectionProvider
-#hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider
-
-
-
-#######################
-### Transaction API ###
-#######################
-
-## Enable automatic flush during the JTA beforeCompletion() callback
-## (This setting is relevant with or without the Transaction API)
-
-#hibernate.transaction.flush_before_completion
-
-
-## Enable automatic session close at the end of transaction
-## (This setting is relevant with or without the Transaction API)
-
-#hibernate.transaction.auto_close_session
-
-
-## the Transaction API abstracts application code from the underlying JTA or JDBC transactions
-
-#hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory
-#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory
-
-
-## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI
-## default is java:comp/UserTransaction
-## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class
-
-#jta.UserTransaction jta/usertransaction
-#jta.UserTransaction javax.transaction.UserTransaction
-#jta.UserTransaction UserTransaction
-
-
-## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager
-
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBossTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WeblogicTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.OrionTransactionManagerLookup
-#hibernate.transaction.manager_lookup_class org.hibernate.transaction.ResinTransactionManagerLookup
-
-
-
-##############################
-### Miscellaneous Settings ###
-##############################
-
-## print all generated SQL to the console
-
-#hibernate.show_sql true
-
-
-## add comments to the generated SQL
-
-#hibernate.use_sql_comments true
-
-
-## generate statistics
-
-#hibernate.generate_statistics true
-
-
-## auto schema export
-
-#hibernate.hbm2ddl.auto create-drop
-#hibernate.hbm2ddl.auto create
-#hibernate.hbm2ddl.auto update
-
-
-## specify a default schema and catalog for unqualified tablenames
-
-#hibernate.default_schema test
-#hibernate.default_catalog test
-
-
-## enable ordering of SQL UPDATEs by primary key
-
-hibernate.order_updates true
-
-
-## set the maximum depth of the outer join fetch tree
-
-hibernate.max_fetch_depth 1
-
-
-## set the default batch size for batch fetching
-
-hibernate.default_batch_fetch_size 8
-
-
-## rollback generated identifier values of deleted entities to default values
-
-#hibernate.use_identifer_rollback true
-
-
-## enable bytecode reflection optimizer (disabled by default)
-
-#hibernate.bytecode.use_reflection_optimizer true
-
-
-
-#####################
-### JDBC Settings ###
-#####################
-
-## specify a JDBC isolation level
-
-#hibernate.connection.isolation 4
-
-
-## enable JDBC autocommit (not recommended!)
-
-#hibernate.connection.autocommit true
-
-
-## set the JDBC fetch size
-
-#hibernate.jdbc.fetch_size 25
-
-
-## set the maximum JDBC 2 batch size (a nonzero value enables batching)
-
-#hibernate.jdbc.batch_size 5
-
-
-## enable batch updates even for versioned data
-
-hibernate.jdbc.batch_versioned_data true
-
-
-## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)
-
-#hibernate.jdbc.use_scrollable_resultset true
-
-
-## use streams when writing binary types to / from JDBC
-
-hibernate.jdbc.use_streams_for_binary true
-
-
-## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row
-
-#hibernate.jdbc.use_get_generated_keys false
-
-
-## choose a custom JDBC batcher
-
-# hibernate.jdbc.factory_class
-
-
-## choose a custom SQL exception converter
-
-#hibernate.jdbc.sql_exception_converter
-
-
-
-##########################
-### Second-level Cache ###
-##########################
-
-## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)
-
-#hibernate.cache.use_minimal_puts true
-
-
-## set a prefix for cache region names
-
-hibernate.cache.region_prefix hibernate.test
-
-
-## disable the second-level cache
-
-#hibernate.cache.use_second_level_cache false
-
-
-## enable the query cache
-
-#hibernate.cache.use_query_cache true
-
-
-## store the second-level cache entries in a more human-friendly format
-
-#hibernate.cache.use_structured_entries true
-
-
-## choose a cache implementation
-
-#hibernate.cache.provider_class org.hibernate.cache.EhCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.EmptyCacheProvider
-hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.TreeCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.OSCacheProvider
-#hibernate.cache.provider_class org.hibernate.cache.SwarmCacheProvider
-
-
-## choose a custom query cache implementation
-
-#hibernate.cache.query_cache_factory
-
-
-
-############
-### JNDI ###
-############
-
-## specify a JNDI name for the SessionFactory
-
-#hibernate.session_factory_name hibernate/session_factory
-
-
-## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;
-## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which
-## is the best approach in an application server
-
-#file system
-#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory
-#hibernate.jndi.url file:/
-
-#WebSphere
-#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory
-#hibernate.jndi.url iiop://localhost:900/
-
+######################
+### Query Language ###
+######################
+
+## define query language constants / function names
+
+hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
+
+
+## Query translator factory class
+
+hibernate.query.factory_class @QUERY_TRANSLATOR_FACTORY@
+
+#################
+### Platforms ###
+#################
+
+hibernate.dialect @HIBERNATE_DIALECT@
+hibernate.connection.driver_class @DRIVER_CLASS@
+hibernate.connection.username @DB_USERNAME@
+hibernate.connection.password @DB_PASSWORD@
+hibernate.connection.url @DB_URL@
+
+## JNDI Datasource
+
+#hibernate.connection.datasource jdbc/test
+#hibernate.connection.username db2
+#hibernate.connection.password db2
+
+
+## HypersonicSQL
+
+#hibernate.dialect org.hibernate.dialect.HSQLDialect
+#hibernate.connection.driver_class org.hsqldb.jdbcDriver
+#hibernate.connection.username sa
+#hibernate.connection.password
+#hibernate.connection.url jdbc:hsqldb:hsql://localhost
+#hibernate.connection.url jdbc:hsqldb:test
+#hibernate.connection.url jdbc:hsqldb:.
+
+
+## MySQL
+
+
+#hibernate.dialect org.hibernate.dialect.MySQLDialect
+#hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
+#hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
+#hibernate.connection.driver_class org.gjt.mm.mysql.Driver
+#hibernate.connection.driver_class com.mysql.jdbc.Driver
+#hibernate.connection.url jdbc:mysql:///test
+#hibernate.connection.username gavin
+#hibernate.connection.password
+
+
+## Oracle
+
+#hibernate.dialect org.hibernate.dialect.OracleDialect
+#hibernate.dialect org.hibernate.dialect.Oracle9Dialect
+#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
+#hibernate.connection.username ora
+#hibernate.connection.password ora
+#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:test
+
+
+## PostgreSQL
+
+#hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
+#hibernate.connection.driver_class org.postgresql.Driver
+#hibernate.connection.url jdbc:postgresql:template1
+#hibernate.connection.username pg
+#hibernate.connection.password
+#hibernate.query.substitutions yes 'Y', no 'N'
+
+
+## DB2
+
+#hibernate.dialect org.hibernate.dialect.DB2Dialect
+#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
+#hibernate.connection.url jdbc:db2:test
+#hibernate.connection.username db2
+#hibernate.connection.password db2
+
+## TimesTen (not supported yet)
+
+#hibernate.dialect org.hibernate.dialect.TimesTenDialect
+#hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver
+#hibernate.connection.url jdbc:timesten:direct:test
+#hibernate.connection.username
+#hibernate.connection.password
+
+## DB2/400
+
+#hibernate.dialect org.hibernate.dialect.DB2400Dialect
+#hibernate.connection.username user
+#hibernate.connection.password password
+
+## Native driver
+#hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver
+#hibernate.connection.url jdbc:db2://systemname
+
+## Toolbox driver
+#hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
+#hibernate.connection.url jdbc:as400://systemname
+
+
+## Derby (Not supported!)
+
+#hibernate.dialect org.hibernate.dialect.DerbyDialect
+#hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver
+#hibernate.connection.username
+#hibernate.connection.password
+#hibernate.connection.url jdbc:derby:/test;create=true
+
+
+## Sybase
+
+#hibernate.dialect org.hibernate.dialect.SybaseDialect
+#hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver
+#hibernate.connection.username sa
+#hibernate.connection.password sasasa
+#hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb
+
+
+## Mckoi SQL
+
+#hibernate.dialect org.hibernate.dialect.MckoiDialect
+#hibernate.connection.driver_class com.mckoi.JDBCDriver
+#hibernate.connection.url jdbc:mckoi:///
+#hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.00/db.conf
+#hibernate.connection.username admin
+#hibernate.connection.password nimda
+
+
+## SAP DB
+
+#hibernate.dialect org.hibernate.dialect.SAPDBDialect
+#hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB
+#hibernate.connection.url jdbc:sapdb://localhost/TST
+#hibernate.connection.username TEST
+#hibernate.connection.password TEST
+#hibernate.query.substitutions yes 'Y', no 'N'
+
+
+## MS SQL Server
+
+#hibernate.dialect org.hibernate.dialect.SQLServerDialect
+#hibernate.connection.username sa
+#hibernate.connection.password sa
+
+## JSQL Driver
+#hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver
+#hibernate.connection.url jdbc:JSQLConnect://1E1/test
+
+## JTURBO Driver
+#hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver
+#hibernate.connection.url jdbc:JTurbo://1E1:1433/test
+
+## WebLogic Driver
+#hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver
+#hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433
+
+## Microsoft Driver (not recommended!)
+#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
+#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor
+
+## jTDS (since version 0.9)
+#hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver
+#hibernate.connection.url jdbc:jtds:sqlserver://1E1/test
+
+## Interbase
+
+#hibernate.dialect org.hibernate.dialect.InterbaseDialect
+#hibernate.connection.username sysdba
+#hibernate.connection.password masterkey
+
+## DO NOT specify hibernate.connection.sqlDialect
+
+## InterClient
+
+#hibernate.connection.driver_class interbase.interclient.Driver
+#hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb
+
+## Pure Java
+
+#hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver
+#hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb
+
+
+## Pointbase
+
+#hibernate.dialect org.hibernate.dialect.PointbaseDialect
+#hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver
+#hibernate.connection.url jdbc:pointbase:embedded:sample
+#hibernate.connection.username PBPUBLIC
+#hibernate.connection.password PBPUBLIC
+
+
+## Ingres
+
+#hibernate.dialect org.hibernate.dialect.IngresDialect
+#hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver
+#hibernate.connection.url jdbc:edbc://localhost:II7/database
+#hibernate.connection.username user
+#hibernate.connection.password password
+
+
+## Mimer SQL
+
+#hibernate.dialect org.hibernate.dialect.MimerSQLDialect
+#hibernate.connection.driver_class com.mimer.jdbc.Driver
+#hibernate.connection.url jdbc:mimer:multi1
+#hibernate.connection.username hibernate
+#hibernate.connection.password hibernate
+
+
+
+#################################
+### Hibernate Connection Pool ###
+#################################
+
+hibernate.connection.pool_size 1
+
+
+
+###########################
+### C3P0 Connection Pool###
+###########################
+
+#hibernate.c3p0.max_size 2
+#hibernate.c3p0.min_size 2
+#hibernate.c3p0.timeout 5000
+#hibernate.c3p0.max_statements 100
+#hibernate.c3p0.idle_test_period 3000
+#hibernate.c3p0.acquire_increment 2
+#hibernate.c3p0.validate false
+
+
+
+##############################
+### Proxool Connection Pool###
+##############################
+
+## Properties for external configuration of Proxool
+
+hibernate.proxool.pool_alias pool1
+
+## Only need one of the following
+
+#hibernate.proxool.existing_pool true
+#hibernate.proxool.xml proxool.xml
+#hibernate.proxool.properties proxool.properties
+
+
+
+#################################
+### Plugin ConnectionProvider ###
+#################################
+
+## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics)
+
+#hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider
+#hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider
+#hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider
+#hibernate.connection.provider_class org.hibernate.connection.DBCPConnectionProvider
+#hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider
+
+
+
+#######################
+### Transaction API ###
+#######################
+
+## Enable automatic flush during the JTA beforeCompletion() callback
+## (This setting is relevant with or without the Transaction API)
+
+#hibernate.transaction.flush_before_completion
+
+
+## Enable automatic session close at the end of transaction
+## (This setting is relevant with or without the Transaction API)
+
+#hibernate.transaction.auto_close_session
+
+
+## the Transaction API abstracts application code from the underlying JTA or JDBC transactions
+
+#hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory
+#hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory
+
+
+## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI
+## default is java:comp/UserTransaction
+## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class
+
+#jta.UserTransaction jta/usertransaction
+#jta.UserTransaction javax.transaction.UserTransaction
+#jta.UserTransaction UserTransaction
+
+
+## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager
+
+#hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBossTransactionManagerLookup
+#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WeblogicTransactionManagerLookup
+#hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereTransactionManagerLookup
+#hibernate.transaction.manager_lookup_class org.hibernate.transaction.OrionTransactionManagerLookup
+#hibernate.transaction.manager_lookup_class org.hibernate.transaction.ResinTransactionManagerLookup
+
+
+
+##############################
+### Miscellaneous Settings ###
+##############################
+
+## print all generated SQL to the console
+
+#hibernate.show_sql true
+
+
+## add comments to the generated SQL
+
+#hibernate.use_sql_comments true
+
+
+## generate statistics
+
+#hibernate.generate_statistics true
+
+
+## auto schema export
+
+#hibernate.hbm2ddl.auto create-drop
+#hibernate.hbm2ddl.auto create
+#hibernate.hbm2ddl.auto update
+
+
+## specify a default schema and catalog for unqualified tablenames
+
+#hibernate.default_schema test
+#hibernate.default_catalog test
+
+
+## enable ordering of SQL UPDATEs by primary key
+
+hibernate.order_updates true
+
+
+## set the maximum depth of the outer join fetch tree
+
+hibernate.max_fetch_depth 1
+
+
+## set the default batch size for batch fetching
+
+hibernate.default_batch_fetch_size 8
+
+
+## rollback generated identifier values of deleted entities to default values
+
+#hibernate.use_identifer_rollback true
+
+
+## enable bytecode reflection optimizer (disabled by default)
+
+#hibernate.bytecode.use_reflection_optimizer true
+
+
+
+#####################
+### JDBC Settings ###
+#####################
+
+## specify a JDBC isolation level
+
+#hibernate.connection.isolation 4
+
+
+## enable JDBC autocommit (not recommended!)
+
+#hibernate.connection.autocommit true
+
+
+## set the JDBC fetch size
+
+#hibernate.jdbc.fetch_size 25
+
+
+## set the maximum JDBC 2 batch size (a nonzero value enables batching)
+
+#hibernate.jdbc.batch_size 5
+
+
+## enable batch updates even for versioned data
+
+hibernate.jdbc.batch_versioned_data true
+
+
+## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)
+
+#hibernate.jdbc.use_scrollable_resultset true
+
+
+## use streams when writing binary types to / from JDBC
+
+hibernate.jdbc.use_streams_for_binary true
+
+
+## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row
+
+#hibernate.jdbc.use_get_generated_keys false
+
+
+## choose a custom JDBC batcher
+
+# hibernate.jdbc.factory_class
+
+
+## choose a custom SQL exception converter
+
+#hibernate.jdbc.sql_exception_converter
+
+
+
+##########################
+### Second-level Cache ###
+##########################
+
+## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)
+
+#hibernate.cache.use_minimal_puts true
+
+
+## set a prefix for cache region names
+
+hibernate.cache.region_prefix hibernate.test
+
+
+## disable the second-level cache
+
+#hibernate.cache.use_second_level_cache false
+
+
+## enable the query cache
+
+#hibernate.cache.use_query_cache true
+
+
+## store the second-level cache entries in a more human-friendly format
+
+#hibernate.cache.use_structured_entries true
+
+
+## choose a cache implementation
+
+#hibernate.cache.region.factory_class org.hibernate.cache.infinispan.InfinispanRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.infinispan.JndiInfinispanRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.internal.EhCacheRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.internal.SingletonEhCacheRegionFactory
+#hibernate.cache.region.factory_class org.hibernate.cache.internal.NoCachingRegionFactory
+
+
+## choose a custom query cache implementation
+
+#hibernate.cache.query_cache_factory
+
+
+
+############
+### JNDI ###
+############
+
+## specify a JNDI name for the SessionFactory
+
+#hibernate.session_factory_name hibernate/session_factory
+
+
+## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction;
+## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which
+## is the best approach in an application server
+
+#file system
+#hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory
+#hibernate.jndi.url file:/
+
+#WebSphere
+#hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory
+#hibernate.jndi.url iiop://localhost:900/
+
View
26 hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java
@@ -25,7 +25,10 @@
import java.util.Map;
+import org.jboss.logging.Logger;
+
import org.hibernate.cfg.Environment;
+import org.hibernate.internal.CoreMessageLogger;
/**
* Describes the methods for multi-tenancy understood by Hibernate.
@@ -33,6 +36,7 @@
* @author Steve Ebersole
*/
public enum MultiTenancyStrategy {
+
/**
* Multi-tenancy implemented by use of discriminator columns.
*/
@@ -49,7 +53,10 @@
* No multi-tenancy
*/
NONE;
-
+ private static final CoreMessageLogger LOG = Logger.getMessageLogger(
+ CoreMessageLogger.class,
+ MultiTenancyStrategy.class.getName()
+ );
public static MultiTenancyStrategy determineMultiTenancyStrategy(Map properties) {
final Object strategy = properties.get( Environment.MULTI_TENANT );
if ( strategy == null ) {
@@ -61,20 +68,11 @@ public static MultiTenancyStrategy determineMultiTenancyStrategy(Map properties)
}
final String strategyName = strategy.toString();
- if ( MultiTenancyStrategy.DISCRIMINATOR.name().equals( strategyName ) ) {
- return MultiTenancyStrategy.DISCRIMINATOR;
- }
- else if ( MultiTenancyStrategy.SCHEMA.name().equals( strategyName ) ) {
- return MultiTenancyStrategy.SCHEMA;
- }
- else if ( MultiTenancyStrategy.DATABASE.name().equals( strategyName ) ) {
- return MultiTenancyStrategy.DATABASE;
- }
- else if ( MultiTenancyStrategy.NONE.name().equals( strategyName ) ) {
- return MultiTenancyStrategy.NONE;
+ try {
+ return MultiTenancyStrategy.valueOf( strategyName.toUpperCase() );
}
- else {
- // todo log?
+ catch ( RuntimeException e ) {
+ LOG.warn( "Unknown multi tenancy strategy [ " +strategyName +" ], using MultiTenancyStrategy.NONE." );
return MultiTenancyStrategy.NONE;
}
}
View
114 hibernate-core/src/main/java/org/hibernate/cache/internal/HashtableCache.java
@@ -1,114 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal;
-
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.Cache;
-
-/**
- * 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 + ')';
- }
-
-}
View
86 hibernate-core/src/main/java/org/hibernate/cache/internal/NoCacheProvider.java
@@ -1,86 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal;
-
-import java.util.Properties;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.NoCachingEnabledException;
-import org.hibernate.cache.spi.Cache;
-import org.hibernate.cache.spi.CacheProvider;
-
-/**
- * Implementation of NoCacheProvider.
- *
- * @author Steve Ebersole
- */
-@Deprecated
-public class NoCacheProvider implements CacheProvider {
- /**
- * Configure the cache
- *
- * @param regionName the name of the cache region
- * @param properties configuration settings
- *
- * @throws org.hibernate.cache.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;
- }
-
-}
View
29 hibernate-core/src/main/java/org/hibernate/cache/internal/Timestamper.java
@@ -23,29 +23,28 @@
*/
package org.hibernate.cache.internal;
+import java.util.concurrent.atomic.AtomicLong;
+
/**
* 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;
-
+ private static final AtomicLong VALUE = new AtomicLong();
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;
- }
+ while (true) {
+ long base = System.currentTimeMillis() << BIN_DIGITS;
+ long maxValue = base + ONE_MS - 1;
+
+ for (long current = VALUE.get(), update = Math.max(base, current + 1); update < maxValue;
+ current = VALUE.get(), update = Math.max(base, current + 1)) {
+ if (VALUE.compareAndSet(current, update)) {
+ return update;
+ }
+ }
+ }
}
private Timestamper() {
View
114 ...re/src/main/java/org/hibernate/cache/internal/bridge/CollectionAccessStrategyAdapter.java
@@ -1,114 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal.bridge;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheConcurrencyStrategy;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-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();
- }
-}
View
81 ...rnate-core/src/main/java/org/hibernate/cache/internal/bridge/CollectionRegionAdapter.java
@@ -1,81 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal.bridge;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.Cache;
-import org.hibernate.cache.spi.CacheConcurrencyStrategy;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.NonstrictReadWriteCache;
-import org.hibernate.cache.spi.OptimisticCache;
-import org.hibernate.cache.spi.ReadOnlyCache;
-import org.hibernate.cache.spi.ReadWriteCache;
-import org.hibernate.cache.spi.TransactionalCache;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-import org.hibernate.cfg.Settings;
-import org.hibernate.internal.CoreMessageLogger;
-
-/**
- * Adapter specifically bridging {@link CollectionRegion} to {@link Cache}.
- *
- * @author Steve Ebersole
- */
-public class CollectionRegionAdapter extends BaseTransactionalDataRegionAdapter implements CollectionRegion {
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
- CollectionRegionAdapter.class.getName());
-
- 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.readOnlyCacheConfiguredForMutableCollection(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 );
- }
-}
View
132 ...e-core/src/main/java/org/hibernate/cache/internal/bridge/EntityAccessStrategyAdapter.java
@@ -1,132 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal.bridge;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheConcurrencyStrategy;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.spi.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();
- }
-}
View
80 hibernate-core/src/main/java/org/hibernate/cache/internal/bridge/EntityRegionAdapter.java
@@ -1,80 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal.bridge;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.Cache;
-import org.hibernate.cache.spi.CacheConcurrencyStrategy;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.NonstrictReadWriteCache;
-import org.hibernate.cache.spi.OptimisticCache;
-import org.hibernate.cache.spi.ReadOnlyCache;
-import org.hibernate.cache.spi.ReadWriteCache;
-import org.hibernate.cache.spi.TransactionalCache;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cfg.Settings;
-import org.hibernate.internal.CoreMessageLogger;
-
-/**
- * Adapter specifically bridging {@link EntityRegion} to {@link org.hibernate.cache.spi.Cache}.
- *
- * @author Steve Ebersole
- */
-public class EntityRegionAdapter extends BaseTransactionalDataRegionAdapter implements EntityRegion {
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, EntityRegionAdapter.class.getName());
-
- 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.readOnlyCacheConfiguredForMutableCollection(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 );
- }
-}
View
125 ...e/src/main/java/org/hibernate/cache/internal/bridge/RegionFactoryCacheProviderBridge.java
@@ -1,125 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal.bridge;
-
-import java.util.Properties;
-
-import org.jboss.logging.Logger;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.internal.NoCacheProvider;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CacheProvider;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.RegionFactory;
-import org.hibernate.cache.spi.TimestampsRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.Settings;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.util.ReflectHelper;
-import org.hibernate.internal.util.config.ConfigurationHelper;
-
-/**
- * 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 CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
- RegionFactoryCacheProviderBridge.class.getName());
-
- private CacheProvider cacheProvider;
- private Settings settings;
-
- public RegionFactoryCacheProviderBridge(Properties properties) {
- String providerClassName = ConfigurationHelper.getString( Environment.CACHE_PROVIDER, properties, DEF_PROVIDER );
- LOG.cacheProvider(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();
- }
-
- /**
- * {@inheritDoc}
- */
- public AccessType getDefaultAccessType() {
- // we really have no idea
- return null;
- }
-
- 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 );
- }
-
-
-}
View
39 ...rnate-core/src/main/java/org/hibernate/cache/internal/bridge/TimestampsRegionAdapter.java
@@ -1,39 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.internal.bridge;
-
-import org.hibernate.cache.spi.Cache;
-import org.hibernate.cache.spi.TimestampsRegion;
-import org.hibernate.cfg.Settings;
-
-/**
- * Adapter specifically bridging {@link TimestampsRegion} to {@link org.hibernate.cache.spi.Cache}.
-*
-* @author Steve Ebersole
- */
-public class TimestampsRegionAdapter extends BaseGeneralDataRegionAdapter implements TimestampsRegion {
- protected TimestampsRegionAdapter(Cache underlyingCache, Settings settings) {
- super( underlyingCache, settings );
- }
-}
View
111 hibernate-core/src/main/java/org/hibernate/cache/spi/AbstractJndiBoundCacheProvider.java
@@ -1,111 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.spi;
-
-import java.util.Properties;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.cfg.Environment;
-import org.hibernate.internal.util.StringHelper;
-import org.hibernate.internal.util.jndi.JndiHelper;
-
-import org.jboss.logging.Logger;
-
-/**
- * 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 CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
- AbstractJndiBoundCacheProvider.class.getName());
-
- 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, JndiHelper.extractJndiProperties( 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.unableToRetrieveCache(jndiNamespace, ne.getMessage());
- throw new CacheException( msg );
- }
- finally {
- if ( ctx != null ) {
- try {
- ctx.close();
- }
- catch( NamingException ne ) {
- LOG.unableToReleaseContext(ne.getMessage());
- }
- }
- }
- }
-
- public Object getCache() {
- return cache;
- }
-}
View
132 hibernate-core/src/main/java/org/hibernate/cache/spi/Cache.java
@@ -1,132 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.spi;
-
-import java.util.Map;
-
-import org.hibernate.cache.CacheException;
-
-/**
- * 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 org.hibernate.cache.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();
-}
-
-
-
-
-
-
View
197 hibernate-core/src/main/java/org/hibernate/cache/spi/CacheConcurrencyStrategy.java
@@ -1,197 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along 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.spi;
-
-import java.util.Comparator;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.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 org.hibernate.cache.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.
- */