Comments (7)
The EnversRepositoryFactoryBean
already exposes a property to customize the revision entity class. If this property is set the ReflectionRevisionEntityInformation
information will be used. So the problem currently is that the infrastructure does not know about your special RevEntity
class, and the namespace configuration you probably use does not expose the property. You should be able to workaround the issue by extending EnversRepositoryFactoryBean
as follows:
public class CustomEnversRevisionRepositoryFactoryBean extends EnversRevisionRepositoryFactoryBean {
public FooCustomEnversRevisionRepositoryFactoryBean() {
setRevisionEntityClass(RevEntity.class);
}
}
then you can alter your Spring Data JPA config as follows:
<jpa:repositories base-package="…" factory-class="….CustomEnversRevisionRepositoryFactoryBean" />
We'll probably add a custom <envers:repositories />
element to the Spring Data Envers project that will expose the revision entity class attribute directly to ease the setup.
from spring-data-envers.
We just created #289.
from spring-data-envers.
Thnx, extending is a good idea.
I was already wondering how to use the setRevisionEntityClass()-Method in the EnversRepositoryFactoryBean, as it is not used as a plain bean ref but as a factory-class....
from spring-data-envers.
public class CustomEnversRevisionRepositoryFactoryBean extends EnversRevisionRepositoryFactoryBean { public FooCustomEnversRevisionRepositoryFactoryBean() { setRevisionEntityClass(RevEntity.class); } }
In the version of hibernate-envers 5.1.1.Final and spring-data-envers 1.1.15.RELEASE this code doesn't work since EnversRevisionRepositoryFactoryBean has no default constructor (and keeping in mind that "Foo" in constructor name is a typo).
This code worked for me:
public class CustomEnversRevisionRepositoryFactoryBean extends EnversRevisionRepositoryFactoryBean {
public CustomEnversRevisionRepositoryFactoryBean(Class repositoryInterface) {
super(repositoryInterface);
setRevisionEntityClass(AbonRevision.class);
}
}
from spring-data-envers.
We'll probably add a custom
<envers:repositories />
element to the Spring Data Envers project that will expose the revision entity class attribute directly to ease the setup.
Hi @odrotbohm, I couldn't find anything about it so I guess this was never added. Is it something you would still consider or is subclassing the preferred approach?
from spring-data-envers.
We have no plans to extend our XML based configurations at the moment.
from spring-data-envers.
Thanks for the fast feedback!
What about something for Java config? I could imagine a custom annotation to avoid the EnversRevisionRepositoryFactoryBean
custom class wired into @EnableJpaRepositories
.
I'm happy to contribute if the idea is acceptable.
from spring-data-envers.
Related Issues (20)
- Release 2.7.9 (2021.2.9)
- Upgrade to Maven Wrapper 3.9.0
- Envers doesn't support serializing with filters? Could not write JSON: Session/EntityManager is closed / the owning session was closed HOT 2
- Release 2.7.10 (2021.2.10)
- Release 2.7.11 (2021.2.11)
- Upgrade to Maven Wrapper 3.9.1
- Missing Pageable Sort interpretation HOT 3
- Release 2.7.12 (2021.2.12)
- Release 2.7.13 (2021.2.13)
- Use snapshots and milestone repositories instead of libs-snapshot and libs-milestone
- Upgrade to Maven Wrapper 3.9.2
- Release 2.7.14 (2021.2.14)
- Upgrade to Maven Wrapper 3.9.3
- Release 2.7.15 (2021.2.15)
- Upgrade to Maven Wrapper 3.9.4
- Release 2.7.16 (2021.2.16)
- Release 2.7.17 (2021.2.17)
- Schema-validation: missing sequence HOT 1
- Upgrade to Maven Wrapper 3.9.5
- Release 2.7.18 (2021.2.18)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-data-envers.