├── .gitignore
├── CONTRIBUTING.md
├── README.md
├── build.gradle
├── build.gradle-4
├── build.properties.dist
├── changelog.txt
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lgpl.txt
├── libraries.gradle
└── src
├── docbook
└── reference
│ ├── .cvsignore
│ ├── README
│ ├── build.xml
│ ├── en
│ ├── images
│ │ └── hibernate_logo_a.png
│ ├── master.xml
│ ├── modules
│ │ ├── architecture.xml
│ │ ├── configuration.xml
│ │ ├── limitations.xml
│ │ ├── querying.xml
│ │ ├── resharding.xml
│ │ └── shardstrategy.xml
│ └── styles
│ │ ├── fopdf.xsl
│ │ ├── html.css
│ │ ├── html.xsl
│ │ └── html_chunk.xsl
│ └── fr
│ ├── images
│ └── hibernate_logo_a.png
│ ├── master.xml
│ ├── modules
│ ├── architecture.xml
│ ├── configuration.xml
│ ├── limitations.xml
│ ├── querying.xml
│ ├── resharding.xml
│ └── shardstrategy.xml
│ └── styles
│ ├── fopdf.xsl
│ ├── html.css
│ ├── html.xsl
│ └── html_chunk.xsl
├── main
└── java
│ └── org
│ └── hibernate
│ └── shards
│ ├── BaseHasShardIdList.java
│ ├── CrossShardAssociationException.java
│ ├── HasShardIdList.java
│ ├── Shard.java
│ ├── ShardId.java
│ ├── ShardImpl.java
│ ├── ShardOperation.java
│ ├── ShardedConfiguration.java
│ ├── ShardedTransaction.java
│ ├── cfg
│ ├── ConfigurationToShardConfigurationAdapter.java
│ ├── ShardConfiguration.java
│ └── ShardedEnvironment.java
│ ├── criteria
│ ├── AddCriterionEvent.java
│ ├── AddOrderEvent.java
│ ├── CreateAliasEvent.java
│ ├── CreateSubcriteriaEvent.java
│ ├── CriteriaEvent.java
│ ├── CriteriaFactory.java
│ ├── CriteriaFactoryImpl.java
│ ├── CriteriaId.java
│ ├── ExitOperationsCriteriaCollector.java
│ ├── InMemoryOrderBy.java
│ ├── SetCacheModeEvent.java
│ ├── SetCacheRegionEvent.java
│ ├── SetCacheableEvent.java
│ ├── SetCommentEvent.java
│ ├── SetFetchModeEvent.java
│ ├── SetFetchSizeEvent.java
│ ├── SetFirstResultEvent.java
│ ├── SetFlushModeEvent.java
│ ├── SetLockModeEvent.java
│ ├── SetMaxResultsEvent.java
│ ├── SetProjectionEvent.java
│ ├── SetReadOnlyEvent.java
│ ├── SetResultTransformerEvent.java
│ ├── SetTimeoutEvent.java
│ ├── ShardedCriteria.java
│ ├── ShardedCriteriaImpl.java
│ ├── ShardedSubcriteria.java
│ ├── ShardedSubcriteriaImpl.java
│ ├── SubcriteriaFactory.java
│ └── SubcriteriaFactoryImpl.java
│ ├── engine
│ ├── ShardedSessionFactoryImplementor.java
│ └── ShardedSessionImplementor.java
│ ├── id
│ ├── GeneratorRequiringControlSessionProvider.java
│ ├── ShardEncodingIdentifierGenerator.java
│ ├── ShardedTableHiLoGenerator.java
│ └── ShardedUUIDGenerator.java
│ ├── loadbalance
│ ├── BaseShardLoadBalancer.java
│ ├── RandomShardLoadBalancer.java
│ ├── RoundRobinShardLoadBalancer.java
│ └── ShardLoadBalancer.java
│ ├── package-info.java
│ ├── query
│ ├── AdHocQueryFactoryImpl.java
│ ├── ExitOperationsQueryCollector.java
│ ├── NamedQueryFactoryImpl.java
│ ├── QueryEvent.java
│ ├── QueryFactory.java
│ ├── QueryId.java
│ ├── QueryResult.java
│ ├── SetBigDecimalEvent.java
│ ├── SetBigIntegerEvent.java
│ ├── SetBinaryEvent.java
│ ├── SetBooleanEvent.java
│ ├── SetByteEvent.java
│ ├── SetCacheModeEvent.java
│ ├── SetCacheRegionEvent.java
│ ├── SetCacheableEvent.java
│ ├── SetCalendarDateEvent.java
│ ├── SetCalendarEvent.java
│ ├── SetCharacterEvent.java
│ ├── SetCommentEvent.java
│ ├── SetDateEvent.java
│ ├── SetDoubleEvent.java
│ ├── SetEntityEvent.java
│ ├── SetFetchSizeEvent.java
│ ├── SetFirstResultEvent.java
│ ├── SetFloatEvent.java
│ ├── SetFlushModeEvent.java
│ ├── SetIntegerEvent.java
│ ├── SetLocaleEvent.java
│ ├── SetLockModeEvent.java
│ ├── SetLockOptionsEvent.java
│ ├── SetLongEvent.java
│ ├── SetMaxResultsEvent.java
│ ├── SetParameterEvent.java
│ ├── SetParameterListEvent.java
│ ├── SetParametersEvent.java
│ ├── SetPropertiesEvent.java
│ ├── SetReadOnlyEvent.java
│ ├── SetResultTransformerEvent.java
│ ├── SetSerializableEvent.java
│ ├── SetShortEvent.java
│ ├── SetStringEvent.java
│ ├── SetTextEvent.java
│ ├── SetTimeEvent.java
│ ├── SetTimeoutEvent.java
│ ├── SetTimestampEvent.java
│ ├── ShardedQuery.java
│ ├── ShardedQueryImpl.java
│ ├── ShardedSQLQuery.java
│ └── ShardedSQLQueryImpl.java
│ ├── session
│ ├── BaseStatefulInterceptorFactory.java
│ ├── ControlSessionProvider.java
│ ├── CrossShardRelationshipDetectingInterceptor.java
│ ├── CrossShardRelationshipDetectingInterceptorDecorator.java
│ ├── DeleteOperation.java
│ ├── DisableFetchProfileOpenSessionEvent.java
│ ├── DisableFilterOpenSessionEvent.java
│ ├── EnableFetchProfileOpenSessionEvent.java
│ ├── EnableFilterOpenSessionEvent.java
│ ├── OpenSessionEvent.java
│ ├── RefreshOperation.java
│ ├── RequiresSession.java
│ ├── SaveOrUpdateOperation.java
│ ├── SetCacheModeOpenSessionEvent.java
│ ├── SetDefaultReadOnlyOpenSessionEvent.java
│ ├── SetFlushModeOpenSessionEvent.java
│ ├── SetReadOnlyOpenSessionEvent.java
│ ├── SetSessionOnRequiresSessionEvent.java
│ ├── SetupTransactionOpenSessionEvent.java
│ ├── ShardAware.java
│ ├── ShardAwareInterceptor.java
│ ├── ShardIdResolver.java
│ ├── ShardedSession.java
│ ├── ShardedSessionException.java
│ ├── ShardedSessionFactory.java
│ ├── ShardedSessionFactoryImpl.java
│ ├── ShardedSessionImpl.java
│ ├── StatefulInterceptorFactory.java
│ ├── SubsetShardedSessionFactoryImpl.java
│ └── UpdateOperation.java
│ ├── stat
│ └── ShardedSessionStatistics.java
│ ├── strategy
│ ├── ShardStrategy.java
│ ├── ShardStrategyFactory.java
│ ├── ShardStrategyImpl.java
│ ├── access
│ │ ├── LoadBalancedSequentialShardAccessStrategy.java
│ │ ├── ParallelShardAccessStrategy.java
│ │ ├── ParallelShardOperationCallable.java
│ │ ├── SequentialShardAccessStrategy.java
│ │ ├── ShardAccessStrategy.java
│ │ └── StartAwareFutureTask.java
│ ├── exit
│ │ ├── AggregateExitOperation.java
│ │ ├── AvgResultsExitOperation.java
│ │ ├── ConcatenateListsExitStrategy.java
│ │ ├── CountExitOperation.java
│ │ ├── DistinctExitOperation.java
│ │ ├── ExitOperation.java
│ │ ├── ExitOperationUtils.java
│ │ ├── ExitOperationsCollector.java
│ │ ├── ExitStrategy.java
│ │ ├── FirstNonNullResultExitStrategy.java
│ │ ├── FirstResultExitOperation.java
│ │ ├── MaxResultsExitOperation.java
│ │ ├── OrderExitOperation.java
│ │ ├── ProjectionExitOperation.java
│ │ ├── ProjectionExitOperationFactory.java
│ │ ├── RowCountExitOperation.java
│ │ └── ShardedAvgExitOperation.java
│ ├── resolution
│ │ ├── AllShardsShardResolutionStrategy.java
│ │ ├── BaseShardResolutionStrategy.java
│ │ └── ShardResolutionStrategy.java
│ └── selection
│ │ ├── BaseShardSelectionStrategy.java
│ │ ├── LoadBalancedShardSelectionStrategy.java
│ │ ├── RoundRobinShardSelectionStrategy.java
│ │ ├── ShardResolutionStrategyData.java
│ │ ├── ShardResolutionStrategyDataImpl.java
│ │ └── ShardSelectionStrategy.java
│ ├── transaction
│ └── ShardedTransactionImpl.java
│ └── util
│ ├── InterceptorDecorator.java
│ ├── InterceptorList.java
│ ├── Iterables.java
│ ├── Lists.java
│ ├── Maps.java
│ ├── Pair.java
│ ├── Preconditions.java
│ ├── Sets.java
│ └── StringUtil.java
└── test
├── java
└── org
│ └── hibernate
│ └── shards
│ ├── BaseHasShardIdListTest.java
│ ├── InstanceShardStrategyImplTest.java
│ ├── PermutationHelper.java
│ ├── ShardDefaultMock.java
│ ├── ShardImplTest.java
│ ├── ShardOperationDefaultMock.java
│ ├── ShardedConfigurationTest.java
│ ├── ShardedSessionFactoryDefaultMock.java
│ ├── ShardedTransactionDefaultMock.java
│ ├── criteria
│ ├── AddCriterionEventTest.java
│ ├── AddOrderEventTest.java
│ ├── CreateAliasEventTest.java
│ ├── CreateSubcriteriaEventTest.java
│ ├── CriteriaEventDefaultMock.java
│ ├── CriteriaFactoryDefaultMock.java
│ ├── CriteriaFactoryImplTest.java
│ ├── InMemoryOrderByTest.java
│ ├── SetCacheModeEventTest.java
│ ├── SetCacheRegionEventTest.java
│ ├── SetCacheableEventTest.java
│ ├── SetCommentEventTest.java
│ ├── SetFetchModeEventTest.java
│ ├── SetFetchSizeEventTest.java
│ ├── SetFirstResultEventTest.java
│ ├── SetFlushModeEventTest.java
│ ├── SetLockModeEventTest.java
│ ├── SetMaxResultsEventTest.java
│ ├── SetProjectionEventTest.java
│ ├── SetResultTransformerEventTest.java
│ ├── SetTimeoutEventTest.java
│ ├── ShardedCriteriaDefaultMock.java
│ ├── ShardedCriteriaImplTest.java
│ ├── ShardedSubcriteriaImplTest.java
│ ├── SubcriteriaFactoryDefaultMock.java
│ └── SubcriteriaFactoryImplTest.java
│ ├── defaultmock
│ ├── ClassMetadataDefaultMock.java
│ ├── CriteriaDefaultMock.java
│ ├── EntityPersisterDefaultMock.java
│ ├── InterceptorDefaultMock.java
│ ├── QueryDefaultMock.java
│ ├── SessionDefaultMock.java
│ ├── SessionFactoryDefaultMock.java
│ ├── SessionImplementorDefaultMock.java
│ ├── ShardConfigurationDefaultMock.java
│ └── TypeDefaultMock.java
│ ├── engine
│ └── ShardedSessionImplementorDefaultMock.java
│ ├── example
│ ├── WeatherReport.java
│ └── WeatherReportApp.java
│ ├── id
│ ├── ShardedTableHiLoGeneratorTest.java
│ ├── ShardedUUIDGeneratorTest.java
│ └── UUIDBigIntGenerator.java
│ ├── integration
│ ├── BaseShardingIntegrationTestCase.java
│ ├── BaseShardingIntegrationTestCasePermutedIntegrationTest.java
│ ├── ConfigPermutedIntegrationTest.java
│ ├── DbAccessPermutedIntegrationTest.java
│ ├── IdGenType.java
│ ├── Permutation.java
│ ├── ShardAccessStrategyType.java
│ ├── id
│ │ └── IdGeneratorPermutedIntegrationTest.java
│ ├── model
│ │ ├── InterceptorBehaviorPermutedIntegrationTest.java
│ │ ├── MemoryLeakTest.java
│ │ ├── ModelCriteriaPermutedIntegrationTest.java
│ │ ├── ModelDataFactory.java
│ │ ├── ModelIntegrationTest.java
│ │ ├── ModelPermutedIntegrationTest.java
│ │ └── ModelQueryPermutedIntegrationTest.java
│ ├── package-info.java
│ └── platform
│ │ ├── BaseDatabasePlatform.java
│ │ ├── DatabasePlatform.java
│ │ ├── DatabasePlatformFactory.java
│ │ ├── hsql
│ │ └── HSQLDatabasePlatform.java
│ │ └── mysql
│ │ └── MySQLDatabasePlatform.java
│ ├── loadbalance
│ ├── RoundRobinShardLoadBalancerTest.java
│ └── ShardLoadBalancerDefaultMock.java
│ ├── model
│ ├── Building.java
│ ├── Elevator.java
│ ├── Escalator.java
│ ├── Floor.java
│ ├── IdIsBaseType.java
│ ├── Office.java
│ ├── Person.java
│ ├── Tenant.java
│ └── Window.java
│ ├── query
│ ├── QueryEventDefaultMock.java
│ ├── QueryFactoryDefaultMock.java
│ ├── SetBigDecimalEventTest.java
│ ├── SetBigIntegerEventTest.java
│ ├── SetBinaryEventTest.java
│ ├── SetBooleanEventTest.java
│ ├── SetByteEventTest.java
│ ├── SetCacheModeEventTest.java
│ ├── SetCacheRegionEventTest.java
│ ├── SetCacheableEventTest.java
│ ├── SetCalendarDateEventTest.java
│ ├── SetCalendarEventTest.java
│ ├── SetCharacterEventTest.java
│ ├── SetCommentEventTest.java
│ ├── SetDateEventTest.java
│ ├── SetDoubleEventTest.java
│ ├── SetEntityEventTest.java
│ ├── SetFetchSizeEventTest.java
│ ├── SetFirstResultEventTest.java
│ ├── SetFloatEventTest.java
│ ├── SetFlushModeEventTest.java
│ ├── SetIntegerEventTest.java
│ ├── SetLocaleEventTest.java
│ ├── SetLockModeEventTest.java
│ ├── SetLongEventTest.java
│ ├── SetMaxResultsEventTest.java
│ ├── SetParameterEventTest.java
│ ├── SetParameterListEventTest.java
│ ├── SetParametersEventTest.java
│ ├── SetPropertiesEventTest.java
│ ├── SetReadOnlyEventTest.java
│ ├── SetResultTransformerEventTest.java
│ ├── SetSerializableEventTest.java
│ ├── SetShortEventTest.java
│ ├── SetStringEventTest.java
│ ├── SetTextEventTest.java
│ ├── SetTimeEventTest.java
│ ├── SetTimeoutEventTest.java
│ ├── SetTimestampEventTest.java
│ └── ShardedQueryDefaultMock.java
│ ├── session
│ ├── CrossShardRelationshipDetectingInterceptorDecoratorTest.java
│ ├── CrossShardRelationshipDetectingInterceptorTest.java
│ ├── DisableFilterOpenSessionEventTest.java
│ ├── EnableFilterOpenSessionEventTest.java
│ ├── OpenSessionEventDefaultMock.java
│ ├── SetCacheModeOpenSessionEventTest.java
│ ├── SetFlushModeOpenSessionEventTest.java
│ ├── SetReadOnlyOpenSessionEventTest.java
│ ├── SetSessionOnRequiresSessionEventTest.java
│ ├── ShardAwareInterceptorTest.java
│ ├── ShardIdResolverDefaultMock.java
│ ├── ShardedSessionFactoryImplTest.java
│ └── ShardedSessionImplTest.java
│ ├── strategy
│ ├── ShardStrategyDefaultMock.java
│ ├── ShardStrategyFactoryDefaultMock.java
│ ├── access
│ │ ├── ParallelShardAccessStrategyTest.java
│ │ ├── ParallelShardOperationCallableTest.java
│ │ ├── ShardAccessStrategyDefaultMock.java
│ │ └── StartAwareFutureTaskTest.java
│ ├── exit
│ │ ├── AggregateExitOperationTest.java
│ │ ├── AvgResultsExitOperationTest.java
│ │ ├── ExitOperationUtilsTest.java
│ │ ├── ExitStrategyDefaultMock.java
│ │ ├── FirstNonNullResultExitStrategyTest.java
│ │ ├── FirstResultExitOperationTest.java
│ │ ├── MaxResultExitOperationTest.java
│ │ ├── OrderExitOperationTest.java
│ │ ├── ProjectionExitOperationFactoryTest.java
│ │ └── RowCountExitOperationTest.java
│ ├── resolution
│ │ ├── ShardResolutionStrategyDataDefaultMock.java
│ │ └── ShardResolutionStrategyDefaultMock.java
│ └── selection
│ │ ├── LoadBalancedShardSelectionStrategyTest.java
│ │ └── ShardSelectionStrategyDefaultMock.java
│ ├── transaction
│ └── ShardedTransactionImplTest.java
│ └── util
│ ├── DatabaseUtils.java
│ ├── JdbcStrategy.java
│ └── JdbcUtil.java
└── resources
├── log4j.properties
└── org
└── hibernate
└── shards
├── example
├── hibernate0.cfg.xml
├── hibernate1.cfg.xml
├── hibernate2.cfg.xml
└── weather.hbm.xml
└── integration
└── platform
├── hsql
└── config
│ ├── mappings-shardedTableHiLo.hbm.xml
│ ├── mappings-shardedUUID.hbm.xml
│ ├── mappings.hbm.xml
│ ├── shard0.hibernate.cfg.xml
│ ├── shard1.hibernate.cfg.xml
│ └── shard2.hibernate.cfg.xml
└── mysql
└── config
├── mappings-shardedTableHiLo.hbm.xml
├── mappings-shardedUUID.hbm.xml
├── mappings.hbm.xml
├── shard0.hibernate.cfg.xml
├── shard1.hibernate.cfg.xml
└── shard2.hibernate.cfg.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Typically *NIX text editors, by default, append '~' to files on saving to make backups
2 | *~
3 |
4 | # Gradle work directory
5 | .gradle
6 |
7 | # Build output directies
8 | /target
9 | */target
10 | /build
11 | */build
12 | testdb
13 |
14 | # IntelliJ specific files/directories
15 | out
16 | .idea
17 | *.ipr
18 | *.iws
19 | *.iml
20 | atlassian-ide-plugin.xml
21 |
22 | # Eclipse specific files/directories
23 | .classpath
24 | .project
25 | .settings
26 | .metadata
27 | bin
28 |
29 | # NetBeans specific files/directories
30 | .nbattrs
31 |
32 | # Miscellaneous
33 | *.log
34 | .clover
35 |
36 | # JBoss Transactions
37 | ObjectStore
38 |
39 | # Profiler and heap dumps
40 | *.jps
41 | *.hprof
42 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This repo holds the Hibernate Shards project which is no longer supported and therefore has been archived
2 |
--------------------------------------------------------------------------------
/build.properties.dist:
--------------------------------------------------------------------------------
1 | common.dir=.
2 | src.dir=src
3 | test.dir=test
4 | hibernate-core.home=../hibernate-3.2
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hibernate/hibernate-shards/487d9e672b1b388fdace42e55a9dce4f41574eb1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Sep 01 02:41:24 CST 2011
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip
7 |
--------------------------------------------------------------------------------
/src/docbook/reference/.cvsignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/src/docbook/reference/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/docbook/reference/en/images/hibernate_logo_a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hibernate/hibernate-shards/487d9e672b1b388fdace42e55a9dce4f41574eb1/src/docbook/reference/en/images/hibernate_logo_a.png
--------------------------------------------------------------------------------
/src/docbook/reference/fr/images/hibernate_logo_a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hibernate/hibernate-shards/487d9e672b1b388fdace42e55a9dce4f41574eb1/src/docbook/reference/fr/images/hibernate_logo_a.png
--------------------------------------------------------------------------------
/src/docbook/reference/fr/master.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hibernate/hibernate-shards/487d9e672b1b388fdace42e55a9dce4f41574eb1/src/docbook/reference/fr/master.xml
--------------------------------------------------------------------------------
/src/docbook/reference/fr/modules/architecture.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hibernate/hibernate-shards/487d9e672b1b388fdace42e55a9dce4f41574eb1/src/docbook/reference/fr/modules/architecture.xml
--------------------------------------------------------------------------------
/src/docbook/reference/fr/modules/querying.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hibernate/hibernate-shards/487d9e672b1b388fdace42e55a9dce4f41574eb1/src/docbook/reference/fr/modules/querying.xml
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/HasShardIdList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * Interface for objects that can provide a List of ShardIds.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | public interface HasShardIdList {
29 |
30 | /**
31 | * @return an unmodifiable list of {@link ShardId}s
32 | */
33 | List getShardIds();
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/ShardOperation.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards;
20 |
21 | /**
22 | * Simple interface used to reference something we can do against a {@link Shard}.
23 | *
24 | * @author maxr@google.com (Max Ross)
25 | */
26 | public interface ShardOperation {
27 |
28 | /**
29 | * @param shard the shard to execute against
30 | * @return the result of the operation
31 | */
32 | T execute(Shard shard);
33 |
34 | /**
35 | * @return the name of the operation (useful for logging and debugging)
36 | */
37 | String getOperationName();
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/ShardedTransaction.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards;
20 |
21 | import org.hibernate.Session;
22 | import org.hibernate.Transaction;
23 |
24 | /**
25 | * Simple interface to represent a shard-aware {@link Transaction}.
26 | *
27 | * @author Tomislav Nad
28 | */
29 | public interface ShardedTransaction extends Transaction {
30 |
31 | /**
32 | * If a new Session is opened while ShardedTransaction exists, this method is
33 | * called with the Session as argument. Implementations should set up a
34 | * transaction for this session and sync it with ShardedTransaction
35 | *
36 | * @param session the Session on which the Transaction should be setup
37 | */
38 | void setupTransaction(Session session);
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/AddCriterionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 | import org.hibernate.criterion.Criterion;
23 |
24 | /**
25 | * Event that allows a Criterion to be lazily added to a Criteria.
26 | * @see Criteria#add(Criterion)
27 | *
28 | * @author maxr@google.com (Max Ross)
29 | */
30 | class AddCriterionEvent implements CriteriaEvent {
31 |
32 | // the Criterion we're going to add when the event fires
33 | private final Criterion criterion;
34 |
35 | public AddCriterionEvent(Criterion criterion) {
36 | this.criterion = criterion;
37 | }
38 |
39 |
40 | public void onEvent(Criteria criteria) {
41 | criteria.add(criterion);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/AddOrderEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 | import org.hibernate.criterion.Order;
23 |
24 | /**
25 | * Event that allows an Order to be lazily added to a Criteria.
26 | * @see Criteria#addOrder(Order)
27 | *
28 | * @author maxr@google.com (Max Ross)
29 | */
30 | class AddOrderEvent implements CriteriaEvent {
31 |
32 | // the Order we're going to add when the event fires
33 | private final Order order;
34 |
35 | /**
36 | * Construct an AddOrderEvent
37 | *
38 | * @param order the Order we'll add when the event fires
39 | */
40 | public AddOrderEvent(Order order) {
41 | this.order = order;
42 | }
43 |
44 | public void onEvent(Criteria criteria) {
45 | criteria.addOrder(order);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/CreateSubcriteriaEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows a Subcriteria to be lazily added to a Criteria.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | public class CreateSubcriteriaEvent implements CriteriaEvent {
29 |
30 | private final SubcriteriaFactory subcriteriaFactory;
31 | private final ShardedSubcriteriaImpl.SubcriteriaRegistrar subcriteriaRegistrar;
32 |
33 | public CreateSubcriteriaEvent(SubcriteriaFactory subcriteriaFactory, ShardedSubcriteriaImpl.SubcriteriaRegistrar subcriteriaRegistrar) {
34 | this.subcriteriaFactory = subcriteriaFactory;
35 | this.subcriteriaRegistrar = subcriteriaRegistrar;
36 | }
37 |
38 | public void onEvent(Criteria criteria) {
39 | subcriteriaRegistrar.establishSubcriteria(criteria, subcriteriaFactory);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/CriteriaEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Interface for events that can be laziliy applied to a
25 | * {@link org.hibernate.Criteria}. Useful because we don't allocate a
26 | * {@link org.hibernate.Criteria} until we actually need it, and programmers
27 | * might be calling a variety of methods against the
28 | * {@link org.hibernate.shards.criteria.ShardedCriteria}
29 | * which need to be applied to the actual {@link org.hibernate.Criteria} once
30 | * the actual {@link org.hibernate.Criteria} when it is allocated.
31 | *
32 | * @author maxr@google.com (Max Ross)
33 | */
34 | public interface CriteriaEvent {
35 |
36 | /**
37 | * Apply the event
38 | *
39 | * @param criteria the Criteria to apply the event to
40 | */
41 | void onEvent(Criteria criteria);
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/CriteriaFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 | import org.hibernate.Session;
23 |
24 | /**
25 | * Factory that knows how to create a {@link Criteria} for a given {@link Session}
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | public interface CriteriaFactory {
30 |
31 | /**
32 | * Create a {@link Criteria} for the given {@link Session}
33 | *
34 | * @param session the {@link Session} to be used when creating the {@link Criteria}
35 | * @return a {@link Criteria} associated with the given {@link Session}
36 | */
37 | Criteria createCriteria(Session session);
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetCacheRegionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows the cache region of a {@link Criteria} to be set lazily.
25 | * @see Criteria#setCacheRegion(String)
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetCacheRegionEvent implements CriteriaEvent {
30 |
31 | // the cache region that we'll set on the Criteria when the event fires
32 | private final String cacheRegion;
33 |
34 | /**
35 | * Construct a CacheRegionEvent
36 | *
37 | * @param cacheRegion the cache region we'll set on the {@link Criteria}
38 | * when the event fires.
39 | */
40 | public SetCacheRegionEvent(String cacheRegion) {
41 | this.cacheRegion = cacheRegion;
42 | }
43 |
44 | public void onEvent(Criteria criteria) {
45 | criteria.setCacheRegion(cacheRegion);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetCacheableEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows the cacheability of a {@link Criteria} to be set lazily.
25 | * @see Criteria#setCacheable(boolean)
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetCacheableEvent implements CriteriaEvent {
30 |
31 | // the value to which we're going to set the cacheability of the Criteria
32 | // when the event fires
33 | private boolean cacheable;
34 |
35 | /**
36 | * Construct a SetCacheableEvent
37 | *
38 | * @param cacheable the value to which we'll set the cacheability when the event
39 | * fires
40 | */
41 | public SetCacheableEvent(boolean cacheable) {
42 | this.cacheable = cacheable;
43 | }
44 |
45 | public void onEvent(Criteria criteria) {
46 | criteria.setCacheable(cacheable);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetCommentEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows the comment of a {@link Criteria} to be set lazily.
25 | * @see Criteria#setComment(String)
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetCommentEvent implements CriteriaEvent {
30 |
31 | // the comment that we'll set on the Criteria when the event fires
32 | private final String comment;
33 |
34 | /**
35 | * Construct a SetCommentEvent
36 | *
37 | * @param comment the comment we'll set on the {@link Criteria}
38 | * when the event fires.
39 | */
40 | public SetCommentEvent(String comment) {
41 | this.comment = comment;
42 | }
43 |
44 | public void onEvent(Criteria criteria) {
45 | criteria.setComment(comment);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetFetchSizeEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows the fetch size of a {@link Criteria} to be set lazily.
25 | * @see Criteria#setFetchSize(int)
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetFetchSizeEvent implements CriteriaEvent {
30 |
31 | // the fetchSize we'll set on the Criteria when the event fires.
32 | private final int fetchSize;
33 |
34 | /**
35 | * Construct a SetFetchSizeEvent
36 | *
37 | * @param fetchSize the fetchSize that
38 | * we'll set on the {@link Criteria} when the event fires.
39 | */
40 | public SetFetchSizeEvent(int fetchSize) {
41 | this.fetchSize = fetchSize;
42 | }
43 |
44 | public void onEvent(Criteria criteria) {
45 | criteria.setFetchSize(fetchSize);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetFirstResultEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows the firstResult of a {@link Criteria} to be set lazily.
25 | * @see Criteria#setFirstResult(int)
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetFirstResultEvent implements CriteriaEvent {
30 |
31 | // the firstResult that we'll set on the Criteria when the event fires
32 | private final int firstResult;
33 |
34 | /**
35 | * Construct a SetFirstResultEvent
36 | *
37 | * @param firstResult the firstResult that
38 | * we'll set on the {@link Criteria} when the event fires.
39 | */
40 | public SetFirstResultEvent(int firstResult) {
41 | this.firstResult = firstResult;
42 | }
43 |
44 | public void onEvent(Criteria criteria) {
45 | criteria.setFirstResult(firstResult);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetReadOnlyEvent.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.criteria;
2 |
3 | import org.hibernate.Criteria;
4 |
5 | class SetReadOnlyEvent implements CriteriaEvent {
6 |
7 | private final boolean readOnly;
8 |
9 | public SetReadOnlyEvent(final boolean readOnly) {
10 | this.readOnly = readOnly;
11 | }
12 |
13 | @Override
14 | public void onEvent(final Criteria criteria) {
15 | criteria.setReadOnly(readOnly);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SetTimeoutEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Event that allows the timeout of a {@link Criteria} to be set lazily.
25 | * @see Criteria#setTimeout(int)
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetTimeoutEvent implements CriteriaEvent {
30 |
31 | // the timeout we'll set on the Criteria when the event fires.
32 | private final int timeout;
33 |
34 | /**
35 | * Constructs a SetTimeoutEvent
36 | *
37 | * @param timeout the timeout we'll set on the {@link Criteria} when the
38 | * event fires.
39 | */
40 | public SetTimeoutEvent(int timeout) {
41 | this.timeout = timeout;
42 | }
43 |
44 | public void onEvent(Criteria criteria) {
45 | criteria.setTimeout(timeout);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/ShardedCriteria.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Interface for a shard-aware {@link Criteria} implementation.
25 | * @see Criteria
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | public interface ShardedCriteria extends Criteria {
30 |
31 | /**
32 | * @return the CriteriaId of this ShardedCriteria instance.
33 | */
34 | CriteriaId getCriteriaId();
35 |
36 | /**
37 | *
38 | * @return the CriteriaFactory of this ShardedCriteria instance.
39 | */
40 | CriteriaFactory getCriteriaFactory();
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/ShardedSubcriteria.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 | import org.hibernate.impl.CriteriaImpl;
23 |
24 | /**
25 | * Interface describing a {@link CriteriaImpl.Subcriteria}
26 | * that is shard-aware. A ShardedSubcriteria must know how to provide
27 | * a reference to its parent {@link ShardedCriteria}.
28 | *
29 | * @author maxr@google.com (Max Ross)
30 | * @see CriteriaImpl.Subcriteria
31 | */
32 | interface ShardedSubcriteria extends Criteria {
33 |
34 | /**
35 | * @return the owning ShardedCriteria
36 | */
37 | ShardedCriteria getParentCriteria();
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/criteria/SubcriteriaFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.criteria;
20 |
21 | import org.hibernate.Criteria;
22 |
23 | /**
24 | * Interface describing an object tha knows how to create {@link Criteria}.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | public interface SubcriteriaFactory {
29 |
30 | /**
31 | * Create a sub {@link Criteria} with the given parent and events
32 | *
33 | * @param parent the parent
34 | * @param events the events to apply
35 | * @return a criteria with the given parent and events
36 | */
37 | Criteria createSubcriteria(Criteria parent, Iterable events);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/engine/ShardedSessionFactoryImplementor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.engine;
20 |
21 | import org.hibernate.engine.SessionFactoryImplementor;
22 | import org.hibernate.shards.ShardId;
23 | import org.hibernate.shards.session.ShardedSessionFactory;
24 |
25 | import java.util.Map;
26 | import java.util.Set;
27 |
28 | /**
29 | * Internal interface for implementors of ShardedSessionFactory
30 | *
31 | * @author Tomislav Nad
32 | */
33 | public interface ShardedSessionFactoryImplementor extends ShardedSessionFactory, SessionFactoryImplementor {
34 |
35 | Map> getSessionFactoryShardIdMap();
36 |
37 | boolean containsFactory(SessionFactoryImplementor factory);
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/engine/ShardedSessionImplementor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.engine;
20 |
21 | import org.hibernate.shards.Shard;
22 | import org.hibernate.shards.session.ShardedSession;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * Defines the internal contract between the ShardedSession and other
28 | * parts of Hibernate Shards.
29 | *
30 | * @author Tomislav Nad
31 | * @see ShardedSession the interface to the application
32 | * @see org.hibernate.shards.session.ShardedSessionImpl the actual implementation
33 | */
34 | public interface ShardedSessionImplementor {
35 |
36 | /**
37 | * Gets all the shards the ShardedSession is spanning.
38 | *
39 | * @return list of all shards the ShardedSession is associated with
40 | */
41 | List getShards();
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/id/GeneratorRequiringControlSessionProvider.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.id;
20 |
21 | import org.hibernate.shards.session.ControlSessionProvider;
22 |
23 | /**
24 | * @author maxr@google.com (Max Ross)
25 | */
26 | public interface GeneratorRequiringControlSessionProvider {
27 |
28 | void setControlSessionProvider(ControlSessionProvider provider);
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/id/ShardEncodingIdentifierGenerator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.id;
20 |
21 | import org.hibernate.id.IdentifierGenerator;
22 | import org.hibernate.shards.ShardId;
23 |
24 | import java.io.Serializable;
25 |
26 | /**
27 | * @author Tomislav Nad
28 | */
29 | public interface ShardEncodingIdentifierGenerator extends IdentifierGenerator {
30 |
31 | ShardId extractShardId(Serializable identifier);
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/loadbalance/ShardLoadBalancer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.loadbalance;
20 |
21 | import org.hibernate.shards.ShardId;
22 |
23 | /**
24 | * Describes a load balance for shards.
25 | * Implementations are expected to be threadsafe.
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | public interface ShardLoadBalancer {
30 |
31 | /**
32 | * @return the next ShardId
33 | */
34 | ShardId getNextShardId();
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/AdHocQueryFactoryImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | import org.hibernate.SQLQuery;
23 | import org.hibernate.Session;
24 |
25 | /**
26 | * @author Maulik Shah
27 | */
28 | public class AdHocQueryFactoryImpl implements QueryFactory {
29 |
30 | private final String queryString;
31 |
32 | public AdHocQueryFactoryImpl(final String queryString) {
33 | this.queryString = queryString;
34 | }
35 |
36 | @Override
37 | public Query createQuery(final Session session) {
38 | return session.createQuery(queryString);
39 | }
40 |
41 | @Override
42 | public SQLQuery createSQLQuery(final Session session) {
43 | return session.createSQLQuery(queryString);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/NamedQueryFactoryImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | import org.hibernate.SQLQuery;
23 | import org.hibernate.Session;
24 |
25 | /**
26 | * Facilitates use of named queries when using ShardedQuery.
27 | *
28 | * @author maxr@google.com (Max Ross)
29 | */
30 | public class NamedQueryFactoryImpl implements QueryFactory {
31 |
32 | private final String queryName;
33 |
34 | public NamedQueryFactoryImpl(final String queryName) {
35 | this.queryName = queryName;
36 | }
37 |
38 | @Override
39 | public Query createQuery(final Session session) {
40 | return session.getNamedQuery(queryName);
41 | }
42 |
43 | @Override
44 | public SQLQuery createSQLQuery(final Session session) {
45 | throw new UnsupportedOperationException("no such thing as named SQLQuery");
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/QueryEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 |
23 | /**
24 | * Interface for events that can be lazily applied to a
25 | * {@link org.hibernate.Query}. Useful because we don't allocate a
26 | * {@link org.hibernate.Query} until we actually need it, and programmers
27 | * might be calling a variety of methods against
28 | * {@link org.hibernate.shards.query.ShardedQueryImpl}
29 | * which need to be applied to the actual {@link org.hibernate.Query} when
30 | * it is allocated.
31 | *
32 | * @author Maulik Shah
33 | */
34 |
35 | public interface QueryEvent {
36 |
37 | /**
38 | * Apply the event
39 | *
40 | * @param query the Query to apply the event to
41 | */
42 | void onEvent(Query query);
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/QueryFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | import org.hibernate.SQLQuery;
23 | import org.hibernate.Session;
24 |
25 | /**
26 | * @author Maulik Shah
27 | */
28 | public interface QueryFactory {
29 |
30 | Query createQuery(Session session);
31 |
32 | SQLQuery createSQLQuery(Session session);
33 | }
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/QueryId.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | /**
22 | * @author Maulik Shah
23 | */
24 | public class QueryId {
25 |
26 | private final int id;
27 |
28 | public QueryId(int id) {
29 | this.id = id;
30 | }
31 |
32 | public int getId() {
33 | return id;
34 | }
35 |
36 | public boolean equals(Object o) {
37 | if (this == o) {
38 | return true;
39 | }
40 | if (!(o instanceof QueryId)) {
41 | return false;
42 | }
43 |
44 | final QueryId queryId = (QueryId) o;
45 |
46 | if (id != queryId.id) {
47 | return false;
48 | }
49 |
50 | return true;
51 | }
52 |
53 | public int hashCode() {
54 | return id;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetCacheModeEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.CacheMode;
22 | import org.hibernate.Query;
23 |
24 | /**
25 | * @author Maulik Shah
26 | */
27 | public class SetCacheModeEvent implements QueryEvent {
28 |
29 | private final CacheMode cacheMode;
30 |
31 | public SetCacheModeEvent(CacheMode cacheMode) {
32 | this.cacheMode = cacheMode;
33 | }
34 |
35 | public void onEvent(Query query) {
36 | query.setCacheMode(cacheMode);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetCacheRegionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetCacheRegionEvent implements QueryEvent {
26 |
27 | private final String cacheRegion;
28 |
29 | public SetCacheRegionEvent(String cacheRegion) {
30 | this.cacheRegion = cacheRegion;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setCacheRegion(cacheRegion);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetCacheableEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetCacheableEvent implements QueryEvent {
26 |
27 | private final boolean cacheable;
28 |
29 | public SetCacheableEvent(boolean cacheable) {
30 | this.cacheable = cacheable;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setCacheable(cacheable);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetCommentEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetCommentEvent implements QueryEvent {
26 |
27 | private final String comment;
28 |
29 | public SetCommentEvent(String comment) {
30 | this.comment = comment;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setComment(comment);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetFetchSizeEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetFetchSizeEvent implements QueryEvent {
26 |
27 | private final int fetchSize;
28 |
29 | public SetFetchSizeEvent(int fetchSize) {
30 | this.fetchSize = fetchSize;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setFetchSize(fetchSize);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetFirstResultEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetFirstResultEvent implements QueryEvent {
26 |
27 | private final int firstResult;
28 |
29 | public SetFirstResultEvent(int firstResult) {
30 | this.firstResult = firstResult;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setFirstResult(firstResult);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetFlushModeEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.FlushMode;
22 | import org.hibernate.Query;
23 |
24 | /**
25 | * @author Maulik Shah
26 | */
27 | public class SetFlushModeEvent implements QueryEvent {
28 |
29 | private final FlushMode flushMode;
30 |
31 | public SetFlushModeEvent(FlushMode flushMode) {
32 | this.flushMode = flushMode;
33 | }
34 |
35 | public void onEvent(Query query) {
36 | query.setFlushMode(flushMode);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetLockModeEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.LockMode;
22 | import org.hibernate.Query;
23 |
24 | /**
25 | * @author Maulik Shah
26 | */
27 | public class SetLockModeEvent implements QueryEvent {
28 |
29 | private final String alias;
30 | private final LockMode lockMode;
31 |
32 | public SetLockModeEvent(String alias, LockMode lockMode) {
33 | this.alias = alias;
34 | this.lockMode = lockMode;
35 | }
36 |
37 | public void onEvent(Query query) {
38 | query.setLockMode(alias, lockMode);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetLockOptionsEvent.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.query;
2 |
3 | import org.hibernate.LockOptions;
4 | import org.hibernate.Query;
5 |
6 | /**
7 | * @author Adriano Machado
8 | */
9 | public class SetLockOptionsEvent implements QueryEvent {
10 |
11 | private final LockOptions lockOptions;
12 |
13 | public SetLockOptionsEvent(final LockOptions lockOptions) {
14 | this.lockOptions = lockOptions;
15 | }
16 |
17 | @Override
18 | public void onEvent(final Query query) {
19 | query.setLockOptions(lockOptions);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetMaxResultsEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 |
23 | /**
24 | * @author Maulik Shah
25 | */
26 |
27 | public class SetMaxResultsEvent implements QueryEvent {
28 | private final int maxResults;
29 |
30 | public SetMaxResultsEvent(int maxResults) {
31 | this.maxResults = maxResults;
32 | }
33 |
34 | public void onEvent(Query query) {
35 | query.setMaxResults(maxResults);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetParametersEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | import org.hibernate.type.Type;
23 |
24 | /**
25 | * @author Maulik Shah
26 | */
27 | public class SetParametersEvent implements QueryEvent {
28 |
29 | private final Object[] values;
30 | private final Type[] types;
31 |
32 | public SetParametersEvent(Object[] values, Type[] types) {
33 | this.values = values;
34 | this.types = types;
35 | }
36 |
37 | public void onEvent(Query query) {
38 | query.setParameters(values, types);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetReadOnlyEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetReadOnlyEvent implements QueryEvent {
26 |
27 | private final boolean readOnly;
28 |
29 | public SetReadOnlyEvent(boolean readOnly) {
30 | this.readOnly = readOnly;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setReadOnly(readOnly);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetResultTransformerEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | import org.hibernate.transform.ResultTransformer;
23 |
24 | /**
25 | * @author Maulik Shah
26 | */
27 | public class SetResultTransformerEvent implements QueryEvent {
28 |
29 | private final ResultTransformer transformer;
30 |
31 | public SetResultTransformerEvent(ResultTransformer transformer) {
32 | this.transformer = transformer;
33 | }
34 |
35 | public void onEvent(Query query) {
36 | query.setResultTransformer(transformer);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/SetTimeoutEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 | /**
23 | * @author Maulik Shah
24 | */
25 | public class SetTimeoutEvent implements QueryEvent {
26 |
27 | private final int timeout;
28 |
29 | public SetTimeoutEvent(int timeout) {
30 | this.timeout = timeout;
31 | }
32 |
33 | public void onEvent(Query query) {
34 | query.setTimeout(timeout);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/ShardedQuery.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.Query;
22 |
23 | /**
24 | * ShardedQuery extends the Query interface to provide the ability to query
25 | * across shards.
26 | *
27 | * @author Maulik Shah
28 | * @see org.hibernate.Query
29 | */
30 |
31 | public interface ShardedQuery extends Query {
32 |
33 | QueryId getQueryId();
34 |
35 | QueryFactory getQueryFactory();
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/query/ShardedSQLQuery.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.query;
20 |
21 | import org.hibernate.SQLQuery;
22 |
23 | /**
24 | * @author aviadl@sentrigo.com (Aviad Lichtenstadt)
25 | */
26 | public interface ShardedSQLQuery extends ShardedQuery, SQLQuery {
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/BaseStatefulInterceptorFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.EmptyInterceptor;
22 |
23 | /**
24 | * @author maxr@google.com (Max Ross)
25 | */
26 | public abstract class BaseStatefulInterceptorFactory extends EmptyInterceptor implements StatefulInterceptorFactory {
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/ControlSessionProvider.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.engine.SessionImplementor;
22 |
23 | /**
24 | * Interface for any entity that can provide the control session.
25 | * Control session is used to access control (meta)data which usually lives on
26 | * only one shard.
27 | *
28 | * @author maxr@google.com (Max Ross)
29 | */
30 | public interface ControlSessionProvider {
31 |
32 | /**
33 | * Opens control session.
34 | *
35 | * @return control session
36 | */
37 | SessionImplementor openControlSession();
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/DeleteOperation.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.shards.Shard;
4 |
5 | interface DeleteOperation {
6 | void delete(Shard shard, Object object);
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/DisableFetchProfileOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.UnknownProfileException;
5 |
6 | /**
7 | * OpenSessionEvent which disables specified fetch profile.
8 | *
9 | * @author maxr@google.com (Max Ross)
10 | */
11 | class DisableFetchProfileOpenSessionEvent implements OpenSessionEvent {
12 |
13 | private final String name;
14 |
15 | public DisableFetchProfileOpenSessionEvent(final String name) {
16 | this.name = name;
17 | }
18 |
19 | @Override
20 | public void onOpenSession(final Session session) {
21 | try {
22 | session.disableFetchProfile(name);
23 | } catch(UnknownProfileException e) {
24 | throw new UnsupportedOperationException("fetch profile " + name + " is unknown to one session", e);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/DisableFilterOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * OpenSessionEvent which disables specified filter.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | class DisableFilterOpenSessionEvent implements OpenSessionEvent {
29 |
30 | private final String filterName;
31 |
32 | public DisableFilterOpenSessionEvent(final String filterName) {
33 | this.filterName = filterName;
34 | }
35 |
36 | @Override
37 | public void onOpenSession(final Session session) {
38 | session.disableFilter(filterName);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/EnableFetchProfileOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.Session;
4 | import org.hibernate.UnknownProfileException;
5 |
6 | class EnableFetchProfileOpenSessionEvent implements OpenSessionEvent {
7 |
8 | private final String name;
9 |
10 | public EnableFetchProfileOpenSessionEvent(final String name) {
11 | this.name = name;
12 | }
13 |
14 | @Override
15 | public void onOpenSession(final Session session) {
16 | try {
17 | session.enableFetchProfile(name);
18 | } catch(UnknownProfileException e) {
19 | throw new UnsupportedOperationException("fetch profile " + name + " is unknown to one session", e);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/EnableFilterOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * OpenSessionEvent which enables specified filter.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | class EnableFilterOpenSessionEvent implements OpenSessionEvent {
29 |
30 | private final String filterName;
31 |
32 | public EnableFilterOpenSessionEvent(final String filterName) {
33 | this.filterName = filterName;
34 | }
35 |
36 | @Override
37 | public void onOpenSession(final Session session) {
38 | session.enableFilter(filterName);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/OpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * Interface for events that can be laziliy applied to a {@link org.hibernate.Session}.
25 | * Useful because we don't allocate a {@link org.hibernate.Session} until we actually need it,
26 | * and programmers might be calling a variety of methods against the
27 | * {@link ShardedSession} which
28 | * need to be applied to the actual {@link org.hibernate.Session}
29 | * once the actual {@link org.hibernate.Session} is allocated.
30 | *
31 | * @author maxr@google.com (Max Ross)
32 | */
33 | public interface OpenSessionEvent {
34 |
35 | /**
36 | * Invokes any actions that have to occur when a session is opened.
37 | *
38 | * @param session Session which is being opened
39 | */
40 | void onOpenSession(Session session);
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/RefreshOperation.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.shards.Shard;
4 |
5 | interface RefreshOperation {
6 | void refresh(Shard shard, Object object);
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/RequiresSession.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * Interface describing an object that can have a Session set on it. This
25 | * is designed to be used in conjunction with stateful interceptors.
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | * @see StatefulInterceptorFactory
29 | */
30 | public interface RequiresSession {
31 | void setSession(Session session);
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SaveOrUpdateOperation.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.shards.Shard;
4 |
5 | interface SaveOrUpdateOperation {
6 |
7 | void saveOrUpdate(Shard shard, Object object);
8 |
9 | void merge(Shard shard, Object object);
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SetCacheModeOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.CacheMode;
22 | import org.hibernate.Session;
23 |
24 | /**
25 | * OpenSessionEvent which sets the CacheMode.
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetCacheModeOpenSessionEvent implements OpenSessionEvent {
30 |
31 | private final CacheMode cacheMode;
32 |
33 | public SetCacheModeOpenSessionEvent(CacheMode cacheMode) {
34 | this.cacheMode = cacheMode;
35 | }
36 |
37 | public void onOpenSession(Session session) {
38 | session.setCacheMode(cacheMode);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SetDefaultReadOnlyOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * OpenSessionEvent which sets specified entity's readOnly flag.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | class SetDefaultReadOnlyOpenSessionEvent implements OpenSessionEvent {
29 |
30 | private final boolean readOnly;
31 |
32 | public SetDefaultReadOnlyOpenSessionEvent(boolean readOnly) {
33 | this.readOnly = readOnly;
34 | }
35 |
36 | @Override
37 | public void onOpenSession(Session session) {
38 | session.setDefaultReadOnly(readOnly);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SetFlushModeOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.FlushMode;
22 | import org.hibernate.Session;
23 |
24 | /**
25 | * OpenSessionEvent which sets the FlushMode.
26 | *
27 | * @author maxr@google.com (Max Ross)
28 | */
29 | class SetFlushModeOpenSessionEvent implements OpenSessionEvent {
30 |
31 | private final FlushMode flushMode;
32 |
33 | public SetFlushModeOpenSessionEvent(FlushMode flushMode) {
34 | this.flushMode = flushMode;
35 | }
36 |
37 | public void onOpenSession(Session session) {
38 | session.setFlushMode(flushMode);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SetReadOnlyOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * OpenSessionEvent which sets specified entity's readOnly flag.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | class SetReadOnlyOpenSessionEvent implements OpenSessionEvent {
29 |
30 | private final Object entity;
31 |
32 | private final boolean readOnly;
33 |
34 | public SetReadOnlyOpenSessionEvent(Object entity, boolean readOnly) {
35 | this.entity = entity;
36 | this.readOnly = readOnly;
37 | }
38 |
39 | public void onOpenSession(Session session) {
40 | session.setReadOnly(entity, readOnly);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SetSessionOnRequiresSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 |
23 | /**
24 | * OpenSessionEvent which sets the provided Session on a RequiresSession.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | public class SetSessionOnRequiresSessionEvent implements OpenSessionEvent {
29 |
30 | private final RequiresSession requiresSession;
31 |
32 |
33 | public SetSessionOnRequiresSessionEvent(RequiresSession requiresSession) {
34 | this.requiresSession = requiresSession;
35 | }
36 |
37 | public void onOpenSession(Session session) {
38 | requiresSession.setSession(session);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/SetupTransactionOpenSessionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Session;
22 | import org.hibernate.shards.ShardedTransaction;
23 |
24 | /**
25 | * OpenSessionEvent which adds newly opened session to the specified
26 | * ShardedTransaction.
27 | *
28 | * @author Tomislav Nad
29 | */
30 | public class SetupTransactionOpenSessionEvent implements OpenSessionEvent {
31 |
32 | private final ShardedTransaction shardedTransaction;
33 |
34 | public SetupTransactionOpenSessionEvent(ShardedTransaction shardedTtransaction) {
35 | this.shardedTransaction = shardedTtransaction;
36 | }
37 |
38 | public void onOpenSession(Session session) {
39 | shardedTransaction.setupTransaction(session);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/ShardAware.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.shards.ShardId;
4 |
5 | /**
6 | * Copyright (C) 2007 Google Inc.
7 | *
8 | * This library is free software; you can redistribute it and/or modify it under
9 | * the terms of the GNU Lesser General Public License as published by the Free
10 | * Software Foundation; either version 2.1 of the License, or (at your option)
11 | * any later version.
12 | *
13 | * This library is distributed in the hope that it will be useful, but WITHOUT
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16 | * details.
17 | *
18 | * You should have received a copy of the GNU Lesser General Public License
19 | * along with this library; if not, write to the Free Software Foundation, Inc.,
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 | */
22 |
23 | /**
24 | * Describes an object that knows the id of the shard on which it lives.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | public interface ShardAware {
29 |
30 | void setShardId(ShardId shardId);
31 |
32 | ShardId getShardId();
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/ShardIdResolver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.shards.ShardId;
22 |
23 | /**
24 | * Interface for objects that are able to resolve shard of objects.
25 | *
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | interface ShardIdResolver {
29 |
30 | /**
31 | * Gets ShardId of the shard given object lives on.
32 | *
33 | * @param obj Object whose Shard should be resolved
34 | * @return ShardId of the shard the object lives on; null if shard could not be resolved
35 | */
36 | /*@Nullable*/ ShardId getShardIdForObject(Object obj);
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/ShardedSessionException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | /**
22 | * Main exception used in Hibernate Shards.
23 | *
24 | * @author maxr@google.com (Max Ross)
25 | */
26 | public class ShardedSessionException extends RuntimeException {
27 |
28 | public ShardedSessionException() {
29 | }
30 |
31 | public ShardedSessionException(String message) {
32 | super(message);
33 | }
34 |
35 | public ShardedSessionException(String message, Throwable cause) {
36 | super(message, cause);
37 | }
38 |
39 | public ShardedSessionException(Throwable cause) {
40 | super(cause);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/StatefulInterceptorFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.session;
20 |
21 | import org.hibernate.Interceptor;
22 |
23 | /**
24 | * Interface describing an object that knows how to create Interceptors.
25 | * Technically this is just an interceptor factory, but it is designed
26 | * to be used by clients who want to use stateful interceptors in conjunction
27 | * with sharded sessions. Clients should make sure their Interceptor
28 | * implementation implements this interface. Furthermore, if the
29 | * Interceptor implementation requires a reference to the Session, the
30 | * Interceptor returned by newInstance() should implement the {@link RequiresSession}
31 | * interface.
32 | *
33 | * @author maxr@google.com (Max Ross)
34 | */
35 | public interface StatefulInterceptorFactory {
36 | Interceptor newInstance();
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/session/UpdateOperation.java:
--------------------------------------------------------------------------------
1 | package org.hibernate.shards.session;
2 |
3 | import org.hibernate.shards.Shard;
4 |
5 | interface UpdateOperation {
6 |
7 | void update(Shard shard, Object object);
8 |
9 | void merge(Shard shard, Object object);
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/strategy/ShardStrategyFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.strategy;
20 |
21 | import org.hibernate.shards.ShardId;
22 |
23 | import java.util.List;
24 |
25 | /**
26 | * @author maxr@google.com (Max Ross)
27 | */
28 | public interface ShardStrategyFactory {
29 | ShardStrategy newShardStrategy(List shardIds);
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/strategy/access/ShardAccessStrategy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.strategy.access;
20 |
21 | import org.hibernate.shards.Shard;
22 | import org.hibernate.shards.ShardOperation;
23 | import org.hibernate.shards.strategy.exit.ExitOperationsCollector;
24 | import org.hibernate.shards.strategy.exit.ExitStrategy;
25 |
26 | import java.util.List;
27 |
28 | public interface ShardAccessStrategy {
29 | T apply(List shards, ShardOperation operation, ExitStrategy exitStrategy, ExitOperationsCollector exitOperationsCollector);
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/hibernate/shards/strategy/exit/ConcatenateListsExitStrategy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2007 Google Inc.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 |
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 |
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 | */
18 |
19 | package org.hibernate.shards.strategy.exit;
20 |
21 | import org.hibernate.shards.Shard;
22 | import org.hibernate.shards.util.Lists;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * Threadsafe ExistStrategy that concatenates all the lists that are added.
28 | *
29 | * @author maxr@google.com (Max Ross)
30 | */
31 | public class ConcatenateListsExitStrategy implements ExitStrategy> {
32 |
33 | private final List