├── .github
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── project.yml
├── .gitignore
├── .mvn
└── wrapper
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── CI.adoc
├── CONTRIBUTING.adoc
├── Jenkinsfile
├── README.adoc
├── SECURITY.adoc
├── Spring Data JPA.sonargraph
├── aop.xml
├── formatting.xml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
├── main
│ ├── asciidoc
│ │ ├── faq.adoc
│ │ ├── glossary.adoc
│ │ ├── images
│ │ │ ├── epub-cover.png
│ │ │ └── epub-cover.svg
│ │ ├── index.adoc
│ │ ├── jpa.adoc
│ │ ├── new-features.adoc
│ │ ├── preface.adoc
│ │ └── query-by-example.adoc
│ ├── java
│ │ └── org
│ │ │ └── springframework
│ │ │ └── data
│ │ │ └── jpa
│ │ │ ├── convert
│ │ │ ├── QueryByExamplePredicateBuilder.java
│ │ │ ├── package-info.java
│ │ │ ├── threeten
│ │ │ │ ├── Jsr310JpaConverters.java
│ │ │ │ └── package-info.java
│ │ │ └── threetenbp
│ │ │ │ ├── ThreeTenBackPortJpaConverters.java
│ │ │ │ └── package-info.java
│ │ │ ├── domain
│ │ │ ├── AbstractAuditable.java
│ │ │ ├── AbstractPersistable.java
│ │ │ ├── JpaSort.java
│ │ │ ├── Specification.java
│ │ │ ├── SpecificationComposition.java
│ │ │ ├── package-info.java
│ │ │ └── support
│ │ │ │ ├── AuditingBeanFactoryPostProcessor.java
│ │ │ │ ├── AuditingEntityListener.java
│ │ │ │ └── package-info.java
│ │ │ ├── mapping
│ │ │ ├── JpaMetamodelMappingContext.java
│ │ │ ├── JpaPersistentEntity.java
│ │ │ ├── JpaPersistentEntityImpl.java
│ │ │ ├── JpaPersistentProperty.java
│ │ │ ├── JpaPersistentPropertyImpl.java
│ │ │ └── package-info.java
│ │ │ ├── projection
│ │ │ └── CollectionAwareProjectionFactory.java
│ │ │ ├── provider
│ │ │ ├── HibernateUtils.java
│ │ │ ├── JpaClassUtils.java
│ │ │ ├── PersistenceProvider.java
│ │ │ ├── ProxyIdAccessor.java
│ │ │ ├── QueryExtractor.java
│ │ │ └── package-info.java
│ │ │ ├── repository
│ │ │ ├── EntityGraph.java
│ │ │ ├── JpaContext.java
│ │ │ ├── JpaRepository.java
│ │ │ ├── JpaSpecificationExecutor.java
│ │ │ ├── Lock.java
│ │ │ ├── Modifying.java
│ │ │ ├── Query.java
│ │ │ ├── QueryHints.java
│ │ │ ├── Temporal.java
│ │ │ ├── cdi
│ │ │ │ ├── JpaRepositoryBean.java
│ │ │ │ ├── JpaRepositoryExtension.java
│ │ │ │ └── package-info.java
│ │ │ ├── config
│ │ │ │ ├── AuditingBeanDefinitionParser.java
│ │ │ │ ├── BeanDefinitionNames.java
│ │ │ │ ├── EnableJpaAuditing.java
│ │ │ │ ├── EnableJpaRepositories.java
│ │ │ │ ├── InspectionClassLoader.java
│ │ │ │ ├── JpaAuditingRegistrar.java
│ │ │ │ ├── JpaMetamodelMappingContextFactoryBean.java
│ │ │ │ ├── JpaRepositoriesRegistrar.java
│ │ │ │ ├── JpaRepositoryConfigExtension.java
│ │ │ │ ├── JpaRepositoryNameSpaceHandler.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ ├── query
│ │ │ │ ├── AbstractJpaQuery.java
│ │ │ │ ├── AbstractStringBasedJpaQuery.java
│ │ │ │ ├── DeclaredQuery.java
│ │ │ │ ├── DefaultJpaEntityMetadata.java
│ │ │ │ ├── DefaultJpaQueryMethodFactory.java
│ │ │ │ ├── EmptyDeclaredQuery.java
│ │ │ │ ├── EscapeCharacter.java
│ │ │ │ ├── ExpressionBasedStringQuery.java
│ │ │ │ ├── InvalidJpaQueryMethodException.java
│ │ │ │ ├── Jpa21Utils.java
│ │ │ │ ├── JpaCountQueryCreator.java
│ │ │ │ ├── JpaEntityGraph.java
│ │ │ │ ├── JpaEntityMetadata.java
│ │ │ │ ├── JpaParameters.java
│ │ │ │ ├── JpaParametersParameterAccessor.java
│ │ │ │ ├── JpaQueryCreator.java
│ │ │ │ ├── JpaQueryExecution.java
│ │ │ │ ├── JpaQueryFactory.java
│ │ │ │ ├── JpaQueryLookupStrategy.java
│ │ │ │ ├── JpaQueryMethod.java
│ │ │ │ ├── JpaQueryMethodFactory.java
│ │ │ │ ├── JpaResultConverters.java
│ │ │ │ ├── NamedQuery.java
│ │ │ │ ├── NativeJpaQuery.java
│ │ │ │ ├── ParameterBinder.java
│ │ │ │ ├── ParameterBinderFactory.java
│ │ │ │ ├── ParameterMetadataProvider.java
│ │ │ │ ├── PartTreeJpaQuery.java
│ │ │ │ ├── Procedure.java
│ │ │ │ ├── QueryParameterSetter.java
│ │ │ │ ├── QueryParameterSetterFactory.java
│ │ │ │ ├── QueryUtils.java
│ │ │ │ ├── SimpleJpaQuery.java
│ │ │ │ ├── StoredProcedureAttributeSource.java
│ │ │ │ ├── StoredProcedureAttributes.java
│ │ │ │ ├── StoredProcedureJpaQuery.java
│ │ │ │ ├── StringQuery.java
│ │ │ │ └── package-info.java
│ │ │ ├── support
│ │ │ │ ├── CrudMethodMetadata.java
│ │ │ │ ├── CrudMethodMetadataPostProcessor.java
│ │ │ │ ├── DefaultJpaContext.java
│ │ │ │ ├── DefaultQueryHints.java
│ │ │ │ ├── EntityManagerBeanDefinitionRegistrarPostProcessor.java
│ │ │ │ ├── JpaEntityInformation.java
│ │ │ │ ├── JpaEntityInformationSupport.java
│ │ │ │ ├── JpaEvaluationContextExtension.java
│ │ │ │ ├── JpaMetamodelEntityInformation.java
│ │ │ │ ├── JpaPersistableEntityInformation.java
│ │ │ │ ├── JpaRepositoryFactory.java
│ │ │ │ ├── JpaRepositoryFactoryBean.java
│ │ │ │ ├── JpaRepositoryImplementation.java
│ │ │ │ ├── MutableQueryHints.java
│ │ │ │ ├── QueryHintValue.java
│ │ │ │ ├── QueryHints.java
│ │ │ │ ├── Querydsl.java
│ │ │ │ ├── QuerydslJpaPredicateExecutor.java
│ │ │ │ ├── QuerydslJpaRepository.java
│ │ │ │ ├── QuerydslRepositorySupport.java
│ │ │ │ ├── SimpleJpaRepository.java
│ │ │ │ └── package-info.java
│ │ │ └── utils
│ │ │ │ └── package-info.java
│ │ │ ├── support
│ │ │ ├── ClasspathScanningPersistenceUnitPostProcessor.java
│ │ │ ├── MergingPersistenceUnitManager.java
│ │ │ └── package-info.java
│ │ │ └── util
│ │ │ ├── BeanDefinitionUtils.java
│ │ │ ├── HibernateProxyDetector.java
│ │ │ ├── JpaMetamodel.java
│ │ │ ├── JpaMetamodelCacheCleanup.java
│ │ │ └── package-info.java
│ └── resources
│ │ ├── META-INF
│ │ ├── services
│ │ │ └── javax.enterprise.inject.spi.Extension
│ │ ├── spring.factories
│ │ ├── spring.handlers
│ │ ├── spring.schemas
│ │ └── spring.tooling
│ │ ├── changelog.txt
│ │ ├── license.txt
│ │ ├── notice.txt
│ │ ├── org
│ │ └── springframework
│ │ │ └── data
│ │ │ └── jpa
│ │ │ └── repository
│ │ │ └── config
│ │ │ ├── spring-jpa-1.0.xsd
│ │ │ ├── spring-jpa-1.1.xsd
│ │ │ ├── spring-jpa-1.11.xsd
│ │ │ ├── spring-jpa-1.2.xsd
│ │ │ ├── spring-jpa-1.3.xsd
│ │ │ └── spring-jpa-1.8.xsd
│ │ └── readme.txt
└── test
│ ├── java
│ └── org
│ │ └── springframework
│ │ └── data
│ │ └── jpa
│ │ ├── convert
│ │ ├── QueryByExamplePredicateBuilderUnitTests.java
│ │ ├── threeten
│ │ │ ├── DateTimeSample.java
│ │ │ ├── Jsr310JpaConvertersIntegrationTests.java
│ │ │ └── Jsr310JpaConvertersUnitTests.java
│ │ └── threetenbp
│ │ │ ├── DateTimeSample.java
│ │ │ └── ThreeTenBackPortJpaConvertersIntegrationTests.java
│ │ ├── domain
│ │ ├── JpaSortTests.java
│ │ ├── SpecificationUnitTests.java
│ │ ├── sample
│ │ │ ├── AbstractAnnotatedAuditable.java
│ │ │ ├── AbstractMappedType.java
│ │ │ ├── Account.java
│ │ │ ├── Address.java
│ │ │ ├── AnnotatedAuditableUser.java
│ │ │ ├── AuditableRole.java
│ │ │ ├── AuditableUser.java
│ │ │ ├── AuditorAwareStub.java
│ │ │ ├── Category.java
│ │ │ ├── Child.java
│ │ │ ├── ConcreteType1.java
│ │ │ ├── ConcreteType2.java
│ │ │ ├── CustomAbstractPersistable.java
│ │ │ ├── Customer.java
│ │ │ ├── Dummy.java
│ │ │ ├── EmbeddedIdExampleDepartment.java
│ │ │ ├── EmbeddedIdExampleEmployee.java
│ │ │ ├── EmbeddedIdExampleEmployeePK.java
│ │ │ ├── EntityWithAssignedId.java
│ │ │ ├── IdClassExampleDepartment.java
│ │ │ ├── IdClassExampleEmployee.java
│ │ │ ├── IdClassExampleEmployeePK.java
│ │ │ ├── Item.java
│ │ │ ├── ItemId.java
│ │ │ ├── ItemSite.java
│ │ │ ├── ItemSiteId.java
│ │ │ ├── MailMessage.java
│ │ │ ├── MailSender.java
│ │ │ ├── MailUser.java
│ │ │ ├── Order.java
│ │ │ ├── OrmXmlEntity.java
│ │ │ ├── Parent.java
│ │ │ ├── PersistableWithIdClass.java
│ │ │ ├── PersistableWithIdClassPK.java
│ │ │ ├── PrimitiveVersionProperty.java
│ │ │ ├── Product.java
│ │ │ ├── Role.java
│ │ │ ├── SampleEntity.java
│ │ │ ├── SampleEntityPK.java
│ │ │ ├── SampleWithIdClass.java
│ │ │ ├── SampleWithIdClassIncludingEntity.java
│ │ │ ├── SampleWithPrimitiveId.java
│ │ │ ├── SampleWithTimestampVersion.java
│ │ │ ├── Site.java
│ │ │ ├── SpecialUser.java
│ │ │ ├── User.java
│ │ │ ├── UserSpecifications.java
│ │ │ └── VersionedUser.java
│ │ └── support
│ │ │ ├── AbstractAttributeConverterIntegrationTests.java
│ │ │ ├── AnnotationAuditingBeanFactoryPostProcessorUnitTests.java
│ │ │ ├── AuditingBeanFactoryPostProcessorUnitTests.java
│ │ │ ├── AuditingEntityListenerTests.java
│ │ │ └── AuditingNamespaceUnitTests.java
│ │ ├── infrastructure
│ │ ├── EclipseLinkMetamodelIntegrationTests.java
│ │ ├── HibernateMetamodelIntegrationTests.java
│ │ ├── HibernateTestUtils.java
│ │ ├── MetamodelIntegrationTests.java
│ │ └── OpenJpaMetamodelIntegrationTests.java
│ │ ├── mapping
│ │ ├── JpaMetamodelMappingContextIntegrationTests.java
│ │ ├── JpaMetamodelMappingContextUnitTests.java
│ │ └── JpaPersistentPropertyImplUnitTests.java
│ │ ├── provider
│ │ ├── PersistenceProviderIntegrationTests.java
│ │ └── PersistenceProviderUnitTests.java
│ │ ├── repository
│ │ ├── AbstractPersistableIntegrationTests.java
│ │ ├── CrudMethodMetadataUnitTests.java
│ │ ├── CustomAbstractPersistableIntegrationTests.java
│ │ ├── CustomEclipseLinkJpaVendorAdapter.java
│ │ ├── CustomHsqlHibernateJpaVendorAdaptor.java
│ │ ├── EclipseLinkEntityGraphRepositoryMethodsIntegrationTests.java
│ │ ├── EclipseLinkNamespaceUserRepositoryTests.java
│ │ ├── EclipseLinkParentRepositoryIntegrationTests.java
│ │ ├── EclipseLinkRepositoryWithCompositeKeyIntegrationTests.java
│ │ ├── EclipseLinkStoredProcedureIntegrationTests.java
│ │ ├── EclipseLinkUserRepositoryFinderTests.java
│ │ ├── EntityGraphRepositoryMethodsIntegrationTests.java
│ │ ├── EntityWithAssignedIdIntegrationTests.java
│ │ ├── JavaConfigUserRepositoryTests.java
│ │ ├── MappedTypeRepositoryIntegrationTests.java
│ │ ├── NamespaceUserRepositoryTests.java
│ │ ├── ORMInfrastructureTests.java
│ │ ├── OpenJpaEntityGraphRepositoryMethodsIntegrationTests.java
│ │ ├── OpenJpaNamespaceUserRepositoryTests.java
│ │ ├── OpenJpaParentRepositoryIntegrationTests.java
│ │ ├── OpenJpaRepositoryWithCompositeKeyIntegrationTests.java
│ │ ├── OpenJpaStoredProcedureIntegrationTests.java
│ │ ├── OpenJpaUserRepositoryFinderTests.java
│ │ ├── ParentRepositoryIntegrationTests.java
│ │ ├── RedeclaringRepositoryMethodsTests.java
│ │ ├── RepositoryWithCompositeKeyTests.java
│ │ ├── RepositoryWithIdClassKeyTests.java
│ │ ├── RoleRepositoryIntegrationTests.java
│ │ ├── SPR8954Tests.java
│ │ ├── SimpleJpaParameterBindingTests.java
│ │ ├── StoredProcedureIntegrationTests.java
│ │ ├── UserRepositoryFinderTests.java
│ │ ├── UserRepositoryStoredProcedureIntegrationTests.java
│ │ ├── UserRepositoryTests.java
│ │ ├── cdi
│ │ │ ├── CdiExtensionIntegrationTests.java
│ │ │ ├── EntityManagerFactoryProducer.java
│ │ │ ├── JpaRepositoryExtensionUnitTests.java
│ │ │ ├── Person.java
│ │ │ ├── PersonDB.java
│ │ │ ├── PersonRepository.java
│ │ │ ├── QualifiedCustomizedCdiConfiguration.java
│ │ │ ├── QualifiedCustomizedUserRepository.java
│ │ │ ├── QualifiedCustomizedUserRepositoryBean.java
│ │ │ ├── QualifiedCustomizedUserRepositoryCustom.java
│ │ │ ├── QualifiedEntityManagerProducer.java
│ │ │ ├── QualifiedFragment.java
│ │ │ ├── QualifiedFragmentBean.java
│ │ │ ├── QualifiedPersonRepository.java
│ │ │ ├── RepositoryConsumer.java
│ │ │ ├── SamplePersonRepository.java
│ │ │ ├── SamplePersonRepositoryCustom.java
│ │ │ ├── SamplePersonRepositoryImpl.java
│ │ │ ├── Transactional.java
│ │ │ ├── TransactionalInterceptor.java
│ │ │ ├── UnqualifiedEntityManagerProducer.java
│ │ │ ├── UnqualifiedPersonRepository.java
│ │ │ └── UserDB.java
│ │ ├── config
│ │ │ ├── AbstractAuditingViaJavaConfigRepositoriesTests.java
│ │ │ ├── AbstractRepositoryConfigTests.java
│ │ │ ├── AllowNestedRepositoriesRepositoryConfigTests.java
│ │ │ ├── AuditingBeanDefinitionParserTests.java
│ │ │ ├── CustomRepositoryFactoryConfigTests.java
│ │ │ ├── DefaultAuditingViaJavaConfigRepositoriesTests.java
│ │ │ ├── ExplicitAuditingViaJavaConfigRepositoriesTests.java
│ │ │ ├── InfrastructureConfig.java
│ │ │ ├── InspectionClassLoaderUnitTests.java
│ │ │ ├── JpaAuditingRegistrarUnitTests.java
│ │ │ ├── JpaRepositoriesRegistrarIntegrationTests.java
│ │ │ ├── JpaRepositoriesRegistrarUnitTests.java
│ │ │ ├── JpaRepositoryConfigDefinitionParserTests.java
│ │ │ ├── JpaRepositoryConfigExtensionUnitTests.java
│ │ │ ├── NestedRepositoriesJavaConfigTests.java
│ │ │ ├── QueryLookupStrategyTests.java
│ │ │ ├── RepositoriesJavaConfigTests.java
│ │ │ ├── RepositoryAutoConfigTests.java
│ │ │ ├── RepositoryConfigTests.java
│ │ │ ├── TypeFilterConfigTests.java
│ │ │ └── package.html
│ │ ├── custom
│ │ │ ├── CustomGenericJpaRepository.java
│ │ │ ├── CustomGenericJpaRepositoryFactory.java
│ │ │ ├── CustomGenericJpaRepositoryFactoryBean.java
│ │ │ ├── CustomGenericRepository.java
│ │ │ ├── UserCustomExtendedRepository.java
│ │ │ └── package-info.java
│ │ ├── projections
│ │ │ ├── ProjectionJoinIntegrationTests.java
│ │ │ └── ProjectionsIntegrationTests.java
│ │ ├── query
│ │ │ ├── AbstractJpaQueryTests.java
│ │ │ ├── AbstractStringBasedJpaQueryIntegrationTests.java
│ │ │ ├── CustomNonBindableJpaParametersIntegrationTests.java
│ │ │ ├── EclipseLinkJpa21UtilsTests.java
│ │ │ ├── EclipseLinkParameterMetadataProviderIntegrationTests.java
│ │ │ ├── EclipseLinkQueryUtilsIntegrationTests.java
│ │ │ ├── EscapeCharacterUnitTests.java
│ │ │ ├── ExpressionBasedStringQueryUnitTests.java
│ │ │ ├── Jpa21UtilsTests.java
│ │ │ ├── Jpa21UtilsUnitTests.java
│ │ │ ├── JpaCountQueryCreatorIntegrationTests.java
│ │ │ ├── JpaParametersUnitTests.java
│ │ │ ├── JpaQueryExecutionUnitTests.java
│ │ │ ├── JpaQueryLookupStrategyUnitTests.java
│ │ │ ├── JpaQueryMethodUnitTests.java
│ │ │ ├── LikeBindingUnitTests.java
│ │ │ ├── NamedOrIndexedQueryParameterSetterUnitTests.java
│ │ │ ├── NamedQueryUnitTests.java
│ │ │ ├── OpenJpaJpa21UtilsTests.java
│ │ │ ├── OpenJpaParameterMetadataProviderIntegrationTests.java
│ │ │ ├── OpenJpaQueryUtilsIntegrationTests.java
│ │ │ ├── ParameterBinderUnitTests.java
│ │ │ ├── ParameterBindingParserUnitTests.java
│ │ │ ├── ParameterExpressionProviderTests.java
│ │ │ ├── ParameterMetadataProviderIntegrationTests.java
│ │ │ ├── ParameterMetadataProviderUnitTests.java
│ │ │ ├── PartTreeJpaQueryIntegrationTests.java
│ │ │ ├── QueryParameterSetterFactoryUnitTests.java
│ │ │ ├── QueryUtilsIntegrationTests.java
│ │ │ ├── QueryUtilsUnitTests.java
│ │ │ ├── SimpleJpaQueryUnitTests.java
│ │ │ ├── StoredProcedureAttributeSourceUnitTests.java
│ │ │ ├── StoredProcedureAttributesUnitTests.java
│ │ │ ├── StringQueryUnitTests.java
│ │ │ └── TupleConverterUnitTests.java
│ │ ├── sample
│ │ │ ├── AnnotatedAuditableUserRepository.java
│ │ │ ├── AuditableUserRepository.java
│ │ │ ├── CategoryRepository.java
│ │ │ ├── ClassWithNestedRepository.java
│ │ │ ├── ConcreteRepository1.java
│ │ │ ├── ConcreteRepository2.java
│ │ │ ├── CustomAbstractPersistableRepository.java
│ │ │ ├── DummyRepository.java
│ │ │ ├── EmployeeRepositoryWithEmbeddedId.java
│ │ │ ├── EmployeeRepositoryWithIdClass.java
│ │ │ ├── EntityWithAssignedIdRepository.java
│ │ │ ├── ItemRepository.java
│ │ │ ├── ItemSiteRepository.java
│ │ │ ├── MailMessageRepository.java
│ │ │ ├── MappedTypeRepository.java
│ │ │ ├── NameOnlyDto.java
│ │ │ ├── ParentRepository.java
│ │ │ ├── ProductRepository.java
│ │ │ ├── RedeclaringRepositoryMethodsRepository.java
│ │ │ ├── RepositoryMethodsWithEntityGraphConfigRepository.java
│ │ │ ├── RoleRepository.java
│ │ │ ├── SampleConfig.java
│ │ │ ├── SampleEvaluationContextExtension.java
│ │ │ ├── SiteRepository.java
│ │ │ ├── UserRepository.java
│ │ │ ├── UserRepositoryCustom.java
│ │ │ └── UserRepositoryImpl.java
│ │ └── support
│ │ │ ├── CrudMethodMetadataPopulatingMethodInterceptorUnitTests.java
│ │ │ ├── DefaultJpaContextIntegrationTests.java
│ │ │ ├── DefaultJpaContextUnitTests.java
│ │ │ ├── DefaultJpaEntityMetadataUnitTest.java
│ │ │ ├── DefaultQueryHintsTest.java
│ │ │ ├── DefaultTransactionDisablingIntegrationTests.java
│ │ │ ├── EclipseLinkJpaMetamodelEntityInformationIntegrationTests.java
│ │ │ ├── EclipseLinkJpaRepositoryTests.java
│ │ │ ├── EclipseLinkProxyIdAccessorTests.java
│ │ │ ├── EntityManagerBeanDefinitionRegistrarPostProcessorIntegrationTests.java
│ │ │ ├── EntityManagerBeanDefinitionRegistrarPostProcessorUnitTests.java
│ │ │ ├── EntityManagerFactoryRefTests.java
│ │ │ ├── EntityManagerFactoryRefUnitTests.java
│ │ │ ├── JavaConfigDefaultTransactionDisablingIntegrationTests.java
│ │ │ ├── JpaEntityInformationSupportUnitTests.java
│ │ │ ├── JpaMetamodelEntityInformationIntegrationTests.java
│ │ │ ├── JpaMetamodelEntityInformationUnitTests.java
│ │ │ ├── JpaPersistableEntityInformationUnitTests.java
│ │ │ ├── JpaRepositoryFactoryBeanEntityPathResolverIntegrationTests.java
│ │ │ ├── JpaRepositoryFactoryBeanUnitTests.java
│ │ │ ├── JpaRepositoryFactoryUnitTests.java
│ │ │ ├── JpaRepositoryTests.java
│ │ │ ├── MailMessageRepositoryIntegrationTests.java
│ │ │ ├── MutableQueryHintsUnitTests.java
│ │ │ ├── OpenJpaJpaRepositoryTests.java
│ │ │ ├── OpenJpaMetamodelEntityInformationIntegrationTests.java
│ │ │ ├── OpenJpaProxyIdAccessorTests.java
│ │ │ ├── QSimpleEntityPathResolverUnitTests_Sample.java
│ │ │ ├── QuerydslIntegrationTests.java
│ │ │ ├── QuerydslJpaPredicateExecutorUnitTests.java
│ │ │ ├── QuerydslJpaRepositoryTests.java
│ │ │ ├── QuerydslRepositorySupportIntegrationTests.java
│ │ │ ├── QuerydslRepositorySupportTests.java
│ │ │ ├── SimpleJpaRepositoryUnitTests.java
│ │ │ ├── TransactionalRepositoryTests.java
│ │ │ ├── XmlConfigDefaultTransactionDisablingIntegrationTests.java
│ │ │ └── package.html
│ │ ├── support
│ │ ├── ClasspathScanningPersistenceUnitPostProcessorUnitTests.java
│ │ ├── EntityManagerTestUtils.java
│ │ └── MergingPersistenceUnitManagerUnitTests.java
│ │ └── util
│ │ ├── FixedDate.java
│ │ ├── JpaMetamodelCacheCleanupIntegrationTests.java
│ │ └── JpaMetamodelUnitTests.java
│ └── resources
│ ├── META-INF
│ ├── jpa-named-queries.properties
│ ├── orm.xml
│ ├── persistence.xml
│ └── persistence2.xml
│ ├── application-context.xml
│ ├── auditing
│ ├── auditing-bfpp-context.xml
│ ├── auditing-entity-listener.xml
│ ├── auditing-namespace-context.xml
│ ├── auditing-namespace-context2.xml
│ └── auditing-namespace-context3.xml
│ ├── config
│ ├── jpa-context-with-jndi.xml
│ ├── lookup-strategies-context.xml
│ ├── namespace-application-context.xml
│ ├── namespace-autoconfig-context.xml
│ ├── namespace-autoconfig-typefilter-context.xml
│ ├── namespace-customfactory-context.xml
│ └── namespace-nested-repositories-application-context.xml
│ ├── eclipselink.xml
│ ├── hibernate.xml
│ ├── infrastructure.xml
│ ├── logback.xml
│ ├── multiple-entity-manager-context.xml
│ ├── multiple-entity-manager-integration-context.xml
│ ├── openjpa.xml
│ ├── org
│ └── springframework
│ │ └── data
│ │ └── jpa
│ │ ├── repository
│ │ └── support
│ │ │ └── disable-default-transactions.xml
│ │ └── support
│ │ ├── mapping.xml
│ │ ├── module1
│ │ └── module1-orm.xml
│ │ ├── module2
│ │ └── module2-orm.xml
│ │ ├── persistence.xml
│ │ └── persistence2.xml
│ ├── scripts
│ ├── hsqldb-init.sql
│ └── schema-stored-procedures.sql
│ ├── simple-persistence
│ └── simple-persistence.xml
│ └── tx-manager.xml
└── template.mf
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
7 |
8 | - [ ] You have read the [Spring Data contribution guidelines](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc).
9 | - [ ] You use the code formatters provided [here](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide) and have them applied to your changes. Don’t submit any formatting related changes.
10 | - [ ] You submit test cases (unit or integration tests) that back your changes.
11 | - [ ] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .idea/
3 | .settings/
4 | *.iml
5 | .project
6 | .classpath
7 | .springBeans
8 | .sonar4clipse
9 | *.sonar4clipseExternals
10 | .DS_Store
11 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SelimHorri/spring-data-jpa/7902888a0b37cc6f20f526ec0c4bc4273e61a00c/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
--------------------------------------------------------------------------------
/CONTRIBUTING.adoc:
--------------------------------------------------------------------------------
1 | = Spring Data contribution guidelines
2 |
3 | You find the contribution guidelines for Spring Data projects https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc[here].
4 |
--------------------------------------------------------------------------------
/SECURITY.adoc:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | Please see the https://spring.io/projects/spring-data-jpa[Spring Data JPA] project page for supported versions.
6 |
7 | ## Reporting a Vulnerability
8 |
9 | Please don't raise security vulnerabilities here. Head over to https://pivotal.io/security to learn how to disclose them responsibly.
10 |
--------------------------------------------------------------------------------
/aop.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/main/asciidoc/glossary.adoc:
--------------------------------------------------------------------------------
1 | [[glossary]]
2 | [appendix, glossary]
3 | = Glossary
4 |
5 | AOP :: Aspect oriented programming
6 |
7 | Commons DBCP :: Commons DataBase Connection Pools - a library from the Apache foundation that offers pooling implementations of the DataSource interface.
8 |
9 | CRUD :: Create, Read, Update, Delete - Basic persistence operations.
10 |
11 | DAO :: Data Access Object - Pattern to separate persisting logic from the object to be persisted
12 |
13 | Dependency Injection :: Pattern to hand a component's dependency to the component from outside, freeing the component to lookup the dependent itself. For more information, see link:$$https://en.wikipedia.org/wiki/Dependency_Injection$$[https://en.wikipedia.org/wiki/Dependency_Injection].
14 |
15 | EclipseLink :: Object relational mapper implementing JPA - link:$$https://www.eclipse.org/eclipselink/$$[https://www.eclipse.org/eclipselink/]
16 |
17 | Hibernate :: Object relational mapper implementing JPA - link:$$https://hibernate.org/$$[https://hibernate.org/]
18 |
19 | JPA :: Java Persistence API
20 |
21 | Spring :: Java application framework - link:$$https://projects.spring.io/spring-framework$$[https://projects.spring.io/spring-framework]
22 |
--------------------------------------------------------------------------------
/src/main/asciidoc/images/epub-cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SelimHorri/spring-data-jpa/7902888a0b37cc6f20f526ec0c4bc4273e61a00c/src/main/asciidoc/images/epub-cover.png
--------------------------------------------------------------------------------
/src/main/asciidoc/index.adoc:
--------------------------------------------------------------------------------
1 | = Spring Data JPA - Reference Documentation
2 | Oliver Gierke; Thomas Darimont; Christoph Strobl; Mark Paluch; Jay Bryant
3 | :revnumber: {version}
4 | :revdate: {localdate}
5 | ifdef::backend-epub3[:front-cover-image: image:epub-cover.png[Front Cover,1050,1600]]
6 | :spring-data-commons-docs: ../../../../spring-data-commons/src/main/asciidoc
7 | :spring-framework-docs: https://docs.spring.io/spring-framework/docs/{springVersion}/spring-framework-reference/
8 |
9 | (C) 2008-2021 The original authors.
10 |
11 | NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
12 |
13 | include::preface.adoc[]
14 |
15 | include::new-features.adoc[leveloffset=+1]
16 |
17 | include::{spring-data-commons-docs}/dependencies.adoc[leveloffset=+1]
18 |
19 | include::{spring-data-commons-docs}/repositories.adoc[leveloffset=+1]
20 |
21 | [[reference]]
22 | == Reference Documentation
23 |
24 | include::jpa.adoc[leveloffset=+1]
25 |
26 | [[appendix]]
27 | == Appendix
28 |
29 | :numbered!:
30 | include::{spring-data-commons-docs}/repository-namespace-reference.adoc[leveloffset=+1]
31 |
32 | include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[leveloffset=+1]
33 |
34 | include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[leveloffset=+1]
35 |
36 | include::{spring-data-commons-docs}/repository-query-return-types-reference.adoc[leveloffset=+1]
37 |
38 | include::faq.adoc[leveloffset=+1]
39 |
40 | include::glossary.adoc[leveloffset=+1]
41 |
--------------------------------------------------------------------------------
/src/main/asciidoc/new-features.adoc:
--------------------------------------------------------------------------------
1 | [[new-features]]
2 | = New & Noteworthy
3 |
4 | [[new-features.1-11-0]]
5 | == What's New in Spring Data JPA 1.11
6 |
7 | Spring Data JPA 1.11 added the following features:
8 |
9 | * Improved compatibility with Hibernate 5.2.
10 | * Support any-match mode for <>.
11 | * Paged query optimizations.
12 | * Support for the `exists` projection in repository query derivation.
13 |
14 | [[new-features.1-10-0]]
15 | == What's New in Spring Data JPA 1.10
16 |
17 | Spring Data JPA 1.10 added the following features:
18 |
19 | * Support for <> in repository query methods.
20 | * Support for <>.
21 | * The following annotations have been enabled to build on composed annotations: `@EntityGraph`, `@Lock`, `@Modifying`, `@Query`, `@QueryHints`, and `@Procedure`.
22 | * Support for the `Contains` keyword on collection expressions.
23 | * `AttributeConverter` implementations for `ZoneId` of JSR-310 and ThreeTenBP.
24 | * Upgrade to Querydsl 4, Hibernate 5, OpenJPA 2.4, and EclipseLink 2.6.1.
25 |
--------------------------------------------------------------------------------
/src/main/asciidoc/preface.adoc:
--------------------------------------------------------------------------------
1 | [[preface]]
2 | == Preface
3 |
4 | Spring Data JPA provides repository support for the Java Persistence API (JPA). It eases development of applications that need to access JPA data sources.
5 |
6 | [[project]]
7 | === Project Metadata
8 |
9 | * Version control: https://github.com/spring-projects/spring-data-jpa
10 | * Bugtracker: https://github.com/spring-projects/spring-data-jpa/issues
11 | * Release repository: https://repo.spring.io/libs-release
12 | * Milestone repository: https://repo.spring.io/libs-milestone
13 | * Snapshot repository: https://repo.spring.io/libs-snapshot
14 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/convert/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Spring Data JPA specific converter infrastructure.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.convert;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/convert/threeten/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Spring Data JPA specific JSR-310 converters.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.convert.threeten;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/convert/threetenbp/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Spring Data JPA specific ThreeTenBp converters.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.convert.threetenbp;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/domain/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JPA specific support classes to implement domain classes.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.domain;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/domain/support/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Implementation classes for auditing with JPA.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.domain.support;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.mapping;
17 |
18 | import org.springframework.data.mapping.PersistentEntity;
19 |
20 | /**
21 | * Interface for a JPA-specific entity.
22 | *
23 | * @author Oliver Gierke
24 | * @since 1.3
25 | */
26 | public interface JpaPersistentEntity extends PersistentEntity {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.mapping;
17 |
18 | import org.springframework.data.mapping.PersistentProperty;
19 |
20 | /**
21 | * Interface for a JPA-specific {@link PersistentProperty}.
22 | *
23 | * @author Oliver Gierke
24 | * @since 1.3
25 | */
26 | public interface JpaPersistentProperty extends PersistentProperty {
27 |
28 | /**
29 | * Return whether the property is considered embeddable.
30 | *
31 | * @return
32 | * @since 2.1
33 | */
34 | boolean isEmbeddable();
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/mapping/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JPA specific support classes for the Spring Data mapping subsystem.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.mapping;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/provider/HibernateUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.provider;
17 |
18 | import org.hibernate.query.Query;
19 | import org.springframework.lang.Nullable;
20 |
21 | /**
22 | * Utility functions to work with Hibernate. Mostly using reflection to make sure common functionality can be executed
23 | * against all the Hibernate version we support.
24 | *
25 | * @author Oliver Gierke
26 | * @author Mark Paluch
27 | * @author Jens Schauder
28 | * @since 1.10.2
29 | * @soundtrack Benny Greb - Soulfood (Live, https://www.youtube.com/watch?v=9_ErMa_CtSw)
30 | */
31 | public abstract class HibernateUtils {
32 |
33 | private HibernateUtils() {}
34 |
35 | /**
36 | * Return the query string of the underlying native Hibernate query.
37 | *
38 | * @param query
39 | * @return
40 | */
41 | @Nullable
42 | public static String getHibernateQuery(Object query) {
43 |
44 | if (query instanceof Query) {
45 | return ((Query) query).getQueryString();
46 | } else {
47 | throw new IllegalArgumentException("Don't know how to extract the query string from " + query);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/provider/ProxyIdAccessor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.provider;
17 |
18 | import org.springframework.lang.Nullable;
19 |
20 | /**
21 | * Interface for a persistence provider specific accessor of identifiers held in proxies.
22 | *
23 | * @author Oliver Gierke
24 | * @author Mark Paluch
25 | */
26 | public interface ProxyIdAccessor {
27 |
28 | /**
29 | * Returns whether the {@link ProxyIdAccessor} should be used for the given entity. Will inspect the entity to see
30 | * whether it is a proxy so that lenient id lookup can be used.
31 | *
32 | * @param entity must not be {@literal null}.
33 | * @return
34 | */
35 | boolean shouldUseAccessorFor(Object entity);
36 |
37 | /**
38 | * Returns the identifier of the given entity by leniently inspecting it for the identifier value.
39 | *
40 | * @param entity must not be {@literal null}.
41 | * @return can be {@literal null}.
42 | */
43 | @Nullable
44 | Object getIdentifierFrom(Object entity);
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/provider/QueryExtractor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.provider;
17 |
18 | import javax.persistence.Query;
19 |
20 | import org.springframework.lang.Nullable;
21 |
22 | /**
23 | * Interface to hide different implementations to extract the original JPA query string from a {@link Query}.
24 | *
25 | * @author Oliver Gierke
26 | * @author Mark Paluch
27 | */
28 | public interface QueryExtractor {
29 |
30 | /**
31 | * Reverse engineers the query string from the {@link Query} object. This requires provider specific API as JPA does
32 | * not provide access to the underlying query string as soon as one has created a {@link Query} instance of it.
33 | *
34 | * @param query
35 | * @return the query string representing the query or {@literal null} if resolving is not possible.
36 | */
37 | @Nullable
38 | String extractQueryString(Query query);
39 |
40 | /**
41 | * Returns whether the extractor is able to extract the original query string from a given {@link Query}.
42 | *
43 | * @return
44 | */
45 | boolean canExtractQuery();
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/provider/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JPA provider-specific utilities.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.provider;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/JpaContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import javax.persistence.EntityManager;
19 |
20 | /**
21 | * Interface for components to provide useful information about the current JPA setup within the current
22 | * {@link org.springframework.context.ApplicationContext}.
23 | *
24 | * @author Oliver Gierke
25 | * @soundtrack Marcus Miller - Water Dancer (Afrodeezia)
26 | * @since 1.9
27 | */
28 | public interface JpaContext {
29 |
30 | /**
31 | * Returns the {@link EntityManager} managing the given domain type.
32 | *
33 | * @param managedType must not be {@literal null}.
34 | * @return the {@link EntityManager} that manages the given type, will never be {@literal null}.
35 | * @throws IllegalArgumentException if the given type is not a JPA managed one no unique {@link EntityManager} managing this type can be resolved.
36 | */
37 | EntityManager getEntityManagerByManagedType(Class> managedType);
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/Lock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | import javax.persistence.LockModeType;
25 |
26 | /**
27 | * Annotation used to specify the {@link LockModeType} to be used when executing the query. It will be evaluated when
28 | * using {@link Query} on a query method or if you derive the query from the method name.
29 | *
30 | * @author Aleksander Blomskøld
31 | * @author Oliver Gierke
32 | */
33 | @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Documented
36 | public @interface Lock {
37 |
38 | /**
39 | * The {@link LockModeType} to be used when executing the annotated query or CRUD method.
40 | *
41 | * @return
42 | */
43 | LockModeType value();
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/Temporal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 | import java.util.Date;
24 |
25 | import javax.persistence.TemporalType;
26 |
27 | /**
28 | * Annotation to declare an appropriate {@code TemporalType} on query method parameters. Note that this annotation can
29 | * only be used on parameters of type {@link Date}.
30 | *
31 | * @author Thomas Darimont
32 | * @author Oliver Gierke
33 | */
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Target(ElementType.PARAMETER)
36 | @Documented
37 | public @interface Temporal {
38 |
39 | /**
40 | * Defines the {@link TemporalType} to use for the annotated parameter.
41 | */
42 | TemporalType value() default TemporalType.DATE;
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/cdi/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * CDI support for Spring Data JPA Repositories.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.repository.cdi;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/config/BeanDefinitionNames.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | /**
19 | * Helper class to manage bean definition names in a single place.
20 | *
21 | * @author Oliver Gierke
22 | * @author Thomas Darimont
23 | * @author Andrew Walters
24 | */
25 | interface BeanDefinitionNames {
26 |
27 | public static final String JPA_MAPPING_CONTEXT_BEAN_NAME = "jpaMappingContext";
28 | public static final String JPA_CONTEXT_BEAN_NAME = "jpaContext";
29 | public static final String EM_BEAN_DEFINITION_REGISTRAR_POST_PROCESSOR_BEAN_NAME = "emBeanDefinitionRegistrarPostProcessor";
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/config/InspectionClassLoader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import org.springframework.instrument.classloading.ShadowingClassLoader;
19 |
20 | /**
21 | * Disposable {@link ClassLoader} used to inspect user-code classes within an isolated class loader without preventing
22 | * class transformation at a later time.
23 | *
24 | * @author Mark Paluch
25 | * @since 2.1
26 | */
27 | class InspectionClassLoader extends ShadowingClassLoader {
28 |
29 | /**
30 | * Create a new {@link InspectionClassLoader} instance.
31 | *
32 | * @param parent the parent classloader.
33 | */
34 | InspectionClassLoader(ClassLoader parent) {
35 |
36 | super(parent, true);
37 |
38 | excludePackage("org.springframework.");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryNameSpaceHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
19 | import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
20 | import org.springframework.data.repository.config.RepositoryConfigurationExtension;
21 |
22 | /**
23 | * Simple namespace handler for {@literal repositories} namespace.
24 | *
25 | * @author Oliver Gierke
26 | */
27 | public class JpaRepositoryNameSpaceHandler extends NamespaceHandlerSupport {
28 |
29 | /*
30 | * (non-Javadoc)
31 | *
32 | * @see org.springframework.beans.factory.xml.NamespaceHandler#init()
33 | */
34 | @Override
35 | public void init() {
36 |
37 | RepositoryConfigurationExtension extension = new JpaRepositoryConfigExtension();
38 | RepositoryBeanDefinitionParser repositoryBeanDefinitionParser = new RepositoryBeanDefinitionParser(extension);
39 |
40 | registerBeanDefinitionParser("repositories", repositoryBeanDefinitionParser);
41 | registerBeanDefinitionParser("auditing", new AuditingBeanDefinitionParser());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/config/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Classes for JPA namespace configuration.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.repository.config;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Interfaces and annotations for JPA specific repositories.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.repository;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/query/DefaultJpaQueryMethodFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import java.lang.reflect.Method;
19 |
20 | import org.springframework.data.jpa.provider.QueryExtractor;
21 | import org.springframework.data.projection.ProjectionFactory;
22 | import org.springframework.data.repository.core.RepositoryMetadata;
23 | import org.springframework.util.Assert;
24 |
25 | /**
26 | * A factory for creating {@link JpaQueryMethod} instances.
27 | *
28 | * @author Jens Schauder
29 | * @since 2.3
30 | */
31 | public class DefaultJpaQueryMethodFactory implements JpaQueryMethodFactory {
32 |
33 | private final QueryExtractor extractor;
34 |
35 | public DefaultJpaQueryMethodFactory(QueryExtractor extractor) {
36 |
37 | Assert.notNull(extractor, "QueryExtractor must not be null");
38 |
39 | this.extractor = extractor;
40 | }
41 |
42 | @Override
43 | public JpaQueryMethod build(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
44 | return new JpaQueryMethod(method, metadata, factory, extractor);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/query/InvalidJpaQueryMethodException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | /**
19 | * Signals that we encountered an invalid query method.
20 | *
21 | * @author Thomas Darimont
22 | * @author Oliver Gierke
23 | */
24 | public class InvalidJpaQueryMethodException extends RuntimeException {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | /**
29 | * Creates a new {@link InvalidJpaQueryMethodException} with the given message.
30 | *
31 | * @param message must not be {@literal null} or empty.
32 | */
33 | public InvalidJpaQueryMethodException(String message) {
34 | super(message);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/query/JpaEntityMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.data.repository.core.EntityMetadata;
19 |
20 | /**
21 | * JPA specific extension of {@link EntityMetadata}.
22 | *
23 | * @author Oliver Gierke
24 | */
25 | public interface JpaEntityMetadata extends EntityMetadata {
26 |
27 | /**
28 | * Returns the name of the entity.
29 | *
30 | * @return
31 | */
32 | String getEntityName();
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryMethodFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2012-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import java.lang.reflect.Method;
19 |
20 | import org.springframework.data.projection.ProjectionFactory;
21 | import org.springframework.data.repository.core.RepositoryMetadata;
22 |
23 | /**
24 | * A factory interface for creating {@link JpaQueryMethodFactory} instances. This may be implemented by extensions to
25 | * Spring Data JPA in order create instances of custom subclasses.
26 | *
27 | * @author Réda Housni Alaoui
28 | * @since 2.3
29 | */
30 | public interface JpaQueryMethodFactory {
31 |
32 | /**
33 | * Creates a {@link JpaQueryMethod}.
34 | *
35 | * @param method must not be {@literal null}
36 | * @param metadata must not be {@literal null}
37 | * @param factory must not be {@literal null}
38 | */
39 | JpaQueryMethod build(Method method, RepositoryMetadata metadata, ProjectionFactory factory);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/query/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Query implementation to execute queries against JPA.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.repository.query;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/support/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JPA repository implementations.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.repository.support;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/repository/utils/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JPA specific utility functions.
3 | */
4 | package org.springframework.data.jpa.repository.utils;
5 |
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/support/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Various helper classes useful when working with JPA.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.support;
6 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/util/JpaMetamodelCacheCleanup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.util;
17 |
18 | import org.springframework.beans.factory.DisposableBean;
19 | import org.springframework.context.ApplicationContext;
20 |
21 | /**
22 | * Simple component to be registered as Spring bean to clear the {@link JpaMetamodel} cache to avoid a memory leak in
23 | * applications bootstrapping multiple {@link ApplicationContext}s.
24 | *
25 | * @author Oliver Gierke
26 | * @author Sylvère Richard
27 | * @see org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension#registerBeansForRoot(org.springframework.beans.factory.support.BeanDefinitionRegistry,
28 | * org.springframework.data.repository.config.RepositoryConfigurationSource)
29 | */
30 | class JpaMetamodelCacheCleanup implements DisposableBean {
31 |
32 | /*
33 | * (non-Javadoc)
34 | * @see org.springframework.beans.factory.DisposableBean#destroy()
35 | */
36 | @Override
37 | public void destroy() throws Exception {
38 | JpaMetamodel.clear();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/springframework/data/jpa/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Spring Data JPA utilities.
3 | */
4 | @org.springframework.lang.NonNullApi
5 | package org.springframework.data.jpa.util;
6 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension:
--------------------------------------------------------------------------------
1 | org.springframework.data.jpa.repository.cdi.JpaRepositoryExtension
--------------------------------------------------------------------------------
/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | org.springframework.data.repository.core.support.RepositoryFactorySupport=org.springframework.data.jpa.repository.support.JpaRepositoryFactory
2 | org.springframework.data.util.ProxyUtils$ProxyDetector=org.springframework.data.jpa.util.HibernateProxyDetector
3 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/spring.handlers:
--------------------------------------------------------------------------------
1 | http\://www.springframework.org/schema/data/jpa=org.springframework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler
2 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/spring.tooling:
--------------------------------------------------------------------------------
1 | # Tooling related information for the JPA namespace
2 | http\://www.springframework.org/schema/data/jpa@name=JPA Namespace
3 | http\://www.springframework.org/schema/data/jpa@prefix=jpa
4 | http\://www.springframework.org/schema/data/jpa@icon=org/springframework/jdbc/config/spring-jdbc.gif
5 |
--------------------------------------------------------------------------------
/src/main/resources/notice.txt:
--------------------------------------------------------------------------------
1 | Spring Data JPA 2.5 M3 (2021.0.0)
2 | Copyright (c) [2011-2019] Pivotal Software, Inc.
3 |
4 | This product is licensed to you under the Apache License, Version 2.0 (the "License").
5 | You may not use this product except in compliance with the License.
6 |
7 | This product may include a number of subcomponents with
8 | separate copyright notices and license terms. Your use of the source
9 | code for the these subcomponents is subject to the terms and
10 | conditions of the subcomponent's license, as noted in the LICENSE file.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/main/resources/readme.txt:
--------------------------------------------------------------------------------
1 | Spring Data JPA 1.6.0 M1 (March 31th, 2014)
2 | -------------------------------------------
3 |
4 | Spring Data Jpa is released under the terms of the Apache Software License Version 2.0 (see license.txt).
5 |
6 |
7 | DISTRIBUTION CONTENTS:
8 |
9 | The JARs are available in the 'dist' directory, and the source JARs are in the 'src' directory.
10 |
11 | The reference manual and javadoc are located in the 'docs' directory.
12 |
13 |
14 | ADDITIONAL RESOURCES:
15 |
16 | Spring Data Homepage: https://projects.spring.io/spring-data
17 | Spring Data JPA on Stackoverflow: https://stackoverflow.com/questions/tagged/spring-data-jpa
18 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/convert/threeten/DateTimeSample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.convert.threeten;
17 |
18 | import java.time.Instant;
19 | import java.time.LocalDate;
20 | import java.time.LocalDateTime;
21 | import java.time.LocalTime;
22 | import java.time.ZoneId;
23 |
24 | import javax.persistence.Entity;
25 | import javax.persistence.GeneratedValue;
26 | import javax.persistence.Id;
27 |
28 | /**
29 | * @author Oliver Gierke
30 | */
31 | @Entity
32 | public class DateTimeSample {
33 |
34 | @Id @GeneratedValue Long id;
35 | Instant instant;
36 | LocalDate localDate;
37 | LocalTime localTime;
38 | LocalDateTime localDateTime;
39 | ZoneId zoneId;
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/convert/threetenbp/DateTimeSample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.convert.threetenbp;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.GeneratedValue;
20 | import javax.persistence.Id;
21 |
22 | import org.threeten.bp.Instant;
23 | import org.threeten.bp.LocalDate;
24 | import org.threeten.bp.LocalDateTime;
25 | import org.threeten.bp.LocalTime;
26 | import org.threeten.bp.ZoneId;
27 |
28 | /**
29 | * @author Oliver Gierke
30 | */
31 | @Entity
32 | public class DateTimeSample {
33 |
34 | @Id @GeneratedValue Long id;
35 |
36 | Instant instant;
37 | LocalDate localDate;
38 | LocalTime localTime;
39 | LocalDateTime localDateTime;
40 | ZoneId zoneId;
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/AbstractMappedType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import lombok.Getter;
19 |
20 | import javax.persistence.GeneratedValue;
21 | import javax.persistence.Id;
22 | import javax.persistence.MappedSuperclass;
23 | import javax.persistence.Version;
24 |
25 | /**
26 | * @author Thomas Darimont
27 | * @author Oliver Gierke
28 | */
29 | @MappedSuperclass
30 | public abstract class AbstractMappedType {
31 |
32 | @Id @GeneratedValue @Getter Long id;
33 | @Version Long version;
34 | private String attribute1;
35 |
36 | AbstractMappedType() {}
37 |
38 | AbstractMappedType(String attribute1) {
39 | this.attribute1 = attribute1;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Account.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 |
20 | import org.springframework.data.jpa.domain.AbstractPersistable;
21 |
22 | /**
23 | * @author Oliver Gierke
24 | */
25 | @Entity
26 | public class Account extends AbstractPersistable {
27 |
28 | private static final long serialVersionUID = -5719129808165758887L;
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Address.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Embeddable;
19 |
20 | /**
21 | * @author Thomas Darimont
22 | */
23 | @Embeddable
24 | public class Address {
25 |
26 | private String country;
27 | private String city;
28 | private String streetName;
29 | private String streetNo;
30 |
31 | public Address() {}
32 |
33 | public Address(String country, String city, String streetName, String streetNo) {
34 | this.country = country;
35 | this.city = city;
36 | this.streetName = streetName;
37 | this.streetNo = streetNo;
38 | }
39 |
40 | public String getCountry() {
41 | return country;
42 | }
43 |
44 | public String getCity() {
45 | return city;
46 | }
47 |
48 | public String getStreetName() {
49 | return streetName;
50 | }
51 |
52 | public String getStreetNo() {
53 | return streetNo;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/AnnotatedAuditableUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 |
20 | /**
21 | * @author Oliver Gierke
22 | * @since 1.6
23 | */
24 | @Entity
25 | public class AnnotatedAuditableUser extends AbstractAnnotatedAuditable {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/AuditableRole.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 |
20 | import org.springframework.data.jpa.domain.AbstractAuditable;
21 |
22 | /**
23 | * Sample auditable role entity.
24 | *
25 | * @author Oliver Gierke
26 | */
27 | @Entity
28 | public class AuditableRole extends AbstractAuditable {
29 |
30 | private static final long serialVersionUID = 5997359055260303863L;
31 |
32 | private String name;
33 |
34 | public void setName(String name) {
35 |
36 | this.name = name;
37 | }
38 |
39 | public String getName() {
40 |
41 | return name;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Category.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.jpa.domain.sample;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.FetchType;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.Id;
7 | import javax.persistence.ManyToOne;
8 |
9 | @Entity
10 | public class Category {
11 |
12 | @Id @GeneratedValue private Long id;
13 |
14 | @ManyToOne(fetch = FetchType.LAZY)//
15 | private Product product;
16 |
17 | public Category(Product product) {
18 | this.product = product;
19 | }
20 |
21 | protected Category() {}
22 |
23 | public Long getId() {
24 | return id;
25 | }
26 |
27 | public Product getProduct() {
28 | return product;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Child.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import java.util.HashSet;
19 | import java.util.Set;
20 |
21 | import javax.persistence.Entity;
22 | import javax.persistence.GeneratedValue;
23 | import javax.persistence.Id;
24 | import javax.persistence.ManyToMany;
25 |
26 | @Entity
27 | public class Child {
28 |
29 | @Id
30 | @GeneratedValue
31 | Long id;
32 |
33 | @ManyToMany(mappedBy = "children")
34 | Set parents = new HashSet();
35 |
36 | /**
37 | * @param parent
38 | */
39 | public Child add(Parent parent) {
40 |
41 | this.parents.add(parent);
42 |
43 | if (!parent.children.contains(this)) {
44 | parent.add(this);
45 | }
46 |
47 | return this;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/ConcreteType1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 |
20 | /**
21 | * @author Thomas Darimont
22 | */
23 | @Entity
24 | public class ConcreteType1 extends AbstractMappedType {
25 |
26 | public ConcreteType1() {}
27 |
28 | public ConcreteType1(String attribute1) {
29 | super(attribute1);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/ConcreteType2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 |
20 | /**
21 | * @author Thomas Darimont
22 | */
23 | @Entity
24 | public class ConcreteType2 extends AbstractMappedType {
25 |
26 | public ConcreteType2() {}
27 |
28 | public ConcreteType2(String attribute1) {
29 | super(attribute1);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/CustomAbstractPersistable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.Table;
20 |
21 | import org.springframework.data.jpa.domain.AbstractPersistable;
22 |
23 | /**
24 | * @author Thomas Darimont
25 | */
26 | @Entity
27 | @Table(name = "customAbstractPersistable")
28 | public class CustomAbstractPersistable extends AbstractPersistable {
29 |
30 | private static final long serialVersionUID = 1L;
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Customer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.Id;
20 |
21 | /**
22 | * @author Oliver Gierke
23 | */
24 | @Entity
25 | public class Customer {
26 |
27 | @Id Long id;
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/EntityWithAssignedId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import java.util.UUID;
19 |
20 | import javax.persistence.Entity;
21 | import javax.persistence.Id;
22 | import javax.persistence.PostLoad;
23 | import javax.persistence.PrePersist;
24 | import javax.persistence.Transient;
25 |
26 | import org.springframework.data.domain.Persistable;
27 |
28 | /**
29 | * @author Oliver Drotbohm
30 | */
31 | @Entity
32 | public class EntityWithAssignedId implements Persistable {
33 |
34 | private @Id UUID id = UUID.randomUUID();
35 |
36 | private @Transient boolean isNew = true;
37 |
38 | /*
39 | * (non-Javadoc)
40 | * @see org.springframework.data.domain.Persistable#getId()
41 | */
42 | @Override
43 | public UUID getId() {
44 | return id;
45 | }
46 |
47 | /*
48 | * (non-Javadoc)
49 | * @see org.springframework.data.domain.Persistable#isNew()
50 | */
51 | @Override
52 | public boolean isNew() {
53 | return isNew;
54 | }
55 |
56 | @PrePersist
57 | @PostLoad
58 | public void markNotNew() {
59 | this.isNew = false;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/IdClassExampleEmployee.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.CascadeType;
19 | import javax.persistence.Entity;
20 | import javax.persistence.Id;
21 | import javax.persistence.IdClass;
22 | import javax.persistence.ManyToOne;
23 |
24 | /**
25 | * @author Thomas Darimont
26 | * @author Mark Paluch
27 | */
28 | @IdClass(IdClassExampleEmployeePK.class)
29 | @Entity
30 | public class IdClassExampleEmployee {
31 |
32 | @Id private long empId;
33 | @Id @ManyToOne(cascade = CascadeType.ALL) private IdClassExampleDepartment department;
34 |
35 | private String name;
36 |
37 | public long getEmpId() {
38 | return empId;
39 | }
40 |
41 | public void setEmpId(long empId) {
42 | this.empId = empId;
43 | }
44 |
45 | public IdClassExampleDepartment getDepartment() {
46 | return department;
47 | }
48 |
49 | public void setDepartment(IdClassExampleDepartment department) {
50 | this.department = department;
51 | }
52 |
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | public void setName(String name) {
58 | this.name = name;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Item.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Column;
19 | import javax.persistence.Entity;
20 | import javax.persistence.Id;
21 | import javax.persistence.IdClass;
22 | import javax.persistence.JoinColumn;
23 | import javax.persistence.Table;
24 |
25 | /**
26 | * @author Mark Paluch
27 | * @see Final JPA 2.1
28 | * Specification 2.4.1.3 Derived Identities Example 2
29 | */
30 | @Entity
31 | @Table
32 | @IdClass(ItemId.class)
33 | public class Item {
34 |
35 | @Id @Column(columnDefinition = "INT") private Integer id;
36 |
37 | @Id @JoinColumn(name = "manufacturer_id", columnDefinition = "INT") private Integer manufacturerId;
38 |
39 | public Item() {}
40 |
41 | public Item(Integer id, Integer manufacturerId) {
42 | this.id = id;
43 | this.manufacturerId = manufacturerId;
44 | }
45 |
46 | public Integer getId() {
47 | return id;
48 | }
49 |
50 | public Integer getManufacturerId() {
51 | return manufacturerId;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/ItemSite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.Id;
20 | import javax.persistence.IdClass;
21 | import javax.persistence.ManyToOne;
22 | import javax.persistence.Table;
23 |
24 | /**
25 | * @author Mark Paluch
26 | * @see Final JPA 2.1
27 | * Specification 2.4.1.3 Derived Identities Example 2
28 | */
29 | @Entity
30 | @Table
31 | @IdClass(ItemSiteId.class)
32 | public class ItemSite {
33 |
34 | @Id @ManyToOne private Item item;
35 | @Id @ManyToOne private Site site;
36 |
37 | public ItemSite() {}
38 |
39 | public ItemSite(Item item, Site site) {
40 | this.item = item;
41 | this.site = site;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/MailMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.CascadeType;
19 | import javax.persistence.Entity;
20 | import javax.persistence.GeneratedValue;
21 | import javax.persistence.Id;
22 | import javax.persistence.OneToOne;
23 |
24 | /**
25 | * @author Thomas Darimont
26 | */
27 | @Entity
28 | public class MailMessage {
29 |
30 | @Id @GeneratedValue private Long id;
31 |
32 | @OneToOne(cascade = CascadeType.ALL) private MailSender mailSender;
33 |
34 | private String content;
35 |
36 | public MailSender getMailSender() {
37 | return mailSender;
38 | }
39 |
40 | public void setMailSender(MailSender sender) {
41 | this.mailSender = sender;
42 | }
43 |
44 | public String getContent() {
45 | return content;
46 | }
47 |
48 | public void setContent(String content) {
49 | this.content = content;
50 | }
51 |
52 | public Long getId() {
53 | return id;
54 | }
55 |
56 | public void setId(Long id) {
57 | this.id = id;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Order.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.Id;
20 | import javax.persistence.ManyToOne;
21 | import javax.persistence.Table;
22 |
23 | /**
24 | * @author Oliver Gierke
25 | */
26 | @Entity
27 | @Table(name = "ORDERS")
28 | public class Order {
29 |
30 | @Id Long id;
31 | @ManyToOne(optional = false) Customer customer;
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/OrmXmlEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | /**
19 | * This entity serves as a test object for orm.xml configuration and MUST NOT be configured via annotations!
20 | *
21 | * @author Thomas Darimont
22 | */
23 | public class OrmXmlEntity {
24 |
25 | private Long id;
26 |
27 | private String property1;
28 |
29 | public Long getId() {
30 | return id;
31 | }
32 |
33 | public void setId(Long id) {
34 | this.id = id;
35 | }
36 |
37 | public String getProperty1() {
38 | return property1;
39 | }
40 |
41 | public void setProperty1(String property1) {
42 | this.property1 = property1;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Parent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import java.util.HashSet;
19 | import java.util.Set;
20 |
21 | import javax.persistence.CascadeType;
22 | import javax.persistence.Entity;
23 | import javax.persistence.GeneratedValue;
24 | import javax.persistence.Id;
25 | import javax.persistence.ManyToMany;
26 |
27 | @Entity
28 | public class Parent {
29 |
30 | @Id
31 | @GeneratedValue
32 | Long id;
33 |
34 | static final long serialVersionUID = -89717120680485957L;
35 |
36 | @ManyToMany(cascade = CascadeType.ALL)
37 | Set children = new HashSet();
38 |
39 | public Parent add(Child child) {
40 |
41 | this.children.add(child);
42 |
43 | if (!child.parents.contains(this)) {
44 | child.add(this);
45 | }
46 |
47 | return this;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/PrimitiveVersionProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.GeneratedValue;
20 | import javax.persistence.Id;
21 | import javax.persistence.Version;
22 |
23 | /**
24 | * @author Oliver Gierke
25 | * @author Christoph Strobl
26 | */
27 | @Entity
28 | public class PrimitiveVersionProperty {
29 |
30 | public @Id @GeneratedValue Long id;
31 | public @Version long version;
32 |
33 | public String someValue;
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Product.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.jpa.domain.sample;
2 |
3 | import javax.persistence.Entity;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.Id;
6 |
7 | @Entity
8 | public class Product {
9 |
10 | @Id @GeneratedValue private Long id;
11 |
12 | public Long getId() {
13 | return id;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/SampleEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.EmbeddedId;
19 | import javax.persistence.Entity;
20 |
21 | /**
22 | * @author Oliver Gierke
23 | */
24 | @Entity
25 | public class SampleEntity {
26 |
27 | @EmbeddedId
28 | private SampleEntityPK id;
29 |
30 | protected SampleEntity() {
31 |
32 | }
33 |
34 | public SampleEntity(String first, String second) {
35 |
36 | this.id = new SampleEntityPK(first, second);
37 | }
38 |
39 | @Override
40 | public boolean equals(Object obj) {
41 |
42 | if (obj == this) {
43 | return true;
44 | }
45 |
46 | if (!getClass().equals(obj.getClass())) {
47 | return false;
48 | }
49 |
50 | SampleEntity that = (SampleEntity) obj;
51 |
52 | return this.id.equals(that.id);
53 | }
54 |
55 | @Override
56 | public int hashCode() {
57 |
58 | return id.hashCode();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/SampleWithIdClass.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.jpa.domain.sample;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.persistence.Access;
6 | import javax.persistence.AccessType;
7 | import javax.persistence.Entity;
8 | import javax.persistence.Id;
9 | import javax.persistence.IdClass;
10 |
11 | @Entity
12 | @IdClass(SampleWithIdClass.SampleWithIdClassPK.class)
13 | @Access(AccessType.FIELD)
14 | public class SampleWithIdClass {
15 |
16 | @Id Long first;
17 | @Id Long second;
18 |
19 | @SuppressWarnings("serial")
20 | static class SampleWithIdClassPK implements Serializable {
21 |
22 | Long first;
23 | Long second;
24 |
25 | /*
26 | * (non-Javadoc)
27 | * @see java.lang.Object#equals(java.lang.Object)
28 | */
29 | @Override
30 | public boolean equals(Object obj) {
31 |
32 | if (obj == this) {
33 | return true;
34 | }
35 |
36 | if (!(obj instanceof SampleWithIdClassPK)) {
37 | return false;
38 | }
39 |
40 | SampleWithIdClassPK that = (SampleWithIdClassPK) obj;
41 |
42 | return this.first.equals(that.first) && this.second.equals(that.second);
43 | }
44 |
45 | /*
46 | * (non-Javadoc)
47 | * @see java.lang.Object#hashCode()
48 | */
49 | @Override
50 | public int hashCode() {
51 | return first.hashCode() + second.hashCode();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/SampleWithIdClassIncludingEntity.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.jpa.domain.sample;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | import javax.persistence.Entity;
8 | import javax.persistence.Id;
9 | import javax.persistence.IdClass;
10 | import javax.persistence.ManyToOne;
11 |
12 | /**
13 | * Sample class for integration testing
14 | * {@link org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation}.
15 | *
16 | * @author Jens Schauder
17 | */
18 | @Entity
19 | @IdClass(SampleWithIdClassIncludingEntity.SampleWithIdClassPK.class)
20 | @Data
21 | public class SampleWithIdClassIncludingEntity {
22 |
23 | @Id Long first;
24 | @ManyToOne @Id OtherEntity second;
25 |
26 | @Data
27 | @SuppressWarnings("serial")
28 | public static class SampleWithIdClassPK implements Serializable {
29 |
30 | Long first;
31 | Long second;
32 | }
33 |
34 | @Entity
35 | @Data
36 | public static class OtherEntity {
37 | @Id Long otherId;
38 | }
39 |
40 | /**
41 | * This class emulates a proxy at is returned from Hibernate.
42 | */
43 | public static class OtherEntity$$PsudoProxy extends OtherEntity {}
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/SampleWithPrimitiveId.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.Id;
20 |
21 | /**
22 | * @author Oliver Gierke
23 | */
24 | @Entity
25 | public class SampleWithPrimitiveId {
26 |
27 | @Id private long id;
28 |
29 | /**
30 | * @param id the id to set
31 | */
32 | public void setId(long id) {
33 | this.id = id;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/SampleWithTimestampVersion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import java.sql.Timestamp;
19 |
20 | import javax.persistence.Entity;
21 | import javax.persistence.Id;
22 | import javax.persistence.Version;
23 |
24 | @Entity
25 | public class SampleWithTimestampVersion {
26 |
27 | public @Id Long id;
28 | public @Version Timestamp version;
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/Site.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.GeneratedValue;
20 | import javax.persistence.Id;
21 | import javax.persistence.Table;
22 |
23 | /**
24 | * @author Mark Paluch
25 | * @author Oliver Gierke
26 | * @see Final JPA 2.1
27 | * Specification 2.4.1.3 Derived Identities Example 2
28 | */
29 | @Entity
30 | @Table
31 | public class Site implements java.io.Serializable {
32 |
33 | private static final long serialVersionUID = 1L;
34 |
35 | @Id @GeneratedValue Integer id;
36 |
37 | public Site() {}
38 |
39 | public Site(Integer id) {
40 | this.id = id;
41 | }
42 |
43 | public Integer getId() {
44 | return id;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/SpecialUser.java:
--------------------------------------------------------------------------------
1 | package org.springframework.data.jpa.domain.sample;
2 |
3 | import javax.persistence.Entity;
4 |
5 | /**
6 | * @author Oliver Gierke
7 | */
8 | @Entity
9 | public class SpecialUser extends User {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/domain/sample/VersionedUser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.domain.sample;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.GeneratedValue;
20 | import javax.persistence.Id;
21 | import javax.persistence.Version;
22 |
23 | /**
24 | * @author Oliver Gierke
25 | */
26 | @Entity
27 | public class VersionedUser {
28 |
29 | @Id
30 | @GeneratedValue
31 | private Long id;
32 |
33 | @Version
34 | private Long version;
35 |
36 | /**
37 | * @return the id
38 | */
39 | public Long getId() {
40 | return id;
41 | }
42 |
43 | /**
44 | * @param id the id to set
45 | */
46 | public void setId(Long id) {
47 | this.id = id;
48 | }
49 |
50 | /**
51 | * @return the version
52 | */
53 | public Long getVersion() {
54 | return version;
55 | }
56 |
57 | /**
58 | * @param version the version to set
59 | */
60 | public void setVersion(Long version) {
61 | this.version = version;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/infrastructure/HibernateMetamodelIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.infrastructure;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 |
21 | /**
22 | * Hibernate-specific integration test using the JPA metamodel.
23 | *
24 | * @author Oliver Gierke
25 | * @soundtrack Umphrey's McGee - Intentions Clear (Safety In Numbers)
26 | */
27 | class HibernateMetamodelIntegrationTests extends MetamodelIntegrationTests {
28 |
29 | @Test
30 | @Disabled
31 | @Override
32 | void pathToEntityIsOfBindableTypeEntityType() {}
33 |
34 | @Test
35 | @Disabled
36 | @Override
37 | void considersOneToOneAttributeAnAssociation() {}
38 |
39 | /**
40 | * @see HHH-10341
41 | */
42 | @Test
43 | @Disabled
44 | @Override
45 | void doesNotExposeAliasForTupleIfNoneDefined() {}
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/infrastructure/OpenJpaMetamodelIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.infrastructure;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.junit.jupiter.api.Test;
20 | import org.springframework.test.context.ContextConfiguration;
21 |
22 | /**
23 | * Metamodel tests using OpenJPA.
24 | *
25 | * @author Oliver Gierke
26 | */
27 | @ContextConfiguration("classpath:openjpa.xml")
28 | class OpenJpaMetamodelIntegrationTests extends MetamodelIntegrationTests {
29 |
30 | @Test
31 | @Disabled
32 | @Override
33 | void canAccessParametersByIndexForNativeQueries() {}
34 |
35 | /**
36 | * TODO: Remove once https://issues.apache.org/jira/browse/OPENJPA-2618 is fixed.
37 | */
38 | @Test
39 | @Disabled
40 | @Override
41 | void doesNotExposeAliasForTupleIfNoneDefined() {}
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/mapping/JpaMetamodelMappingContextUnitTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.mapping;
17 |
18 | import static org.mockito.Mockito.*;
19 |
20 | import java.util.Collections;
21 |
22 | import javax.persistence.metamodel.Metamodel;
23 |
24 | import org.junit.jupiter.api.Test;
25 | import org.springframework.data.annotation.Version;
26 |
27 | /**
28 | * Unit tests for {@link JpaMetamodelMappingContext}.
29 | *
30 | * @author Oliver Gierke
31 | */
32 | class JpaMetamodelMappingContextUnitTests {
33 |
34 | @Test // DATAJPA-775
35 | void jpaPersistentEntityRejectsSprignDataAtVersionAnnotation() {
36 |
37 | Metamodel metamodel = mock(Metamodel.class);
38 |
39 | JpaMetamodelMappingContext context = new JpaMetamodelMappingContext(Collections.singleton(metamodel));
40 | context.getPersistentEntity(Sample.class);
41 | }
42 |
43 | private static class Sample {
44 | @Version Long version;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/EclipseLinkParentRepositoryIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | @ContextConfiguration("classpath:eclipselink.xml")
21 | class EclipseLinkParentRepositoryIntegrationTests extends ParentRepositoryIntegrationTests {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/EclipseLinkRepositoryWithCompositeKeyIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.springframework.context.annotation.ImportResource;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Testcase to run {@link RepositoryWithIdClassKeyTests} integration tests on top of EclipseLink.
23 | *
24 | * @author Mark Paluch
25 | */
26 | @ContextConfiguration
27 | class EclipseLinkRepositoryWithCompositeKeyIntegrationTests extends RepositoryWithIdClassKeyTests {
28 |
29 | @ImportResource({ "classpath:infrastructure.xml", "classpath:eclipselink.xml" })
30 | static class TestConfig extends Config {}
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/EclipseLinkStoredProcedureIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.springframework.context.annotation.ImportResource;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Testcase to run {@link StoredProcedureIntegrationTests} integration tests on top of EclipseLink.
23 | *
24 | * @author Thomas Darimont
25 | * @author Oliver Gierke
26 | */
27 | @ContextConfiguration
28 | class EclipseLinkStoredProcedureIntegrationTests extends StoredProcedureIntegrationTests {
29 |
30 | @ImportResource({ "classpath:infrastructure.xml", "classpath:eclipselink.xml" })
31 | static class TestConfig extends Config {}
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Ignores some test cases using IN queries as long as we wait for fix for
23 | * https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477.
24 | *
25 | * @author Oliver Gierke
26 | */
27 | @ContextConfiguration("classpath:eclipselink.xml")
28 | class EclipseLinkUserRepositoryFinderTests extends UserRepositoryFinderTests {
29 |
30 | @Disabled
31 | @Override
32 | void executesNotInQueryCorrectly() throws Exception {}
33 |
34 | @Disabled
35 | @Override
36 | void executesInKeywordForPageCorrectly() {}
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/OpenJpaEntityGraphRepositoryMethodsIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * @author Oliver Gierke
22 | */
23 | @ContextConfiguration("classpath:openjpa.xml")
24 | class OpenJpaEntityGraphRepositoryMethodsIntegrationTests extends EntityGraphRepositoryMethodsIntegrationTests {}
25 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/OpenJpaParentRepositoryIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | @ContextConfiguration("classpath:openjpa.xml")
22 | class OpenJpaParentRepositoryIntegrationTests extends ParentRepositoryIntegrationTests {
23 |
24 | @Override
25 | @Disabled
26 | void testWithJoin() throws Exception {}
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/OpenJpaRepositoryWithCompositeKeyIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.springframework.context.annotation.ImportResource;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Testcase to run {@link RepositoryWithIdClassKeyTests} integration tests on top of OpenJPA.
23 | *
24 | * @author Mark Paluch
25 | */
26 | @ContextConfiguration
27 | class OpenJpaRepositoryWithCompositeKeyIntegrationTests extends RepositoryWithIdClassKeyTests {
28 |
29 | @ImportResource({ "classpath:infrastructure.xml", "classpath:openjpa.xml" })
30 | static class TestConfig extends Config {
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/OpenJpaStoredProcedureIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.context.annotation.ImportResource;
20 | import org.springframework.test.context.ContextConfiguration;
21 |
22 | /**
23 | * Test case to run {@link StoredProcedureIntegrationTests} integration tests on top of OpenJpa. This is currently not
24 | * supported since, the OpenJPA tests need to be executed with hsqldb1 which doesn't supported stored procedures.
25 | *
26 | * @author Thomas Darimont
27 | * @author Oliver Gierke
28 | */
29 | @Disabled
30 | @ContextConfiguration(classes = { StoredProcedureIntegrationTests.Config.class })
31 | class OpenJpaStoredProcedureIntegrationTests extends StoredProcedureIntegrationTests {
32 |
33 | @ImportResource({ "classpath:infrastructure.xml", "classpath:openjpa.xml" })
34 | static class TestConfig extends Config {}
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/OpenJpaUserRepositoryFinderTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Ignores some test cases using IN queries as long as we wait for fix for
23 | * https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477.
24 | *
25 | * @author Oliver Gierke
26 | */
27 | @ContextConfiguration("classpath:openjpa.xml")
28 | class OpenJpaUserRepositoryFinderTests extends UserRepositoryFinderTests {
29 |
30 | @Disabled
31 | @Override
32 | void findsByLastnameIgnoringCaseLike() throws Exception {}
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/EntityManagerFactoryProducer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import javax.enterprise.context.ApplicationScoped;
19 | import javax.enterprise.inject.Disposes;
20 | import javax.enterprise.inject.Produces;
21 | import javax.persistence.EntityManagerFactory;
22 | import javax.persistence.Persistence;
23 |
24 | /**
25 | * Produces and {@link EntityManagerFactory}.
26 | *
27 | * @author Dirk Mahler
28 | * @author Jens Schauder
29 | */
30 | class EntityManagerFactoryProducer {
31 |
32 | @Produces
33 | @ApplicationScoped
34 | public EntityManagerFactory createEntityManagerFactory() {
35 | return Persistence.createEntityManagerFactory("cdi");
36 | }
37 |
38 | public void close(@Disposes EntityManagerFactory entityManagerFactory) {
39 | entityManagerFactory.close();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/Person.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import javax.persistence.Entity;
19 | import javax.persistence.GeneratedValue;
20 | import javax.persistence.GenerationType;
21 | import javax.persistence.Id;
22 |
23 | @Entity
24 | class Person {
25 |
26 | @Id
27 | @GeneratedValue(strategy = GenerationType.AUTO)
28 | private long id;
29 |
30 | private String name;
31 |
32 | public long getId() {
33 | return id;
34 | }
35 |
36 | public void setId(long id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/PersonDB.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import javax.inject.Qualifier;
24 |
25 | @Qualifier
26 | @Retention(RetentionPolicy.RUNTIME)
27 | @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
28 | @interface PersonDB {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/PersonRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import java.util.List;
19 |
20 | import org.springframework.data.repository.cdi.Eager;
21 |
22 | @Eager
23 | public interface PersonRepository {
24 |
25 | List findAll();
26 |
27 | void save(Person person);
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedCustomizedCdiConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.data.jpa.repository.cdi;
18 |
19 | import org.springframework.data.repository.cdi.CdiRepositoryConfiguration;
20 |
21 | /**
22 | * @author Mark Paluch
23 | */
24 | @UserDB
25 | class QualifiedCustomizedCdiConfiguration implements CdiRepositoryConfiguration {
26 |
27 | @Override
28 | public String getRepositoryImplementationPostfix() {
29 | return "Bean";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedCustomizedUserRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import org.springframework.data.jpa.domain.sample.User;
19 | import org.springframework.data.repository.Repository;
20 |
21 | /**
22 | * @author Mark Paluch
23 | */
24 | @UserDB
25 | public interface QualifiedCustomizedUserRepository extends Repository,
26 | QualifiedCustomizedUserRepositoryCustom, QualifiedFragment {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedCustomizedUserRepositoryBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.data.jpa.repository.cdi;
18 |
19 | /**
20 | * @author Mark Paluch
21 | */
22 | @UserDB
23 | public class QualifiedCustomizedUserRepositoryBean implements QualifiedCustomizedUserRepositoryCustom {
24 |
25 | @Override
26 | public void doSomething() {}
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedCustomizedUserRepositoryCustom.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.data.jpa.repository.cdi;
18 |
19 | /**
20 | * @author Mark Paluch
21 | */
22 | interface QualifiedCustomizedUserRepositoryCustom {
23 |
24 | void doSomething();
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedEntityManagerProducer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import javax.enterprise.inject.Disposes;
19 | import javax.enterprise.inject.Produces;
20 | import javax.persistence.EntityManager;
21 | import javax.persistence.EntityManagerFactory;
22 |
23 | /**
24 | * @author Oliver Gierke
25 | * @author Mark Paluch
26 | */
27 | class QualifiedEntityManagerProducer {
28 |
29 | @Produces
30 | @PersonDB
31 | public EntityManager createPersonDBEntityManager(EntityManagerFactory entityManagerFactory) {
32 | return entityManagerFactory.createEntityManager();
33 | }
34 |
35 | public void closePersonDB(@Disposes @PersonDB EntityManager entityManager) {
36 | entityManager.close();
37 | }
38 |
39 | @Produces
40 | @UserDB
41 | public EntityManager createUserDBEntityManager(EntityManagerFactory entityManagerFactory) {
42 | return entityManagerFactory.createEntityManager();
43 | }
44 |
45 | public void closeUserDB(@Disposes @UserDB EntityManager entityManager) {
46 | entityManager.close();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | /**
19 | * @author Mark Paluch
20 | */
21 | interface QualifiedFragment {
22 | int returnOne();
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedFragmentBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | /**
19 | * @author Mark Paluch
20 | */
21 | @UserDB
22 | public class QualifiedFragmentBean implements QualifiedFragment {
23 |
24 | @Override
25 | public int returnOne() {
26 | return 1;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/QualifiedPersonRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import org.springframework.data.repository.Repository;
19 |
20 | @PersonDB
21 | public interface QualifiedPersonRepository extends PersonRepository, Repository {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/RepositoryConsumer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import javax.inject.Inject;
19 |
20 | /**
21 | * @author Oliver Gierke
22 | * @author Mark Paluch
23 | */
24 | @Transactional
25 | class RepositoryConsumer {
26 |
27 | @Inject PersonRepository unqualifiedRepo;
28 | @Inject @PersonDB PersonRepository qualifiedRepo;
29 | @Inject SamplePersonRepository samplePersonRepository;
30 | @Inject @UserDB QualifiedCustomizedUserRepository qualifiedCustomizedUserRepository;
31 |
32 | public void findAll() {
33 | unqualifiedRepo.findAll();
34 | qualifiedRepo.findAll();
35 | }
36 |
37 | public void save(Person person) {
38 | unqualifiedRepo.save(person);
39 | qualifiedRepo.save(person);
40 | }
41 |
42 | public int returnOne() {
43 | return samplePersonRepository.returnOne();
44 | }
45 |
46 | public void doSomethingOnUserDB() {
47 | qualifiedCustomizedUserRepository.doSomething();
48 | }
49 |
50 | public int returnOneUserDB() {
51 | return qualifiedCustomizedUserRepository.returnOne();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/SamplePersonRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.data.jpa.repository.cdi;
18 |
19 | import org.springframework.data.repository.Repository;
20 |
21 | /**
22 | * @author Mark Paluch
23 | */
24 | public interface SamplePersonRepository extends Repository, SamplePersonRepositoryCustom {}
25 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/SamplePersonRepositoryCustom.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.data.jpa.repository.cdi;
18 |
19 | /**
20 | * @author Mark Paluch
21 | */
22 | interface SamplePersonRepositoryCustom {
23 |
24 | int returnOne();
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/SamplePersonRepositoryImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.springframework.data.jpa.repository.cdi;
18 |
19 | /**
20 | * @author Mark Paluch
21 | */
22 | class SamplePersonRepositoryImpl implements SamplePersonRepositoryCustom {
23 |
24 | @Override
25 | public int returnOne() {
26 | return 1;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/Transactional.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import javax.interceptor.InterceptorBinding;
24 |
25 | @InterceptorBinding
26 | @Target({ ElementType.METHOD, ElementType.TYPE })
27 | @Retention(RetentionPolicy.RUNTIME)
28 | @interface Transactional {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/TransactionalInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import javax.enterprise.inject.Any;
19 | import javax.inject.Inject;
20 | import javax.interceptor.AroundInvoke;
21 | import javax.interceptor.Interceptor;
22 | import javax.interceptor.InvocationContext;
23 | import javax.persistence.EntityManager;
24 | import javax.persistence.EntityTransaction;
25 |
26 | @Transactional
27 | @Interceptor
28 | class TransactionalInterceptor {
29 |
30 | @Inject
31 | @Any
32 | private EntityManager entityManager;
33 |
34 | @AroundInvoke
35 | public Object runInTransaction(InvocationContext ctx) throws Exception {
36 | EntityTransaction entityTransaction = this.entityManager.getTransaction();
37 | boolean isNew = !entityTransaction.isActive();
38 | try {
39 | if (isNew) {
40 | entityTransaction.begin();
41 | }
42 | Object result = ctx.proceed();
43 | if (isNew) {
44 | entityTransaction.commit();
45 | }
46 | return result;
47 | } catch (RuntimeException r) {
48 | if (isNew) {
49 | entityTransaction.rollback();
50 | }
51 | throw r;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedEntityManagerProducer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import javax.enterprise.inject.Disposes;
19 | import javax.enterprise.inject.Produces;
20 | import javax.persistence.EntityManager;
21 | import javax.persistence.EntityManagerFactory;
22 |
23 | class UnqualifiedEntityManagerProducer {
24 |
25 | @Produces
26 | public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory) {
27 | return entityManagerFactory.createEntityManager();
28 | }
29 |
30 | public void close(@Disposes EntityManager entityManager) {
31 | entityManager.close();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/UnqualifiedPersonRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import org.springframework.data.repository.Repository;
19 |
20 | public interface UnqualifiedPersonRepository extends PersonRepository, Repository {
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/cdi/UserDB.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.cdi;
17 |
18 | import java.lang.annotation.ElementType;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 | import java.lang.annotation.Target;
22 |
23 | import javax.inject.Qualifier;
24 |
25 | /**
26 | * @author Mark Paluch
27 | */
28 | @Qualifier
29 | @Retention(RetentionPolicy.RUNTIME)
30 | @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
31 | @interface UserDB {
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/AllowNestedRepositoriesRepositoryConfigTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import static org.assertj.core.api.Assertions.*;
19 |
20 | import org.junit.jupiter.api.Test;
21 | import org.springframework.beans.factory.annotation.Autowired;
22 | import org.springframework.data.jpa.repository.sample.ClassWithNestedRepository.NestedUserRepository;
23 | import org.springframework.test.context.ContextConfiguration;
24 |
25 | /**
26 | * Integration test for repository name-space configuration with nested repositories.
27 | *
28 | * @author Thomas Darimont
29 | * @author Oliver Gierke
30 | * @author Jens Schauder
31 | */
32 | @ContextConfiguration(locations = "classpath:config/namespace-nested-repositories-application-context.xml")
33 | public class AllowNestedRepositoriesRepositoryConfigTests extends AbstractRepositoryConfigTests {
34 |
35 | @Autowired NestedUserRepository fooRepository;
36 |
37 | @Test // DATAJPA-416
38 | void shouldFindNestedRepository() {
39 | assertThat(fooRepository).isNotNull();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/DefaultAuditingViaJavaConfigRepositoriesTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import static org.mockito.Mockito.*;
19 |
20 | import org.springframework.context.annotation.Bean;
21 | import org.springframework.context.annotation.Configuration;
22 | import org.springframework.context.annotation.Import;
23 | import org.springframework.data.domain.AuditorAware;
24 | import org.springframework.data.jpa.domain.sample.AuditableUser;
25 | import org.springframework.test.context.ContextConfiguration;
26 |
27 | /**
28 | * Integration tests for auditing via Java config with default configuration.
29 | *
30 | * @author Thomas Darimont
31 | * @author Oliver Gierke
32 | */
33 | @ContextConfiguration
34 | class DefaultAuditingViaJavaConfigRepositoriesTests extends AbstractAuditingViaJavaConfigRepositoriesTests {
35 |
36 | @Configuration
37 | @EnableJpaAuditing
38 | @Import(TestConfig.class)
39 | static class Config {
40 |
41 | @Bean
42 | @SuppressWarnings("unchecked")
43 | public AuditorAware auditorProvider() {
44 | return mock(AuditorAware.class);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/InspectionClassLoaderUnitTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import static org.assertj.core.api.Assertions.*;
19 |
20 | import org.junit.jupiter.api.Test;
21 |
22 | /**
23 | * Unit tests for {@link InspectionClassLoader}.
24 | *
25 | * @author Mark Paluch
26 | */
27 | class InspectionClassLoaderUnitTests {
28 |
29 | @Test // DATAJPA-1250
30 | void shouldLoadExternalClass() throws ClassNotFoundException {
31 |
32 | InspectionClassLoader classLoader = new InspectionClassLoader(getClass().getClassLoader());
33 |
34 | Class> isolated = classLoader.loadClass("org.hsqldb.Database");
35 | Class> included = getClass().getClassLoader().loadClass("org.hsqldb.Database");
36 |
37 | assertThat(isolated.getClassLoader()) //
38 | .isSameAs(classLoader) //
39 | .isNotSameAs(getClass().getClassLoader());
40 |
41 | assertThat(isolated).isNotEqualTo(included);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/RepositoryAutoConfigTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * Integration test to test repository auto configuration.
22 | *
23 | * @author Oliver Gierke
24 | */
25 | @ContextConfiguration(locations = "classpath:config/namespace-autoconfig-context.xml")
26 | class RepositoryAutoConfigTests extends AbstractRepositoryConfigTests {
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/RepositoryConfigTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * Integration test for repository namespace configuration.
22 | *
23 | * @author Oliver Gierke
24 | */
25 | @ContextConfiguration(locations = "classpath:config/namespace-application-context.xml")
26 | class RepositoryConfigTests extends AbstractRepositoryConfigTests {
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/TypeFilterConfigTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.config;
17 |
18 | import static org.assertj.core.api.Assertions.*;
19 |
20 | import org.springframework.test.context.ContextConfiguration;
21 |
22 | /**
23 | * Integration test to test {@link org.springframework.core.type.filter.TypeFilter} integration into namespace.
24 | *
25 | * @author Oliver Gierke
26 | * @author Jens Schauder
27 | */
28 | @ContextConfiguration(locations = "classpath:config/namespace-autoconfig-typefilter-context.xml")
29 | class TypeFilterConfigTests extends AbstractRepositoryConfigTests {
30 |
31 | /*
32 | * (non-Javadoc)
33 | *
34 | * @see
35 | * org.springframework.data.jpa.repository.config.AbstractRepositoryConfigTests
36 | * #testContextCreation()
37 | */
38 | @Override
39 | void testContextCreation() {
40 |
41 | assertThat(userRepository).isNotNull();
42 | assertThat(roleRepository).isNotNull();
43 | assertThat(auditableUserRepository).isNull();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/config/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Test cases for configuration support classes.
4 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/custom/CustomGenericRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.custom;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.springframework.data.jpa.repository.JpaRepository;
21 | import org.springframework.data.repository.NoRepositoryBean;
22 | import org.springframework.data.repository.CrudRepository;
23 |
24 | /**
25 | * Extension of {@link CrudRepository} to be added on a custom repository base class. This tests the facility to
26 | * implement custom base class functionality for all repository instances derived from this interface and implementation
27 | * base class.
28 | *
29 | * @author Oliver Gierke
30 | */
31 | @NoRepositoryBean
32 | public interface CustomGenericRepository extends JpaRepository {
33 |
34 | /**
35 | * Custom sample method.
36 | *
37 | * @param id
38 | * @return
39 | */
40 | T customMethod(ID id);
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/custom/UserCustomExtendedRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.custom;
17 |
18 | import java.util.List;
19 | import java.util.Optional;
20 |
21 | import org.springframework.data.jpa.domain.sample.User;
22 | import org.springframework.transaction.annotation.Transactional;
23 |
24 | /**
25 | * Custom Extended repository interface for a {@code User}. This relies on the custom intermediate repository interface
26 | * {@link CustomGenericRepository}.
27 | *
28 | * @author Oliver Gierke
29 | */
30 | public interface UserCustomExtendedRepository extends CustomGenericRepository {
31 |
32 | /**
33 | * Sample method to test reconfiguring transactions on CRUD methods in combination with custom factory.
34 | */
35 | @Override
36 | @Transactional(readOnly = false, timeout = 10)
37 | List findAll();
38 |
39 | @Override
40 | @Transactional(readOnly = false, timeout = 10)
41 | Optional findById(Integer id);
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/custom/package-info.java:
--------------------------------------------------------------------------------
1 | @NonNullApi
2 | package org.springframework.data.jpa.repository.custom;
3 |
4 | import org.springframework.lang.NonNullApi;
5 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkJpa21UtilsTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * @author Christoph Strobl
22 | */
23 | @ContextConfiguration("classpath:eclipselink.xml")
24 | class EclipseLinkJpa21UtilsTests extends Jpa21UtilsTests {}
25 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkParameterMetadataProviderIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * EclipseLink-specific tests for {@link ParameterMetadataProvider}.
22 | *
23 | * @author Oliver Gierke
24 | * @soundtrack Elephants Crossing - We are (Irrelephant)
25 | */
26 | @ContextConfiguration("classpath:eclipselink.xml")
27 | class EclipseLinkParameterMetadataProviderIntegrationTests extends ParameterMetadataProviderIntegrationTests {}
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/EclipseLinkQueryUtilsIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * @author Oliver Gierke
22 | */
23 | @ContextConfiguration("classpath:eclipselink.xml")
24 | class EclipseLinkQueryUtilsIntegrationTests extends QueryUtilsIntegrationTests {
25 |
26 | int getNumberOfJoinsAfterCreatingAPath() {
27 | return 1;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/EscapeCharacterUnitTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import static org.assertj.core.api.Assertions.*;
19 |
20 | import org.junit.jupiter.api.Test;
21 |
22 | /**
23 | * Unit tests for {@link EscapeCharacter}.
24 | *
25 | * @author Jens Schauder
26 | */
27 | class EscapeCharacterUnitTests {
28 |
29 | @Test // DATAJPA-1522
30 | void nothingToEscape() {
31 | assertThat(EscapeCharacter.of('x').escape("alpha")).isEqualTo("alpha");
32 | }
33 |
34 | @Test // DATAJPA-1522
35 | void wildcardGetsEscaped() {
36 | assertThat(EscapeCharacter.of('x').escape("alp_ha")).isEqualTo("alpx_ha");
37 | }
38 |
39 | @Test // DATAJPA-1522
40 | void escapeCharacterGetsEscaped() {
41 | assertThat(EscapeCharacter.of('x').escape("axlpx_ha")).isEqualTo("axxlpxxx_ha");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/OpenJpaJpa21UtilsTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * @author Christoph Strobl
22 | */
23 | @ContextConfiguration("classpath:openjpa.xml")
24 | class OpenJpaJpa21UtilsTests extends Jpa21UtilsTests {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/OpenJpaParameterMetadataProviderIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * OpenJpa-specific tests for {@link ParameterMetadataProvider}.
22 | *
23 | * @author Oliver Gierke
24 | * @soundtrack Elephants Crossing - We are (Irrelephant)
25 | */
26 | @ContextConfiguration("classpath:openjpa.xml")
27 | class OpenJpaParameterMetadataProviderIntegrationTests extends ParameterMetadataProviderIntegrationTests {}
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/OpenJpaQueryUtilsIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * @author Oliver Gierke
22 | */
23 | @ContextConfiguration("classpath:openjpa.xml")
24 | class OpenJpaQueryUtilsIntegrationTests extends QueryUtilsIntegrationTests {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/query/StoredProcedureAttributesUnitTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.query;
17 |
18 | import static org.assertj.core.api.Assertions.*;
19 | import static org.springframework.data.jpa.repository.query.StoredProcedureAttributes.*;
20 |
21 | import org.junit.jupiter.api.Test;
22 |
23 | /**
24 | * Unit tests for {@link StoredProcedureAttributes}.
25 | *
26 | * @author Oliver Gierke
27 | * @author Jens Schauder
28 | */
29 | class StoredProcedureAttributesUnitTests {
30 |
31 | @Test // DATAJPA-681
32 | void usesSyntheticOutputParameterNameForAdhocProcedureWithoutOutputName() {
33 |
34 | StoredProcedureAttributes attributes = new StoredProcedureAttributes("procedure", null, Long.class);
35 | assertThat(attributes.getOutputParameterNames().get(0)).isEqualTo(SYNTHETIC_OUTPUT_PARAMETER_NAME);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/AnnotatedAuditableUserRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.context.annotation.Lazy;
19 | import org.springframework.data.jpa.domain.sample.AnnotatedAuditableUser;
20 | import org.springframework.data.repository.CrudRepository;
21 |
22 | /**
23 | * Repository interface for {@code AuditableUser}.
24 | *
25 | * @author Oliver Gierke
26 | */
27 | @Lazy
28 | public interface AnnotatedAuditableUserRepository extends CrudRepository {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/AuditableUserRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import java.util.List;
19 |
20 | import org.springframework.data.jpa.domain.sample.AuditableUser;
21 | import org.springframework.data.jpa.repository.JpaRepository;
22 | import org.springframework.data.jpa.repository.Modifying;
23 | import org.springframework.data.jpa.repository.Query;
24 |
25 | /**
26 | * Repository interface for {@code AuditableUser}.
27 | *
28 | * @author Oliver Gierke
29 | * @author Thomas Darimont
30 | */
31 | public interface AuditableUserRepository extends JpaRepository {
32 |
33 | /**
34 | * Returns all users with the given firstname.
35 | *
36 | * @param firstname
37 | * @return all users with the given firstname.
38 | */
39 | List findByFirstname(final String firstname);
40 |
41 | @Modifying
42 | @Query("update AuditableUser a set a.firstname = upper(a.firstname), a.lastModifiedBy = :#{#security.principal}, a.lastModifiedDate = :#{T(org.springframework.data.jpa.util.FixedDate).INSTANCE.getDate()}")
43 | void updateAllNamesToUpperCase();
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/CategoryRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.Category;
19 | import org.springframework.data.repository.CrudRepository;
20 |
21 | /**
22 | * @author Oliver Gierke
23 | */
24 | public interface CategoryRepository extends CrudRepository {}
25 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ClassWithNestedRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.User;
19 | import org.springframework.data.repository.Repository;
20 |
21 | /**
22 | * @author Thomas Darimont
23 | * @author Oliver Gierke
24 | */
25 | public class ClassWithNestedRepository {
26 |
27 | public static interface NestedUserRepository extends Repository {}
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ConcreteRepository1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.context.annotation.Lazy;
19 | import org.springframework.data.jpa.domain.sample.ConcreteType1;
20 |
21 | /**
22 | * @author Thomas Darimont
23 | */
24 | @Lazy
25 | public interface ConcreteRepository1 extends MappedTypeRepository {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ConcreteRepository2.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.context.annotation.Lazy;
19 | import org.springframework.data.jpa.domain.sample.ConcreteType2;
20 |
21 | /**
22 | * @author Thomas Darimont
23 | */
24 | @Lazy
25 | public interface ConcreteRepository2 extends MappedTypeRepository {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/CustomAbstractPersistableRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.CustomAbstractPersistable;
19 | import org.springframework.data.jpa.repository.JpaRepository;
20 |
21 | /**
22 | * @author Thomas Darimont
23 | * @author Oliver Gierke
24 | */
25 | public interface CustomAbstractPersistableRepository extends JpaRepository {}
26 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/EntityWithAssignedIdRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import java.util.UUID;
19 |
20 | import org.springframework.data.jpa.domain.sample.EntityWithAssignedId;
21 | import org.springframework.data.repository.CrudRepository;
22 |
23 | /**
24 | * @author Oliver Drotbohm
25 | */
26 | public interface EntityWithAssignedIdRepository extends CrudRepository {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ItemRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.Item;
19 | import org.springframework.data.jpa.domain.sample.ItemId;
20 | import org.springframework.data.jpa.repository.JpaRepository;
21 |
22 | /**
23 | * @author Mark Paluch
24 | * @see Final JPA 2.1
25 | * Specification 2.4.1.3 Derived Identities Example 2
26 | */
27 | public interface ItemRepository extends JpaRepository- {}
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ItemSiteRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.ItemSite;
19 | import org.springframework.data.jpa.domain.sample.ItemSiteId;
20 | import org.springframework.data.jpa.repository.JpaRepository;
21 |
22 | /**
23 | * @author Mark Paluch
24 | * @see Final JPA 2.1
25 | * Specification 2.4.1.3 Derived Identities Example 2
26 | */
27 | public interface ItemSiteRepository extends JpaRepository {}
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/MailMessageRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import java.util.List;
19 |
20 | import org.springframework.data.jpa.domain.sample.MailMessage;
21 | import org.springframework.data.jpa.repository.JpaRepository;
22 | import org.springframework.data.querydsl.QuerydslPredicateExecutor;
23 |
24 | import com.querydsl.core.types.OrderSpecifier;
25 | import com.querydsl.core.types.Predicate;
26 |
27 | /**
28 | * @author Thomas Darimont
29 | */
30 | public interface MailMessageRepository
31 | extends JpaRepository, QuerydslPredicateExecutor {
32 |
33 | @Override
34 | List findAll(Predicate predicate, OrderSpecifier>... orders);
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/MappedTypeRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import java.util.List;
19 |
20 | import org.springframework.data.domain.Page;
21 | import org.springframework.data.domain.Pageable;
22 | import org.springframework.data.jpa.domain.sample.AbstractMappedType;
23 | import org.springframework.data.jpa.repository.JpaRepository;
24 | import org.springframework.data.jpa.repository.Query;
25 | import org.springframework.data.repository.NoRepositoryBean;
26 | import org.springframework.data.repository.query.Param;
27 |
28 | /**
29 | * @author Thomas Darimont
30 | */
31 | @NoRepositoryBean
32 | public interface MappedTypeRepository extends JpaRepository {
33 |
34 | @Query("from #{#entityName} t where t.attribute1=?1")
35 | List findAllByAttribute1(String attribute1);
36 |
37 | @Query("SELECT o FROM #{#entityName} o where o.attribute1=:attribute1")
38 | Page findByAttribute1Custom(@Param("attribute1") String attribute1, Pageable pageable);
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/NameOnlyDto.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | // DATAJPA-1334
19 | class NameOnlyDto {
20 |
21 | private String firstname;
22 | private String lastname;
23 |
24 | public NameOnlyDto(String firstname, String lastname) {
25 | this.firstname = firstname;
26 | this.lastname = lastname;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ParentRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.context.annotation.Lazy;
19 | import org.springframework.data.jpa.domain.sample.Parent;
20 | import org.springframework.data.jpa.repository.JpaRepository;
21 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
22 |
23 | @Lazy
24 | public interface ParentRepository extends JpaRepository, JpaSpecificationExecutor {}
25 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/ProductRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.Product;
19 | import org.springframework.data.jpa.repository.JpaRepository;
20 |
21 | /**
22 | * @author Oliver Gierke
23 | */
24 | public interface ProductRepository extends JpaRepository {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/RedeclaringRepositoryMethodsRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import java.util.List;
19 |
20 | import org.springframework.data.domain.Page;
21 | import org.springframework.data.domain.Pageable;
22 | import org.springframework.data.jpa.domain.sample.User;
23 | import org.springframework.data.jpa.repository.Query;
24 | import org.springframework.data.repository.CrudRepository;
25 |
26 | /**
27 | * Custom repository interface that adjusts the querys of well known repository interface methods via {@link Query}
28 | * annotation.
29 | *
30 | * @author Thomas Darimont
31 | */
32 | public interface RedeclaringRepositoryMethodsRepository extends CrudRepository {
33 |
34 | /**
35 | * Should not find any users at all.
36 | */
37 | @Override
38 | @Query("SELECT u FROM User u where u.id = -1")
39 | List findAll();
40 |
41 | /**
42 | * Should only find users with the firstname 'Oliver'.
43 | *
44 | * @param page
45 | * @return
46 | */
47 | @Query("SELECT u FROM User u where u.firstname = 'Oliver'")
48 | Page findAll(Pageable page);
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/SampleConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.context.annotation.Configuration;
19 | import org.springframework.context.annotation.ImportResource;
20 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
21 |
22 | /**
23 | * @author Oliver Gierke
24 | */
25 | @Configuration
26 | @ImportResource("classpath:infrastructure.xml")
27 | @EnableJpaRepositories
28 | public class SampleConfig {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/SiteRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.Site;
19 | import org.springframework.data.jpa.repository.JpaRepository;
20 |
21 | /**
22 | * @author Mark Paluch
23 | * @see Final JPA 2.1
24 | * Specification 2.4.1.3 Derived Identities Example 2
25 | */
26 | public interface SiteRepository extends JpaRepository {}
27 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/sample/UserRepositoryCustom.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.sample;
17 |
18 | import org.springframework.data.jpa.domain.sample.User;
19 |
20 | /**
21 | * Simple interface for custom methods on the repository for {@code User}s.
22 | *
23 | * @author Oliver Gierke
24 | */
25 | public interface UserRepositoryCustom {
26 |
27 | /**
28 | * Method actually triggering a finder but being overridden.
29 | */
30 | void findByOverrridingMethod();
31 |
32 | /**
33 | * Some custom method to implement.
34 | *
35 | * @param user
36 | */
37 | void someCustomMethod(User user);
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/DefaultJpaContextUnitTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | import static org.assertj.core.api.Assertions.*;
19 |
20 | import java.util.Collections;
21 |
22 | import javax.persistence.EntityManager;
23 |
24 | import org.junit.jupiter.api.Test;
25 |
26 | /**
27 | * Unit tests for {@link DefaultJpaContext}.
28 | *
29 | * @author Oliver Gierke
30 | * @soundtrack Marcus Miller - B's River (Afrodeezia)
31 | * @since 1.9
32 | */
33 | class DefaultJpaContextUnitTests {
34 |
35 | @Test // DATAJPA-669
36 | void rejectsNullEntityManagers() {
37 | assertThatIllegalArgumentException().isThrownBy(() -> new DefaultJpaContext(null));
38 | }
39 |
40 | @Test // DATAJPA-669
41 | void rejectsEmptyEntityManagers() {
42 | assertThatIllegalArgumentException()
43 | .isThrownBy(() -> new DefaultJpaContext(Collections. emptySet()));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/EclipseLinkJpaRepositoryTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Integration tests to execute {@link JpaRepositoryTests} against EclipseLink.
23 | *
24 | * @author Oliver Gierke
25 | */
26 | @ContextConfiguration("classpath:eclipselink.xml")
27 | class EclipseLinkJpaRepositoryTests extends JpaRepositoryTests {
28 |
29 | @Override
30 | /**
31 | * Ignored until https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477 is resolved.
32 | */
33 | void deleteAllByIdInBatch() {
34 | super.deleteAllByIdInBatch();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/EclipseLinkProxyIdAccessorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.context.annotation.Configuration;
20 | import org.springframework.context.annotation.ImportResource;
21 | import org.springframework.data.jpa.provider.PersistenceProviderIntegrationTests;
22 | import org.springframework.test.context.ContextConfiguration;
23 |
24 | /**
25 | * @author Oliver Gierke
26 | */
27 | @ContextConfiguration(classes = EclipseLinkProxyIdAccessorTests.EclipseLinkConfig.class)
28 | class EclipseLinkProxyIdAccessorTests extends PersistenceProviderIntegrationTests {
29 |
30 | @Configuration
31 | @ImportResource("classpath:eclipselink.xml")
32 | static class EclipseLinkConfig {}
33 |
34 | /**
35 | * Do not execute the test as EclipseLink does not create a lazy-loading proxy as expected.
36 | */
37 | @Override
38 | @Disabled
39 | public void testname() {}
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/OpenJpaJpaRepositoryTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | import org.junit.jupiter.api.Disabled;
19 | import org.springframework.test.context.ContextConfiguration;
20 |
21 | /**
22 | * Integration tests to execute {@link JpaRepositoryTests} against OpenJpa.
23 | *
24 | * @author Oliver Gierke
25 | */
26 | @ContextConfiguration("classpath:openjpa.xml")
27 | class OpenJpaJpaRepositoryTests extends JpaRepositoryTests {
28 |
29 | /*
30 | * (non-Javadoc)
31 | * @see org.springframework.data.jpa.repository.support.JpaRepositoryTests#testCrudOperationsForCompoundKeyEntity()
32 | */
33 | @Override
34 | @Disabled
35 | void testCrudOperationsForCompoundKeyEntity() throws Exception {
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/OpenJpaProxyIdAccessorTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | import org.springframework.context.annotation.Configuration;
19 | import org.springframework.context.annotation.ImportResource;
20 | import org.springframework.data.jpa.provider.PersistenceProviderIntegrationTests;
21 | import org.springframework.test.context.ContextConfiguration;
22 |
23 | /**
24 | * @author Oliver Gierke
25 | */
26 | @ContextConfiguration
27 | class OpenJpaProxyIdAccessorTests extends PersistenceProviderIntegrationTests {
28 |
29 | @Configuration
30 | @ImportResource("classpath:openjpa.xml")
31 | static class Config {}
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/QSimpleEntityPathResolverUnitTests_Sample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2011-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | /**
19 | * Stub for a generated QueryDsl query class.
20 | *
21 | * @author Oliver Gierke
22 | */
23 | class QSimpleEntityPathResolverUnitTests_Sample {
24 |
25 | public QSimpleEntityPathResolverUnitTests_Sample field;
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/XmlConfigDefaultTransactionDisablingIntegrationTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.repository.support;
17 |
18 | import org.springframework.test.context.ContextConfiguration;
19 |
20 | /**
21 | * Integration tests for disabled default configurations via XML configuration.
22 | *
23 | * @author Oliver Gierke
24 | * @soundtrack The Intersphere - Live in Mannheim
25 | */
26 | @ContextConfiguration("disable-default-transactions.xml")
27 | class XmlConfigDefaultTransactionDisablingIntegrationTests extends DefaultTransactionDisablingIntegrationTests {}
28 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/repository/support/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Test cases for ORM DAO implementations.
4 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/support/EntityManagerTestUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.support;
17 |
18 | import javax.persistence.EntityManager;
19 |
20 | import org.springframework.util.ReflectionUtils;
21 |
22 | /**
23 | * Utility class with {@link EntityManager} related helper methods.
24 | *
25 | * @author Thomas Darimont
26 | */
27 | public abstract class EntityManagerTestUtils {
28 |
29 | private EntityManagerTestUtils() {}
30 |
31 | public static boolean currentEntityManagerIsAJpa21EntityManager(EntityManager em) {
32 | return ReflectionUtils.findMethod(((org.springframework.orm.jpa.EntityManagerProxy) em).getTargetEntityManager()
33 | .getClass(), "getEntityGraph", String.class) != null;
34 | }
35 |
36 | public static boolean currentEntityManagerIsHibernateEntityManager(EntityManager em) {
37 | return em.getDelegate().getClass().getName().toLowerCase().contains("hibernate");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/springframework/data/jpa/util/FixedDate.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015-2021 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.jpa.util;
17 |
18 | import java.util.Date;
19 |
20 | /**
21 | * Holds a fixed {@link Date} value to use in components that have no direct connection.
22 | *
23 | * @author Thomas Darimont
24 | */
25 | public enum FixedDate {
26 |
27 | INSTANCE;
28 |
29 | private Date fixedDate;
30 |
31 | public void setDate(Date date) {
32 | this.fixedDate = date;
33 | }
34 |
35 | public Date getDate() {
36 | return fixedDate;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/resources/META-INF/jpa-named-queries.properties:
--------------------------------------------------------------------------------
1 | User.findBySpringDataNamedQuery=select u from User u where u.lastname=?1
--------------------------------------------------------------------------------
/src/test/resources/META-INF/orm.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
16 |
17 | SELECT u FROM User u WHERE u.lastname = ?1
18 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/test/resources/auditing/auditing-bfpp-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/auditing/auditing-entity-listener.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/test/resources/auditing/auditing-namespace-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/test/resources/auditing/auditing-namespace-context2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/auditing/auditing-namespace-context3.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/resources/config/jpa-context-with-jndi.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/test/resources/config/lookup-strategies-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/test/resources/config/namespace-application-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/test/resources/config/namespace-autoconfig-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/test/resources/config/namespace-autoconfig-typefilter-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/config/namespace-customfactory-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/config/namespace-nested-repositories-application-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/test/resources/eclipselink.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 | org.hsqldb.jdbcDriver
13 | jdbc:hsqldb:mem:hades
14 | sa
15 |
16 | create-tables
17 | false
18 | SEVERE
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/test/resources/hibernate.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/test/resources/infrastructure.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d %5p %40.40c:%4L - %m%n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/multiple-entity-manager-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/test/resources/openjpa.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
13 |
14 |
15 |
16 |
17 | none
18 |
19 |
20 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/test/resources/org/springframework/data/jpa/repository/support/disable-default-transactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/test/resources/org/springframework/data/jpa/support/mapping.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/test/resources/org/springframework/data/jpa/support/module1/module1-orm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/test/resources/org/springframework/data/jpa/support/module2/module2-orm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/test/resources/org/springframework/data/jpa/support/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | foo.xml
5 | org.springframework.data.jpa.domain.sample.User
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/test/resources/org/springframework/data/jpa/support/persistence2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bar.xml
5 | org.springframework.data.jpa.domain.sample.Role
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/test/resources/scripts/hsqldb-init.sql:
--------------------------------------------------------------------------------
1 | /;
2 | SET DATABASE SQL SYNTAX ORA TRUE
3 | /;
--------------------------------------------------------------------------------
/src/test/resources/simple-persistence/simple-persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/test/resources/tx-manager.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/template.mf:
--------------------------------------------------------------------------------
1 | Bundle-ManifestVersion: 2
2 | Bundle-SymbolicName: org.springframework.data.jpa
3 | Bundle-Name: ${project.name}
4 | Bundle-Vendor: Pivotal Software, Inc
5 | Bundle-Version: ${project.version}
6 | Bundle-RequiredExecutionEnvironment: J2SE-1.5
7 | Export-Template:
8 | org.springframework.data.jpa.*;version="${project.version}"
9 | Import-Template:
10 | com.querydsl.*;version="${querydsl:[=.=.=,+1.0.0)}";resolution:=optional,
11 | javax.persistence.*;version="${jpa:[=.=.=,+1.0.0)}",
12 | javax.annotation.*;version="0.0.0",
13 | javax.enterprise.*;version="${cdi:[=.=.=,+1.0.0)}";resolution:=optional,
14 | org.aopalliance.*;version="[1.0.0,2.0.0)",
15 | org.apache.openjpa.*;version="${openjpa:[=.=.=,+1.0.0)}";resolution:=optional,
16 | org.aspectj.*;version="${aspectj:[=.=.=,+1.0.0)}";resolution:=optional,
17 | org.eclipse.persistence.*;version="${eclipselink:[=.=.=,+1.0.0)}";resolution:=optional,
18 | org.hibernate.*;version="[3.6.10,4.4.0)";resolution:=optional,
19 | org.slf4j.*;version="${slf4j:[=.=.=,+1.0.0)}",
20 | org.springframework.*;version="${spring:[=.=.=.=,+1.1.0)}",
21 | org.springframework.beans.factory.aspectj;version="${spring:[=.=.=.=,+1.1.0)}";resolution:=optional,
22 | org.springframework.data.*;version="${springdata.commons:[=.=.=.=,+1.0.0)}",
23 | org.threeten.bp.*;version="${threetenbp:[=.=.=,+1.0.0)}";resolution:=optional,
24 | org.w3c.*;version="0.0.0"
25 | Import-Package: org.aspectj.lang;version="${aspectj:[=.=.=,+1.0.0)}";resolution:=optional,
26 | org.aspectj.runtime.reflect;version="${aspectj:[=.=.=,+1.0.0)}";resolution:=optional,
27 | org.springframework.beans.factory.aspectj;version="${spring:[=.=.=.=,+1.1.0)}";resolution:=optional
28 |
29 |
--------------------------------------------------------------------------------