Polish "Add auto-configuration for Spring Data Envers"
See gh-22610
This commit is contained in:
@@ -60,6 +60,8 @@
|
||||
:spring-data-couchbase-docs: https://docs.spring.io/spring-data/couchbase/docs/{spring-data-couchbase-version}/reference/html/
|
||||
:spring-data-elasticsearch: https://spring.io/projects/spring-data-elasticsearch
|
||||
:spring-data-elasticsearch-docs: https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/
|
||||
:spring-data-envers: https://spring.io/projects/spring-data-envers
|
||||
:spring-data-envers-doc: https://docs.spring.io/spring-data/envers/docs/{spring-data-envers-version}/reference/html/
|
||||
:spring-data-gemfire: https://spring.io/projects/spring-data-gemfire
|
||||
:spring-data-geode: https://spring.io/projects/spring-data-geode
|
||||
:spring-data-jpa: https://spring.io/projects/spring-data-jpa
|
||||
|
||||
@@ -247,6 +247,21 @@ For complete details, see the {spring-data-jpa-docs}[Spring Data JPA reference d
|
||||
|
||||
|
||||
|
||||
[[features.sql.jpa-and-spring-data.envers-repositories]]
|
||||
==== Spring Data Envers Repositories
|
||||
If {spring-data-envers}[Spring Data Envers] is available, JPA repositories are auto-configured to support typical Envers queries.
|
||||
|
||||
To use Spring Data Envers, make sure your repository extends from `RevisionRepository` as show in the following example:
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/features/sql/jpaandspringdata/repositories/CountryRepository.java[]
|
||||
----
|
||||
|
||||
NOTE: For more details, check the {spring-data-envers-doc}[Spring Data Envers reference documentation].
|
||||
|
||||
|
||||
|
||||
[[features.sql.jpa-and-spring-data.creating-and-dropping]]
|
||||
==== Creating and Dropping JPA Databases
|
||||
By default, JPA databases are automatically created *only* if you use an embedded database (H2, HSQL, or Derby).
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.features.sql.jpaandspringdata.entityclasses;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.envers.Audited;
|
||||
|
||||
@Entity
|
||||
public class Country implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Audited
|
||||
@Column(nullable = false)
|
||||
private String name;
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.features.sql.jpaandspringdata.repositories;
|
||||
|
||||
import org.springframework.boot.docs.features.sql.jpaandspringdata.entityclasses.Country;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.history.RevisionRepository;
|
||||
|
||||
public interface CountryRepository extends RevisionRepository<Country, Long, Integer>, Repository<Country, Long> {
|
||||
|
||||
Page<Country> findAll(Pageable pageable);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user