Skip to content

Commit 716955b

Browse files
committed
Merge the Envers repo.
Spring Data JPA is now a multimodule project. The artifacts build are still separate, except for the documentation which is now a single one. Closes # 2316
1 parent 9c30a01 commit 716955b

File tree

474 files changed

+3249
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

474 files changed

+3249
-414
lines changed

pom.xml

+15-386
Large diffs are not rendered by default.
File renamed without changes.

spring-data-envers/pom.xml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.springframework.data</groupId>
7+
<artifactId>spring-data-envers</artifactId>
8+
<version>3.0.0-SNAPSHOT</version>
9+
10+
<parent>
11+
<groupId>org.springframework.data</groupId>
12+
<artifactId>spring-data-jpa-parent</artifactId>
13+
<version>3.0.0-SNAPSHOT</version>
14+
<relativePath>../pom.xml</relativePath>
15+
</parent>
16+
17+
<name>Spring Data Envers</name>
18+
<description>Spring Data extension to work with Hibernate Envers</description>
19+
20+
<developers>
21+
<developer>
22+
<name>Oliver Gierke</name>
23+
<email>[email protected]</email>
24+
<organization>Pivotal Software, Inc.</organization>
25+
<organizationUrl>www.spring.io</organizationUrl>
26+
</developer>
27+
<developer>
28+
<name>Philip Huegelmeyer</name>
29+
<email>[email protected]</email>
30+
<organization>BLE</organization>
31+
<organizationUrl>www.ble.de</organizationUrl>
32+
</developer>
33+
<developer>
34+
<name>Michael Igler</name>
35+
<email>[email protected]</email>
36+
<organization>Freelancer</organization>
37+
</developer>
38+
<developer>
39+
<name>Jens Schauder</name>
40+
<email>[email protected]</email>
41+
<organization>VMware, Inc.</organization>
42+
<organizationUrl>www.spring.io</organizationUrl>
43+
</developer>
44+
</developers>
45+
46+
<scm>
47+
<url>https://github.com/SpringSource/spring-data-envers</url>
48+
</scm>
49+
50+
<properties>
51+
<hibernate.envers>5.5.7.Final</hibernate.envers>
52+
<java-module-name>spring.data.envers</java-module-name>
53+
</properties>
54+
55+
<dependencies>
56+
57+
<dependency>
58+
<groupId>org.springframework.data</groupId>
59+
<artifactId>spring-data-jpa</artifactId>
60+
<version>${project.version}</version>
61+
</dependency>
62+
63+
<!-- Hibernate -->
64+
<dependency>
65+
<groupId>org.hibernate</groupId>
66+
<artifactId>hibernate-envers-jakarta</artifactId>
67+
<version>${hibernate.envers}</version>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>com.querydsl</groupId>
72+
<artifactId>querydsl-jpa</artifactId>
73+
<version>${querydsl}</version>
74+
<classifier>jakarta</classifier>
75+
<optional>true</optional>
76+
</dependency>
77+
78+
<!-- Test -->
79+
<dependency>
80+
<groupId>com.h2database</groupId>
81+
<artifactId>h2</artifactId>
82+
<version>1.4.200</version>
83+
<scope>test</scope>
84+
</dependency>
85+
86+
</dependencies>
87+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
/*
2+
* Copyright 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.envers.repository.config;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
import jakarta.persistence.EntityManagerFactory;
26+
27+
import org.springframework.beans.factory.FactoryBean;
28+
import org.springframework.context.annotation.ComponentScan.Filter;
29+
import org.springframework.context.annotation.Lazy;
30+
import org.springframework.core.annotation.AliasFor;
31+
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
32+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
33+
import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
34+
import org.springframework.data.repository.config.BootstrapMode;
35+
import org.springframework.data.repository.config.DefaultRepositoryBaseClass;
36+
import org.springframework.data.repository.query.QueryLookupStrategy;
37+
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
38+
import org.springframework.transaction.PlatformTransactionManager;
39+
40+
/**
41+
* Annotation to enable Envers repositories. Will scan the package of the annotated configuration class for Spring Data
42+
* repositories by default.
43+
* <p>
44+
* This annotation is a meta-annotation for {@link EnableJpaRepositories @EnableJpaRepositories} overriding the default
45+
* {@link #repositoryFactoryBeanClass} to {@link EnversRevisionRepositoryFactoryBean}.
46+
*
47+
* @author Mark Paluch
48+
* @since 2.5
49+
* @see EnableJpaRepositories
50+
* @see AliasFor
51+
*/
52+
@Target(ElementType.TYPE)
53+
@Retention(RetentionPolicy.RUNTIME)
54+
@Documented
55+
@Inherited
56+
@EnableJpaRepositories
57+
public @interface EnableEnversRepositories {
58+
59+
/**
60+
* Alias for the {@link #basePackages()} attribute. Allows for more concise annotation declarations e.g.:
61+
* {@code @EnableJpaRepositories("org.my.pkg")} instead of
62+
* {@code @EnableEnversRepositories(basePackages="org.my.pkg")}.
63+
*/
64+
@AliasFor(annotation = EnableJpaRepositories.class)
65+
String[] value() default {};
66+
67+
/**
68+
* Base packages to scan for annotated components. {@link #value()} is an alias for (and mutually exclusive with) this
69+
* attribute. Use {@link #basePackageClasses()} for a type-safe alternative to String-based package names.
70+
*/
71+
@AliasFor(annotation = EnableJpaRepositories.class)
72+
String[] basePackages() default {};
73+
74+
/**
75+
* Type-safe alternative to {@link #basePackages()} for specifying the packages to scan for annotated components. The
76+
* package of each class specified will be scanned. Consider creating a special no-op marker class or interface in
77+
* each package that serves no purpose other than being referenced by this attribute.
78+
*/
79+
@AliasFor(annotation = EnableJpaRepositories.class)
80+
Class<?>[] basePackageClasses() default {};
81+
82+
/**
83+
* Specifies which types are eligible for component scanning. Further narrows the set of candidate components from
84+
* everything in {@link #basePackages()} to everything in the base packages that matches the given filter or filters.
85+
*/
86+
@AliasFor(annotation = EnableJpaRepositories.class)
87+
Filter[] includeFilters() default {};
88+
89+
/**
90+
* Specifies which types are not eligible for component scanning.
91+
*/
92+
@AliasFor(annotation = EnableJpaRepositories.class)
93+
Filter[] excludeFilters() default {};
94+
95+
/**
96+
* Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So
97+
* for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning
98+
* for {@code PersonRepositoryImpl}.
99+
*
100+
* @return
101+
*/
102+
@AliasFor(annotation = EnableJpaRepositories.class)
103+
String repositoryImplementationPostfix() default "Impl";
104+
105+
/**
106+
* Configures the location of where to find the Spring Data named queries properties file. Will default to
107+
* {@code META-INF/jpa-named-queries.properties}.
108+
*
109+
* @return
110+
*/
111+
@AliasFor(annotation = EnableJpaRepositories.class)
112+
String namedQueriesLocation() default "";
113+
114+
/**
115+
* Returns the key of the {@link QueryLookupStrategy} to be used for lookup queries for query methods. Defaults to
116+
* {@link Key#CREATE_IF_NOT_FOUND}.
117+
*
118+
* @return
119+
*/
120+
@AliasFor(annotation = EnableJpaRepositories.class)
121+
Key queryLookupStrategy() default Key.CREATE_IF_NOT_FOUND;
122+
123+
/**
124+
* Returns the {@link FactoryBean} class to be used for each repository instance. Defaults to
125+
* {@link JpaRepositoryFactoryBean}.
126+
*
127+
* @return
128+
*/
129+
@AliasFor(annotation = EnableJpaRepositories.class)
130+
Class<?> repositoryFactoryBeanClass() default EnversRevisionRepositoryFactoryBean.class;
131+
132+
/**
133+
* Configure the repository base class to be used to create repository proxies for this particular configuration.
134+
*
135+
* @return
136+
*/
137+
@AliasFor(annotation = EnableJpaRepositories.class)
138+
Class<?> repositoryBaseClass() default DefaultRepositoryBaseClass.class;
139+
140+
// JPA specific configuration
141+
142+
/**
143+
* Configures the name of the {@link EntityManagerFactory} bean definition to be used to create repositories
144+
* discovered through this annotation. Defaults to {@code entityManagerFactory}.
145+
*
146+
* @return
147+
*/
148+
@AliasFor(annotation = EnableJpaRepositories.class)
149+
String entityManagerFactoryRef() default "entityManagerFactory";
150+
151+
/**
152+
* Configures the name of the {@link PlatformTransactionManager} bean definition to be used to create repositories
153+
* discovered through this annotation. Defaults to {@code transactionManager}.
154+
*
155+
* @return
156+
*/
157+
@AliasFor(annotation = EnableJpaRepositories.class)
158+
String transactionManagerRef() default "transactionManager";
159+
160+
/**
161+
* Configures whether nested repository-interfaces (e.g. defined as inner classes) should be discovered by the
162+
* repositories infrastructure.
163+
*/
164+
@AliasFor(annotation = EnableJpaRepositories.class)
165+
boolean considerNestedRepositories() default false;
166+
167+
/**
168+
* Configures whether to enable default transactions for Spring Data JPA repositories. Defaults to {@literal true}. If
169+
* disabled, repositories must be used behind a facade that's configuring transactions (e.g. using Spring's annotation
170+
* driven transaction facilities) or repository methods have to be used to demarcate transactions.
171+
*
172+
* @return whether to enable default transactions, defaults to {@literal true}.
173+
*/
174+
@AliasFor(annotation = EnableJpaRepositories.class)
175+
boolean enableDefaultTransactions() default true;
176+
177+
/**
178+
* Configures when the repositories are initialized in the bootstrap lifecycle. {@link BootstrapMode#DEFAULT}
179+
* (default) means eager initialization except all repository interfaces annotated with {@link Lazy},
180+
* {@link BootstrapMode#LAZY} means lazy by default including injection of lazy-initialization proxies into client
181+
* beans so that those can be instantiated but will only trigger the initialization upon first repository usage (i.e a
182+
* method invocation on it). This means repositories can still be uninitialized when the application context has
183+
* completed its bootstrap. {@link BootstrapMode#DEFERRED} is fundamentally the same as {@link BootstrapMode#LAZY},
184+
* but triggers repository initialization when the application context finishes its bootstrap.
185+
*
186+
* @return
187+
*/
188+
@AliasFor(annotation = EnableJpaRepositories.class)
189+
BootstrapMode bootstrapMode() default BootstrapMode.DEFAULT;
190+
191+
/**
192+
* Configures what character is used to escape the wildcards {@literal _} and {@literal %} in derived queries with
193+
* {@literal contains}, {@literal startsWith} or {@literal endsWith} clauses.
194+
*
195+
* @return a single character used for escaping.
196+
*/
197+
@AliasFor(annotation = EnableJpaRepositories.class)
198+
char escapeCharacter() default '\\';
199+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Classes for Envers Repositories configuration support.
3+
*/
4+
@org.springframework.lang.NonNullApi
5+
package org.springframework.data.envers.repository.config;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.envers.repository.support;
17+
18+
import org.hibernate.envers.DefaultRevisionEntity;
19+
import org.springframework.data.repository.history.support.RevisionEntityInformation;
20+
21+
/**
22+
* {@link RevisionEntityInformation} for {@link DefaultRevisionEntity}.
23+
*
24+
* @author Oliver Gierke
25+
*/
26+
class DefaultRevisionEntityInformation implements RevisionEntityInformation {
27+
28+
/*
29+
* (non-Javadoc)
30+
* @see org.springframework.data.repository.history.support.RevisionEntityInformation#getRevisionNumberType()
31+
*/
32+
public Class<?> getRevisionNumberType() {
33+
return Integer.class;
34+
}
35+
36+
/*
37+
* (non-Javadoc)
38+
* @see org.springframework.data.repository.history.support.RevisionEntityInformation#isDefaultRevisionEntity()
39+
*/
40+
public boolean isDefaultRevisionEntity() {
41+
return true;
42+
}
43+
44+
/*
45+
* (non-Javadoc)
46+
* @see org.springframework.data.repository.history.support.RevisionEntityInformation#getRevisionEntityClass()
47+
*/
48+
public Class<?> getRevisionEntityClass() {
49+
return DefaultRevisionEntity.class;
50+
}
51+
}

0 commit comments

Comments
 (0)