├── .gitignore ├── LICENSE ├── README.md ├── build.bat ├── build.sh ├── core ├── pom.xml ├── spring-loadtime-weaving.bat └── src │ ├── main │ └── java │ │ └── com │ │ └── vladmihalcea │ │ └── hpjp │ │ └── hibernate │ │ ├── forum │ │ ├── Attachment.java │ │ ├── MediaType.java │ │ ├── Post.java │ │ ├── PostComment.java │ │ ├── PostDetails.java │ │ ├── Tag.java │ │ └── dto │ │ │ └── PostDTO.java │ │ └── type │ │ └── json │ │ └── model │ │ ├── BaseEntity.java │ │ ├── Event.java │ │ ├── Location.java │ │ ├── Participant.java │ │ └── Ticket.java │ └── test │ ├── java │ └── com │ │ └── vladmihalcea │ │ └── hpjp │ │ ├── hibernate │ │ ├── access │ │ │ └── property │ │ │ │ └── FluentApiPropertyAccessTest.java │ │ ├── association │ │ │ ├── AllAssociationTest.java │ │ │ ├── BidirectionalManyToManyExtraColumnsTest.java │ │ │ ├── BidirectionalManyToManyLinkEntityEmbeddableTest.java │ │ │ ├── BidirectionalManyToManyLinkEntityIdColumnsTest.java │ │ │ ├── BidirectionalManyToManyLinkEntityMapKeyJoinColumnTest.java │ │ │ ├── BidirectionalManyToManyLinkEntityOrderColumnTest.java │ │ │ ├── BidirectionalManyToManyLinkEntityTest.java │ │ │ ├── BidirectionalManyToManyListTest.java │ │ │ ├── BidirectionalManyToManyOrderColumnTest.java │ │ │ ├── BidirectionalManyToManySetTest.java │ │ │ ├── BidirectionalManyToManyTest.java │ │ │ ├── BidirectionalOneToManyJoinColumnTest.java │ │ │ ├── BidirectionalOneToManyMergeTest.java │ │ │ ├── BidirectionalOneToManyOrphanRemovalWithoutCascadeTest.java │ │ │ ├── BidirectionalOneToManySetTest.java │ │ │ ├── BidirectionalOneToManyTest.java │ │ │ ├── BidirectionalOneToManyUniquenessTest.java │ │ │ ├── BidirectionalOneToOneMapsIdStringTest.java │ │ │ ├── BidirectionalOneToOneMapsIdTest.java │ │ │ ├── BidirectionalOneToOneNPlusOneBytecodeEnhancementTest.java │ │ │ ├── BidirectionalOneToOneNPlusOneNonOptionalTest.java │ │ │ ├── BidirectionalOneToOneNPlusOneTest.java │ │ │ ├── BidirectionalOneToOneOptionalFalseEagerFetchingDefaultTest.java │ │ │ ├── BidirectionalOneToOneOptionalFalseLazyFetchingMapsIdTest.java │ │ │ ├── BidirectionalOneToOneOptionalTrueEagerFetchingDefaultTest.java │ │ │ ├── BidirectionalOneToOneOptionalTrueEagerFetchingMapsIdTest.java │ │ │ ├── BidirectionalOneToOneTest.java │ │ │ ├── ElementCollectionArrayTest.java │ │ │ ├── ElementCollectionListMergeTest.java │ │ │ ├── ElementCollectionListOrderColumnTest.java │ │ │ ├── ElementCollectionListTest.java │ │ │ ├── ElementCollectionNestedTest.java │ │ │ ├── ElementCollectionSetMergeTest.java │ │ │ ├── ElementCollectionSetTest.java │ │ │ ├── ElementCollectionSortedSetMergeTest.java │ │ │ ├── ElementCollectionWithCollectionTableTest.java │ │ │ ├── LazyToOneFalseTest.java │ │ │ ├── LazyToOneNoProxyTest.java │ │ │ ├── LazyToOneProxyTest.java │ │ │ ├── ManyToOneJoinColumnNonPKTest.java │ │ │ ├── ManyToOneTest.java │ │ │ ├── MultiLevelOneToManyTest.java │ │ │ ├── OneToOneIdTest.java │ │ │ ├── OneToOneInsertableUpdatableFalseTest.java │ │ │ ├── OneToOneJoinColumnWithoutMapsIdTest.java │ │ │ ├── OneToOneMapsIdJoinColumnTest.java │ │ │ ├── OneToOneMapsIdTest.java │ │ │ ├── TwoMapsIdsTest.java │ │ │ ├── UnidirectionalManyAsOneToManyExtraColumnsTest.java │ │ │ ├── UnidirectionalManyToManySetTest.java │ │ │ ├── UnidirectionalManyToManySortedSetTest.java │ │ │ ├── UnidirectionalManyToManyTest.java │ │ │ ├── UnidirectionalOneToManyJoinColumnAndOrderColumnTest.java │ │ │ ├── UnidirectionalOneToManyJoinColumnNotNullTest.java │ │ │ ├── UnidirectionalOneToManyJoinColumnSetTest.java │ │ │ ├── UnidirectionalOneToManyJoinColumnTest.java │ │ │ ├── UnidirectionalOneToManySetIdEqualsTest.java │ │ │ ├── UnidirectionalOneToManySetTest.java │ │ │ ├── UnidirectionalOneToManyTest.java │ │ │ ├── UnidirectionalOneToOneTest.java │ │ │ └── UnidirectionalOrderedOneToManyTest.java │ │ ├── audit │ │ │ ├── envers │ │ │ │ ├── EnversAuditedDefaultStrategyTest.java │ │ │ │ ├── EnversAuditedValidityStrategyTest.java │ │ │ │ └── EnversBatchInsertTest.java │ │ │ ├── hibernate │ │ │ │ ├── LoadEventListenerTest.java │ │ │ │ ├── listener │ │ │ │ │ ├── AuditLogPostLoadEventListener.java │ │ │ │ │ └── EventListenerIntegrator.java │ │ │ │ └── model │ │ │ │ │ ├── Auditable.java │ │ │ │ │ ├── LoadEventLogEntry.java │ │ │ │ │ ├── LoggedUser.java │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ └── PostCommentDetails.java │ │ │ └── trigger │ │ │ │ ├── MySQLTriggerBasedAuditedTest.java │ │ │ │ ├── MySQLTriggerBasedJsonAuditLogTest.java │ │ │ │ ├── PostgreSQLTriggerBasedJsonAuditLogTest.java │ │ │ │ ├── SQLServerTriggerBasedJsonAuditLogTest.java │ │ │ │ └── YugabyteDBTriggerBasedJsonAuditLogTest.java │ │ ├── basic │ │ │ ├── DefaultTimestampTest.java │ │ │ └── MySQLBinaryTest.java │ │ ├── batch │ │ │ ├── BatchMergeVsUpdateTest.java │ │ │ ├── BatchTest.java │ │ │ ├── BatchingOptimisticLockingTest.java │ │ │ ├── BatchingTest.java │ │ │ ├── DeletingWithSQLCascadeBatchingTest.java │ │ │ ├── DeletingWithoutCascadeBatchingTest.java │ │ │ ├── MySQLBatchInsertLoadTest.java │ │ │ ├── MySQLBatchRewriteTest.java │ │ │ ├── OracleVersionedBatchingTest.java │ │ │ ├── PersistenceContextExtendedBatchTest.java │ │ │ ├── PostgreSQLBatchRewriteTest.java │ │ │ ├── SQLServerBulkCopyForBatchInsertTest.java │ │ │ ├── StatelessSessionBatchingTest.java │ │ │ ├── VersionedBatchingTest.java │ │ │ ├── failure │ │ │ │ ├── AbstractBatchUpdateExceptionTest.java │ │ │ │ ├── MySQLBatchUpdateExceptionTest.java │ │ │ │ ├── OracleBatchUpdateExceptionTest.java │ │ │ │ ├── PostgreSQLBatchUpdateExceptionTest.java │ │ │ │ └── SQLServerBatchUpdateExceptionTest.java │ │ │ └── identity │ │ │ │ ├── IdentityBatchingTest.java │ │ │ │ └── stateless │ │ │ │ ├── MySQLIdentityStatelessSessionTest.java │ │ │ │ ├── NoIdentityGenerator.java │ │ │ │ └── model │ │ │ │ ├── AbstractPost.java │ │ │ │ ├── BatchInsertPost.java │ │ │ │ └── Post.java │ │ ├── binding │ │ │ ├── EntityBindingTest.java │ │ │ └── ParameterBindingTest.java │ │ ├── bootstrap │ │ │ ├── AbstractJPAProgrammaticBootstrapTest.java │ │ │ └── BootstrapTest.java │ │ ├── bulk │ │ │ └── JPQLBulkUpdateDeleteTest.java │ │ ├── bytecode │ │ │ ├── BytecodeEnhancedOneToOneTest.java │ │ │ ├── BytecodeEnhancedTest.java │ │ │ ├── BytecodeEnhancementBidirectionalOneToManyAssociationManagementTest.java │ │ │ ├── BytecodeEnhancementBidirectionalOneToOneAssociationManagementTest.java │ │ │ └── BytecodeEnhancementDirtyCheckingTest.java │ │ ├── cache │ │ │ ├── CollectionCacheTest.java │ │ │ ├── CollectionLoadedStateTest.java │ │ │ ├── EntityCacheEntryLoadedStateTest.java │ │ │ ├── EntityCacheEntryReferenceTest.java │ │ │ ├── EntityNullResultCacheTest.java │ │ │ ├── InheritanceCacheTest.java │ │ │ ├── JPACacheableTest.java │ │ │ ├── LoadedStateBenchmarkTest.java │ │ │ ├── LoadedStateReferenceEntitiesTest.java │ │ │ ├── QueryLoadedStateTest.java │ │ │ ├── nonstrictreadwrite │ │ │ │ ├── NonStrictReadWriteCacheConcurrencyStrategyTest.java │ │ │ │ └── NonStrictReadWriteCacheConcurrencyStrategyWithConcurrentUpdateTest.java │ │ │ ├── query │ │ │ │ ├── PostCommentSummary.java │ │ │ │ ├── PostSummary.java │ │ │ │ ├── QueryCacheDTOTest.java │ │ │ │ ├── QueryCacheNPlus1Test.java │ │ │ │ └── QueryCacheTest.java │ │ │ ├── readonly │ │ │ │ ├── IdentityReadOnlyCacheConcurrencyStrategyTest.java │ │ │ │ ├── ReadOnlyCacheConcurrencyStrategyImmutableTest.java │ │ │ │ ├── ReadOnlyCacheConcurrencyStrategyTest.java │ │ │ │ └── SequenceReadOnlyCacheConcurrencyStrategyTest.java │ │ │ ├── readwrite │ │ │ │ ├── IdentityReadWriteCacheConcurrencyStrategyTest.java │ │ │ │ ├── ReadWriteCacheConcurrencyStrategyTest.java │ │ │ │ ├── ReadWriteCacheConcurrencyStrategyWithLockTimeoutTest.java │ │ │ │ ├── RepositoryReadWriteCacheConcurrencyStrategyTest.java │ │ │ │ └── SequenceReadWriteCacheConcurrencyStrategyTest.java │ │ │ └── transactional │ │ │ │ ├── assigned │ │ │ │ ├── TransactionalCacheConcurrencyStrategyTest.java │ │ │ │ ├── TransactionalCacheConcurrencyStrategyTestConfiguration.java │ │ │ │ └── TransactionalEntities.java │ │ │ │ └── identity │ │ │ │ ├── IdentityTransactionalCacheConcurrencyStrategyTest.java │ │ │ │ ├── IdentityTransactionalCacheConcurrencyStrategyTestConfiguration.java │ │ │ │ └── IdentityTransactionalEntities.java │ │ ├── cascade │ │ │ └── CascadeTest.java │ │ ├── concurrency │ │ │ ├── AbstractEntityOptimisticLockingCollectionTest.java │ │ │ ├── AbstractLockModeOptimisticTest.java │ │ │ ├── AllPropertiesOptimisticLockingTest.java │ │ │ ├── BulkUpdateOptimisticLockingIntegerVersionTest.java │ │ │ ├── BulkUpdateOptimisticLockingShortVersionTest.java │ │ │ ├── CascadeLockElementCollectionTest.java │ │ │ ├── CascadeLockManyToOneTest.java │ │ │ ├── CascadeLockTest.java │ │ │ ├── CascadeLockUnidirectionalOneToManyTest.java │ │ │ ├── DefaultOptimisticLockingTest.java │ │ │ ├── EntityFirstLevelCacheReuseTest.java │ │ │ ├── EntityOptimisticLockingOnBidirectionalChildOwningCollectionTest.java │ │ │ ├── EntityOptimisticLockingOnBidirectionalParentOwningCollectionTest.java │ │ │ ├── EntityOptimisticLockingOnComponentCollectionTest.java │ │ │ ├── EntityOptimisticLockingOnUnidirectionalCollectionTest.java │ │ │ ├── EntityOptimisticLockingOverruleOnBidirectionalParentOwningCollectionTest.java │ │ │ ├── FollowOnLockingTest.java │ │ │ ├── LockModeOptimisticForceIncrementTest.java │ │ │ ├── LockModeOptimisticRaceConditionTest.java │ │ │ ├── LockModeOptimisticTest.java │ │ │ ├── LockModeOptimisticWithPessimisticLockUpgradeTest.java │ │ │ ├── LockModePessimisticForceIncrementTest.java │ │ │ ├── LockModePessimisticReadWriteTest.java │ │ │ ├── NoWaitTest.java │ │ │ ├── OptimisticLockingAggregateRootVersionTest.java │ │ │ ├── OptimisticLockingBidirectionalChildUpdatesRootVersionTest.java │ │ │ ├── OptimisticLockingContractTest.java │ │ │ ├── OptimisticLockingOneRootDirtyVersioningSelectBeforeUpdateTest.java │ │ │ ├── OptimisticLockingOneRootDirtyVersioningTest.java │ │ │ ├── OptimisticLockingOneRootEntityMultipleVersionsTest.java │ │ │ ├── OptimisticLockingOneRootOneVersionTest.java │ │ │ ├── OptimisticLockingRepeatableReadTest.java │ │ │ ├── SkipLockJobQueueTest.java │ │ │ ├── VersionWrapperOptimisticLockingTest.java │ │ │ ├── acid │ │ │ │ ├── ACIDRaceConditionIsolationLevelTest.java │ │ │ │ ├── ACIDRaceConditionTest.java │ │ │ │ ├── Account.java │ │ │ │ └── check │ │ │ │ │ ├── ACIDRaceConditionPositiveBalanceCheckFirstOperationTest.java │ │ │ │ │ └── ACIDRaceConditionPositiveBalanceCheckLastOperationTest.java │ │ │ ├── deadlock │ │ │ │ ├── DeadLockTest.java │ │ │ │ ├── SQLServerDeadLockTest.java │ │ │ │ └── fk │ │ │ │ │ ├── MySQLFKNoParentLockRRTest.java │ │ │ │ │ ├── MySQLFKNoParentLockSerializableTest.java │ │ │ │ │ ├── OracleNoFKNoParentLockSerializableTest.java │ │ │ │ │ ├── PostgreSQLNoFKNoParentLockRRTest.java │ │ │ │ │ ├── SQLServerFKParentLockRCSITest.java │ │ │ │ │ └── SQLServerNoFKParentLockRCSIDynamicUpdateTest.java │ │ │ ├── latch │ │ │ │ └── CountDownLatchTest.java │ │ │ ├── linearizable │ │ │ │ └── JavaLinearizableTest.java │ │ │ ├── updates │ │ │ │ ├── PostgreSQLRowLevelLockingTest.java │ │ │ │ ├── YugabyteDBColumnLevelLockingDefaultUpdateTest.java │ │ │ │ ├── YugabyteDBColumnLevelLockingReadCommittedTest.java │ │ │ │ └── YugabyteDBColumnLevelLockingTest.java │ │ │ ├── upsert │ │ │ │ └── SQLServerUpsertAlternativeTest.java │ │ │ └── version │ │ │ │ ├── DefaultMinValueShortVersionTest.java │ │ │ │ ├── DefaultMinValueVersionTest.java │ │ │ │ ├── MinValueIntegerVersionTest.java │ │ │ │ ├── MinValueVersionTest.java │ │ │ │ ├── ShortVersionType.java │ │ │ │ ├── TimestampVersionTest.java │ │ │ │ └── VersionTest.java │ │ ├── connection │ │ │ ├── AbstractConnectionProviderTest.java │ │ │ ├── C3P0ConnectionProviderTest.java │ │ │ ├── C3P0JPAConnectionProviderTest.java │ │ │ ├── DataSourceProxyConnectionProvider.java │ │ │ ├── DriverManagerConnectionProviderJakartaTest.java │ │ │ ├── DriverManagerConnectionProviderTest.java │ │ │ ├── FlexyPoolTest.java │ │ │ ├── FlexyPoolTestConfiguration.java │ │ │ ├── HikariCPConnectionProviderTest.java │ │ │ ├── HikariConnectionThreadBoundTest.java │ │ │ ├── JPADataSourceConnectionProviderTest.java │ │ │ ├── JPADataSourceProxyConnectionProviderTest.java │ │ │ ├── JPADriverConnectionProviderTest.java │ │ │ ├── ResourceLocalDelayConnectionAcquisitionTest.java │ │ │ ├── SessionDoWorkTest.java │ │ │ ├── UserSuppliedConnectionProviderTest.java │ │ │ └── jta │ │ │ │ ├── AtomikosJTAConnectionReleaseConfiguration.java │ │ │ │ ├── FlexyPoolEntities.java │ │ │ │ ├── HandlingModeJTAConnectionReleaseConfiguration.java │ │ │ │ ├── HandlingModeJtaConnectionReleaseTest.java │ │ │ │ ├── JTAConnectionReleaseTest.java │ │ │ │ ├── JTAConnectionThreadBoundTest.java │ │ │ │ └── NarayanaJTAConnectionReleaseConfiguration.java │ │ ├── criteria │ │ │ ├── CriteriaBulkUpdateDeleteTest.java │ │ │ ├── CriteriaCountGroupByTest.java │ │ │ ├── TupleTest.java │ │ │ ├── blaze │ │ │ │ ├── BlazePersistenceCriteriaTest.java │ │ │ │ ├── Post.java │ │ │ │ ├── PostComment.java │ │ │ │ ├── bulk │ │ │ │ │ ├── BlazePersistenceBulkUpdateDeleteTest.java │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── PostModerate.java │ │ │ │ │ └── PostStatus.java │ │ │ │ └── tab │ │ │ │ │ ├── AbstractEntity.java │ │ │ │ │ ├── BlazePersistenceTabInstanceTest-new.sql │ │ │ │ │ ├── BlazePersistenceTabInstanceTest-old.sql │ │ │ │ │ ├── BlazePersistenceTabInstanceTest.java │ │ │ │ │ ├── TabInstance.java │ │ │ │ │ ├── TabInstancePK.java │ │ │ │ │ ├── TabObject.java │ │ │ │ │ ├── TabSource.java │ │ │ │ │ ├── TabVersion.java │ │ │ │ │ └── cte │ │ │ │ │ └── TabKeyVer.java │ │ │ └── literal │ │ │ │ ├── BindCriteriaLiteralTest.java │ │ │ │ ├── DefaultCriteriaLiteralTest.java │ │ │ │ └── InlineCriteriaLiteralTest.java │ │ ├── equality │ │ │ ├── AbstractEqualityCheckTest.java │ │ │ ├── DefaultEqualityTest.java │ │ │ ├── DefaultIdEqualityTest.java │ │ │ ├── IdEqualityParentChildTest.java │ │ │ ├── IdEqualityTest.java │ │ │ ├── IdWasNullEqualityTest.java │ │ │ ├── NaturalIdEqualityTest.java │ │ │ └── UUIDEqualityTest.java │ │ ├── fetching │ │ │ ├── BatchSizeCollectionTest.java │ │ │ ├── CriteriaAPIEntityTypeJoinedTest.java │ │ │ ├── CriteriaAPIEntityTypeTest.java │ │ │ ├── CriteriaAPIMemberOfTest.java │ │ │ ├── CriteriaAPITest.java │ │ │ ├── DistinctTest.java │ │ │ ├── EagerFetchingCollectionsFindVsQueryTest.java │ │ │ ├── EagerFetchingCollectionsQueryTest.java │ │ │ ├── EagerFetchingManyToOneEntityGraphTest.java │ │ │ ├── EagerFetchingManyToOneTest.java │ │ │ ├── EntityGraphEagerPostTest.java │ │ │ ├── EntityGraphTest.java │ │ │ ├── ExtraLazyCollectionTest.java │ │ │ ├── FetchAllAssociationsTest.java │ │ │ ├── FetchTypeEagerManyToOneEntityGraphTest.java │ │ │ ├── FindByMultipleIdsTest.java │ │ │ ├── FindEntityTest.java │ │ │ ├── FindVsGetReferenceTest.java │ │ │ ├── GroupByMapTest.java │ │ │ ├── HibernateInitializeTest.java │ │ │ ├── HibernateProxyTest.java │ │ │ ├── LazyAttributeTest.java │ │ │ ├── LazyAttributeWithMultipleEntitiesTest.java │ │ │ ├── LazyFetchingManyToOneFindEntityTest.java │ │ │ ├── LazyInitializationExceptionFixTest.java │ │ │ ├── LazyInitializationExceptionFixWithDTOTest.java │ │ │ ├── LazyInitializationExceptionTest.java │ │ │ ├── LazyInitializationOutsideTransactionTest.java │ │ │ ├── MySQLScrollableResultsNoStreamingTest.java │ │ │ ├── MySQLScrollableResultsStreamingCustomFetchSizeTest.java │ │ │ ├── MySQLScrollableResultsStreamingTest.java │ │ │ ├── NPlusOneEagerFetchingManyToOneFindEntityTest.java │ │ │ ├── NPlusOneLazyFetchingManyToOneFindEntityTest.java │ │ │ ├── NPlusOneLazyFetchingWithSubselectManyToOneFindEntityTest.java │ │ │ ├── NPlusOneManyToOneEagerTechingTest.java │ │ │ ├── NPlusOneSQLFetchingFKTest.java │ │ │ ├── NamedNativeQueryParameterTest.java │ │ │ ├── NamedQueryPerformanceTest.java │ │ │ ├── NativeQueryTest.java │ │ │ ├── NaturalIdTest.java │ │ │ ├── PlanCacheSizePerformanceTest.java │ │ │ ├── PostCommentDTO.java │ │ │ ├── PostCommentSummary.java │ │ │ ├── PostgreSQLScrollableResultsStreamingTest.java │ │ │ ├── ProjectionTest.java │ │ │ ├── detector │ │ │ │ ├── AssociationFetch.java │ │ │ │ ├── AssociationFetchLoadEventListener.java │ │ │ │ ├── AssociationFetchPostLoadEventListener.java │ │ │ │ ├── AssociationFetchPreLoadEventListener.java │ │ │ │ ├── AssociationFetchingEventListenerIntegrator.java │ │ │ │ ├── EagerFetchingDetectorTest.java │ │ │ │ └── SessionStatistics.java │ │ │ ├── file │ │ │ │ └── PostgreSQLCopyQueryResultSetToFileTest.java │ │ │ ├── maxrows │ │ │ │ ├── MySQLSetMaxRowsTest.java │ │ │ │ ├── OracleSetMaxRowsTest.java │ │ │ │ ├── PostgreSQLSetMaxRowsTest.java │ │ │ │ └── SQLServerSetMaxRowsTest.java │ │ │ ├── multiple │ │ │ │ ├── CriteriaAPIFetchingTest.java │ │ │ │ ├── EagerFetchingMultipleBagLazyCollectionOptionTest.java │ │ │ │ ├── EagerFetchingMultipleBagTest.java │ │ │ │ ├── EagerFetchingMultipleSetTest.java │ │ │ │ ├── EagerFetchingMultipleToOneTest.java │ │ │ │ └── MultiLevelCollectionFetchingTest.java │ │ │ └── pagination │ │ │ │ ├── DistinctPostResultTransformer.java │ │ │ │ ├── FailOnPaginationWithCollectionFetchTest.java │ │ │ │ ├── PaginationTest.java │ │ │ │ ├── Post.java │ │ │ │ ├── PostComment.java │ │ │ │ └── blaze │ │ │ │ └── BlazeKeysetPaginationTest.java │ │ ├── flushing │ │ │ ├── AlwaysFlushTest.java │ │ │ ├── BatchProcessingArticleTest.java │ │ │ ├── BatchProcessingTest.java │ │ │ ├── BytecodeEnhancementDirtyCheckingPerformanceTest.java │ │ │ ├── CommitFlushTest.java │ │ │ ├── DefaultDirtyCheckingPerformanceTest.java │ │ │ ├── HibernateAlwaysFlushConfigurationPropertyTest.java │ │ │ ├── HibernateAutoFlushTest.java │ │ │ ├── HibernateDeleteEntityTest.java │ │ │ ├── HibernateSaveSequenceTest.java │ │ │ ├── JPAAutoFlushTest.java │ │ │ ├── JPARemoveEntityTest.java │ │ │ ├── ManualFlushTest.java │ │ │ ├── PersistIdentityTest.java │ │ │ ├── PersistSequenceTest.java │ │ │ ├── ReadOnlyQueryTest.java │ │ │ ├── RefreshTest.java │ │ │ ├── SessionAlwaysFlushTest.java │ │ │ └── order │ │ │ │ ├── FlushOrderBidirectionalOneToManyMergeTest.java │ │ │ │ └── FlushOrderTest.java │ │ ├── identifier │ │ │ ├── AbstractPooledSequenceIdentifierTest.java │ │ │ ├── AssignedIdentifierTest.java │ │ │ ├── AutoIdentifierMySQLTest.java │ │ │ ├── BaseClassIdentifierMySQLTest.java │ │ │ ├── EnhancedSequenceVsTableGeneratorTest.java │ │ │ ├── EntityIdentifierCockroachDBTest.java │ │ │ ├── EntityIdentifierTimestampCockroachDBTest.java │ │ │ ├── HiloIdentifierTest.java │ │ │ ├── HiloPooledDefaultSwitchTest.java │ │ │ ├── HiloPooledMigrationTest.java │ │ │ ├── Identifiable.java │ │ │ ├── LegacySequenceVsTableGeneratorTest.java │ │ │ ├── MySQLIdentityIdentifierTest.java │ │ │ ├── MySQLNativeIdentifierTest.java │ │ │ ├── OracleRowIdTest.java │ │ │ ├── PooledDefaultSequenceIdentifierTest.java │ │ │ ├── PooledLoSequenceIdentifierTest.java │ │ │ ├── PooledSequenceIdentifierTest.java │ │ │ ├── PostgreSQLSerialTest.java │ │ │ ├── PreferredPooledLoSequenceIdentifierTest.java │ │ │ ├── SQLServerScopeIdentity.java │ │ │ ├── SequenceVsTableGeneratorTest.java │ │ │ ├── SimpleSequenceIdentifierTest.java │ │ │ ├── SimpleTableIdentifierTest.java │ │ │ ├── StringSequenceIdentifier.java │ │ │ ├── StringSequenceIdentifierTest.java │ │ │ ├── access │ │ │ │ ├── EmbeddableAccessStrategyTest.java │ │ │ │ ├── EmbeddableCollectionAccessStrategyTest.java │ │ │ │ └── OverrideAccessStrategyTest.java │ │ │ ├── batch │ │ │ │ ├── AbstractBatchIdentifierTest.java │ │ │ │ ├── AssignedTableBatchIdentifierTest.java │ │ │ │ ├── AssignedTableGenerator.java │ │ │ │ ├── AutoIdentifierWithSequenceGeneratorTest.java │ │ │ │ ├── BatchSequenceIdentifierTest.java │ │ │ │ ├── IdentityIdentifierTest.java │ │ │ │ ├── MariaDBIdentifierTest.java │ │ │ │ ├── PooledLoGenericGeneratorIdentifierTest.java │ │ │ │ ├── PostgresTableGeneratorTest.java │ │ │ │ ├── SequenceAllocationSizeIdentifierTest.java │ │ │ │ ├── SequenceGeneratorIdentifierTest.java │ │ │ │ ├── SequenceIdentifierTest.java │ │ │ │ ├── TableAllocationSizeIdentifierTest.java │ │ │ │ ├── TableIdentifierTest.java │ │ │ │ ├── concurrent │ │ │ │ │ ├── ConcurrentBatchIdentifierTest.java │ │ │ │ │ └── providers │ │ │ │ │ │ ├── IdentityPostEntityProvider.java │ │ │ │ │ │ ├── PostEntityProvider.java │ │ │ │ │ │ ├── SequencePostEntityProvider.java │ │ │ │ │ │ └── TablePostEntityProvider.java │ │ │ │ └── jta │ │ │ │ │ ├── JTATableIdentifierTest.java │ │ │ │ │ ├── JTATableIdentifierTestConfiguration.java │ │ │ │ │ └── Post.java │ │ │ ├── composite │ │ │ │ ├── CompositeIdGeneratedIdClassTest.java │ │ │ │ ├── CompositeIdIdentityGeneratedTest.java │ │ │ │ ├── CompositeIdManyToOneTest.java │ │ │ │ ├── CompositeIdManyToOneWithCompanyInIdTest.java │ │ │ │ └── CompositeIdOneToOneTest.java │ │ │ ├── global │ │ │ │ ├── MySQLIdentifierTest.java │ │ │ │ ├── Post.java │ │ │ │ └── PostgreSQLIdentifierTest.java │ │ │ ├── globalsequence │ │ │ │ ├── GlobalIdentifierGeneratorScopeTest.java │ │ │ │ └── package-info.java │ │ │ ├── optimizer │ │ │ │ ├── SequenceOptimizerIdentifierTest.java │ │ │ │ └── providers │ │ │ │ │ ├── PostEntityProvider.java │ │ │ │ │ ├── Sequence10PostEntityProvider.java │ │ │ │ │ ├── Sequence1PostEntityProvider.java │ │ │ │ │ ├── Sequence50PostEntityProvider.java │ │ │ │ │ ├── Sequence5PostEntityProvider.java │ │ │ │ │ ├── Table10PostEntityProvider.java │ │ │ │ │ ├── Table1PostEntityProvider.java │ │ │ │ │ ├── Table50PostEntityProvider.java │ │ │ │ │ └── Table5PostEntityProvider.java │ │ │ ├── tsid │ │ │ │ └── TsidTest.java │ │ │ └── uuid │ │ │ │ ├── AssignedUUIDIdentifierTest.java │ │ │ │ ├── AutoUUIDIdentifierTest.java │ │ │ │ ├── PostgreSQLUUIDGenerationStrategy.java │ │ │ │ ├── PostgreSQLUUIDIdentifierTest.java │ │ │ │ ├── UUID2IdentifierTest.java │ │ │ │ └── UUIDIdentifierTest.java │ │ ├── index │ │ │ ├── DefaultDatabaseIndexTest.java │ │ │ ├── SQLServerSendStringParametersAsUnicodeComparisonTest.java │ │ │ └── postgres │ │ │ │ ├── Book.java │ │ │ │ ├── PostgreSQLBRINIndexTest.java │ │ │ │ ├── PostgreSQLBalancedTreeIndexTest.java │ │ │ │ ├── PostgreSQLGINIndexTest.java │ │ │ │ ├── PostgreSQLHashIndexTest.java │ │ │ │ └── hot │ │ │ │ ├── PostgreSQLCtidDefaultUpdateTest.java │ │ │ │ ├── PostgreSQLCtidTest.java │ │ │ │ ├── PostgreSQLCtidVersionIndexTest.java │ │ │ │ └── PostgreSQLHOTDynamicUpdateTest.java │ │ ├── inheritance │ │ │ ├── ImplicitPolymorphismTest.java │ │ │ ├── JoinedTableBulkDeleteTest.java │ │ │ ├── JoinedTableDiscriminatorColumnTest.java │ │ │ ├── JoinedTableDiscriminatorTest.java │ │ │ ├── JoinedTablePrimaryKeyJoinColumnTest.java │ │ │ ├── JoinedTableTest.java │ │ │ ├── MappedSuperclassTest.java │ │ │ ├── SingleTableCheckConstraintTest.java │ │ │ ├── SingleTableMySQLTriggerTest.java │ │ │ ├── SingleTableTest.java │ │ │ ├── SortIndexCollectionInheritance.java │ │ │ ├── TablePerClassMySQLUnionAllTest.java │ │ │ ├── TablePerClassMySQLUnionTest.java │ │ │ ├── TablePerClassTest.java │ │ │ ├── discriminator │ │ │ │ ├── CharDiscriminatorTest.java │ │ │ │ ├── DefaultDiscriminatorTest.java │ │ │ │ ├── DefaultIntegerDiscriminatorTest.java │ │ │ │ ├── JoinedStringDiscriminatorTest.java │ │ │ │ ├── JoinedStringWithoutDiscriminatorTest.java │ │ │ │ ├── MySQLIntegerDiscriminatorTest.java │ │ │ │ ├── PostgreSQLIntegerDiscriminatorTest.java │ │ │ │ ├── StringDiscriminatorTest.java │ │ │ │ └── description │ │ │ │ │ ├── Announcement.java │ │ │ │ │ ├── IntegerDiscriminatorDescriptionTest.java │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── Topic.java │ │ │ │ │ └── TopicType.java │ │ │ ├── embeddable │ │ │ │ └── EmbeddedInheritanceTest.java │ │ │ └── spring │ │ │ │ ├── BehaviorDrivenInheritanceTest.java │ │ │ │ ├── config │ │ │ │ └── BehaviorDrivenInheritanceConfiguration.java │ │ │ │ ├── dao │ │ │ │ ├── GenericDAO.java │ │ │ │ ├── GenericDAOImpl.java │ │ │ │ ├── SubscriberDAO.java │ │ │ │ └── SubscriberDAOImpl.java │ │ │ │ ├── model │ │ │ │ ├── EmailSubscriber.java │ │ │ │ ├── SmsSubscriber.java │ │ │ │ └── Subscriber.java │ │ │ │ └── service │ │ │ │ ├── CampaignService.java │ │ │ │ ├── CampaignServiceImpl.java │ │ │ │ └── sender │ │ │ │ ├── CampaignSender.java │ │ │ │ ├── EmailCampaignSender.java │ │ │ │ └── SmsCampaignSender.java │ │ ├── listener │ │ │ ├── EntityReplicationTest.java │ │ │ ├── Updatable.java │ │ │ ├── UpdatableListener.java │ │ │ └── UpdatableTest.java │ │ ├── logging │ │ │ ├── DataSourceProxySlowQueryLogTest.java │ │ │ ├── DataSourceProxyTest.java │ │ │ ├── HibernateLoggingTest.java │ │ │ ├── LoggingStatementInspector.java │ │ │ ├── MDCLoggingTest.java │ │ │ ├── MySQLMDCLoggingTest.java │ │ │ ├── P6spyTest.java │ │ │ ├── QueryStackTraceLoggerTest.java │ │ │ ├── StatementInspectorLoggingTest.java │ │ │ ├── comment │ │ │ │ ├── HibernateCommentLoggingTest.java │ │ │ │ └── Post.java │ │ │ ├── inspector │ │ │ │ ├── Book.java │ │ │ │ ├── SQLCommentStatementInspector.java │ │ │ │ ├── SQLCommentTest.java │ │ │ │ └── StatementInspectorSqlCommentTest.java │ │ │ └── validator │ │ │ │ ├── SQLStatementCountValidatorTest.java │ │ │ │ └── sql │ │ │ │ ├── SQLStatementCountValidator.java │ │ │ │ └── exception │ │ │ │ └── SQLStatementCountMismatchException.java │ │ ├── mapping │ │ │ ├── DefaultUpdateTest.java │ │ │ ├── DynamicUpdateTest.java │ │ │ ├── FluentSettersTest.java │ │ │ ├── GeneratedTest.java │ │ │ ├── HibernateImmutableExceptionTest.java │ │ │ ├── HibernateImmutableWarningTest.java │ │ │ ├── HydratedStateListenerTest.java │ │ │ ├── JPAFluentInterfaceTest.java │ │ │ ├── JPAImmutableTest.java │ │ │ ├── JoinFormulaCollationTest.java │ │ │ ├── JoinFormulaLastMonthSalaryTest.java │ │ │ ├── JoinFormulaTest.java │ │ │ ├── LatestChildJoinFormulaTest.java │ │ │ ├── MapsIdWithManyToOneTest.java │ │ │ ├── MapsIdWithOneToOneTest.java │ │ │ ├── MultipleEntitiesOneTableTest.java │ │ │ ├── OptionalAttributeTest.java │ │ │ ├── calculated │ │ │ │ ├── FormulaCurrentDateTest.java │ │ │ │ ├── FormulaTest.java │ │ │ │ ├── JPACalculatedPostLoadTest.java │ │ │ │ └── JpaCalculatedTest.java │ │ │ ├── compact │ │ │ │ ├── MySQLCountryByteIdTest.java │ │ │ │ ├── MySQLCountryShortIdTest.java │ │ │ │ ├── PostgreSQLCountryIntIdAutoPaddingTest.java │ │ │ │ ├── PostgreSQLCountryIntIdNoPaddingTest.java │ │ │ │ ├── PostgreSQLCountryShortIdAutoPaddingTest.java │ │ │ │ └── PostgreSQLCountryShortIdNoPaddingTest.java │ │ │ ├── embeddable │ │ │ │ ├── EmbeddableEntityListenerTest.java │ │ │ │ ├── EmbeddableInheritanceTest.java │ │ │ │ └── EmbeddableTest.java │ │ │ ├── encrypt │ │ │ │ ├── MySQLEncryptTest.java │ │ │ │ ├── MySQLJsonEncryptTest.java │ │ │ │ └── PostgreSQLEncryptTest.java │ │ │ ├── enums │ │ │ │ ├── CustomOrdinalEnumConverterTest.java │ │ │ │ ├── EnumCustomOrdinalTest.java │ │ │ │ ├── EnumOrdinalDescriptionMySQLTest.java │ │ │ │ ├── EnumOrdinalDescriptionTest.java │ │ │ │ ├── EnumOrdinalMySQLWithCheckTest.java │ │ │ │ ├── EnumOrdinalMySQLWithoutCheckTest.java │ │ │ │ ├── EnumOrdinalOracleTest.java │ │ │ │ ├── EnumOrdinalTest.java │ │ │ │ ├── EnumPostgreSQLTest.java │ │ │ │ ├── EnumStringPostgreSQLWithCheckTest.java │ │ │ │ ├── EnumStringPostgreSQLWithoutCheckTest.java │ │ │ │ └── EnumStringTest.java │ │ │ ├── generated │ │ │ │ ├── LoggedUserTest.java │ │ │ │ └── SequenceDefaultColumnValueTest.java │ │ │ ├── softdelete │ │ │ │ ├── SoftDeleteAnnotationTest.java │ │ │ │ ├── SoftDeleteTest.java │ │ │ │ ├── SoftDeleteVersionAnnotationTest.java │ │ │ │ └── SoftDeleteVersionTest.java │ │ │ └── types │ │ │ │ ├── CreationDetails.java │ │ │ │ ├── EmbeddedTest.java │ │ │ │ ├── Post.java │ │ │ │ └── PostStatus.java │ │ ├── metadata │ │ │ ├── MetadataExtractorIntegrator.java │ │ │ └── MetadataTest.java │ │ ├── multitenancy │ │ │ ├── CatalogMultitenancyTest.java │ │ │ ├── MultiTenantConnectionProvider.java │ │ │ ├── SchemaMultitenancyTest.java │ │ │ ├── TenantContext.java │ │ │ └── partition │ │ │ │ ├── PartitionContext.java │ │ │ │ ├── PostgreSQLTablePartitionTest.java │ │ │ │ ├── TablePartitionTest.java │ │ │ │ └── model │ │ │ │ ├── PartitionAware.java │ │ │ │ ├── Post.java │ │ │ │ └── User.java │ │ ├── naming │ │ │ ├── CamelCaseToSnakeCaseNamingStrategy.java │ │ │ ├── CamelCaseToSnakeCaseNamingStrategyTest.java │ │ │ ├── DefaultNamingTest.java │ │ │ ├── ExtendedNamingTest.java │ │ │ └── OracleNamingStrategy.java │ │ ├── pc │ │ │ ├── CloneTest.java │ │ │ ├── SaveVariantsSelectBeforeUpdateTest.java │ │ │ └── SaveVariantsTest.java │ │ ├── query │ │ │ ├── EscapeLikeTest.java │ │ │ ├── InQueryTest.java │ │ │ ├── JoinUnrelatedEntitiesTest.java │ │ │ ├── ManyToManyFetchParentWithChildMatchAllFilteringCriteriaTest.java │ │ │ ├── MySQLExecutionPlanTest.java │ │ │ ├── NativeQueryEntityMappingTest.java │ │ │ ├── NativeQueryWithCustomSchemaTest.java │ │ │ ├── OracleExecutionPlanNativeQueryTest.java │ │ │ ├── PostgreSQLCastTest.java │ │ │ ├── PostgreSQLExecutionPlanTest.java │ │ │ ├── PostgreSQLNativeQueryNullParameterTest.java │ │ │ ├── PostgreSQLUpdateNullTest.java │ │ │ ├── RowValueExpressionTest.java │ │ │ ├── RunningTotalTest.java │ │ │ ├── SQLInjectionTest.java │ │ │ ├── UpdateSubQueryTest.java │ │ │ ├── WindowFunctionGroupingTest.java │ │ │ ├── WindowFunctionPercentilesTest.java │ │ │ ├── WindowFunctionUpdateByGroupingTest.java │ │ │ ├── YugabyteDBTest.java │ │ │ ├── any │ │ │ │ └── PostgreSQLAnyClauseTest.java │ │ │ ├── cte │ │ │ │ ├── DerivedTableTest.java │ │ │ │ └── WithCTETest.java │ │ │ ├── dto │ │ │ │ ├── mixed │ │ │ │ │ ├── Country.java │ │ │ │ │ ├── DTOWithEntityTest.java │ │ │ │ │ ├── Person.java │ │ │ │ │ └── PersonAndCountryDTO.java │ │ │ │ └── projection │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── hibernate │ │ │ │ │ └── HibernateDTOProjectionTest.java │ │ │ │ │ ├── jpa │ │ │ │ │ ├── JPADTOProjectionTest.java │ │ │ │ │ └── compact │ │ │ │ │ │ ├── JPADTOProjectionClassImportIntegratorPropertyClassTest.java │ │ │ │ │ │ ├── JPADTOProjectionClassImportIntegratorPropertyObjectExcludePathTest.java │ │ │ │ │ │ ├── JPADTOProjectionClassImportIntegratorPropertyObjectTest.java │ │ │ │ │ │ └── JPADTOProjectionClassImportIntegratorTest.java │ │ │ │ │ ├── record │ │ │ │ │ ├── EntityToRecordTest.java │ │ │ │ │ ├── PostLegacyTest.java │ │ │ │ │ ├── PostRecordOverrideTest.java │ │ │ │ │ └── PostRecordTest.java │ │ │ │ │ └── transformer │ │ │ │ │ ├── DistinctListTransformer.java │ │ │ │ │ ├── PostCommentDTO.java │ │ │ │ │ ├── PostDTO.java │ │ │ │ │ ├── PostDTOResultTransformer.java │ │ │ │ │ └── PostDTOTupleTransformer.java │ │ │ ├── escape │ │ │ │ ├── HibernateEscapeKeywordTest.java │ │ │ │ ├── HibernateGlobalEscapeKeywordSkipReservedIdentifierTest.java │ │ │ │ ├── HibernateGlobalEscapeKeywordTest.java │ │ │ │ ├── JPAEscapeKeywordTest.java │ │ │ │ ├── NoEscapeKeywordTest.java │ │ │ │ └── SQLServerEscapeQuestionCharacterTest.java │ │ │ ├── function │ │ │ │ ├── DateTruncTimeZoneFunctionTest.java │ │ │ │ ├── DateTruncUtcFunctionTest.java │ │ │ │ ├── GroupConcatFunctionTest.java │ │ │ │ ├── PostSummaryDTO.java │ │ │ │ └── ToDateFunctionTest.java │ │ │ ├── hierarchical │ │ │ │ ├── AbstractTreeTest.java │ │ │ │ ├── PostComment.java │ │ │ │ ├── PostCommentTreeTransformer.java │ │ │ │ ├── PostCommentTreeTupleTransformer.java │ │ │ │ ├── Status.java │ │ │ │ ├── TreeCTETest.java │ │ │ │ ├── TreeConnectByTest.java │ │ │ │ └── TreeTest.java │ │ │ ├── join │ │ │ │ ├── SQLInnerJoinTest.java │ │ │ │ └── algorithm │ │ │ │ │ ├── HashJoinSqlTest.java │ │ │ │ │ ├── HashJoinTest.java │ │ │ │ │ ├── MergeJoinSqlTest.java │ │ │ │ │ ├── MergeJoinTest.java │ │ │ │ │ ├── NestedLoopsSqlTest.java │ │ │ │ │ ├── NestedLoopsTest.java │ │ │ │ │ └── Tuple.java │ │ │ ├── mapping │ │ │ │ └── ResultSetMappingTest.java │ │ │ ├── pivot │ │ │ │ ├── Component.java │ │ │ │ ├── DataSourceConfiguration.java │ │ │ │ ├── PivotTest.java │ │ │ │ ├── Property.java │ │ │ │ ├── PropertyId.java │ │ │ │ └── Service.java │ │ │ ├── plan │ │ │ │ ├── DefaultInQueryPlanCacheTest.java │ │ │ │ └── PaddingInQueryPlanCacheTest.java │ │ │ ├── recursive │ │ │ │ ├── PostCommentScore.java │ │ │ │ ├── PostCommentScoreResultTransformer.java │ │ │ │ ├── WithRecursiveCTEFetchingTest.java │ │ │ │ ├── WithRecursiveCTEHibernateTest.java │ │ │ │ ├── category │ │ │ │ │ ├── BookCategoryWithRecursiveCTETest.java │ │ │ │ │ └── model │ │ │ │ │ │ ├── Book.java │ │ │ │ │ │ ├── Category.java │ │ │ │ │ │ ├── CategoryView.java │ │ │ │ │ │ └── dto │ │ │ │ │ │ ├── BookDTO.java │ │ │ │ │ │ └── CategoryDTO.java │ │ │ │ ├── complex │ │ │ │ │ ├── AbstractPostCommentScorePerformanceTest.java │ │ │ │ │ ├── AllFetch.txt │ │ │ │ │ ├── FetchProjection.txt │ │ │ │ │ ├── PostCommentScoreFetchAllPerformanceTest.java │ │ │ │ │ ├── PostCommentScoreFetchProjectionPerformanceTest.java │ │ │ │ │ ├── PostCommentScoreRecursiveCTEPerformanceTest.java │ │ │ │ │ ├── PostCommentScoreRecursiveCTESelectPerformanceTest.java │ │ │ │ │ ├── PostCommentScoreTest.java │ │ │ │ │ ├── RecursiveCTE.txt │ │ │ │ │ └── cte.sql │ │ │ │ └── simple │ │ │ │ │ ├── AbstractPostCommentScorePerformanceTest.java │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── PostCommentScoreFetchProjectionOrderByPerformanceTest.java │ │ │ │ │ ├── PostCommentScoreFetchProjectionPerformanceStreamTest.java │ │ │ │ │ ├── PostCommentScoreFetchProjectionPerformanceTest.java │ │ │ │ │ ├── PostCommentScoreRecursiveCTEPerformanceTest.java │ │ │ │ │ └── PostCommentScoreTest.java │ │ │ ├── sets │ │ │ │ └── UnionIntersectExceptTest.java │ │ │ ├── spatial │ │ │ │ └── SpatialTest.java │ │ │ ├── subquery │ │ │ │ ├── Post.java │ │ │ │ ├── PostComment.java │ │ │ │ └── SubqueryExistsTest.java │ │ │ ├── time │ │ │ │ └── ExtractTest.java │ │ │ ├── timeout │ │ │ │ ├── QueryTimeoutTest.java │ │ │ │ ├── SQLServerJDBCQueryTimeoutTest.java │ │ │ │ ├── SQLServerJPAQueryTimeoutTest.java │ │ │ │ ├── SQLServerLockTimeoutTest.java │ │ │ │ ├── SQLServerServerSideTimeoutTest.java │ │ │ │ └── SessionQueryTimeoutTest.java │ │ │ ├── upsert │ │ │ │ ├── HibernateUpsertMergeTest.java │ │ │ │ ├── HibernateUpsertOnConflictTest.java │ │ │ │ ├── MySQLUpsertUniqueColumnTest.java │ │ │ │ └── PostgreSQLUpsertConcurrencyTest.java │ │ │ └── window │ │ │ │ └── WindowFunctionRunningTotalTest.java │ │ ├── schema │ │ │ └── flyway │ │ │ │ ├── DropPostgreSQLPublicSchemaTest.java │ │ │ │ ├── FlywayEntities.java │ │ │ │ ├── FlywayTest.java │ │ │ │ ├── HSQLDBFlywayConfiguration.java │ │ │ │ └── PostgreSQLFlywayConfiguration.java │ │ ├── sp │ │ │ ├── ActivityHistorySQLServerStoredProcedureTest.java │ │ │ ├── MySQLStoredProcedureTest.java │ │ │ ├── OracleCustomSQLWithStoredProcedureTest.java │ │ │ ├── OracleDeleteGlobalTableStoredProcedureTest.java │ │ │ ├── OracleDeleteStoredProcedureTest.java │ │ │ ├── OracleStoredProcedureTest.java │ │ │ ├── PostgreSQLStoredProcedureQATest.java │ │ │ ├── PostgreSQLStoredProcedureTest.java │ │ │ └── SQLServerStoredProcedureTest.java │ │ ├── statistics │ │ │ ├── ConnectionStatisticsTest.java │ │ │ ├── SlowQueryLogTest.java │ │ │ ├── StatisticsReport.java │ │ │ ├── TransactionStatistics.java │ │ │ └── TransactionStatisticsFactory.java │ │ ├── time │ │ │ ├── JavaSqlDateTest.java │ │ │ ├── JavaUtilDateTest.java │ │ │ ├── LocalDateAndLocalDateTimeTest.java │ │ │ ├── ZonedDateTimeTest.java │ │ │ ├── offset │ │ │ │ ├── MySQLOffsetDateTimeTest.java │ │ │ │ ├── OffsetDateTimeOffsetTimeTest.java │ │ │ │ ├── OffsetDateTimeTest.java │ │ │ │ └── PostgreSQLOffsetDateTimeTest.java │ │ │ └── utc │ │ │ │ ├── Book.java │ │ │ │ ├── DefaultMySQLTimestampTest.java │ │ │ │ ├── DefaultPostgreSQLTimestampTest.java │ │ │ │ ├── UTCTimeZoneMySQLTimestampTest.java │ │ │ │ └── UTCTimeZonePostgreSQLTimestampTest.java │ │ ├── transaction │ │ │ ├── ConsistencyTest.java │ │ │ ├── MultipleTransactionsPerEntityManagerTest.java │ │ │ ├── SessionContainsTransactionTest.java │ │ │ ├── forum │ │ │ │ ├── Post.java │ │ │ │ ├── PostComment.java │ │ │ │ ├── PostDetails.java │ │ │ │ └── Tag.java │ │ │ └── identifier │ │ │ │ ├── OracleTransactionIdTest.java │ │ │ │ └── TransactionIdTest.java │ │ ├── type │ │ │ ├── CharacterTypeTest.java │ │ │ ├── IPv4InetAddressJavaTypeTest.java │ │ │ ├── IPv4PostgreSQLInetJdbcTypeTest.java │ │ │ ├── IPv4TypeTest.java │ │ │ ├── LongToNumericTypeTest.java │ │ │ ├── MySQLTextStringTest.java │ │ │ ├── PostgreSQLRangeTest.java │ │ │ ├── PostgresSelectGeneratorTest.java │ │ │ ├── PostgresUUIDIdTest.java │ │ │ ├── PostgresUUIDPropertyTest.java │ │ │ ├── PostgresUUIDTest.java │ │ │ ├── TaskTypingTest.java │ │ │ ├── array │ │ │ │ ├── EnumArrayTypeTest.java │ │ │ │ ├── PostgreSQLArrayTypeTest.java │ │ │ │ └── PostgreSQLArrayUnnestTest.java │ │ │ ├── attributeconverter │ │ │ │ ├── AttributeConverterMonthDayAutoRegisterTest.java │ │ │ │ ├── AttributeConverterMonthDayTest.java │ │ │ │ ├── MySQLYearAndMonthIntegerTest.java │ │ │ │ ├── MySQLYearMonthIntegerTest.java │ │ │ │ ├── PostgreSQLYearMonthDateTest.java │ │ │ │ ├── PostgreSQLYearMonthIntegerConverterAutoApplyTest.java │ │ │ │ ├── PostgreSQLYearMonthIntegerTest.java │ │ │ │ └── YearAndMonthTest.java │ │ │ ├── binary │ │ │ │ └── MySQLBinaryTypeTest.java │ │ │ ├── datetime │ │ │ │ ├── DateTimeTest.java │ │ │ │ ├── InstantTest.java │ │ │ │ ├── LocalDateTimeTest.java │ │ │ │ ├── MySQLDateTimeTest.java │ │ │ │ ├── MySQLJavaDateTimeJDBCBindingTest.java │ │ │ │ ├── PostgreSQLIntervalDurationTest.java │ │ │ │ ├── PostgreSQLJavaDateTimeJDBCBindingTest.java │ │ │ │ ├── PostgreSQLTimestampTimezoneHikariTest.java │ │ │ │ ├── PostgreSQLTimestampTimezoneTest.java │ │ │ │ ├── SQLServerJavaDateTimeJDBCBindingTest.java │ │ │ │ ├── WebToDatabaseTimestampTest.java │ │ │ │ └── oracle │ │ │ │ │ ├── OracleAllTimestampTypesOffsetDateTimeTest.java │ │ │ │ │ ├── OracleDateVsTimestampTest.java │ │ │ │ │ ├── OracleJavaDateTimeJDBCBindingTest.java │ │ │ │ │ ├── OracleTimestampColumnSizeTest.java │ │ │ │ │ ├── OracleTimestampWithTimeZoneOffsetDateTimeTest.java │ │ │ │ │ ├── OracleTimestampWithTimeZoneVsLocalTest.java │ │ │ │ │ ├── OracleTimestampWithTimeZoneZonedDateTimeTest.java │ │ │ │ │ ├── SQLServerDateTimeColumnSizeTest.java │ │ │ │ │ ├── SQLServerDateTimeOffsetColumnSizeTest.java │ │ │ │ │ └── SQLServerDateTimeVsOffsetTest.java │ │ │ ├── json │ │ │ │ ├── MySQLJsonRecordTest.java │ │ │ │ ├── MySQLJsonTypeTest.java │ │ │ │ ├── PostgreSQLJsonBinaryTypeLazyGroupTest.java │ │ │ │ ├── PostgreSQLJsonBinaryTypeNativeTest.java │ │ │ │ ├── PostgreSQLJsonBinaryTypeTest.java │ │ │ │ ├── PostgreSQLJsonDynamicUpdateTest.java │ │ │ │ ├── PostgreSQLJsonNodeBinaryTypeTest.java │ │ │ │ ├── PostgreSQLJsonRecordTest.java │ │ │ │ ├── PostgreSQLJsonStringTypeTest.java │ │ │ │ ├── PostgreSQLJsonTypeRegistryTest.java │ │ │ │ ├── PostgreSQLNativeJsonMapTest.java │ │ │ │ └── sql │ │ │ │ │ ├── DefaultPostgreSQLJsonNodeBinaryTypeFetchTest.java │ │ │ │ │ └── NativeQueryScalarJsonNodeBinaryTypeFetchTest.java │ │ │ └── money │ │ │ │ └── MonetaryAmountTypeTest.java │ │ └── view │ │ │ ├── SubselectTest.java │ │ │ └── ViewTest.java │ │ ├── jdbc │ │ ├── batch │ │ │ ├── AbstractBatchPreparedStatementTest.java │ │ │ ├── AbstractBatchStatementTest.java │ │ │ ├── BatchPreparedStatementTest.java │ │ │ ├── BatchStatementTest.java │ │ │ ├── MySQLBatchPreparedStatementTest.java │ │ │ ├── MySQLBatchStatementTest.java │ │ │ ├── MySQLRewriteBatchPreparedStatementTest.java │ │ │ ├── NoBatchPreparedStatementTest.java │ │ │ ├── NoBatchStatementTest.java │ │ │ ├── OracleBatchStatementTest.java │ │ │ ├── OracleDefaultExecuteBatchPreparedStatementTest.java │ │ │ ├── PostgreSQLRewriteBatchInsertsTest.java │ │ │ ├── SQLServerBulkCopyForBatchInsertPerformanceTest.java │ │ │ ├── SimpleBatchTest.java │ │ │ └── generatedkeys │ │ │ │ ├── identity │ │ │ │ ├── MySQLGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ ├── OracleGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ ├── PostgreSQLGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ └── SQLServerGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ └── sequence │ │ │ │ ├── AbstractSequenceCallTest.java │ │ │ │ ├── AbstractSequenceGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ ├── OracleSequenceCallTest.java │ │ │ │ ├── OracleSequenceGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ ├── PostgreSQLSequenceCallTest.java │ │ │ │ ├── PostgreSQLSequenceGeneratedKeysBatchPreparedStatementTest.java │ │ │ │ ├── SQLServerSequenceCallTest.java │ │ │ │ └── SQLServerSequenceGeneratedKeysBatchPreparedStatementTest.java │ │ ├── caching │ │ │ ├── MySQLStatementCacheTest.java │ │ │ ├── OracleExplicitStatementCacheTest.java │ │ │ ├── OracleImplicitStatementCacheTest.java │ │ │ ├── OraclePreparedStatementLifecycleTest.java │ │ │ ├── PostgreSQLPlanCacheModeTest.java │ │ │ ├── PostgreSQLPreparedStatementCompilingTest.java │ │ │ ├── PostgreSQLStatementCachePoolingTest.java │ │ │ ├── PostgreSQLStatementCacheTest.java │ │ │ ├── SQLServerImplicitStatementCacheTest.java │ │ │ ├── SQLServerPreparedStatementLifecycleTest.java │ │ │ ├── StatementCachePoolableTest.java │ │ │ └── StatementCacheTest.java │ │ ├── connection │ │ │ ├── ConnectionPoolCallTest.java │ │ │ ├── ConnectionPoolThreadsTest.java │ │ │ ├── FlexyPoolAutoSizingTest.java │ │ │ └── OracleConnectionCallTest.java │ │ ├── fetching │ │ │ ├── JDBCVsJPATest.java │ │ │ ├── OracleResultSetLimitTest.java │ │ │ ├── ResultSetCursorTest.java │ │ │ ├── ResultSetFetchSizeTest.java │ │ │ ├── ResultSetLimitTest.java │ │ │ ├── ResultSetProjectionTest.java │ │ │ ├── ResultSetScollabilityTest.java │ │ │ ├── SQLServerResultSetLimitTest.java │ │ │ └── SQLStandardResultSetLimitTest.java │ │ ├── index │ │ │ ├── MySQLIndexSelectivityTest.java │ │ │ ├── PostgreSQLIndexSelectivityTest.java │ │ │ ├── SQLServerMissingIndexTest.java │ │ │ └── providers │ │ │ │ └── IndexEntityProvider.java │ │ └── transaction │ │ │ ├── AutoCommitTest.java │ │ │ ├── ConnectionReadyOnlyTransactionTest.java │ │ │ ├── MVCCPostgreSQLTest.java │ │ │ ├── OracleConnectionReadyOnlyTransactionTest.java │ │ │ ├── SQLServerConnectionReadyOnlyTransactionTest.java │ │ │ ├── locking │ │ │ ├── AbstractPredicateLockTest.java │ │ │ ├── AbstractTableLockTest.java │ │ │ ├── MySQLPredicateLockTest.java │ │ │ ├── MySQLTableLockTest.java │ │ │ ├── MySQLTableLockWithEmployeesInFirstDepartmentOnlyTest.java │ │ │ ├── OraclePredicateLockTest.java │ │ │ ├── OracleTableLockTest.java │ │ │ ├── PostgreSQLForNoKeyUpdateTest.java │ │ │ ├── PostgreSQLPredicateLockTest.java │ │ │ ├── PostgreSQLTableLockTest.java │ │ │ ├── SQLServerPredicateLockTest.java │ │ │ ├── SQLServerTableLockMultipleEntriesTest.java │ │ │ ├── SQLServerTableLockTest.java │ │ │ └── advisory │ │ │ │ ├── AbstractPostgreSQLAdvisoryLocksTest.java │ │ │ │ ├── PostgreSQLNoAdvisoryLocksTest.java │ │ │ │ ├── PostgreSQLReadWriteAdvisoryLocksTest.java │ │ │ │ ├── PostgreSQLSessionAdvisoryLocksTest.java │ │ │ │ └── PostgreSQLSessionTryAdvisoryLocksTest.java │ │ │ └── phenomena │ │ │ ├── AbstractPhenomenaTest.java │ │ │ ├── MySQLPhenomenaTest.java │ │ │ ├── OraclePhenomenaTest.java │ │ │ ├── PostgreSQLPhenomenaTest.java │ │ │ ├── SQLServerPhenomenaTest.java │ │ │ ├── YugabyteDBPhenomenaTest.java │ │ │ └── writeskew │ │ │ ├── AbstractDepartmentEmployeePhenomenaTest.java │ │ │ ├── AbstractRangeBasedWriteSkewPhenomenaTest.java │ │ │ ├── OracleRangeBasedWriteSkewPhenomenaTest.java │ │ │ ├── PostgreSQLRangeBasedWriteSkewPhenomenaConstraintTest.java │ │ │ ├── PostgreSQLRangeBasedWriteSkewPhenomenaTest.java │ │ │ └── PostgreSQLRangeBasedWriteSkewReadCommittedTest.java │ │ ├── spring │ │ ├── batch │ │ │ ├── SpringBatchTest.java │ │ │ ├── config │ │ │ │ └── SpringBatchConfiguration.java │ │ │ ├── domain │ │ │ │ ├── Post.java │ │ │ │ └── PostStatus.java │ │ │ ├── repository │ │ │ │ └── PostRepository.java │ │ │ └── service │ │ │ │ └── ForumService.java │ │ ├── blaze │ │ │ ├── SpringBlazePersistenceKeysetPaginationTest.java │ │ │ ├── SpringBlazePersistenceMockTest.java │ │ │ ├── SpringBlazePersistenceMultisetTest.java │ │ │ ├── config │ │ │ │ └── SpringBlazePersistenceConfiguration.java │ │ │ ├── domain │ │ │ │ ├── Post.java │ │ │ │ ├── PostComment.java │ │ │ │ ├── Tag.java │ │ │ │ ├── User.java │ │ │ │ ├── UserVote.java │ │ │ │ └── views │ │ │ │ │ ├── PostCommentView.java │ │ │ │ │ ├── PostView.java │ │ │ │ │ ├── PostWithCommentsAndTagsView.java │ │ │ │ │ ├── TagView.java │ │ │ │ │ ├── UserView.java │ │ │ │ │ └── UserVoteView.java │ │ │ ├── repository │ │ │ │ ├── CustomPostRepository.java │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ └── PostRepository.java │ │ │ └── service │ │ │ │ └── ForumService.java │ │ ├── common │ │ │ ├── AbstractSpringTest.java │ │ │ ├── config │ │ │ │ └── CommonSpringConfiguration.java │ │ │ ├── domain │ │ │ │ ├── Post.java │ │ │ │ └── PostComment.java │ │ │ ├── repository │ │ │ │ ├── PostCommentRepository.java │ │ │ │ └── PostRepository.java │ │ │ └── service │ │ │ │ └── ForumService.java │ │ ├── data │ │ │ ├── assigned │ │ │ │ ├── SpringDataJPAAssignedTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPAAssignedConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ └── Book.java │ │ │ │ └── repository │ │ │ │ │ ├── BookBaseJpaRepository.java │ │ │ │ │ └── BookRepository.java │ │ │ ├── audit │ │ │ │ ├── SpringDataJPAAuditTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPAAuditConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ └── PostStatus.java │ │ │ │ ├── repository │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── PostService.java │ │ │ ├── base │ │ │ │ ├── SpringDataJPABaseRepositoryTest.java │ │ │ │ ├── config │ │ │ │ │ ├── SpringDataJPABaseConfiguration.java │ │ │ │ │ └── SpringDataJPABaseRepositoryConfiguration.java │ │ │ │ ├── repository │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ ├── ForumService.java │ │ │ │ │ └── ForumServiceImpl.java │ │ │ ├── bidirectional │ │ │ │ ├── SpringDataJPABidirectionalTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPABidirectionalConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── PostDetails.java │ │ │ │ │ └── Tag.java │ │ │ │ ├── repository │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ ├── PostDetailsRepository.java │ │ │ │ │ ├── PostRepository.java │ │ │ │ │ └── TagRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ ├── bytecode │ │ │ │ ├── AttachmentLazyLoading.java │ │ │ │ ├── SpringDataJPARuntimeBytecodeEnhancementTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPARuntimeBytecodeEnhancementConfiguration.java │ │ │ │ └── repository │ │ │ │ │ └── AttachmentRepository.java │ │ │ ├── cascade │ │ │ │ ├── SpringDataJPACascadeTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPACascadeConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── PostDetails.java │ │ │ │ │ └── Tag.java │ │ │ │ └── repository │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ ├── PostDetailsRepository.java │ │ │ │ │ ├── PostRepository.java │ │ │ │ │ └── TagRepository.java │ │ │ ├── crud │ │ │ │ ├── SpringDataJPACrudTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPACrudConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ └── PostStatus.java │ │ │ │ ├── repository │ │ │ │ │ ├── DefaultPostRepository.java │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── PostService.java │ │ │ ├── custom │ │ │ │ ├── SpringDataJPACustomRepositoryTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPACustomRepositoryConfiguration.java │ │ │ │ ├── repository │ │ │ │ │ ├── CustomPostRepository.java │ │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ ├── lock │ │ │ │ ├── SpringDataJPALockTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPALockConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ └── PostComment.java │ │ │ │ └── repository │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ └── PostRepository.java │ │ │ ├── masquerade │ │ │ │ ├── SpringDataJPAMasqueradeTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPAMasqueradeConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ └── PostComment.java │ │ │ │ ├── dto │ │ │ │ │ ├── PostCommentDTO.java │ │ │ │ │ └── PostDTO.java │ │ │ │ ├── repository │ │ │ │ │ ├── CustomPostRepository.java │ │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ ├── merge │ │ │ │ ├── SpringDataJPAMergeTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPAMergeConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ └── PostComment.java │ │ │ │ ├── repository │ │ │ │ │ ├── BetterPostRepository.java │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ ├── projection │ │ │ │ ├── SpringDataJPAProjectionTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPAProjectionConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ └── PostComment.java │ │ │ │ ├── dto │ │ │ │ │ ├── PostCommentDTO.java │ │ │ │ │ ├── PostCommentRecord.java │ │ │ │ │ └── PostCommentSummary.java │ │ │ │ └── repository │ │ │ │ │ ├── CustomPostRepository.java │ │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ │ └── PostRepository.java │ │ │ ├── query │ │ │ │ ├── example │ │ │ │ │ ├── SpringDataJPAQueryByExampleTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPAQueryByExampleConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── Post.java │ │ │ │ │ │ ├── PostComment.java │ │ │ │ │ │ ├── PostCommentDTO.java │ │ │ │ │ │ └── Tag.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ │ └── PostRepository.java │ │ │ │ ├── exists │ │ │ │ │ ├── SpringDataJPAExistsTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPAExistsConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ └── Post.java │ │ │ │ │ └── repository │ │ │ │ │ │ └── PostRepository.java │ │ │ │ ├── fetch │ │ │ │ │ ├── SpringDataJPAJoinFetchPaginationTest.java │ │ │ │ │ ├── SpringDataJPAOSIVTest.java │ │ │ │ │ ├── SpringDataJPAStreamTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPAJoinFetchPaginationConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── Post.java │ │ │ │ │ │ └── PostComment.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── PostRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ └── ForumService.java │ │ │ │ ├── hint │ │ │ │ │ ├── SpringDataJPAQueryHintTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPAQueryHintConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── Post.java │ │ │ │ │ │ └── PostComment.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── PostRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ └── ForumService.java │ │ │ │ ├── method │ │ │ │ │ ├── SpringDataJPAQueryMethodTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPAQueryMethodConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── Post.java │ │ │ │ │ │ ├── PostComment.java │ │ │ │ │ │ ├── PostCommentDTO.java │ │ │ │ │ │ └── Tag.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── CustomPostCommentRepository.java │ │ │ │ │ │ ├── CustomPostCommentRepositoryImpl.java │ │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ │ └── PostRepository.java │ │ │ │ ├── multibag │ │ │ │ │ ├── SpringDataJPAMultipleBagFetchTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPAMultipleBagFetchConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── Post.java │ │ │ │ │ │ ├── PostComment.java │ │ │ │ │ │ └── Tag.java │ │ │ │ │ ├── repository │ │ │ │ │ │ ├── CustomPostRepository.java │ │ │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ │ └── PostRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── BrokenForumService.java │ │ │ │ │ │ └── ForumService.java │ │ │ │ ├── specification │ │ │ │ │ ├── SpringDataJPASpecificationTest.java │ │ │ │ │ ├── config │ │ │ │ │ │ └── SpringDataJPASpecificationConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ │ ├── Post.java │ │ │ │ │ │ ├── PostComment.java │ │ │ │ │ │ ├── PostCommentDTO.java │ │ │ │ │ │ └── Tag.java │ │ │ │ │ └── repository │ │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ │ └── PostRepository.java │ │ │ │ └── window │ │ │ │ │ ├── SpringDataJPAWindowTest.java │ │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPAWindowConfiguration.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ └── PostComment.java │ │ │ │ │ └── repository │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ └── PostRepository.java │ │ │ ├── record │ │ │ │ ├── SpringDataJPARecordTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPARecordConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── PostCommentRecord.java │ │ │ │ │ └── PostRecord.java │ │ │ │ ├── repository │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ ├── recursive │ │ │ │ ├── SpringDataJPARecursiveTest.java │ │ │ │ ├── config │ │ │ │ │ └── SpringDataJPARecursiveConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ └── PostCommentDTO.java │ │ │ │ ├── repository │ │ │ │ │ ├── CustomPostRepository.java │ │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ │ └── PostRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ ├── unidirectional │ │ │ │ ├── SpringDataJPAUnidirectionalBulkTest.java │ │ │ │ ├── SpringDataJPAUnidirectionalEventListenerTest.java │ │ │ │ ├── config │ │ │ │ │ ├── SpringDataJPAUnidirectionalConfiguration.java │ │ │ │ │ └── SpringDataJPAUnidirectionalEventListenerConfiguration.java │ │ │ │ ├── domain │ │ │ │ │ ├── Post.java │ │ │ │ │ ├── PostComment.java │ │ │ │ │ ├── PostDetails.java │ │ │ │ │ ├── PostTag.java │ │ │ │ │ ├── PostTagId.java │ │ │ │ │ ├── Tag.java │ │ │ │ │ ├── User.java │ │ │ │ │ ├── UserVote.java │ │ │ │ │ └── VersionedEntity.java │ │ │ │ ├── event │ │ │ │ │ ├── CascadeDeleteEventListener.java │ │ │ │ │ └── CascadeDeleteEventListenerIntegrator.java │ │ │ │ ├── repository │ │ │ │ │ ├── CustomPostRepository.java │ │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ │ ├── DefaultPostRepository.java │ │ │ │ │ ├── PostCommentRepository.java │ │ │ │ │ ├── PostDetailsRepository.java │ │ │ │ │ ├── PostRepository.java │ │ │ │ │ ├── PostTagRepository.java │ │ │ │ │ ├── TagRepository.java │ │ │ │ │ ├── UserRepository.java │ │ │ │ │ └── UserVoteRepository.java │ │ │ │ └── service │ │ │ │ │ └── ForumService.java │ │ │ └── update │ │ │ │ ├── SpringDataJPAUpdateTest.java │ │ │ │ ├── config │ │ │ │ └── SpringDataJPAUpdateConfiguration.java │ │ │ │ ├── domain │ │ │ │ └── Post.java │ │ │ │ └── repository │ │ │ │ └── PostRepository.java │ │ ├── partition │ │ │ ├── SpringTablePartitioningTest.java │ │ │ ├── config │ │ │ │ └── SpringTablePartitioningConfiguration.java │ │ │ ├── domain │ │ │ │ ├── Partition.java │ │ │ │ ├── PartitionAware.java │ │ │ │ ├── Post.java │ │ │ │ └── User.java │ │ │ ├── event │ │ │ │ ├── PartitionAwareEventListenerIntegrator.java │ │ │ │ └── PartitionAwareInsertEventListener.java │ │ │ ├── repository │ │ │ │ ├── PostRepository.java │ │ │ │ └── UserRepository.java │ │ │ ├── service │ │ │ │ └── ForumService.java │ │ │ └── util │ │ │ │ └── UserContext.java │ │ ├── stateless │ │ │ ├── SpringStatelessSessionBatchingTest.java │ │ │ ├── config │ │ │ │ └── SpringStatelessSessionBatchingConfiguration.java │ │ │ ├── domain │ │ │ │ ├── AbstractPost.java │ │ │ │ ├── BatchInsertPost.java │ │ │ │ ├── NoOpGenerator.java │ │ │ │ └── Post.java │ │ │ ├── repository │ │ │ │ ├── CustomPostRepository.java │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ └── PostRepository.java │ │ │ └── service │ │ │ │ └── ForumService.java │ │ └── transaction │ │ │ ├── contract │ │ │ ├── ContractTest.java │ │ │ ├── config │ │ │ │ └── ContractConfiguration.java │ │ │ ├── domain │ │ │ │ ├── Annex.java │ │ │ │ ├── AnnexSignature.java │ │ │ │ ├── BaseSignature.java │ │ │ │ ├── Contract.java │ │ │ │ ├── ContractSignature.java │ │ │ │ └── RootAware.java │ │ │ ├── event │ │ │ │ ├── RootAwareEventListenerIntegrator.java │ │ │ │ ├── RootAwareInsertEventListener.java │ │ │ │ └── RootAwareUpdateAndDeleteEventListener.java │ │ │ └── repository │ │ │ │ └── ContractRepository.java │ │ │ ├── hibernate │ │ │ ├── HibernateTransactionManagerTest.java │ │ │ ├── config │ │ │ │ ├── HibernateTransactionManagerConfiguration.java │ │ │ │ └── MonitoringHibernateTransactionManager.java │ │ │ ├── dao │ │ │ │ ├── GenericDAO.java │ │ │ │ ├── GenericDAOImpl.java │ │ │ │ ├── PostDAO.java │ │ │ │ ├── PostDAOImpl.java │ │ │ │ ├── TagDAO.java │ │ │ │ └── TagDAOImpl.java │ │ │ └── service │ │ │ │ ├── ForumService.java │ │ │ │ └── ForumServiceImpl.java │ │ │ ├── jpa │ │ │ ├── JPATransactionManagerTest.java │ │ │ ├── ResourceLocalReleaseAfterStatementTest.java │ │ │ ├── config │ │ │ │ ├── JPATransactionManagerConfiguration.java │ │ │ │ └── ResourceLocalReleaseAfterStatementConfiguration.java │ │ │ ├── repository │ │ │ │ ├── CustomPostRepository.java │ │ │ │ ├── CustomPostRepositoryImpl.java │ │ │ │ ├── PostRepository.java │ │ │ │ └── TagRepository.java │ │ │ └── service │ │ │ │ ├── ForumService.java │ │ │ │ ├── ForumServiceImpl.java │ │ │ │ ├── ReleaseAfterStatementForumService.java │ │ │ │ └── ReleaseAfterStatementForumServiceImpl.java │ │ │ ├── jta │ │ │ ├── atomikos │ │ │ │ ├── AromikosJTATransactionManagerTest.java │ │ │ │ ├── config │ │ │ │ │ └── AtomikosJTATransactionManagerConfiguration.java │ │ │ │ ├── dao │ │ │ │ │ ├── GenericDAO.java │ │ │ │ │ ├── GenericDAOImpl.java │ │ │ │ │ ├── PostBatchDAO.java │ │ │ │ │ ├── PostBatchDAOImpl.java │ │ │ │ │ ├── PostDAO.java │ │ │ │ │ ├── PostDAOImpl.java │ │ │ │ │ ├── TagDAO.java │ │ │ │ │ └── TagDAOImpl.java │ │ │ │ └── service │ │ │ │ │ ├── ForumService.java │ │ │ │ │ └── ForumServiceImpl.java │ │ │ └── narayana │ │ │ │ ├── NarayanaJTATransactionManagerTest.java │ │ │ │ ├── config │ │ │ │ └── NarayanaJTATransactionManagerConfiguration.java │ │ │ │ ├── dao │ │ │ │ ├── GenericDAO.java │ │ │ │ ├── GenericDAOImpl.java │ │ │ │ ├── PostBatchDAO.java │ │ │ │ ├── PostBatchDAOImpl.java │ │ │ │ ├── PostDAO.java │ │ │ │ ├── PostDAOImpl.java │ │ │ │ ├── TagDAO.java │ │ │ │ └── TagDAOImpl.java │ │ │ │ └── service │ │ │ │ ├── ForumService.java │ │ │ │ └── ForumServiceImpl.java │ │ │ ├── mdc │ │ │ ├── SpringMdcTest.java │ │ │ ├── config │ │ │ │ └── TransactionInfoMdcConfiguration.java │ │ │ └── event │ │ │ │ ├── TransactionInfo.java │ │ │ │ └── TransactionInfoSessionEventListener.java │ │ │ ├── readonly │ │ │ ├── SpringDataJPAReadOnlyLazyTest.java │ │ │ ├── SpringDataJPAReadOnlyTest.java │ │ │ ├── config │ │ │ │ ├── SpringDataJPAReadOnlyConfiguration.java │ │ │ │ ├── SpringDataJPAReadOnlyLazyConfiguration.java │ │ │ │ └── stats │ │ │ │ │ ├── SpringTransactionStatistics.java │ │ │ │ │ ├── SpringTransactionStatisticsFactory.java │ │ │ │ │ └── SpringTransactionStatisticsReport.java │ │ │ ├── domain │ │ │ │ └── Product.java │ │ │ ├── repository │ │ │ │ └── ProductRepository.java │ │ │ └── service │ │ │ │ ├── ProductService.java │ │ │ │ └── fxrate │ │ │ │ ├── FxCurrency.java │ │ │ │ ├── FxRate.java │ │ │ │ └── FxRateUtil.java │ │ │ ├── routing │ │ │ ├── DataSourceType.java │ │ │ ├── ForumService.java │ │ │ ├── ForumServiceImpl.java │ │ │ ├── TransactionRoutingConfiguration.java │ │ │ ├── TransactionRoutingDataSource.java │ │ │ └── TransactionRoutingDataSourceTest.java │ │ │ └── transfer │ │ │ ├── ACIDRaceConditionTransferTest.java │ │ │ ├── FlexyPoolACIDRaceConditionTransferTest.java │ │ │ ├── config │ │ │ ├── ACIDRaceConditionTransferConfiguration.java │ │ │ └── FlexyPoolACIDRaceConditionTransferConfiguration.java │ │ │ ├── domain │ │ │ └── Account.java │ │ │ ├── repository │ │ │ └── AccountRepository.java │ │ │ └── service │ │ │ └── TransferService.java │ │ └── util │ │ ├── AbstractCockroachDBIntegrationTest.java │ │ ├── AbstractMySQLIntegrationTest.java │ │ ├── AbstractOracleIntegrationTest.java │ │ ├── AbstractPostgreSQLIntegrationTest.java │ │ ├── AbstractSQLServerIntegrationTest.java │ │ ├── AbstractTest.java │ │ ├── CollectionUtils.java │ │ ├── CryptoUtils.java │ │ ├── CryptoUtilsTest.java │ │ ├── DataSourceProviderIntegrationTest.java │ │ ├── DataSourceProxyType.java │ │ ├── DatabaseProviderIntegrationTest.java │ │ ├── EntityProvider.java │ │ ├── PersistenceUnitInfoImpl.java │ │ ├── RandomUtils.java │ │ ├── ReflectionUtils.java │ │ ├── SpringTransactionUtils.java │ │ ├── StackTraceUtils.java │ │ ├── TsidUtils.java │ │ ├── XmlUtils.java │ │ ├── exception │ │ ├── DataAccessException.java │ │ └── ExceptionUtil.java │ │ ├── logging │ │ └── InlineQueryLogEntryCreator.java │ │ ├── providers │ │ ├── AbstractContainerDataSourceProvider.java │ │ ├── CockroachDBDataSourceProvider.java │ │ ├── DataSourceProvider.java │ │ ├── Database.java │ │ ├── FastOracleDialect.java │ │ ├── HSQLDBDataSourceProvider.java │ │ ├── LegacyOracleDialect.java │ │ ├── LockType.java │ │ ├── MariaDBDataSourceProvider.java │ │ ├── MySQLDataSourceProvider.java │ │ ├── OracleDataSourceProvider.java │ │ ├── PostgreSQLDataSourceProvider.java │ │ ├── SQLServerDataSourceProvider.java │ │ ├── YugabyteDBClusterDataSourceProvider.java │ │ ├── YugabyteDBDataSourceProvider.java │ │ ├── aiven │ │ │ └── AivenPostgreSQLDataSourceProvider.java │ │ ├── entity │ │ │ ├── AutoIncrementBatchEntityProvider.java │ │ │ ├── BankEntityProvider.java │ │ │ ├── BlogEntityProvider.java │ │ │ ├── PostDetailsCommentsEntityProvider.java │ │ │ ├── SequenceBatchEntityProvider.java │ │ │ └── TaskEntityProvider.java │ │ └── queries │ │ │ ├── HSQLDBServerQueries.java │ │ │ ├── MySQLQueries.java │ │ │ ├── OracleQueries.java │ │ │ ├── PostgreSQLQueries.java │ │ │ ├── Queries.java │ │ │ └── SQLServerQueries.java │ │ ├── resources │ │ └── CpuTest.java │ │ ├── spring │ │ └── config │ │ │ ├── flyway │ │ │ ├── AbstractFlywayConfiguration.java │ │ │ ├── AbstractHSQLDBFlywayConfiguration.java │ │ │ └── AbstractPostgreSQLFlywayConfiguration.java │ │ │ ├── jpa │ │ │ ├── AbstractHsqldbJPAConfiguration.java │ │ │ ├── AbstractJPAConfiguration.java │ │ │ ├── HikariCPJPAConfiguration.java │ │ │ └── PostgreSQLJPAConfiguration.java │ │ │ └── jta │ │ │ ├── AbstractJTATransactionManagerConfiguration.java │ │ │ ├── HSQLDBJtaTransactionManagerConfiguration.java │ │ │ └── PostgreSQLJTATransactionManagerConfiguration.java │ │ └── transaction │ │ ├── ConnectionCallable.java │ │ ├── ConnectionVoidCallable.java │ │ ├── HibernateStatelessTransactionConsumer.java │ │ ├── HibernateStatelessTransactionFunction.java │ │ ├── HibernateTransactionConsumer.java │ │ ├── HibernateTransactionFunction.java │ │ ├── JPATransactionFunction.java │ │ ├── JPATransactionVoidFunction.java │ │ └── VoidCallable.java │ └── resources │ ├── META-INF │ ├── jdbc-hsqldb.properties │ ├── jdbc-mysql.properties │ ├── jdbc-postgresql-replication.properties │ ├── jdbc-postgresql.properties │ ├── jta-hsqldb.properties │ └── jta-postgresql.properties │ ├── OracleLog.properties │ ├── data │ ├── oracle_quotes.sql │ ├── quotes.sql │ └── weather.xml │ ├── ehcache.xml │ ├── flexy-pool.properties │ ├── flyway │ └── scripts │ │ ├── hsqldb │ │ ├── drop │ │ │ └── drop.sql │ │ ├── migration │ │ │ ├── V1_0__post_tag.sql │ │ │ ├── V1_1__post_details.sql │ │ │ └── V1_2__post_comment.sql │ │ └── staging │ │ │ └── V1_3__users.sql │ │ └── postgresql │ │ ├── drop │ │ └── drop.sql │ │ ├── migration │ │ ├── V1_0__post_tag.sql │ │ ├── V1_1__post_details.sql │ │ └── V1_2__post_comment.sql │ │ └── staging │ │ └── V1_3__users.sql │ ├── logback-test.xml │ ├── mappings │ └── identifier │ │ └── global │ │ └── mysql-orm.xml │ └── spy.properties ├── jooq ├── jooq-core │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── vladmihalcea │ │ ├── hpjp │ │ └── jooq │ │ │ └── AbstractJOOQIntegrationTest.java │ │ └── util │ │ ├── AbstractOracleIntegrationTest.java │ │ ├── AbstractPostgreSQLIntegrationTest.java │ │ ├── AbstractSQLServerIntegrationTest.java │ │ ├── AbstractTest.java │ │ ├── CollectionUtils.java │ │ ├── DataSourceProxyType.java │ │ ├── PersistenceUnitInfoImpl.java │ │ ├── ReflectionUtils.java │ │ ├── exception │ │ └── ExceptionUtil.java │ │ ├── logging │ │ └── InlineQueryLogEntryCreator.java │ │ ├── providers │ │ ├── AbstractContainerDataSourceProvider.java │ │ ├── DataSourceProvider.java │ │ ├── Database.java │ │ ├── MySQLDataSourceProvider.java │ │ ├── OracleDataSourceProvider.java │ │ ├── PostgreSQLDataSourceProvider.java │ │ └── SQLServerDataSourceProvider.java │ │ └── transaction │ │ ├── ConnectionVoidCallable.java │ │ ├── JPATransactionFunction.java │ │ ├── JPATransactionVoidFunction.java │ │ └── VoidCallable.java ├── jooq-mysql │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── vladmihalcea │ │ │ └── hpjp │ │ │ └── jooq │ │ │ └── mysql │ │ │ └── crud │ │ │ ├── AbstractJOOQMySQLIntegrationTest.java │ │ │ ├── BatchTest.java │ │ │ ├── CrudTest.java │ │ │ ├── HibernateFlushTest.java │ │ │ ├── InlineBindParametersTest.java │ │ │ ├── KeysetPaginationTest.java │ │ │ ├── SQLInjectionTest.java │ │ │ ├── StreamTest.java │ │ │ ├── UpsertAndGetConcurrencyTest.java │ │ │ └── UpsertTest.java │ │ └── resources │ │ └── mysql │ │ ├── clean_schema.sql │ │ └── initial_schema.sql ├── jooq-pgsql-score │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── vladmihalcea │ │ │ └── hpjp │ │ │ └── jooq │ │ │ └── pgsql │ │ │ └── score │ │ │ ├── AbstractJOOQPostgreSQLIntegrationTest.java │ │ │ ├── PostCommentFingerprintTest.java │ │ │ ├── PostCommentScoreStoredProcedureTest.java │ │ │ ├── PostCommentScoreTest.java │ │ │ ├── dto │ │ │ └── PostCommentScore.java │ │ │ └── transformer │ │ │ ├── PostCommentScoreResultTransformer.java │ │ │ └── PostCommentScoreRootTransformer.java │ │ └── resources │ │ └── pgsql │ │ ├── clean_schema.sql │ │ └── initial_schema.sql ├── jooq-pgsql │ ├── pom.xml │ └── src │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── vladmihalcea │ │ │ └── hpjp │ │ │ └── jooq │ │ │ └── pgsql │ │ │ ├── batching │ │ │ └── BatchTest.java │ │ │ ├── crud │ │ │ ├── CrudTest.java │ │ │ └── SQLInjectionTest.java │ │ │ ├── fetching │ │ │ └── StreamTest.java │ │ │ ├── functions │ │ │ └── qa │ │ │ │ └── QuestionAndAnswerTest.java │ │ │ ├── pagination │ │ │ └── KeysetPaginationTest.java │ │ │ ├── upsert │ │ │ ├── UpsertAndGetConcurrencyTest.java │ │ │ ├── UpsertAndGetTest.java │ │ │ └── UpsertTest.java │ │ │ └── util │ │ │ └── AbstractJOOQPostgreSQLIntegrationTest.java │ │ └── resources │ │ └── pgsql │ │ ├── clean_schema.sql │ │ └── initial_schema.sql └── pom.xml └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | .idea/ 14 | target/ 15 | *.iml 16 | core/btm1.tlog 17 | core/btm2.tlog 18 | *.tlog 19 | *.log 20 | *.lck 21 | core/PutObjectStoreDirHere/ 22 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | pushd core 4 | call mvn -D skipTests clean install 5 | popd 6 | 7 | pushd jooq 8 | call mvn -D skipTests clean install 9 | call mvn test-compile 10 | popd 11 | 12 | goto:eof -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | call mvn -D skipTests clean install -------------------------------------------------------------------------------- /core/spring-loadtime-weaving.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call mvn -Dcmd.args="-javaagent:%M2_REPOSITORY%\org\springframework\spring-instrument\6.0.8\spring-instrument-6.0.8.jar" -Dtest=SpringDataJPARuntimeBytecodeEnhancementTest test 4 | 5 | goto:eof -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/forum/MediaType.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.forum; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum MediaType { 7 | APPLICATION_BINARY, 8 | APPLICATION_XML_UTF_8, 9 | ATOM_UTF_8, 10 | BMP, 11 | BZIP2, 12 | CSV_UTF_8, 13 | EPUB, 14 | GIF, 15 | GZIP, 16 | HTML_UTF_8, 17 | JPEG, 18 | JSON_UTF_8, 19 | MBOX, 20 | MICROSOFT_EXCEL, 21 | MICROSOFT_POWERPOINT, 22 | MICROSOFT_WORD, 23 | MP4_AUDIO, 24 | MP4_VIDEO, 25 | MPEG_AUDIO, 26 | MPEG_VIDEO, 27 | PDF, 28 | PLAIN_TEXT_UTF_8, 29 | PNG, 30 | POSTSCRIPT, 31 | ZIP 32 | } 33 | -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/forum/PostComment.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.forum; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @Entity 9 | @Table(name = "post_comment") 10 | public class PostComment { 11 | 12 | @Id 13 | private Long id; 14 | 15 | @ManyToOne(fetch = FetchType.LAZY) 16 | private Post post; 17 | 18 | private String review; 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public PostComment setId(Long id) { 25 | this.id = id; 26 | return this; 27 | } 28 | 29 | public Post getPost() { 30 | return post; 31 | } 32 | 33 | public PostComment setPost(Post post) { 34 | this.post = post; 35 | return this; 36 | } 37 | 38 | public String getReview() { 39 | return review; 40 | } 41 | 42 | public PostComment setReview(String review) { 43 | this.review = review; 44 | return this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/forum/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.forum; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @Table(name = "tag") 12 | public class Tag { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String name; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Tag setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public Tag setName(String name) { 33 | this.name = name; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/forum/dto/PostDTO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.forum.dto; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PostDTO { 7 | 8 | private final Long id; 9 | 10 | private final String title; 11 | 12 | public PostDTO(Number id, String title) { 13 | this.id = id.longValue(); 14 | this.title = title; 15 | } 16 | 17 | public Long getId() { 18 | return id; 19 | } 20 | 21 | public String getTitle() { 22 | return title; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/type/json/model/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.type.json.model; 2 | 3 | import jakarta.persistence.Id; 4 | import jakarta.persistence.MappedSuperclass; 5 | import jakarta.persistence.Version; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @MappedSuperclass 11 | public class BaseEntity { 12 | 13 | @Id 14 | private Long id; 15 | 16 | @Version 17 | private Short version; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public Short getVersion() { 28 | return version; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/type/json/model/Event.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.type.json.model; 2 | 3 | import io.hypersistence.utils.hibernate.type.json.JsonBinaryType; 4 | import jakarta.persistence.*; 5 | import org.hibernate.annotations.Type; 6 | 7 | /** 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | @Entity(name = "Event") 12 | @Table(name = "event") 13 | public class Event extends BaseEntity { 14 | 15 | @Type(JsonBinaryType.class) 16 | @Column(columnDefinition = "jsonb") 17 | @Basic( fetch = FetchType.LAZY ) 18 | private Location location; 19 | 20 | public Location getLocation() { 21 | return location; 22 | } 23 | 24 | public void setLocation(Location location) { 25 | this.location = location; 26 | } 27 | } -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/type/json/model/Location.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.type.json.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class Location implements Serializable { 9 | 10 | private String country; 11 | 12 | private String city; 13 | 14 | public String getCountry() { 15 | return country; 16 | } 17 | 18 | public void setCountry(String country) { 19 | this.country = country; 20 | } 21 | 22 | public String getCity() { 23 | return city; 24 | } 25 | 26 | public void setCity(String city) { 27 | this.city = city; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/type/json/model/Participant.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.type.json.model; 2 | 3 | import io.hypersistence.utils.hibernate.type.json.JsonBinaryType; 4 | import jakarta.persistence.*; 5 | import org.hibernate.annotations.Type; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Participant") 11 | @Table(name = "participant") 12 | public class Participant extends BaseEntity { 13 | 14 | @Type(JsonBinaryType.class) 15 | @Column(columnDefinition = "jsonb") 16 | @Basic(fetch = FetchType.LAZY) 17 | private Ticket ticket; 18 | 19 | @ManyToOne(fetch = FetchType.LAZY) 20 | private Event event; 21 | 22 | public Ticket getTicket() { 23 | return ticket; 24 | } 25 | 26 | public void setTicket(Ticket ticket) { 27 | this.ticket = ticket; 28 | } 29 | 30 | public Event getEvent() { 31 | return event; 32 | } 33 | 34 | public void setEvent(Event event) { 35 | this.event = event; 36 | } 37 | } -------------------------------------------------------------------------------- /core/src/main/java/com/vladmihalcea/hpjp/hibernate/type/json/model/Ticket.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.type.json.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class Ticket implements Serializable { 9 | 10 | private String registrationCode; 11 | 12 | private double price; 13 | 14 | public String getRegistrationCode() { 15 | return registrationCode; 16 | } 17 | 18 | public void setRegistrationCode(String registrationCode) { 19 | this.registrationCode = registrationCode; 20 | } 21 | 22 | public double getPrice() { 23 | return price; 24 | } 25 | 26 | public void setPrice(double price) { 27 | this.price = price; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/audit/envers/EnversAuditedValidityStrategyTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.audit.envers; 2 | 3 | import java.util.Properties; 4 | 5 | import org.hibernate.envers.configuration.EnversSettings; 6 | import org.hibernate.envers.strategy.internal.ValidityAuditStrategy; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public class EnversAuditedValidityStrategyTest extends EnversAuditedDefaultStrategyTest { 12 | 13 | @Override 14 | protected void additionalProperties(Properties properties) { 15 | properties.setProperty( 16 | EnversSettings.AUDIT_STRATEGY, 17 | ValidityAuditStrategy.class.getName() 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/audit/hibernate/model/Auditable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.audit.hibernate.model; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface Auditable { 7 | 8 | I getId(); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/audit/hibernate/model/LoggedUser.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.audit.hibernate.model; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class LoggedUser { 7 | 8 | private static final ThreadLocal userHolder = new ThreadLocal<>(); 9 | 10 | public static void logIn(String user) { 11 | userHolder.set(user); 12 | } 13 | 14 | public static void logOut() { 15 | userHolder.remove(); 16 | } 17 | 18 | public static String get() { 19 | return userHolder.get(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/audit/hibernate/model/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.audit.hibernate.model; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Post") 11 | @Table(name = "post") 12 | public class Post implements Auditable { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String title; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Post setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 30 | } 31 | 32 | public Post setTitle(String title) { 33 | this.title = title; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/batch/failure/MySQLBatchUpdateExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.batch.failure; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.sql.BatchUpdateException; 6 | import java.util.Arrays; 7 | 8 | import static org.junit.Assert.assertSame; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | public class MySQLBatchUpdateExceptionTest extends AbstractBatchUpdateExceptionTest { 14 | 15 | @Override 16 | protected Database database() { 17 | return Database.MYSQL; 18 | } 19 | 20 | @Override 21 | protected void onBatchUpdateException(BatchUpdateException e) { 22 | assertSame(3, e.getUpdateCounts().length); 23 | LOGGER.info(e.getMessage()); 24 | LOGGER.info( 25 | "Batch has managed to process {} entries", 26 | Arrays.stream(e.getUpdateCounts()).asLongStream().filter(l -> l > 0).count() 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/batch/failure/OracleBatchUpdateExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.batch.failure; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.sql.*; 6 | 7 | import static org.junit.Assert.assertEquals; 8 | import static org.junit.Assert.assertSame; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | public class OracleBatchUpdateExceptionTest extends AbstractBatchUpdateExceptionTest { 14 | 15 | @Override 16 | protected Database database() { 17 | return Database.ORACLE; 18 | } 19 | 20 | @Override 21 | protected void onBatchUpdateException(BatchUpdateException e) { 22 | assertSame(2, e.getUpdateCounts().length); 23 | LOGGER.info(e.getMessage()); 24 | LOGGER.info("Batch has managed to process {} entries", e.getUpdateCounts().length); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/batch/failure/PostgreSQLBatchUpdateExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.batch.failure; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.sql.BatchUpdateException; 6 | 7 | import static org.junit.Assert.assertSame; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | public class PostgreSQLBatchUpdateExceptionTest extends AbstractBatchUpdateExceptionTest { 13 | 14 | @Override 15 | protected Database database() { 16 | return Database.POSTGRESQL; 17 | } 18 | 19 | @Override 20 | protected void onBatchUpdateException(BatchUpdateException e) { 21 | LOGGER.info("Batch failure", e); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/batch/failure/SQLServerBatchUpdateExceptionTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.batch.failure; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.sql.BatchUpdateException; 6 | import java.util.Arrays; 7 | 8 | import static org.junit.Assert.assertSame; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | public class SQLServerBatchUpdateExceptionTest extends AbstractBatchUpdateExceptionTest { 14 | 15 | @Override 16 | protected Database database() { 17 | return Database.SQLSERVER; 18 | } 19 | 20 | @Override 21 | protected void onBatchUpdateException(BatchUpdateException e) { 22 | assertSame(3, e.getUpdateCounts().length); 23 | LOGGER.info(e.getMessage()); 24 | LOGGER.info("Batch has managed to process {} entries", 25 | Arrays.stream(e.getUpdateCounts()).asLongStream().filter(l -> l > 0).count() 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/batch/identity/stateless/NoIdentityGenerator.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.batch.identity.stateless; 2 | 3 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 4 | import org.hibernate.id.IdentifierGenerator; 5 | import org.hibernate.id.factory.spi.StandardGenerator; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class NoIdentityGenerator implements IdentifierGenerator, StandardGenerator { 11 | 12 | @Override 13 | public Object generate(SharedSessionContractImplementor session, Object obj) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/batch/identity/stateless/model/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.batch.identity.stateless.model; 2 | 3 | import jakarta.persistence.*; 4 | import org.hibernate.annotations.GenericGenerator; 5 | import org.hibernate.annotations.SQLInsert; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Post") 11 | @Table(name = "post") 12 | public class Post extends AbstractPost { 13 | 14 | @Id 15 | @GeneratedValue(strategy = GenerationType.IDENTITY) 16 | private Long id; 17 | 18 | public Long getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Long id) { 23 | this.id = id; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/cache/LoadedStateReferenceEntitiesTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.cache; 2 | 3 | import java.util.Properties; 4 | 5 | 6 | /** 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public class LoadedStateReferenceEntitiesTest extends LoadedStateBenchmarkTest { 11 | 12 | public LoadedStateReferenceEntitiesTest(int insertCount) { 13 | super(insertCount); 14 | } 15 | 16 | @Override 17 | protected Properties properties() { 18 | Properties properties = super.properties(); 19 | properties.put("hibernate.cache.use_reference_entries", Boolean.TRUE.toString()); 20 | return properties; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/cache/query/PostCommentSummary.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.cache.query; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PostCommentSummary { 7 | 8 | private Long commentId; 9 | 10 | private String title; 11 | 12 | private String review; 13 | 14 | public PostCommentSummary(Long commentId, String title, String review) { 15 | this.commentId = commentId; 16 | this.title = title; 17 | this.review = review; 18 | } 19 | 20 | public Long getCommentId() { 21 | return commentId; 22 | } 23 | 24 | public String getTitle() { 25 | return title; 26 | } 27 | 28 | public String getReview() { 29 | return review; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/cache/transactional/identity/IdentityTransactionalCacheConcurrencyStrategyTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.cache.transactional.identity; 2 | 3 | import com.vladmihalcea.hpjp.util.spring.config.jta.HSQLDBJtaTransactionManagerConfiguration; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | import java.util.Properties; 7 | 8 | @Configuration 9 | public class IdentityTransactionalCacheConcurrencyStrategyTestConfiguration extends 10 | HSQLDBJtaTransactionManagerConfiguration { 11 | 12 | @Override 13 | protected Properties additionalProperties() { 14 | Properties properties = super.additionalProperties(); 15 | properties.put("hibernate.cache.region.factory_class", "jcache"); 16 | properties.put("hibernate.generate_statistics", Boolean.TRUE.toString()); 17 | return properties; 18 | } 19 | 20 | @Override 21 | protected Class configurationClass() { 22 | return IdentityTransactionalEntities.class; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/concurrency/LockModeOptimisticWithPessimisticLockUpgradeTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.concurrency; 2 | 3 | import jakarta.persistence.EntityManager; 4 | import jakarta.persistence.LockModeType; 5 | 6 | /** 7 | * LockModeOptimisticWithPessimisticLockUpgradeTest - Test to check LockMode.OPTIMISTIC with pessimistic lock upgrade 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class LockModeOptimisticWithPessimisticLockUpgradeTest extends LockModeOptimisticRaceConditionTest { 12 | 13 | @Override 14 | protected void lockUpgrade(EntityManager entityManager, Post post) { 15 | entityManager.lock(post, LockModeType.PESSIMISTIC_READ); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/concurrency/acid/Account.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.concurrency.acid; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Account") 11 | @Table(name = "account") 12 | public class Account { 13 | 14 | @Id 15 | private String id; 16 | 17 | private String owner; 18 | 19 | private long balance; 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public String getOwner() { 30 | return owner; 31 | } 32 | 33 | public void setOwner(String owner) { 34 | this.owner = owner; 35 | } 36 | 37 | public long getAccountBalance() { 38 | return balance; 39 | } 40 | 41 | public void setBalance(long balance) { 42 | this.balance = balance; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/concurrency/deadlock/fk/MySQLFKNoParentLockSerializableTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.concurrency.deadlock.fk; 2 | 3 | import org.hibernate.Session; 4 | 5 | import jakarta.persistence.EntityManager; 6 | import java.sql.Connection; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public class MySQLFKNoParentLockSerializableTest extends MySQLFKNoParentLockRRTest { 12 | 13 | protected void prepareConnection(EntityManager entityManager) { 14 | entityManager.unwrap(Session.class).doWork(connection -> { 15 | connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); 16 | setJdbcTimeout(connection); 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/concurrency/version/ShortVersionType.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.concurrency.version; 2 | 3 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 4 | import org.hibernate.type.descriptor.java.ShortJavaType; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class ShortVersionType extends ShortJavaType { 10 | 11 | @Override 12 | public Short seed(Long length, Integer precision, Integer scale, SharedSessionContractImplementor session) { 13 | return Short.MIN_VALUE; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/connection/C3P0ConnectionProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.connection; 2 | 3 | import org.hibernate.c3p0.internal.C3P0ConnectionProvider; 4 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; 5 | 6 | import java.util.Properties; 7 | 8 | public class C3P0ConnectionProviderTest extends JPADriverConnectionProviderTest { 9 | 10 | @Override 11 | protected void appendDriverProperties(Properties properties) { 12 | super.appendDriverProperties(properties); 13 | int maxPoolSize = 5; 14 | properties.put("hibernate.c3p0.min_size", 1); 15 | properties.put("hibernate.c3p0.max_size", maxPoolSize); 16 | } 17 | 18 | @Override 19 | public Class expectedConnectionProviderClass() { 20 | return C3P0ConnectionProvider.class; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/connection/C3P0JPAConnectionProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.connection; 2 | 3 | import org.hibernate.c3p0.internal.C3P0ConnectionProvider; 4 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; 5 | 6 | import java.util.Properties; 7 | 8 | public class C3P0JPAConnectionProviderTest extends DriverManagerConnectionProviderTest { 9 | 10 | @Override 11 | protected void appendDriverProperties(Properties properties) { 12 | super.appendDriverProperties(properties); 13 | properties.put("hibernate.c3p0.min_size", 1); 14 | properties.put("hibernate.c3p0.max_size", 5); 15 | } 16 | 17 | @Override 18 | public Class expectedConnectionProviderClass() { 19 | return C3P0ConnectionProvider.class; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/connection/DataSourceProxyConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.connection; 2 | 3 | import net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener; 4 | import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; 5 | import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl; 6 | 7 | import javax.sql.DataSource; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | public class DataSourceProxyConnectionProvider extends DatasourceConnectionProviderImpl { 14 | 15 | @Override 16 | public void configure(Map configValues) { 17 | super.configure(configValues); 18 | DataSource dataSource = ProxyDataSourceBuilder 19 | .create(getDataSource()) 20 | .name(getClass().getSimpleName()) 21 | .listener(new SLF4JQueryLoggingListener()) 22 | .build(); 23 | super.setDataSource(dataSource); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/connection/HikariCPConnectionProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.connection; 2 | 3 | import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; 4 | import org.hibernate.hikaricp.internal.HikariCPConnectionProvider; 5 | 6 | import java.util.Properties; 7 | 8 | public class HikariCPConnectionProviderTest extends DriverManagerConnectionProviderTest { 9 | 10 | @Override 11 | protected void appendDriverProperties(Properties properties) { 12 | super.appendDriverProperties(properties); 13 | String maxPoolSize = String.valueOf(5); 14 | properties.put("hibernate.hikari.maximumPoolSize", maxPoolSize); 15 | properties.put("hibernate.hikari.minimumIdle", maxPoolSize); 16 | } 17 | 18 | @Override 19 | public Class expectedConnectionProviderClass() { 20 | return HikariCPConnectionProvider.class; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/connection/JPADataSourceProxyConnectionProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.connection; 2 | 3 | import java.util.Properties; 4 | 5 | public class JPADataSourceProxyConnectionProviderTest extends JPADataSourceConnectionProviderTest { 6 | 7 | protected void appendDriverProperties(Properties properties) { 8 | properties.put("hibernate.connection.provider_class", DataSourceProxyConnectionProvider.class.getName()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/connection/JPADriverConnectionProviderTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.connection; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | 5 | import java.util.Properties; 6 | 7 | public class JPADriverConnectionProviderTest extends DriverManagerConnectionProviderTest { 8 | 9 | protected void appendDriverProperties(Properties properties) { 10 | DataSourceProvider dataSourceProvider = dataSourceProvider(); 11 | properties.put("jakarta.persistence.jdbc.driver", dataSourceProvider.driverClassName().getName()); 12 | properties.put("jakarta.persistence.jdbc.url", dataSourceProvider.url()); 13 | properties.put("jakarta.persistence.jdbc.user", dataSourceProvider.username()); 14 | properties.put("jakarta.persistence.jdbc.password", dataSourceProvider.password()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/criteria/blaze/bulk/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.criteria.blaze.bulk; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum PostStatus { 7 | PENDING, 8 | APPROVED, 9 | SPAM 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/criteria/blaze/tab/AbstractEntity.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.criteria.blaze.tab; 2 | 3 | import org.springframework.lang.Nullable; 4 | 5 | import jakarta.persistence.MappedSuperclass; 6 | import jakarta.persistence.PostLoad; 7 | import jakarta.persistence.PrePersist; 8 | import jakarta.persistence.Transient; 9 | import java.io.Serializable; 10 | 11 | @MappedSuperclass 12 | public abstract class AbstractEntity implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | @Transient 17 | private boolean isNew = true; 18 | 19 | public boolean isNew() { 20 | return isNew; 21 | } 22 | 23 | @Nullable 24 | public abstract I getId(); 25 | 26 | @PrePersist 27 | @PostLoad 28 | void markNotNew() { 29 | this.isNew = false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/criteria/blaze/tab/cte/TabKeyVer.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.criteria.blaze.tab.cte; 2 | 3 | import com.blazebit.persistence.CTE; 4 | 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.Id; 7 | import java.io.Serializable; 8 | 9 | @CTE 10 | @Entity 11 | public class TabKeyVer implements Serializable { 12 | @Id 13 | private Long tabKey; 14 | @Id 15 | private Long tabVer; 16 | } -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/criteria/literal/BindCriteriaLiteralTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.criteria.literal; 2 | 3 | import org.hibernate.cfg.AvailableSettings; 4 | import org.hibernate.query.criteria.ValueHandlingMode; 5 | 6 | import java.util.Properties; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public class BindCriteriaLiteralTest extends DefaultCriteriaLiteralTest { 12 | 13 | @Override 14 | protected void additionalProperties(Properties properties) { 15 | properties.put(AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, ValueHandlingMode.BIND); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/criteria/literal/InlineCriteriaLiteralTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.criteria.literal; 2 | 3 | import org.hibernate.cfg.AvailableSettings; 4 | import org.hibernate.query.criteria.ValueHandlingMode; 5 | 6 | import java.util.Properties; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public class InlineCriteriaLiteralTest extends DefaultCriteriaLiteralTest { 12 | 13 | @Override 14 | protected void additionalProperties(Properties properties) { 15 | properties.put(AvailableSettings.CRITERIA_VALUE_HANDLING_MODE, ValueHandlingMode.INLINE); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/fetching/PostCommentDTO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.fetching; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PostCommentDTO { 7 | 8 | private final Long id; 9 | 10 | private final String review; 11 | 12 | private final String title; 13 | 14 | public PostCommentDTO(Long id, String review, String title) { 15 | this.id = id; 16 | this.review = review; 17 | this.title = title; 18 | } 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public String getReview() { 25 | return review; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/fetching/PostCommentSummary.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.fetching; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PostCommentSummary { 7 | 8 | private Number id; 9 | private String title; 10 | private String review; 11 | 12 | public PostCommentSummary(Number id, String title, String review) { 13 | this.id = id; 14 | this.title = title; 15 | this.review = review; 16 | } 17 | 18 | public PostCommentSummary() {} 19 | 20 | public Number getId() { 21 | return id; 22 | } 23 | 24 | public String getTitle() { 25 | return title; 26 | } 27 | 28 | public String getReview() { 29 | return review; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/fetching/detector/AssociationFetchLoadEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.fetching.detector; 2 | 3 | import org.hibernate.event.spi.LoadEvent; 4 | import org.hibernate.event.spi.LoadEventListener; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class AssociationFetchLoadEventListener implements LoadEventListener { 10 | 11 | public static final AssociationFetchLoadEventListener INSTANCE = new AssociationFetchLoadEventListener(); 12 | 13 | @Override 14 | public void onLoad(LoadEvent event, LoadType loadType) { 15 | AssociationFetch.Context 16 | .get(event.getSession()) 17 | .load(event); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/fetching/detector/AssociationFetchPostLoadEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.fetching.detector; 2 | 3 | import org.hibernate.event.spi.PostLoadEvent; 4 | import org.hibernate.event.spi.PostLoadEventListener; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class AssociationFetchPostLoadEventListener implements PostLoadEventListener { 10 | 11 | public static final AssociationFetchPostLoadEventListener INSTANCE = new AssociationFetchPostLoadEventListener(); 12 | 13 | @Override 14 | public void onPostLoad(PostLoadEvent event) { 15 | AssociationFetch.Context 16 | .get(event.getSession()) 17 | .postLoad(event); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/fetching/detector/AssociationFetchPreLoadEventListener.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.fetching.detector; 2 | 3 | import org.hibernate.event.spi.LoadEvent; 4 | import org.hibernate.event.spi.LoadEventListener; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class AssociationFetchPreLoadEventListener implements LoadEventListener { 10 | 11 | public static final AssociationFetchPreLoadEventListener INSTANCE = new AssociationFetchPreLoadEventListener(); 12 | 13 | @Override 14 | public void onLoad(LoadEvent event, LoadType loadType) { 15 | AssociationFetch.Context 16 | .get(event.getSession()) 17 | .preLoad(event); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/EnhancedSequenceVsTableGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier; 2 | 3 | import java.util.Properties; 4 | 5 | public class EnhancedSequenceVsTableGeneratorTest extends SequenceVsTableGeneratorTest { 6 | 7 | @Override 8 | protected Properties properties() { 9 | Properties properties = super.properties(); 10 | properties.put("hibernate.id.new_generator_mappings", "true"); 11 | return properties; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/Identifiable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Identifiable - Identifiable 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public interface Identifiable { 11 | 12 | T getId(); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/LegacySequenceVsTableGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier; 2 | 3 | import java.util.Properties; 4 | 5 | public class LegacySequenceVsTableGeneratorTest extends SequenceVsTableGeneratorTest { 6 | 7 | @Override 8 | protected Properties properties() { 9 | Properties properties = super.properties(); 10 | properties.put("hibernate.id.new_generator_mappings", "false"); 11 | return properties; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/batch/AbstractBatchIdentifierTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.batch; 2 | 3 | import com.vladmihalcea.hpjp.util.AbstractTest; 4 | 5 | import java.util.Properties; 6 | 7 | public abstract class AbstractBatchIdentifierTest extends AbstractTest { 8 | 9 | @Override 10 | protected void additionalProperties(Properties properties) { 11 | properties.put("hibernate.order_inserts", "true"); 12 | properties.put("hibernate.order_updates", "true"); 13 | properties.put("hibernate.jdbc.batch_size", "2"); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/batch/AssignedTableGenerator.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.batch; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.identifier.Identifiable; 4 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 5 | import org.hibernate.id.enhanced.TableGenerator; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * AssignedTableGenerator - Assigned TableGenerator 11 | * 12 | * @author Vlad Mihalcea 13 | */ 14 | public class AssignedTableGenerator extends TableGenerator { 15 | 16 | @Override 17 | public Object generate(SharedSessionContractImplementor session, Object obj) { 18 | if(obj instanceof Identifiable) { 19 | Identifiable identifiable = (Identifiable) obj; 20 | Serializable id = identifiable.getId(); 21 | if(id != null) { 22 | return id; 23 | } 24 | } 25 | return super.generate(session, obj); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/batch/concurrent/providers/IdentityPostEntityProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.batch.concurrent.providers; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class IdentityPostEntityProvider extends PostEntityProvider { 9 | 10 | public IdentityPostEntityProvider() { 11 | super(Post.class); 12 | } 13 | 14 | @Override 15 | public Post newPost() { 16 | return new Post(); 17 | } 18 | 19 | @Entity(name = "Post") 20 | @Table(name = "post") 21 | public static class Post { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private Long id; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/batch/concurrent/providers/PostEntityProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.batch.concurrent.providers; 2 | 3 | import com.vladmihalcea.hpjp.util.EntityProvider; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public abstract class PostEntityProvider implements EntityProvider { 9 | 10 | private final Class clazz; 11 | 12 | protected PostEntityProvider(Class clazz) { 13 | this.clazz = clazz; 14 | } 15 | 16 | public abstract T newPost(); 17 | 18 | @Override 19 | public Class[] entities() { 20 | return new Class[] { 21 | clazz 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/batch/jta/JTATableIdentifierTestConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.batch.jta; 2 | 3 | import com.vladmihalcea.hpjp.util.spring.config.jta.PostgreSQLJTATransactionManagerConfiguration; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | public class JTATableIdentifierTestConfiguration extends PostgreSQLJTATransactionManagerConfiguration { 8 | 9 | @Override 10 | protected Class configurationClass() { 11 | return Post.class; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/batch/jta/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.batch.jta; 2 | 3 | import org.hibernate.annotations.GenericGenerator; 4 | 5 | import jakarta.persistence.*; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Post") 11 | @Table(name = "post") 12 | public class Post { 13 | 14 | @Id 15 | @GenericGenerator(name = "table", strategy = "enhanced-table", parameters = { 16 | @org.hibernate.annotations.Parameter(name = "table_name", value = "sequence_table") 17 | }) 18 | @GeneratedValue(generator = "table", strategy = GenerationType.TABLE) 19 | private Long id; 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/global/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.global; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @Entity(name = "Post") 9 | @Table(name = "post") 10 | public class Post { 11 | 12 | @Id 13 | @GeneratedValue(generator = "post_sequence", strategy = GenerationType.SEQUENCE) 14 | @SequenceGenerator(name = "post_sequence", allocationSize = 10) 15 | private Long id; 16 | 17 | private String title; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public String getTitle() { 28 | return title; 29 | } 30 | 31 | public void setTitle(String title) { 32 | this.title = title; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/globalsequence/package-info.java: -------------------------------------------------------------------------------- 1 | @GenericGenerator( 2 | name = "pooled", 3 | strategy = "sequence", 4 | parameters = { 5 | @Parameter(name = "sequence_name", value = "sequence"), 6 | @Parameter(name = "initial_value", value = "1"), 7 | @Parameter(name = "increment_size", value = "5"), 8 | @Parameter(name = "optimizer", value = "pooled-lo"), 9 | } 10 | ) 11 | package com.vladmihalcea.hpjp.hibernate.identifier.globalsequence; 12 | 13 | import org.hibernate.annotations.GenericGenerator; 14 | import org.hibernate.annotations.Parameter; -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/identifier/optimizer/providers/PostEntityProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.identifier.optimizer.providers; 2 | 3 | import com.vladmihalcea.hpjp.util.EntityProvider; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public abstract class PostEntityProvider implements EntityProvider { 9 | 10 | private final Class clazz; 11 | 12 | protected PostEntityProvider(Class clazz) { 13 | this.clazz = clazz; 14 | } 15 | 16 | public abstract T newPost(); 17 | 18 | @Override 19 | public Class[] entities() { 20 | return new Class[] { 21 | clazz 22 | }; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/TablePerClassMySQLUnionAllTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.MySQLDataSourceProvider; 5 | import org.hibernate.dialect.MySQL8Dialect; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class TablePerClassMySQLUnionAllTest extends TablePerClassTest { 11 | 12 | @Override 13 | protected DataSourceProvider dataSourceProvider() { 14 | return new MySQLDataSourceProvider() { 15 | @Override 16 | public String hibernateDialect() { 17 | return MySQLUnionAllSupportDialect.class.getName(); 18 | } 19 | }; 20 | } 21 | 22 | public static class MySQLUnionAllSupportDialect extends MySQL8Dialect { 23 | @Override 24 | public boolean supportsUnionAll() { 25 | return true; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/TablePerClassMySQLUnionTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.MySQLDataSourceProvider; 5 | import org.hibernate.dialect.MySQL8Dialect; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class TablePerClassMySQLUnionTest extends TablePerClassTest { 11 | 12 | @Override 13 | protected DataSourceProvider dataSourceProvider() { 14 | return new MySQLDataSourceProvider() { 15 | @Override 16 | public String hibernateDialect() { 17 | return MySQLUnionSupportDialect.class.getName(); 18 | } 19 | }; 20 | } 21 | 22 | public static class MySQLUnionSupportDialect extends MySQL8Dialect { 23 | @Override 24 | public boolean supportsUnionAll() { 25 | return false; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/discriminator/description/Announcement.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.discriminator.description; 2 | 3 | import java.util.Date; 4 | import jakarta.persistence.DiscriminatorValue; 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.Table; 7 | import jakarta.persistence.Temporal; 8 | import jakarta.persistence.TemporalType; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | @Entity 14 | @DiscriminatorValue("2") 15 | public class Announcement extends Topic { 16 | 17 | @Temporal(TemporalType.TIMESTAMP) 18 | private Date validUntil; 19 | 20 | public Date getValidUntil() { 21 | return validUntil; 22 | } 23 | 24 | public void setValidUntil(Date validUntil) { 25 | this.validUntil = validUntil; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/discriminator/description/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.discriminator.description; 2 | 3 | import jakarta.persistence.DiscriminatorValue; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @DiscriminatorValue("1") 12 | public class Post extends Topic { 13 | 14 | private String content; 15 | 16 | public String getContent() { 17 | return content; 18 | } 19 | 20 | public void setContent(String content) { 21 | this.content = content; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/dao/GenericDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.dao; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public interface GenericDAO { 10 | 11 | T findById(ID id); 12 | 13 | List findAll(); 14 | 15 | T persist(T entity); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/dao/SubscriberDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.inheritance.spring.model.Subscriber; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface SubscriberDAO extends GenericDAO { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/dao/SubscriberDAOImpl.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.inheritance.spring.model.Subscriber; 4 | import org.springframework.stereotype.Repository; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @Repository 10 | public class SubscriberDAOImpl 11 | extends GenericDAOImpl 12 | implements SubscriberDAO { 13 | 14 | protected SubscriberDAOImpl() { 15 | super(Subscriber.class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/model/EmailSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.model; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @Table(name = "email_subscriber") 12 | public class EmailSubscriber extends Subscriber { 13 | 14 | @Column(name = "email_address", nullable = false) 15 | private String emailAddress; 16 | 17 | public String getEmailAddress() { 18 | return emailAddress; 19 | } 20 | 21 | public void setEmailAddress(String emailAddress) { 22 | this.emailAddress = emailAddress; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/model/SmsSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.model; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @Table(name = "sms_subscriber") 12 | public class SmsSubscriber extends Subscriber { 13 | 14 | @Column(name = "phone_number", nullable = false) 15 | private String phoneNumber; 16 | 17 | public String getPhoneNumber() { 18 | return phoneNumber; 19 | } 20 | 21 | public void setPhoneNumber(String phoneNumber) { 22 | this.phoneNumber = phoneNumber; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/service/CampaignService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.service; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface CampaignService { 7 | 8 | void send(String title, String message); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/service/sender/CampaignSender.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.service.sender; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.inheritance.spring.model.Subscriber; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface CampaignSender { 9 | 10 | Class appliesTo(); 11 | 12 | void send(String title, String message, S subscriber); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/service/sender/EmailCampaignSender.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.service.sender; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.inheritance.spring.model.EmailSubscriber; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Component 12 | public class EmailCampaignSender implements CampaignSender { 13 | 14 | protected final Logger LOGGER = LoggerFactory.getLogger(getClass()); 15 | 16 | @Override 17 | public Class appliesTo() { 18 | return EmailSubscriber.class; 19 | } 20 | 21 | @Override 22 | public void send(String title, String message, EmailSubscriber subscriber) { 23 | LOGGER.info("Send Email: {} - {} to address: {}", 24 | title, 25 | message, 26 | subscriber.getEmailAddress() 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/inheritance/spring/service/sender/SmsCampaignSender.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.inheritance.spring.service.sender; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.inheritance.spring.model.SmsSubscriber; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Component 12 | public class SmsCampaignSender implements CampaignSender { 13 | 14 | protected final Logger LOGGER = LoggerFactory.getLogger(getClass()); 15 | 16 | @Override 17 | public Class appliesTo() { 18 | return SmsSubscriber.class; 19 | } 20 | 21 | @Override 22 | public void send(String title, String message, SmsSubscriber subscriber) { 23 | LOGGER.info("Send SMS: {} - {} to phone number: {}", 24 | title, 25 | message, 26 | subscriber.getPhoneNumber() 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/listener/Updatable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.listener; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface Updatable { 9 | 10 | void setTimestamp(Date timestamp); 11 | 12 | Date getTimestamp(); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/listener/UpdatableListener.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.listener; 2 | 3 | import jakarta.persistence.PrePersist; 4 | import jakarta.persistence.PreUpdate; 5 | import java.util.Date; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class UpdatableListener { 11 | 12 | @PrePersist 13 | @PreUpdate 14 | private void setCurrentTimestamp(Object entity) { 15 | if(entity instanceof Updatable) { 16 | Updatable updatable = (Updatable) entity; 17 | updatable.setTimestamp(new Date()); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/logging/comment/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.logging.comment; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @Table(name = "post") 12 | public class Post { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String title; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Post setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 30 | } 31 | 32 | public Post setTitle(String title) { 33 | this.title = title; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/logging/inspector/SQLCommentStatementInspector.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.logging.inspector; 2 | 3 | import org.hibernate.resource.jdbc.spi.StatementInspector; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | public class SQLCommentStatementInspector implements StatementInspector { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger(SQLCommentStatementInspector.class); 15 | 16 | private static final Pattern SQL_COMMENT_PATTERN = Pattern.compile("\\/\\*.*?\\*\\/\\s*"); 17 | 18 | @Override 19 | public String inspect(String sql) { 20 | LOGGER.debug( 21 | "Executing SQL query: {}", 22 | sql 23 | ); 24 | 25 | return SQL_COMMENT_PATTERN.matcher(sql).replaceAll(""); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/logging/inspector/StatementInspectorSqlCommentTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.logging.inspector; 2 | 3 | import java.util.Properties; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class StatementInspectorSqlCommentTest extends SQLCommentTest { 9 | 10 | @Override 11 | protected void additionalProperties(Properties properties) { 12 | super.additionalProperties(properties); 13 | properties.put( 14 | "hibernate.session_factory.statement_inspector", 15 | SQLCommentStatementInspector.class.getName() 16 | ); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/logging/validator/sql/exception/SQLStatementCountMismatchException.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.logging.validator.sql.exception; 2 | 3 | /** 4 | * SQLStatementCountMismatchException - Thrown whenever there is a mismatch between expected statements count and 5 | * the ones being executed. 6 | * 7 | * @author Vlad Mihalcea 8 | */ 9 | public class SQLStatementCountMismatchException extends RuntimeException { 10 | 11 | private final long expected; 12 | private final long recorded; 13 | 14 | public SQLStatementCountMismatchException(long expected, long recorded) { 15 | super(String.format("Expected %d statement(s) but recorded %d instead!", 16 | expected, recorded)); 17 | this.expected = expected; 18 | this.recorded = recorded; 19 | } 20 | 21 | public long getExpected() { 22 | return expected; 23 | } 24 | 25 | public long getRecorded() { 26 | return recorded; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/mapping/types/CreationDetails.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.mapping.types; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Embeddable; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Embeddable 12 | public class CreationDetails { 13 | 14 | @Column(name = "created_on") 15 | private LocalDateTime createdOn = LocalDateTime.now(); 16 | 17 | @Column(name = "created_by") 18 | private String createdBy; 19 | 20 | public LocalDateTime getCreatedOn() { 21 | return createdOn; 22 | } 23 | 24 | public CreationDetails setCreatedOn(LocalDateTime createdOn) { 25 | this.createdOn = createdOn; 26 | return this; 27 | } 28 | 29 | public String getCreatedBy() { 30 | return createdBy; 31 | } 32 | 33 | public CreationDetails setCreatedBy(String createdBy) { 34 | this.createdBy = createdBy; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/mapping/types/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.mapping.types; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum PostStatus { 7 | PENDING, 8 | APPROVED, 9 | SPAM 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/multitenancy/partition/PartitionContext.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.multitenancy.partition; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PartitionContext { 7 | 8 | public static final String DEFAULT_PARTITION = "default"; 9 | 10 | private static final ThreadLocal CURRENT_PARTITION = new ThreadLocal<>(); 11 | 12 | public static String get() { 13 | String currentTenantId = CURRENT_PARTITION.get(); 14 | return currentTenantId != null ? currentTenantId : DEFAULT_PARTITION; 15 | } 16 | 17 | public static void set(String tenantId) { 18 | CURRENT_PARTITION.set(tenantId); 19 | } 20 | 21 | public static void reset() { 22 | CURRENT_PARTITION.remove(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/naming/ExtendedNamingTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.naming; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.util.Properties; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class ExtendedNamingTest extends DefaultNamingTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.ORACLE; 15 | } 16 | 17 | @Override 18 | protected void additionalProperties(Properties properties) { 19 | properties.put( 20 | "hibernate.physical_naming_strategy", 21 | OracleNamingStrategy.class.getName() 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/naming/OracleNamingStrategy.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.naming; 2 | 3 | import org.hibernate.boot.model.naming.Identifier; 4 | import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl; 5 | import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class OracleNamingStrategy extends PhysicalNamingStrategyStandardImpl { 11 | 12 | @Override 13 | public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) { 14 | Identifier original = super.toPhysicalColumnName(name, context); 15 | if(original.getText().length() > 30) { 16 | return Identifier.toIdentifier(original.getText().substring(0, 30), original.isQuoted()); 17 | } 18 | return original; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/dto/mixed/Country.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.dto.mixed; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.Id; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Country") 11 | public class Country { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | private String name; 18 | 19 | private String locale; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getLocale() { 38 | return locale; 39 | } 40 | 41 | public void setLocale(String locale) { 42 | this.locale = locale; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/dto/mixed/Person.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.dto.mixed; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.Id; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Person") 11 | public class Person { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | private String name; 18 | 19 | private String locale; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getLocale() { 38 | return locale; 39 | } 40 | 41 | public void setLocale(String locale) { 42 | this.locale = locale; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/dto/mixed/PersonAndCountryDTO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.dto.mixed; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PersonAndCountryDTO { 7 | 8 | private final Person person; 9 | 10 | private final String country; 11 | 12 | public PersonAndCountryDTO(Person person, String country) { 13 | this.person = person; 14 | this.country = country; 15 | } 16 | 17 | public Person getPerson() { 18 | return person; 19 | } 20 | 21 | public String getCountry() { 22 | return country; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/dto/projection/PostComment.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.dto.projection; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @Entity 9 | @Table(name = "post_comment") 10 | public class PostComment { 11 | 12 | @Id 13 | private Long id; 14 | 15 | @ManyToOne(fetch = FetchType.LAZY) 16 | private Post post; 17 | 18 | private String review; 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public PostComment setId(Long id) { 25 | this.id = id; 26 | return this; 27 | } 28 | 29 | public Post getPost() { 30 | return post; 31 | } 32 | 33 | public PostComment setPost(Post post) { 34 | this.post = post; 35 | return this; 36 | } 37 | 38 | public String getReview() { 39 | return review; 40 | } 41 | 42 | public PostComment setReview(String review) { 43 | this.review = review; 44 | return this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/dto/projection/transformer/DistinctListTransformer.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.dto.projection.transformer; 2 | 3 | import org.hibernate.query.ResultListTransformer; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class DistinctListTransformer implements ResultListTransformer { 12 | 13 | public static final DistinctListTransformer INSTANCE = new DistinctListTransformer(); 14 | 15 | @Override 16 | public List transformList(List collection) { 17 | return collection.stream().distinct().toList(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/dto/projection/transformer/PostDTOResultTransformer.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.dto.projection.transformer; 2 | 3 | /** 4 | * 5 | * @author Vlad Mihalcea 6 | */ 7 | public class PostDTOResultTransformer extends PostDTOTupleTransformer { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/function/PostSummaryDTO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.function; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class PostSummaryDTO { 7 | 8 | private Long id; 9 | 10 | private String title; 11 | 12 | private String tags; 13 | 14 | public PostSummaryDTO() { 15 | } 16 | 17 | public PostSummaryDTO(Long id, String title, String tags) { 18 | this.id = id; 19 | this.title = title; 20 | this.tags = tags; 21 | } 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getTitle() { 32 | return title; 33 | } 34 | 35 | public void setTitle(String title) { 36 | this.title = title; 37 | } 38 | 39 | public String getTags() { 40 | return tags; 41 | } 42 | 43 | public void setTags(String tags) { 44 | this.tags = tags; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/hierarchical/PostCommentTreeTupleTransformer.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.hierarchical; 2 | 3 | import org.hibernate.query.TupleTransformer; 4 | import org.hibernate.transform.ResultTransformer; 5 | 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | public class PostCommentTreeTupleTransformer implements TupleTransformer { 13 | 14 | public static final PostCommentTreeTupleTransformer INSTANCE = new PostCommentTreeTupleTransformer(); 15 | 16 | @Override 17 | public Object transformTuple(Object[] tuple, String[] aliases) { 18 | PostComment comment = (PostComment) tuple[0]; 19 | if (comment.getParent() != null) { 20 | comment.getParent().addChild(comment); 21 | } 22 | return comment.getRoot(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/hierarchical/Status.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.hierarchical; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum Status { 7 | 8 | APPROVED, 9 | PENDING 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/join/algorithm/Tuple.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.join.algorithm; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class Tuple { 10 | 11 | private final Map valueMap = new HashMap<>(); 12 | 13 | public Tuple add(String alias, Object value) { 14 | valueMap.put(alias, value); 15 | return this; 16 | } 17 | 18 | public E get(String alias) { 19 | return (E) valueMap.get(alias); 20 | } 21 | 22 | public long getLong(String alias) { 23 | return (Long) valueMap.get(alias); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/pivot/Component.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.pivot; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @Entity 10 | public class Component { 11 | 12 | @Id 13 | private String name; 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/pivot/Property.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.pivot; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.EmbeddedId; 5 | import jakarta.persistence.Entity; 6 | 7 | /** 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | @Entity 12 | public class Property { 13 | 14 | @EmbeddedId 15 | private PropertyId id; 16 | 17 | @Column(name = "property_value") 18 | private String value; 19 | 20 | public PropertyId getId() { 21 | return id; 22 | } 23 | 24 | public void setId(PropertyId id) { 25 | this.id = id; 26 | } 27 | 28 | public String getValue() { 29 | return value; 30 | } 31 | 32 | public void setValue(String value) { 33 | this.value = value; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/pivot/Service.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.pivot; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @Entity 10 | public class Service { 11 | 12 | @Id 13 | private String name; 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/recursive/simple/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.recursive.simple; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Post") 11 | @Table(name = "post") 12 | public class Post { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String title; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | 27 | public String getTitle() { 28 | return title; 29 | } 30 | 31 | public void setTitle(String title) { 32 | this.title = title; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/query/subquery/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.query.subquery; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Post") 11 | @Table(name = "post") 12 | public class Post { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String title; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Post setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 30 | } 31 | 32 | public Post setTitle(String title) { 33 | this.title = title; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/schema/flyway/HSQLDBFlywayConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.schema.flyway; 2 | 3 | import com.vladmihalcea.hpjp.util.spring.config.flyway.AbstractHSQLDBFlywayConfiguration; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @Configuration 10 | public class HSQLDBFlywayConfiguration extends AbstractHSQLDBFlywayConfiguration { 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/schema/flyway/PostgreSQLFlywayConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.schema.flyway; 2 | 3 | import com.vladmihalcea.hpjp.util.spring.config.flyway.AbstractPostgreSQLFlywayConfiguration; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @Configuration 10 | public class PostgreSQLFlywayConfiguration extends AbstractPostgreSQLFlywayConfiguration { 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/statistics/TransactionStatisticsFactory.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.statistics; 2 | 3 | import org.hibernate.engine.spi.SessionFactoryImplementor; 4 | import org.hibernate.stat.spi.StatisticsFactory; 5 | import org.hibernate.stat.spi.StatisticsImplementor; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class TransactionStatisticsFactory implements StatisticsFactory { 11 | 12 | @Override 13 | public StatisticsImplementor buildStatistics( 14 | SessionFactoryImplementor sessionFactory) { 15 | return new TransactionStatistics(sessionFactory); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/time/utc/UTCTimeZonePostgreSQLTimestampTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.time.utc; 2 | 3 | import org.hibernate.cfg.AvailableSettings; 4 | 5 | import java.util.Properties; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class UTCTimeZonePostgreSQLTimestampTest extends DefaultPostgreSQLTimestampTest { 11 | 12 | @Override 13 | protected Properties properties() { 14 | Properties properties = super.properties(); 15 | properties.setProperty(AvailableSettings.JDBC_TIME_ZONE, "UTC"); 16 | return properties; 17 | } 18 | 19 | @Override 20 | protected String expectedServerTimestamp() { 21 | return "2016-08-25 11:23:46"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/transaction/forum/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.transaction.forum; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Entity 12 | @Table(name = "tag") 13 | public class Tag { 14 | 15 | @Id 16 | @GeneratedValue 17 | private Long id; 18 | 19 | private String name; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public void setId(Long id) { 26 | this.id = id; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/hibernate/type/TaskTypingTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.hibernate.type; 2 | 3 | import com.vladmihalcea.hpjp.util.AbstractPostgreSQLIntegrationTest; 4 | import com.vladmihalcea.hpjp.util.providers.entity.TaskEntityProvider; 5 | import org.junit.Test; 6 | 7 | /** 8 | * EntityGraphMapperTest - Test mapping to entity 9 | * 10 | * @author Vlad Mihalcea 11 | */ 12 | public class TaskTypingTest extends AbstractPostgreSQLIntegrationTest { 13 | 14 | private TaskEntityProvider entityProvider = new TaskEntityProvider(); 15 | 16 | @Override 17 | protected Class[] entities() { 18 | return entityProvider.entities(); 19 | } 20 | 21 | @Test 22 | public void testJdbcOneToManyMapping() { 23 | doInJDBC(connection -> { 24 | 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/NoBatchPreparedStatementTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.sql.PreparedStatement; 6 | import java.sql.SQLException; 7 | 8 | /** 9 | * NoBatchPreparedStatementTest - Test without batching PreparedStatements 10 | * 11 | * @author Vlad Mihalcea 12 | */ 13 | public class NoBatchPreparedStatementTest extends AbstractBatchPreparedStatementTest { 14 | 15 | public NoBatchPreparedStatementTest(Database database) { 16 | super(database); 17 | } 18 | 19 | @Override 20 | protected void onStatement(PreparedStatement statement) throws SQLException { 21 | statement.executeUpdate(); 22 | } 23 | 24 | @Override 25 | protected void onEnd(PreparedStatement statement) throws SQLException { 26 | } 27 | 28 | @Override 29 | protected void onFlush(PreparedStatement statement) throws SQLException { 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/NoBatchStatementTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | import java.sql.SQLException; 6 | import java.sql.Statement; 7 | 8 | /** 9 | * BatchStatementTest - Test without batching Statements 10 | * 11 | * @author Vlad Mihalcea 12 | */ 13 | public class NoBatchStatementTest extends AbstractBatchStatementTest { 14 | 15 | private int count; 16 | 17 | public NoBatchStatementTest(Database database) { 18 | super(database); 19 | } 20 | 21 | @Override 22 | protected void onStatement(Statement statement, String dml) throws SQLException { 23 | statement.executeUpdate(dml); 24 | count++; 25 | } 26 | 27 | @Override 28 | protected void onEnd(Statement statement) throws SQLException { 29 | //assertEquals((getPostCommentCount() + 1) * getPostCount(), count); 30 | } 31 | 32 | @Override 33 | protected void onFlush(Statement statement) { 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/generatedkeys/sequence/OracleSequenceCallTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch.generatedkeys.sequence; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.OracleDataSourceProvider; 5 | 6 | /** 7 | * OracleSequenceCallTest - Oracle sequence call 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class OracleSequenceCallTest extends AbstractSequenceCallTest { 12 | 13 | @Override 14 | protected String callSequenceSyntax() { 15 | return "select post_seq.NEXTVAL from dual"; 16 | } 17 | 18 | @Override 19 | protected DataSourceProvider dataSourceProvider() { 20 | return new OracleDataSourceProvider(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/generatedkeys/sequence/OracleSequenceGeneratedKeysBatchPreparedStatementTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch.generatedkeys.sequence; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.OracleDataSourceProvider; 5 | 6 | /** 7 | * OracleSequenceGeneratedKeysBatchPreparedStatementTest - Oracle class for testing JDBC PreparedStatement generated keys for Sequences 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class OracleSequenceGeneratedKeysBatchPreparedStatementTest extends AbstractSequenceGeneratedKeysBatchPreparedStatementTest { 12 | 13 | @Override 14 | protected String callSequenceSyntax() { 15 | return "select post_seq.NEXTVAL from dual"; 16 | } 17 | 18 | @Override 19 | protected DataSourceProvider dataSourceProvider() { 20 | return new OracleDataSourceProvider(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/generatedkeys/sequence/PostgreSQLSequenceCallTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch.generatedkeys.sequence; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.PostgreSQLDataSourceProvider; 5 | 6 | /** 7 | * PostgreSQLSequenceCallTest - PostgreSQL sequence call 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class PostgreSQLSequenceCallTest extends AbstractSequenceCallTest { 12 | 13 | @Override 14 | protected String callSequenceSyntax() { 15 | return "select nextval('post_seq')"; 16 | } 17 | 18 | @Override 19 | protected DataSourceProvider dataSourceProvider() { 20 | return new PostgreSQLDataSourceProvider(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/generatedkeys/sequence/PostgreSQLSequenceGeneratedKeysBatchPreparedStatementTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch.generatedkeys.sequence; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.PostgreSQLDataSourceProvider; 5 | 6 | /** 7 | * PostgreSQLSequenceGeneratedKeysBatchPreparedStatementTest - PostgreSQL class for testing JDBC PreparedStatement generated keys for Sequences 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class PostgreSQLSequenceGeneratedKeysBatchPreparedStatementTest extends AbstractSequenceGeneratedKeysBatchPreparedStatementTest { 12 | 13 | @Override 14 | protected String callSequenceSyntax() { 15 | return "select nextval('post_seq')"; 16 | } 17 | 18 | @Override 19 | protected DataSourceProvider dataSourceProvider() { 20 | return new PostgreSQLDataSourceProvider(); 21 | } 22 | } -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/generatedkeys/sequence/SQLServerSequenceCallTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch.generatedkeys.sequence; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.SQLServerDataSourceProvider; 5 | 6 | /** 7 | * PostgreSQLSequenceCallTest - PostgreSQL sequence call 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class SQLServerSequenceCallTest extends AbstractSequenceCallTest { 12 | 13 | @Override 14 | protected String callSequenceSyntax() { 15 | return "select NEXT VALUE FOR post_seq"; 16 | } 17 | 18 | @Override 19 | protected DataSourceProvider dataSourceProvider() { 20 | return new SQLServerDataSourceProvider(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/batch/generatedkeys/sequence/SQLServerSequenceGeneratedKeysBatchPreparedStatementTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.batch.generatedkeys.sequence; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.SQLServerDataSourceProvider; 5 | 6 | /** 7 | * SQLServerSequenceGeneratedKeysBatchPreparedStatementTest - SQL Server class for testing JDBC PreparedStatement generated keys for Sequences 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class SQLServerSequenceGeneratedKeysBatchPreparedStatementTest extends AbstractSequenceGeneratedKeysBatchPreparedStatementTest { 12 | 13 | @Override 14 | protected String callSequenceSyntax() { 15 | return "select NEXT VALUE FOR post_seq"; 16 | } 17 | 18 | @Override 19 | protected DataSourceProvider dataSourceProvider() { 20 | return new SQLServerDataSourceProvider(); 21 | } 22 | } -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/MySQLPredicateLockTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.MySQLDataSourceProvider; 5 | 6 | import java.sql.Connection; 7 | import java.sql.SQLException; 8 | 9 | import static org.junit.Assert.fail; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | public class MySQLPredicateLockTest extends AbstractPredicateLockTest { 15 | 16 | @Override 17 | protected DataSourceProvider dataSourceProvider() { 18 | return new MySQLDataSourceProvider(); 19 | } 20 | 21 | protected void prepareConnection(Connection connection) { 22 | try { 23 | connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); 24 | } catch (SQLException e) { 25 | fail(e.getMessage()); 26 | } 27 | executeStatement(connection, "SET GLOBAL innodb_lock_wait_timeout = 1"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/OraclePredicateLockTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.OracleDataSourceProvider; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class OraclePredicateLockTest extends AbstractPredicateLockTest { 10 | 11 | @Override 12 | protected DataSourceProvider dataSourceProvider() { 13 | return new OracleDataSourceProvider(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/OracleTableLockTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.OracleDataSourceProvider; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class OracleTableLockTest extends AbstractTableLockTest { 10 | 11 | @Override 12 | protected DataSourceProvider dataSourceProvider() { 13 | return new OracleDataSourceProvider(); 14 | } 15 | 16 | @Override 17 | protected String lockEmployeeTableSql() { 18 | return "LOCK TABLE employee IN SHARE MODE"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/PostgreSQLTableLockTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.PostgreSQLDataSourceProvider; 5 | 6 | import java.sql.Connection; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public class PostgreSQLTableLockTest extends AbstractTableLockTest { 12 | 13 | @Override 14 | protected DataSourceProvider dataSourceProvider() { 15 | return new PostgreSQLDataSourceProvider(); 16 | } 17 | 18 | @Override 19 | protected String lockEmployeeTableSql() { 20 | return "LOCK TABLE employee IN SHARE ROW EXCLUSIVE MODE"; 21 | } 22 | 23 | @Override 24 | protected void prepareConnection(Connection connection) { 25 | executeStatement(connection, "SET statement_timeout TO 1000"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/SQLServerPredicateLockTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.SQLServerDataSourceProvider; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class SQLServerPredicateLockTest extends AbstractPredicateLockTest { 10 | 11 | @Override 12 | protected DataSourceProvider dataSourceProvider() { 13 | return new SQLServerDataSourceProvider(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/SQLServerTableLockTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.SQLServerDataSourceProvider; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | public class SQLServerTableLockTest extends AbstractTableLockTest { 10 | 11 | @Override 12 | protected DataSourceProvider dataSourceProvider() { 13 | return new SQLServerDataSourceProvider(); 14 | } 15 | 16 | @Override 17 | protected String lockEmployeeTableSql() { 18 | return "SELECT 1 FROM employee WITH (HOLDLOCK) WHERE department_id = 1"; 19 | } 20 | 21 | protected String insertEmployeeSql() { 22 | return "INSERT INTO employee WITH(NOWAIT) (department_id, name, salary, id) VALUES (?, ?, ?, ?)"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/locking/advisory/PostgreSQLNoAdvisoryLocksTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.locking.advisory; 2 | 3 | import java.sql.Connection; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class PostgreSQLNoAdvisoryLocksTest extends AbstractPostgreSQLAdvisoryLocksTest { 9 | 10 | @Override 11 | protected int acquireLock(Connection connection, int logIndex, int workerId) { 12 | LOGGER.info( "Worker {} writes to log {}", workerId, logIndex ); 13 | return logIndex; 14 | } 15 | 16 | @Override 17 | protected void releaseLock(Connection connection, int logIndex, int workerId) { 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/phenomena/MySQLPhenomenaTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.phenomena; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.MySQLDataSourceProvider; 5 | 6 | /** 7 | * MySQLPhenomenaTest - Test to validate MySQL phenomena 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class MySQLPhenomenaTest extends AbstractPhenomenaTest { 12 | 13 | public MySQLPhenomenaTest(String isolationLevelName, int isolationLevel) { 14 | super(isolationLevelName, isolationLevel); 15 | } 16 | 17 | @Override 18 | protected DataSourceProvider dataSourceProvider() { 19 | return new MySQLDataSourceProvider(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/jdbc/transaction/phenomena/PostgreSQLPhenomenaTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jdbc.transaction.phenomena; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.DataSourceProvider; 4 | import com.vladmihalcea.hpjp.util.providers.PostgreSQLDataSourceProvider; 5 | 6 | /** 7 | * PostgreSQLPhenomenaTest - Test to validate PostgreSQL phenomena 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | public class PostgreSQLPhenomenaTest extends AbstractPhenomenaTest { 12 | 13 | public PostgreSQLPhenomenaTest(String isolationLevelName, int isolationLevel) { 14 | super(isolationLevelName, isolationLevel); 15 | } 16 | 17 | @Override 18 | protected DataSourceProvider dataSourceProvider() { 19 | return new PostgreSQLDataSourceProvider(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/batch/domain/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.batch.domain; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @Entity 9 | @Table(name = "post") 10 | public class Post { 11 | 12 | @Id 13 | private Long id; 14 | 15 | private String title; 16 | 17 | @Enumerated(EnumType.ORDINAL) 18 | private PostStatus status; 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public Post setId(Long id) { 25 | this.id = id; 26 | return this; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public Post setTitle(String title) { 34 | this.title = title; 35 | return this; 36 | } 37 | 38 | public PostStatus getStatus() { 39 | return status; 40 | } 41 | 42 | public Post setStatus(PostStatus status) { 43 | this.status = status; 44 | return this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/batch/domain/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.batch.domain; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum PostStatus { 7 | PENDING, 8 | APPROVED, 9 | SPAM; 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/batch/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.batch.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.batch.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Tag") 11 | @Table(name = "tag") 12 | public class Tag { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String name; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Tag setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public Tag setName(String name) { 33 | this.name = name; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/views/PostCommentView.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain.views; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | import com.blazebit.persistence.view.Mapping; 6 | import com.vladmihalcea.hpjp.spring.blaze.domain.PostComment; 7 | 8 | import java.util.List; 9 | 10 | import static com.blazebit.persistence.view.FetchStrategy.MULTISET; 11 | 12 | /** 13 | * @author Vlad Mihalcea 14 | */ 15 | @EntityView(PostComment.class) 16 | public interface PostCommentView { 17 | @IdMapping 18 | Long getId(); 19 | 20 | String getReview(); 21 | 22 | @Mapping(fetch = MULTISET) 23 | List getVotes(); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/views/PostView.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain.views; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | import com.vladmihalcea.hpjp.spring.blaze.domain.Post; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @EntityView(Post.class) 11 | public interface PostView { 12 | @IdMapping 13 | Long getId(); 14 | 15 | String getTitle(); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/views/PostWithCommentsAndTagsView.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain.views; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.Mapping; 5 | import com.vladmihalcea.hpjp.spring.blaze.domain.Post; 6 | 7 | import java.util.List; 8 | 9 | import static com.blazebit.persistence.view.FetchStrategy.MULTISET; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @EntityView(Post.class) 15 | public interface PostWithCommentsAndTagsView extends PostView { 16 | 17 | @Mapping(fetch = MULTISET) 18 | List getComments(); 19 | 20 | @Mapping(fetch = MULTISET) 21 | List getTags(); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/views/TagView.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain.views; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | import com.vladmihalcea.hpjp.spring.blaze.domain.Tag; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @EntityView(Tag.class) 11 | public interface TagView { 12 | @IdMapping 13 | Long getId(); 14 | 15 | String getName(); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/views/UserView.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain.views; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | import com.vladmihalcea.hpjp.spring.blaze.domain.User; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @EntityView(User.class) 11 | public interface UserView { 12 | @IdMapping 13 | Long getId(); 14 | 15 | String getFirstName(); 16 | 17 | String getLastName(); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/domain/views/UserVoteView.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.domain.views; 2 | 3 | import com.blazebit.persistence.view.EntityView; 4 | import com.blazebit.persistence.view.IdMapping; 5 | import com.vladmihalcea.hpjp.spring.blaze.domain.UserVote; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @EntityView(UserVote.class) 11 | public interface UserVoteView { 12 | @IdMapping 13 | Long getId(); 14 | 15 | UserView getUser(); 16 | 17 | int getScore(); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.repository; 2 | 3 | import com.blazebit.persistence.PagedList; 4 | import com.vladmihalcea.hpjp.spring.blaze.domain.Post; 5 | import com.vladmihalcea.hpjp.spring.blaze.domain.views.PostWithCommentsAndTagsView; 6 | import org.springframework.data.domain.Sort; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | public interface CustomPostRepository { 14 | 15 | PagedList findTopN(Sort sortBy, int pageSize); 16 | 17 | PagedList findNextN(Sort sortBy, PagedList previousPage); 18 | 19 | List findWithCommentsAndTagsByIds(Long minId, Long maxId); 20 | 21 | List findPostWithCommentsAndTagsViewByIds(Long minId, Long maxId); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/blaze/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.blaze.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.blaze.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository, CustomPostRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/common/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.common.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.common.domain.PostComment; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostCommentRepository extends BaseJpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/common/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.common.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.common.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | 13 | Post findBySlug(String slug); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/assigned/repository/BookBaseJpaRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.assigned.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.assigned.domain.Book; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface BookBaseJpaRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/assigned/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.assigned.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.assigned.domain.Book; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface BookRepository extends JpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/audit/domain/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.audit.domain; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum PostStatus { 7 | PENDING, 8 | APPROVED, 9 | SPAM, 10 | REQUIRES_MODERATOR_INTERVENTION 11 | } -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/audit/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.audit.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.audit.domain.Post; 4 | import com.vladmihalcea.hpjp.spring.data.audit.domain.PostComment; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.repository.history.RevisionRepository; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Repository 13 | public interface PostCommentRepository extends JpaRepository, 14 | RevisionRepository { 15 | 16 | void deleteByPost(Post post); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/audit/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.audit.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.audit.domain.Post; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.repository.history.RevisionRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Repository 12 | public interface PostRepository extends JpaRepository, 13 | RevisionRepository { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/base/config/SpringDataJPABaseRepositoryConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.base.config; 2 | 3 | import io.hypersistence.utils.spring.repository.BaseJpaRepositoryImpl; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 6 | 7 | /** 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | @ComponentScan( 12 | basePackages = { 13 | "com.vladmihalcea.hpjp.spring.data.base.service", 14 | } 15 | ) 16 | @EnableJpaRepositories( 17 | value = "com.vladmihalcea.hpjp.spring.data.base.repository", 18 | repositoryBaseClass = BaseJpaRepositoryImpl.class 19 | ) 20 | public class SpringDataJPABaseRepositoryConfiguration extends SpringDataJPABaseConfiguration { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/base/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.base.repository; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/base/service/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.base.service; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.Post; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface ForumService { 9 | 10 | Post findById(Long id); 11 | 12 | Post createPost(Post post); 13 | 14 | Post updatePost(Post post); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/bidirectional/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.bidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.bidirectional.domain.PostComment; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostCommentRepository extends BaseJpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/bidirectional/repository/PostDetailsRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.bidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.bidirectional.domain.PostDetails; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostDetailsRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/bidirectional/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.bidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.bidirectional.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Repository 13 | public interface PostRepository extends BaseJpaRepository { 14 | 15 | @Query(""" 16 | select p 17 | from Post p 18 | join fetch p.details 19 | join fetch p.comments 20 | where p.id = :id 21 | """) 22 | Post findByIdWithDetailsAndComments(@Param("id") Long id); 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/bidirectional/repository/TagRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.bidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.bidirectional.domain.Tag; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface TagRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/bytecode/repository/AttachmentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.bytecode.repository; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.Attachment; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface AttachmentRepository extends JpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/cascade/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.cascade.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.GeneratedValue; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | import org.hibernate.annotations.NaturalId; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Entity(name = "Tag") 13 | @Table(name = "tag") 14 | public class Tag { 15 | 16 | @Id 17 | @GeneratedValue 18 | private Long id; 19 | 20 | @NaturalId 21 | private String name; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public Tag setId(Long id) { 28 | this.id = id; 29 | return this; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public Tag setName(String name) { 37 | this.name = name; 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/cascade/repository/PostDetailsRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.cascade.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.cascade.domain.PostDetails; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostDetailsRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/cascade/repository/TagRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.cascade.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.cascade.domain.Tag; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface TagRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/crud/domain/PostStatus.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.crud.domain; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum PostStatus { 7 | PENDING, 8 | APPROVED, 9 | SPAM, 10 | REQUIRES_MODERATOR_INTERVENTION 11 | } -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/crud/repository/DefaultPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.crud.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.crud.domain.Post; 4 | import io.hypersistence.utils.spring.repository.HibernateRepository; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Repository 12 | public interface DefaultPostRepository extends JpaRepository { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/crud/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.crud.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.crud.domain.PostComment; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostCommentRepository extends JpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/crud/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.crud.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.crud.domain.Post; 4 | import io.hypersistence.utils.spring.repository.HibernateRepository; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Repository 12 | public interface PostRepository extends HibernateRepository, JpaRepository { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/custom/config/SpringDataJPACustomRepositoryConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.custom.config; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.base.config.SpringDataJPABaseConfiguration; 4 | import org.springframework.context.annotation.ComponentScan; 5 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 6 | 7 | /** 8 | * 9 | * @author Vlad Mihalcea 10 | */ 11 | @ComponentScan( 12 | basePackages = { 13 | "com.vladmihalcea.hpjp.spring.data.custom.service", 14 | } 15 | ) 16 | @EnableJpaRepositories( 17 | basePackages = { 18 | "com.vladmihalcea.hpjp.spring.data.custom.repository", 19 | "io.hypersistence.utils.spring.repository" 20 | } 21 | ) 22 | public class SpringDataJPACustomRepositoryConfiguration extends SpringDataJPABaseConfiguration { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/custom/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.custom.repository; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.Post; 4 | import com.vladmihalcea.hpjp.hibernate.query.dto.projection.transformer.PostDTO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface CustomPostRepository { 12 | 13 | List findPostDTOWithComments(); 14 | 15 | List findPostTitleByTags(List tags); 16 | 17 | void deleteAll(List posts); 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/custom/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.custom.repository; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.Post; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends 12 | //HibernateRepository, 13 | JpaRepository, CustomPostRepository { 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/lock/domain/PostComment.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.lock.domain; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @Entity(name = "PostComment") 9 | @Table(name = "post_comment") 10 | public class PostComment { 11 | 12 | @Id 13 | private Long id; 14 | 15 | @ManyToOne(fetch = FetchType.LAZY) 16 | private Post post; 17 | 18 | private String review; 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | 24 | public PostComment setId(Long id) { 25 | this.id = id; 26 | return this; 27 | } 28 | 29 | public Post getPost() { 30 | return post; 31 | } 32 | 33 | public PostComment setPost(Post post) { 34 | this.post = post; 35 | return this; 36 | } 37 | 38 | public String getReview() { 39 | return review; 40 | } 41 | 42 | public PostComment setReview(String review) { 43 | this.review = review; 44 | return this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/lock/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.lock.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.lock.domain.PostComment; 4 | import jakarta.persistence.LockModeType; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Lock; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author Vlad Mihalcea 15 | */ 16 | @Repository 17 | public interface PostCommentRepository extends JpaRepository { 18 | 19 | @Query(""" 20 | select pc 21 | from PostComment pc 22 | where pc.post.id = :postId 23 | """) 24 | @Lock(LockModeType.PESSIMISTIC_READ) 25 | List lockAllByPostId(@Param("postId") Long postId); 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/lock/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.lock.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.lock.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Repository 13 | public interface PostRepository extends BaseJpaRepository { 14 | 15 | @Query(""" 16 | select p 17 | from Post p 18 | where p.slug = :slug 19 | """) 20 | Post findBySlug(@Param("slug") String slug); 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/masquerade/dto/PostCommentDTO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.masquerade.dto; 2 | 3 | import com.vladmihalcea.hpjp.util.CryptoUtils; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class PostCommentDTO { 9 | 10 | private final String id; 11 | 12 | private final String review; 13 | 14 | public PostCommentDTO(Long id, String review) { 15 | this.id = CryptoUtils.encrypt(id); 16 | this.review = review; 17 | } 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public String getReview() { 24 | return review; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/masquerade/dto/PostDTO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.masquerade.dto; 2 | 3 | import com.vladmihalcea.hpjp.util.CryptoUtils; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class PostDTO { 9 | 10 | private final String id; 11 | 12 | private final String title; 13 | 14 | public PostDTO(Long id, String title) { 15 | this.id = CryptoUtils.encrypt(id); 16 | this.title = title; 17 | } 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public String getTitle() { 24 | return title; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/masquerade/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.masquerade.repository; 2 | 3 | import com.blazebit.persistence.PagedList; 4 | import com.vladmihalcea.hpjp.spring.data.masquerade.dto.PostDTO; 5 | import org.springframework.data.domain.Sort; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public interface CustomPostRepository { 11 | 12 | PagedList findTopN(Sort sortBy, int pageSize); 13 | 14 | PagedList findNextN(Sort sortBy, PagedList previousPage); 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/masquerade/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.masquerade.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.masquerade.domain.Post; 4 | import com.vladmihalcea.hpjp.spring.data.masquerade.dto.PostCommentDTO; 5 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author Vlad Mihalcea 14 | */ 15 | @Repository 16 | public interface PostRepository extends BaseJpaRepository, CustomPostRepository { 17 | 18 | @Query(""" 19 | select new PostCommentDTO( 20 | pc.id, 21 | pc.review 22 | ) 23 | from PostComment pc 24 | where pc.post.id = :postId 25 | order by pc.id 26 | """) 27 | List findCommentsByPost(@Param("postId") Long postId); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/merge/repository/BetterPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.merge.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.merge.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @Repository 15 | public interface BetterPostRepository extends BaseJpaRepository { 16 | 17 | @Query(""" 18 | select p 19 | from Post p 20 | left join fetch p.comments 21 | where p.title like :titlePrefix 22 | """) 23 | List findAllWithCommentsByTitleLike(@Param("titlePrefix") String titlePrefix); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/merge/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.merge.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.merge.domain.Post; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @Repository 15 | public interface PostRepository extends JpaRepository { 16 | 17 | @Query(""" 18 | select p 19 | from Post p 20 | left join fetch p.comments 21 | where p.title like :titlePrefix 22 | """) 23 | List findAllWithCommentsByTitleLike(@Param("titlePrefix") String titlePrefix); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/projection/dto/PostCommentRecord.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.projection.dto; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public record PostCommentRecord( 7 | Long id, 8 | String title, 9 | String review 10 | ) { 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/projection/dto/PostCommentSummary.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.projection.dto; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface PostCommentSummary { 7 | 8 | Long getId(); 9 | 10 | String getTitle(); 11 | 12 | String getReview(); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/projection/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.projection.repository; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.query.dto.projection.transformer.PostDTO; 4 | import org.springframework.data.repository.query.Param; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface CustomPostRepository { 12 | 13 | List findPostDTOByPostTitle(@Param("postTitle") String postTitle); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/example/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.example.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Tag") 11 | @Table(name = "tag") 12 | public class Tag { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String name; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Tag setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public Tag setName(String name) { 33 | this.name = name; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/example/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.example.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.example.domain.PostComment; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostCommentRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/example/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.example.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.example.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/method/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.method.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Tag") 11 | @Table(name = "tag") 12 | public class Tag { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String name; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Tag setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public Tag setName(String name) { 33 | this.name = name; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/method/repository/CustomPostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.method.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.method.domain.Post; 4 | import com.vladmihalcea.hpjp.spring.data.query.method.domain.PostCommentDTO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface CustomPostCommentRepository { 12 | 13 | List findCommentHierarchy(Post post); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/multibag/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.multibag.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Tag") 11 | @Table(name = "tag") 12 | public class Tag { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String name; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Tag setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public Tag setName(String name) { 33 | this.name = name; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/multibag/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.multibag.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.multibag.domain.Post; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public interface CustomPostRepository { 11 | 12 | List findAllWithCommentsAndTags(long minId, long maxId); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/multibag/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.multibag.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.multibag.domain.PostComment; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Repository 13 | public interface PostCommentRepository extends BaseJpaRepository { 14 | 15 | List findAllByReview(String review); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/specification/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.specification.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Tag") 11 | @Table(name = "tag") 12 | public class Tag { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String name; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Tag setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public Tag setName(String name) { 33 | this.name = name; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/specification/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.specification.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.specification.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/window/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.window.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.window.domain.Post; 4 | import com.vladmihalcea.hpjp.spring.data.query.window.domain.PostComment; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.domain.ScrollPosition; 7 | import org.springframework.data.domain.Window; 8 | import org.springframework.data.jpa.repository.JpaRepository; 9 | import org.springframework.stereotype.Repository; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @Repository 15 | public interface PostCommentRepository extends JpaRepository { 16 | 17 | Window findByPost( 18 | Post post, 19 | Pageable pageable, 20 | ScrollPosition position 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/query/window/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.query.window.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.query.window.domain.Post; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends JpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/record/domain/PostCommentRecord.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.record.domain; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public record PostCommentRecord( 7 | Long id, 8 | String review 9 | ) { 10 | public PostComment toPostComment() { 11 | return new PostComment() 12 | .setId(id) 13 | .setReview(review); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/record/domain/PostRecord.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.record.domain; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public record PostRecord( 9 | Long id, 10 | String title, 11 | List comments 12 | ) { 13 | public Post toPost() { 14 | Post post = new Post() 15 | .setId(id) 16 | .setTitle(title); 17 | comments.forEach(comment -> post.addComment(comment.toPostComment())); 18 | return post; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/record/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.record.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.record.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Optional; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @Repository 15 | public interface PostRepository extends BaseJpaRepository { 16 | 17 | @Query(""" 18 | select p 19 | from Post p 20 | join fetch p.comments 21 | where p.id = :postId 22 | """) 23 | Optional findWithCommentsById(@Param("postId") Long postId); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/recursive/domain/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.recursive.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity(name = "Post") 11 | @Table(name = "post") 12 | public class Post { 13 | 14 | @Id 15 | private Long id; 16 | 17 | private String title; 18 | 19 | public Long getId() { 20 | return id; 21 | } 22 | 23 | public Post setId(Long id) { 24 | this.id = id; 25 | return this; 26 | } 27 | 28 | public String getTitle() { 29 | return title; 30 | } 31 | 32 | public Post setTitle(String title) { 33 | this.title = title; 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/recursive/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.recursive.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.recursive.domain.PostCommentDTO; 4 | import org.springframework.data.repository.query.Param; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface CustomPostRepository { 12 | 13 | List findTopCommentDTOsByPost(@Param("postId") Long postId, int ranking); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/domain/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.domain; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Entity 12 | @Table(name = "posts") 13 | public class Post extends VersionedEntity { 14 | 15 | @Id 16 | private Long id; 17 | 18 | @Column(length = 250) 19 | private String title; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public Post setId(Long id) { 26 | this.id = id; 27 | return this; 28 | } 29 | 30 | public String getTitle() { 31 | return title; 32 | } 33 | 34 | public Post setTitle(String title) { 35 | this.title = title; 36 | return this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/domain/Tag.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.domain; 2 | 3 | import jakarta.persistence.*; 4 | import org.hibernate.annotations.NaturalId; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @Entity 10 | @Table(name = "tags") 11 | public class Tag extends VersionedEntity { 12 | 13 | @Id 14 | @GeneratedValue 15 | private Long id; 16 | 17 | @NaturalId 18 | @Column(length = 40) 19 | private String name; 20 | 21 | public Long getId() { 22 | return id; 23 | } 24 | 25 | public Tag setId(Long id) { 26 | this.id = id; 27 | return this; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public Tag setName(String name) { 35 | this.name = name; 36 | return this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/domain/VersionedEntity.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.domain; 2 | 3 | import jakarta.persistence.MappedSuperclass; 4 | import jakarta.persistence.Version; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @MappedSuperclass 10 | public class VersionedEntity { 11 | 12 | @Version 13 | private Short version; 14 | 15 | public Short getVersion() { 16 | return version; 17 | } 18 | 19 | public void setVersion(Short version) { 20 | this.version = version; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface CustomPostRepository { 7 | 8 | void deleteById(ID postId); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/DefaultPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.Post; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface DefaultPostRepository extends JpaRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/PostCommentRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.PostComment; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Modifying; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | @Repository 14 | public interface PostCommentRepository extends BaseJpaRepository { 15 | 16 | @Query(""" 17 | delete from PostComment 18 | where post.id = :postId 19 | """) 20 | @Modifying 21 | void deleteAllByPostId(@Param("postId") Long postId); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/PostDetailsRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.PostDetails; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Modifying; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | @Repository 14 | public interface PostDetailsRepository extends BaseJpaRepository { 15 | 16 | @Query(""" 17 | delete from PostDetails 18 | where post.id = :postId 19 | """) 20 | @Modifying 21 | void deleteByPostId(@Param("postId") Long postId); 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository, 12 | CustomPostRepository { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/PostTagRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.PostTag; 4 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.PostTagId; 5 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 6 | import org.springframework.data.jpa.repository.Modifying; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @Repository 15 | public interface PostTagRepository extends BaseJpaRepository { 16 | 17 | @Query(""" 18 | delete from PostTag 19 | where post.id = :postId 20 | """) 21 | @Modifying 22 | void deleteAllByPostId(@Param("postId") Long postId); 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/TagRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.Tag; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface TagRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.User; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface UserRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/repository/UserVoteRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.domain.UserVote; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Modifying; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | @Repository 14 | public interface UserVoteRepository extends BaseJpaRepository { 15 | 16 | @Query(""" 17 | delete from UserVote 18 | where comment.id in ( 19 | select id 20 | from PostComment 21 | where post.id = :postId 22 | ) 23 | """) 24 | @Modifying 25 | void deleteAllByPostId(@Param("postId") Long postId); 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/unidirectional/service/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.unidirectional.service; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.unidirectional.repository.PostRepository; 4 | import org.springframework.stereotype.Service; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Service 11 | @Transactional(readOnly = true) 12 | public class ForumService { 13 | 14 | private final PostRepository postRepository; 15 | 16 | public ForumService(PostRepository postRepository) { 17 | this.postRepository = postRepository; 18 | } 19 | 20 | @Transactional 21 | public void deletePostById(Long postId) { 22 | postRepository.deleteById(postId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/data/update/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.data.update.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.data.update.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/partition/domain/Partition.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.partition.domain; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum Partition { 7 | ASIA("Asia"), 8 | AFRICA("Africa"), 9 | NORTH_AMERICA("North America"), 10 | SOUTH_AMERICA("South America"), 11 | EUROPE("Europe"), 12 | AUSTRALIA("Australia"), 13 | ; 14 | 15 | private final String key; 16 | 17 | Partition(String key) { 18 | this.key = key; 19 | } 20 | 21 | public String getKey() { 22 | return key; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/partition/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.partition.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.partition.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/partition/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.partition.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.partition.domain.User; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface UserRepository extends BaseJpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/partition/util/UserContext.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.partition.util; 2 | 3 | import com.vladmihalcea.hpjp.spring.partition.domain.User; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public class UserContext { 9 | 10 | private static final ThreadLocal userHolder = new ThreadLocal<>(); 11 | 12 | public static void logIn(User user) { 13 | userHolder.set(user); 14 | } 15 | 16 | public static void logOut() { 17 | userHolder.remove(); 18 | } 19 | 20 | public static User getCurrent() { 21 | return userHolder.get(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/stateless/domain/NoOpGenerator.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.stateless.domain; 2 | 3 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 4 | import org.hibernate.id.IdentifierGenerator; 5 | import org.hibernate.id.factory.spi.StandardGenerator; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class NoOpGenerator implements IdentifierGenerator, StandardGenerator { 11 | 12 | @Override 13 | public Object generate(SharedSessionContractImplementor session, Object obj) { 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/stateless/domain/Post.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.stateless.domain; 2 | 3 | import jakarta.persistence.*; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @Entity 9 | @Table(name = "post") 10 | public class Post extends AbstractPost { 11 | 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | private Long id; 15 | 16 | public Long getId() { 17 | return id; 18 | } 19 | 20 | public Post setId(Long id) { 21 | this.id = id; 22 | return this; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/stateless/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.stateless.repository; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface CustomPostRepository { 9 | List persistAll(Iterable entities); 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/stateless/repository/PostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.stateless.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.stateless.domain.Post; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface PostRepository extends BaseJpaRepository, CustomPostRepository { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/contract/domain/AnnexSignature.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.contract.domain; 2 | 3 | import jakarta.persistence.*; 4 | import org.hibernate.annotations.OnDelete; 5 | import org.hibernate.annotations.OnDeleteAction; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @Table(name = "annex_signature") 12 | public class AnnexSignature extends BaseSignature 13 | implements RootAware { 14 | 15 | @OneToOne(fetch = FetchType.LAZY) 16 | @MapsId 17 | @OnDelete(action = OnDeleteAction.CASCADE) 18 | private Annex annex; 19 | 20 | public Annex getAnnex() { 21 | return annex; 22 | } 23 | 24 | public AnnexSignature setAnnex(Annex annex) { 25 | this.annex = annex; 26 | return this; 27 | } 28 | 29 | @Override 30 | public Contract root() { 31 | return annex.root(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/contract/domain/Contract.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.contract.domain; 2 | 3 | import jakarta.persistence.Entity; 4 | import jakarta.persistence.Id; 5 | import jakarta.persistence.Table; 6 | import jakarta.persistence.Version; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Entity 12 | @Table(name = "contract") 13 | public class Contract { 14 | 15 | @Id 16 | private Long id; 17 | 18 | private String title; 19 | 20 | @Version 21 | private Short version; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public Contract setId(Long id) { 28 | this.id = id; 29 | return this; 30 | } 31 | 32 | public String getTitle() { 33 | return title; 34 | } 35 | 36 | public Contract setTitle(String title) { 37 | this.title = title; 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/contract/domain/ContractSignature.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.contract.domain; 2 | 3 | import jakarta.persistence.*; 4 | import org.hibernate.annotations.OnDelete; 5 | import org.hibernate.annotations.OnDeleteAction; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Entity 11 | @Table(name = "contract_signature") 12 | public class ContractSignature extends BaseSignature 13 | implements RootAware { 14 | 15 | @OneToOne(fetch = FetchType.LAZY) 16 | @MapsId 17 | @OnDelete(action = OnDeleteAction.CASCADE) 18 | private Contract contract; 19 | 20 | public Contract getContract() { 21 | return contract; 22 | } 23 | 24 | public ContractSignature setContract(Contract contract) { 25 | this.contract = contract; 26 | return this; 27 | } 28 | 29 | @Override 30 | public Contract root() { 31 | return contract; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/contract/domain/RootAware.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.contract.domain; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface RootAware { 7 | T root(); 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/contract/repository/ContractRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.contract.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.transaction.contract.domain.Contract; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | import org.springframework.transaction.annotation.Transactional; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Repository 12 | @Transactional(readOnly = true) 13 | public interface ContractRepository extends JpaRepository { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/hibernate/dao/GenericDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.hibernate.dao; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface GenericDAO { 9 | 10 | T findById(ID id); 11 | 12 | T persist(T entity); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/hibernate/dao/PostDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.hibernate.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface PostDAO extends GenericDAO { 12 | 13 | List findByTitle(String title); 14 | 15 | PostDTO getPostDTOById(Long id); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/hibernate/dao/TagDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.hibernate.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Tag; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public interface TagDAO extends GenericDAO { 11 | 12 | List findByName(String... tags); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/hibernate/dao/TagDAOImpl.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.hibernate.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Tag; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Repository 13 | public class TagDAOImpl extends GenericDAOImpl implements TagDAO { 14 | 15 | protected TagDAOImpl() { 16 | super(Tag.class); 17 | } 18 | 19 | @Override 20 | public List findByName(String... tags) { 21 | if(tags.length == 0) { 22 | throw new IllegalArgumentException("There's no tag name to search for!"); 23 | } 24 | return getSession().createQuery( 25 | "select t " + 26 | "from Tag t " + 27 | "where t.name in :tags") 28 | .setParameterList("tags", Arrays.asList(tags)) 29 | .list(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/hibernate/service/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.hibernate.service; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Service 13 | public interface ForumService { 14 | 15 | Post newPost(String title, String... tags); 16 | 17 | List findAllByTitle(String title); 18 | 19 | Post findById(Long id); 20 | 21 | PostDTO getPostDTOById(Long id); 22 | 23 | void processData(); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jpa/repository/CustomPostRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jpa.repository; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface CustomPostRepository { 7 | 8 | void savePosts(); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jpa/repository/TagRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jpa.repository; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Tag; 4 | import io.hypersistence.utils.spring.repository.BaseJpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author Vlad Mihalcea 13 | */ 14 | @Repository 15 | public interface TagRepository extends BaseJpaRepository { 16 | 17 | @Query(""" 18 | select t 19 | from Tag t 20 | where t.name in :tags 21 | """ 22 | ) 23 | List findByName(@Param("tags") String... tags); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jpa/service/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jpa.service; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Service 13 | public interface ForumService { 14 | 15 | Post newPost(String title, String... tags); 16 | 17 | List findAllByTitle(String title); 18 | 19 | Post findById(Long id); 20 | 21 | PostDTO getPostDTOById(Long id); 22 | 23 | PostDTO savePostTitle(Long id, String title); 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jpa/service/ReleaseAfterStatementForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jpa.service; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | import org.springframework.stereotype.Service; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Service 11 | public interface ReleaseAfterStatementForumService { 12 | 13 | Post newPost(String title); 14 | 15 | PostDTO savePostTitle(Long id, String title); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/atomikos/dao/GenericDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.atomikos.dao; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface GenericDAO { 9 | 10 | T findById(ID id); 11 | 12 | T persist(T entity); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/atomikos/dao/PostBatchDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.atomikos.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface PostBatchDAO extends GenericDAO { 9 | 10 | void savePosts(); 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/atomikos/dao/PostDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.atomikos.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface PostDAO extends GenericDAO { 12 | 13 | List findByTitle(String title); 14 | 15 | PostDTO getPostDTOById(Long id); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/atomikos/dao/TagDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.atomikos.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Tag; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public interface TagDAO extends GenericDAO { 11 | 12 | List findByName(String... tags); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/atomikos/service/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.atomikos.service; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Service 13 | public interface ForumService { 14 | 15 | Post newPost(String title, String... tags); 16 | 17 | List findAllByTitle(String title); 18 | 19 | Post findById(Long id); 20 | 21 | PostDTO getPostDTOById(Long id);} 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/narayana/dao/GenericDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.narayana.dao; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface GenericDAO { 9 | 10 | T findById(ID id); 11 | 12 | T persist(T entity); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/narayana/dao/PostBatchDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.narayana.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | public interface PostBatchDAO extends GenericDAO { 9 | 10 | void savePosts(); 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/narayana/dao/PostDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.narayana.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public interface PostDAO extends GenericDAO { 12 | 13 | List findByTitle(String title); 14 | 15 | PostDTO getPostDTOById(Long id); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/narayana/dao/TagDAO.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.narayana.dao; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Tag; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public interface TagDAO extends GenericDAO { 11 | 12 | List findByName(String... tags); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/jta/narayana/service/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.jta.narayana.service; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.forum.dto.PostDTO; 4 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | @Service 13 | public interface ForumService { 14 | 15 | Post newPost(String title, String... tags); 16 | 17 | List findAllByTitle(String title); 18 | 19 | Post findById(Long id); 20 | 21 | PostDTO getPostDTOById(Long id);} 22 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/readonly/config/stats/SpringTransactionStatisticsFactory.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.readonly.config.stats; 2 | 3 | import org.hibernate.engine.spi.SessionFactoryImplementor; 4 | import org.hibernate.stat.spi.StatisticsFactory; 5 | import org.hibernate.stat.spi.StatisticsImplementor; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class SpringTransactionStatisticsFactory implements StatisticsFactory { 11 | 12 | @Override 13 | public StatisticsImplementor buildStatistics(SessionFactoryImplementor sessionFactory) { 14 | return new SpringTransactionStatistics(sessionFactory); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/readonly/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.readonly.repository; 2 | 3 | import com.vladmihalcea.hpjp.spring.transaction.readonly.domain.Product; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @Repository 11 | public interface ProductRepository extends JpaRepository { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/routing/DataSourceType.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.routing; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum DataSourceType { 7 | READ_WRITE, 8 | READ_ONLY 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/routing/ForumService.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.routing; 2 | 3 | import com.vladmihalcea.hpjp.hibernate.transaction.forum.Post; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | @Service 12 | public interface ForumService { 13 | 14 | Post newPost(String title, String... tags); 15 | 16 | List findAllPostsByTitle(String title); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/spring/transaction/routing/TransactionRoutingDataSource.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.spring.transaction.routing; 2 | 3 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 4 | import org.springframework.lang.Nullable; 5 | import org.springframework.transaction.support.TransactionSynchronizationManager; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public class TransactionRoutingDataSource extends AbstractRoutingDataSource { 11 | 12 | @Nullable 13 | @Override 14 | protected Object determineCurrentLookupKey() { 15 | return TransactionSynchronizationManager.isCurrentTransactionReadOnly() ? 16 | DataSourceType.READ_ONLY : 17 | DataSourceType.READ_WRITE; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/AbstractCockroachDBIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | /** 6 | * AbstractCockroachDBIntegrationTest - Abstract CockroachDB IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractCockroachDBIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.COCKROACHDB; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/AbstractMySQLIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | /** 6 | * AbstractMySQLIntegrationTest - Abstract MySQL IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractMySQLIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.MYSQL; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/AbstractOracleIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | /** 6 | * AbstractOracleXEIntegrationTest - Abstract Orcale XE IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractOracleIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.ORACLE; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/AbstractPostgreSQLIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | /** 6 | * AbstractPostgreSQLIntegrationTest - Abstract PostgreSQL IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractPostgreSQLIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.POSTGRESQL; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/AbstractSQLServerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util; 2 | 3 | import com.vladmihalcea.hpjp.util.providers.Database; 4 | 5 | /** 6 | * AbstractSQLServerIntegrationTest - Abstract SQL Server IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractSQLServerIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.SQLSERVER; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/EntityProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface EntityProvider { 7 | 8 | /** 9 | * Entity types shared among multiple test configurations 10 | * 11 | * @return entity types 12 | */ 13 | Class[] entities(); 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/exception/DataAccessException.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.exception; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class DataAccessException extends RuntimeException { 7 | public DataAccessException() { 8 | } 9 | 10 | public DataAccessException(String message) { 11 | super( message ); 12 | } 13 | 14 | public DataAccessException(String message, Throwable cause) { 15 | super( message, cause ); 16 | } 17 | 18 | public DataAccessException(Throwable cause) { 19 | super( cause ); 20 | } 21 | 22 | public DataAccessException( 23 | String message, 24 | Throwable cause, 25 | boolean enableSuppression, 26 | boolean writableStackTrace) { 27 | super( message, cause, enableSuppression, writableStackTrace ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/DataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers; 2 | 3 | import com.vladmihalcea.hpjp.util.ReflectionUtils; 4 | import com.vladmihalcea.hpjp.util.providers.queries.Queries; 5 | import org.hibernate.dialect.Dialect; 6 | 7 | import java.util.Properties; 8 | import javax.sql.DataSource; 9 | 10 | /** 11 | * @author Vlad Mihalcea 12 | */ 13 | public interface DataSourceProvider { 14 | 15 | enum IdentifierStrategy { 16 | IDENTITY, 17 | SEQUENCE 18 | } 19 | 20 | String hibernateDialect(); 21 | 22 | DataSource dataSource(); 23 | 24 | Class driverClassName(); 25 | 26 | Class dataSourceClassName(); 27 | 28 | Properties dataSourceProperties(); 29 | 30 | String url(); 31 | 32 | String username(); 33 | 34 | String password(); 35 | 36 | Database database(); 37 | 38 | Queries queries(); 39 | 40 | default Class hibernateDialectClass() { 41 | return ReflectionUtils.getClass(hibernateDialect()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/FastOracleDialect.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers; 2 | 3 | import org.hibernate.dialect.DatabaseVersion; 4 | import org.hibernate.dialect.OracleDialect; 5 | import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; 6 | import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl; 7 | import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor; 8 | 9 | /*** 10 | * @author Vlad Mihalcea 11 | */ 12 | public class FastOracleDialect extends OracleDialect { 13 | 14 | public FastOracleDialect() { 15 | } 16 | 17 | public FastOracleDialect(DatabaseVersion version) { 18 | super(version); 19 | } 20 | 21 | public FastOracleDialect(DialectResolutionInfo info) { 22 | super(info); 23 | } 24 | 25 | @Override 26 | public SequenceInformationExtractor getSequenceInformationExtractor() { 27 | return SequenceInformationExtractorNoOpImpl.INSTANCE; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/LockType.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public enum LockType { 7 | LOCKS, 8 | MVLOCKS, 9 | MVCC 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/queries/HSQLDBServerQueries.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers.queries; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class HSQLDBServerQueries implements Queries { 7 | 8 | public static final Queries INSTANCE = new HSQLDBServerQueries(); 9 | 10 | @Override 11 | public String transactionId() { 12 | return "VALUES (TRANSACTION_ID())"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/queries/MySQLQueries.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers.queries; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class MySQLQueries implements Queries { 7 | 8 | public static final Queries INSTANCE = new MySQLQueries(); 9 | 10 | @Override 11 | public String transactionId() { 12 | return "SELECT tx.trx_id FROM information_schema.innodb_trx tx WHERE tx.trx_mysql_thread_id = connection_id()"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/queries/OracleQueries.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers.queries; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class OracleQueries implements Queries { 7 | 8 | public static final Queries INSTANCE = new OracleQueries(); 9 | 10 | @Override 11 | public String transactionId() { 12 | return """ 13 | SELECT RAWTOHEX(tx.xid) 14 | FROM v$transaction tx 15 | JOIN v$session s ON tx.addr=s.taddr 16 | WHERE s.sid = sys_context('userenv','sid') 17 | """ ; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/queries/Queries.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers.queries; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public interface Queries { 7 | 8 | String transactionId(); 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/providers/queries/SQLServerQueries.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.providers.queries; 2 | 3 | /** 4 | * @author Vlad Mihalcea 5 | */ 6 | public class SQLServerQueries implements Queries { 7 | 8 | public static final Queries INSTANCE = new SQLServerQueries(); 9 | 10 | @Override 11 | public String transactionId() { 12 | return "SELECT CONVERT(VARCHAR, CURRENT_TRANSACTION_ID())"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/ConnectionCallable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @FunctionalInterface 10 | public interface ConnectionCallable { 11 | T execute(Connection connection) throws SQLException; 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/ConnectionVoidCallable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @FunctionalInterface 10 | public interface ConnectionVoidCallable { 11 | void execute(Connection connection) throws SQLException; 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/HibernateStatelessTransactionConsumer.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import org.hibernate.StatelessSession; 4 | 5 | import java.util.function.Consumer; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @FunctionalInterface 11 | public interface HibernateStatelessTransactionConsumer extends Consumer { 12 | default void beforeTransactionCompletion() { 13 | 14 | } 15 | 16 | default void afterTransactionCompletion() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/HibernateStatelessTransactionFunction.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import org.hibernate.StatelessSession; 4 | 5 | import java.util.function.Function; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @FunctionalInterface 11 | public interface HibernateStatelessTransactionFunction extends Function { 12 | default void beforeTransactionCompletion() { 13 | 14 | } 15 | 16 | default void afterTransactionCompletion() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/HibernateTransactionConsumer.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import org.hibernate.Session; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @FunctionalInterface 11 | public interface HibernateTransactionConsumer extends Consumer { 12 | default void beforeTransactionCompletion() { 13 | 14 | } 15 | 16 | default void afterTransactionCompletion() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/HibernateTransactionFunction.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.util.function.Function; 4 | 5 | import org.hibernate.Session; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @FunctionalInterface 11 | public interface HibernateTransactionFunction extends Function { 12 | default void beforeTransactionCompletion() { 13 | 14 | } 15 | 16 | default void afterTransactionCompletion() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/JPATransactionFunction.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.util.function.Function; 4 | import jakarta.persistence.EntityManager; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @FunctionalInterface 10 | public interface JPATransactionFunction extends Function { 11 | default void beforeTransactionCompletion() { 12 | 13 | } 14 | 15 | default void afterTransactionCompletion() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/JPATransactionVoidFunction.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.util.function.Consumer; 4 | import jakarta.persistence.EntityManager; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @FunctionalInterface 10 | public interface JPATransactionVoidFunction extends Consumer { 11 | default void beforeTransactionCompletion() { 12 | 13 | } 14 | 15 | default void afterTransactionCompletion() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/com/vladmihalcea/hpjp/util/transaction/VoidCallable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.util.transaction; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @FunctionalInterface 9 | public interface VoidCallable extends Callable { 10 | 11 | void execute(); 12 | 13 | default Void call() throws Exception { 14 | execute(); 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/jdbc-hsqldb.properties: -------------------------------------------------------------------------------- 1 | hibernate.dialect=org.hibernate.dialect.HSQLDialect 2 | jdbc.driverClassName=org.hsqldb.jdbc.JDBCDriver 3 | jdbc.dataSourceClassName=org.hsqldb.jdbc.JDBCDataSource 4 | jdbc.url=jdbc:hsqldb:mem:test 5 | jdbc.username=sa 6 | jdbc.password= -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/jdbc-mysql.properties: -------------------------------------------------------------------------------- 1 | jdbc.dataSourceClassName=com.mysql.cj.jdbc.MysqlDataSource 2 | jdbc.url=jdbc:mysql://localhost/high_performance_java_persistence 3 | jdbc.database=high_performance_java_persistence 4 | jdbc.username=mysql 5 | jdbc.password=admin -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/jdbc-postgresql-replication.properties: -------------------------------------------------------------------------------- 1 | jdbc.url.primary=jdbc:postgresql://localhost:5432/high_performance_java_persistence 2 | jdbc.url.replica=jdbc:postgresql://localhost:5432/high_performance_java_persistence_replica 3 | jdbc.username=postgres 4 | jdbc.password=admin -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/jdbc-postgresql.properties: -------------------------------------------------------------------------------- 1 | jdbc.dataSourceClassName=org.postgresql.ds.PGSimpleDataSource 2 | jdbc.url=jdbc:postgresql://localhost:5432/high_performance_java_persistence 3 | jdbc.host=localhost 4 | jdbc.port=5432 5 | jdbc.database=high_performance_java_persistence 6 | jdbc.username=postgres 7 | jdbc.password=admin -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/jta-hsqldb.properties: -------------------------------------------------------------------------------- 1 | hibernate.dialect=org.hibernate.dialect.HSQLDialect 2 | jdbc.driverClassName=org.hsqldb.jdbc.JDBCDriver 3 | jdbc.dataSourceClassName=org.hsqldb.jdbc.pool.JDBCXADataSource 4 | jdbc.url=jdbc:hsqldb:mem:test 5 | jdbc.username=sa 6 | jdbc.password= -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/jta-postgresql.properties: -------------------------------------------------------------------------------- 1 | hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect 2 | jdbc.dataSourceClassName=org.postgresql.xa.PGXADataSource 3 | jdbc.host=localhost 4 | jdbc.port=5432 5 | jdbc.database=high_performance_java_persistence 6 | jdbc.username=postgres 7 | jdbc.password=admin -------------------------------------------------------------------------------- /core/src/test/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | java.lang.Object 15 | java.lang.Object 16 | 17 | 10000 18 | 1 19 | 10 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /core/src/test/resources/flexy-pool.properties: -------------------------------------------------------------------------------- 1 | flexy.pool.data.source.unique.name=unique-name 2 | flexy.pool.metrics.reporter.jmx.auto.start=true -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/hsqldb/drop/drop.sql: -------------------------------------------------------------------------------- 1 | drop table if exists schema_version cascade; 2 | 3 | alter table post_comment drop constraint POST_COMMENT_POST_ID_FK; 4 | alter table post_details drop constraint POST_DETAILS_POST_ID_FK; 5 | alter table post_tag drop constraint POST_TAG_TAG_ID_FK; 6 | alter table post_tag drop constraint POST_TAG_POST_ID_FK; 7 | 8 | drop table post if exists; 9 | drop table post_comment if exists; 10 | drop table post_details if exists; 11 | drop table post_tag if exists; 12 | drop table tag if exists; 13 | drop table users if exists; 14 | 15 | drop sequence hibernate_sequence; -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/hsqldb/migration/V1_0__post_tag.sql: -------------------------------------------------------------------------------- 1 | create sequence hibernate_sequence start with 1 increment by 1; 2 | 3 | create table post (id bigint not null, title varchar(255), primary key (id)); 4 | create table tag (id bigint not null, name varchar(255), primary key (id)); 5 | 6 | create table post_tag (post_id bigint not null, tag_id bigint not null); 7 | 8 | alter table post_tag add constraint POST_TAG_TAG_ID_FK foreign key (tag_id) references tag (id); 9 | alter table post_tag add constraint POST_TAG_POST_ID_FK foreign key (post_id) references post (id); -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/hsqldb/migration/V1_1__post_details.sql: -------------------------------------------------------------------------------- 1 | create table post_details (id bigint not null, created_by varchar(255), created_on datetime, primary key (id)); 2 | 3 | alter table post_details add constraint POST_DETAILS_POST_ID_FK foreign key (id) references post (id); 4 | -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/hsqldb/migration/V1_2__post_comment.sql: -------------------------------------------------------------------------------- 1 | create table post_comment (id bigint not null, review varchar(255), post_id bigint, primary key (id)); 2 | 3 | alter table post_comment add constraint POST_COMMENT_POST_ID_FK foreign key (post_id) references post (id); -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/hsqldb/staging/V1_3__users.sql: -------------------------------------------------------------------------------- 1 | create table users (id bigint not null, name varchar(255), primary key (id)); -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/postgresql/drop/drop.sql: -------------------------------------------------------------------------------- 1 | DROP SCHEMA public CASCADE; 2 | CREATE SCHEMA public; 3 | GRANT ALL ON SCHEMA public TO postgres; 4 | GRANT ALL ON SCHEMA public TO public; 5 | COMMENT ON SCHEMA public IS 'standard public schema'; -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/postgresql/migration/V1_0__post_tag.sql: -------------------------------------------------------------------------------- 1 | CREATE SEQUENCE post_seq 2 | START 1 INCREMENT 1; 3 | 4 | CREATE TABLE post ( 5 | id int8 NOT NULL, 6 | title varchar(255), 7 | PRIMARY KEY (id) 8 | ); 9 | 10 | CREATE SEQUENCE tag_seq 11 | START 1 INCREMENT 1; 12 | 13 | CREATE TABLE tag ( 14 | id int8 NOT NULL, 15 | name varchar(255), 16 | PRIMARY KEY (id) 17 | ); 18 | 19 | CREATE TABLE post_tag ( 20 | post_id int8 NOT NULL, 21 | tag_id int8 NOT NULL, 22 | PRIMARY KEY (post_id, tag_id) 23 | ); 24 | 25 | ALTER TABLE post_tag 26 | ADD CONSTRAINT POST_TAG_TAG_ID_FK 27 | FOREIGN KEY (tag_id) REFERENCES tag; 28 | 29 | ALTER TABLE post_tag 30 | ADD CONSTRAINT POST_TAG_POST_ID_FK 31 | FOREIGN KEY (post_id) REFERENCES post; -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/postgresql/migration/V1_1__post_details.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE post_details ( 2 | id int8 NOT NULL, 3 | created_by varchar(255), 4 | created_on TIMESTAMP, 5 | PRIMARY KEY (id) 6 | ); 7 | 8 | ALTER TABLE post_details 9 | ADD CONSTRAINT POST_DETAILS_POST_ID_FK 10 | FOREIGN KEY (id) REFERENCES post; -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/postgresql/migration/V1_2__post_comment.sql: -------------------------------------------------------------------------------- 1 | CREATE SEQUENCE post_comment_seq 2 | START 1 INCREMENT 1; 3 | 4 | CREATE TABLE post_comment ( 5 | id int8 NOT NULL, 6 | review varchar(255), 7 | post_id int8, PRIMARY KEY (id) 8 | ); 9 | 10 | ALTER TABLE post_comment 11 | ADD CONSTRAINT POST_COMMENT_POST_ID_FK 12 | FOREIGN KEY (post_id) REFERENCES post; -------------------------------------------------------------------------------- /core/src/test/resources/flyway/scripts/postgresql/staging/V1_3__users.sql: -------------------------------------------------------------------------------- 1 | CREATE SEQUENCE user_seq 2 | START 1 INCREMENT 1; 3 | 4 | CREATE TABLE users ( 5 | id bigint NOT NULL, 6 | name varchar(255), 7 | PRIMARY KEY (id) 8 | ); -------------------------------------------------------------------------------- /core/src/test/resources/mappings/identifier/global/mysql-orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | com.vladmihalcea.hpjp.hibernate.identifier.global 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/AbstractOracleIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util; 2 | 3 | import com.vladmihalcea.util.providers.Database; 4 | 5 | /** 6 | * AbstractOracleXEIntegrationTest - Abstract Orcale XE IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractOracleIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.ORACLE; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/AbstractPostgreSQLIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util; 2 | 3 | import com.vladmihalcea.util.providers.Database; 4 | 5 | /** 6 | * AbstractPostgreSQLIntegrationTest - Abstract PostgreSQL IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractPostgreSQLIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.POSTGRESQL; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/AbstractSQLServerIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util; 2 | 3 | import com.vladmihalcea.util.providers.Database; 4 | 5 | /** 6 | * AbstractSQLServerIntegrationTest - Abstract SQL Server IntegrationTest 7 | * 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractSQLServerIntegrationTest extends AbstractTest { 11 | 12 | @Override 13 | protected Database database() { 14 | return Database.SQLSERVER; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/providers/AbstractContainerDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util.providers; 2 | 3 | import javax.sql.DataSource; 4 | import java.sql.Connection; 5 | import java.sql.SQLException; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | public abstract class AbstractContainerDataSourceProvider implements DataSourceProvider { 11 | 12 | @Override 13 | public DataSource dataSource() { 14 | DataSource dataSource = newDataSource(); 15 | try (Connection connection = dataSource.getConnection()) { 16 | return dataSource; 17 | } catch (SQLException e) { 18 | throw new IllegalStateException(e); 19 | } 20 | } 21 | 22 | @Override 23 | public String url() { 24 | return defaultJdbcUrl(); 25 | } 26 | 27 | protected abstract String defaultJdbcUrl(); 28 | 29 | protected abstract DataSource newDataSource(); 30 | } 31 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/providers/DataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util.providers; 2 | 3 | import io.hypersistence.utils.common.ReflectionUtils; 4 | import org.hibernate.dialect.Dialect; 5 | 6 | import javax.sql.DataSource; 7 | import java.util.Properties; 8 | 9 | /** 10 | * @author Vlad Mihalcea 11 | */ 12 | public interface DataSourceProvider { 13 | 14 | String hibernateDialect(); 15 | 16 | DataSource dataSource(); 17 | 18 | Class dataSourceClassName(); 19 | 20 | Properties dataSourceProperties(); 21 | 22 | String url(); 23 | 24 | String username(); 25 | 26 | String password(); 27 | 28 | Database database(); 29 | 30 | default Class hibernateDialectClass() { 31 | return ReflectionUtils.getClass(hibernateDialect()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/transaction/ConnectionVoidCallable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util.transaction; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | 6 | /** 7 | * @author Vlad Mihalcea 8 | */ 9 | @FunctionalInterface 10 | public interface ConnectionVoidCallable { 11 | void execute(Connection connection) throws SQLException; 12 | } 13 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/transaction/JPATransactionFunction.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util.transaction; 2 | 3 | import jakarta.persistence.EntityManager; 4 | 5 | import java.util.function.Function; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @FunctionalInterface 11 | public interface JPATransactionFunction extends Function { 12 | default void beforeTransactionCompletion() { 13 | 14 | } 15 | 16 | default void afterTransactionCompletion() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/transaction/JPATransactionVoidFunction.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util.transaction; 2 | 3 | import jakarta.persistence.EntityManager; 4 | 5 | import java.util.function.Consumer; 6 | 7 | /** 8 | * @author Vlad Mihalcea 9 | */ 10 | @FunctionalInterface 11 | public interface JPATransactionVoidFunction extends Consumer { 12 | default void beforeTransactionCompletion() { 13 | 14 | } 15 | 16 | default void afterTransactionCompletion() { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /jooq/jooq-core/src/main/java/com/vladmihalcea/util/transaction/VoidCallable.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.util.transaction; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | /** 6 | * @author Vlad Mihalcea 7 | */ 8 | @FunctionalInterface 9 | public interface VoidCallable extends Callable { 10 | 11 | void execute(); 12 | 13 | default Void call() throws Exception { 14 | execute(); 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /jooq/jooq-mysql/src/test/java/com/vladmihalcea/hpjp/jooq/mysql/crud/AbstractJOOQMySQLIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jooq.mysql.crud; 2 | 3 | import com.vladmihalcea.hpjp.jooq.AbstractJOOQIntegrationTest; 4 | import com.vladmihalcea.util.providers.DataSourceProvider; 5 | import com.vladmihalcea.util.providers.MySQLDataSourceProvider; 6 | import org.jooq.SQLDialect; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public abstract class AbstractJOOQMySQLIntegrationTest extends AbstractJOOQIntegrationTest { 12 | 13 | @Override 14 | protected String ddlFolder() { 15 | return "mysql"; 16 | } 17 | 18 | @Override 19 | protected SQLDialect sqlDialect() { 20 | return SQLDialect.MYSQL; 21 | } 22 | 23 | protected DataSourceProvider dataSourceProvider() { 24 | return new MySQLDataSourceProvider(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jooq/jooq-mysql/src/test/resources/mysql/clean_schema.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM post_tag; 2 | DELETE FROM tag; 3 | DELETE FROM post_details; 4 | DELETE FROM post_comment_details; 5 | DELETE FROM post_comment; 6 | DELETE FROM post; 7 | 8 | ALTER TABLE post_tag AUTO_INCREMENT = 1; 9 | ALTER TABLE tag AUTO_INCREMENT = 1; 10 | ALTER TABLE post_details AUTO_INCREMENT = 1; 11 | ALTER TABLE post_comment_details AUTO_INCREMENT = 1; 12 | ALTER TABLE post_comment AUTO_INCREMENT = 1; 13 | ALTER TABLE post AUTO_INCREMENT = 1; -------------------------------------------------------------------------------- /jooq/jooq-pgsql-score/src/test/java/com/vladmihalcea/hpjp/jooq/pgsql/score/AbstractJOOQPostgreSQLIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jooq.pgsql.score; 2 | 3 | import com.vladmihalcea.hpjp.jooq.AbstractJOOQIntegrationTest; 4 | import com.vladmihalcea.util.providers.DataSourceProvider; 5 | import com.vladmihalcea.util.providers.PostgreSQLDataSourceProvider; 6 | import org.jooq.SQLDialect; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public abstract class AbstractJOOQPostgreSQLIntegrationTest extends AbstractJOOQIntegrationTest { 12 | 13 | @Override 14 | protected String ddlFolder() { 15 | return "pgsql"; 16 | } 17 | 18 | @Override 19 | protected SQLDialect sqlDialect() { 20 | return SQLDialect.POSTGRES; 21 | } 22 | 23 | protected DataSourceProvider dataSourceProvider() { 24 | return new PostgreSQLDataSourceProvider(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jooq/jooq-pgsql-score/src/test/resources/pgsql/clean_schema.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM post_comment; 2 | DELETE FROM post; 3 | 4 | ALTER SEQUENCE hibernate_sequence RESTART; -------------------------------------------------------------------------------- /jooq/jooq-pgsql/src/test/java/com/vladmihalcea/hpjp/jooq/pgsql/util/AbstractJOOQPostgreSQLIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package com.vladmihalcea.hpjp.jooq.pgsql.util; 2 | 3 | import com.vladmihalcea.hpjp.jooq.AbstractJOOQIntegrationTest; 4 | import com.vladmihalcea.util.providers.DataSourceProvider; 5 | import com.vladmihalcea.util.providers.PostgreSQLDataSourceProvider; 6 | import org.jooq.SQLDialect; 7 | 8 | /** 9 | * @author Vlad Mihalcea 10 | */ 11 | public abstract class AbstractJOOQPostgreSQLIntegrationTest extends AbstractJOOQIntegrationTest { 12 | 13 | @Override 14 | protected String ddlFolder() { 15 | return "pgsql"; 16 | } 17 | 18 | @Override 19 | protected SQLDialect sqlDialect() { 20 | return SQLDialect.POSTGRES; 21 | } 22 | 23 | protected DataSourceProvider dataSourceProvider() { 24 | return new PostgreSQLDataSourceProvider(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /jooq/jooq-pgsql/src/test/resources/pgsql/clean_schema.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM post_tag; 2 | DELETE FROM tag; 3 | DELETE FROM post_details; 4 | DELETE FROM post_comment_details; 5 | DELETE FROM post_comment; 6 | DELETE FROM post; 7 | DELETE FROM answer; 8 | DELETE FROM question; 9 | 10 | ALTER SEQUENCE hibernate_sequence RESTART; -------------------------------------------------------------------------------- /jooq/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | high-performance-java-persistence 7 | com.vladmihalcea 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | high-performance-java-persistence-jooq 12 | pom 13 | 14 | 15 | jooq-core 16 | jooq-mysql 17 | jooq-pgsql 18 | jooq-pgsql-score 19 | 20 | 21 | 22 | 3.17.7 23 | 1.1.1 24 | 25 | 26 | --------------------------------------------------------------------------------