We are currently introducing Javers into our spring applications for auditing. We have our entities and other central classes defined in a single project that some of our APIs use as a dependency. I noticed there are properties to disable SQL management for various purposes but not for mongo. We have some APIs that will be sending up audit data and others that will not.
Is there a property or configuration that can disable the attempt to connect to the mongo/document DB and the creation of the DBs and collections for the mongo starter?
Related
I would like to know what's the key difference between Apache Open JPA and Spring JPA.
Spring already has a mature JPA for dealing with all kinds of Java persistence but still saw few projects in my company where they uses Apache Open JPA.
Can we integrate Apache Open JPA with Spring. Also like to know what are key benefits of Open JPA.
for example ElasticPath uses Spring but for JPA they uses Apache Open JPA
First: There is no Spring JPA.
There is spring-orm which is one of the many artifacts published by the Spring Framework. It contains classes dealing with JPA and it's main implementations (Hibernate and EclipsLink) in order to integrate them into the rest of the framework. Most Spring users rarely deal with it directly.
You are probably thinking of Spring Data JPA which offers repositories implemented with JPA, which in turn offer many ways to declare queries: Query derivation from method names, named queries based on method names, annotated queries, query by example, specifications ... It is part of the Spring Data project, which offers similar features with many different persistence technologies (JPA, MongoDb, Couchbase, Elasticsearch, Jdbc, Redis, Ldap ...). Spring Data JPA uses spring-orm
Since it got mentioned a couple of times now it is time to explain JPA: JPA stands for Java Persistence API and is an API which can and is implemented by multiple vendors. Hibernate is the most popular implementation, EclipseLink is the reference implementation and Apache Open JPA is another one.
Spring Data JPA (and spring-orm) are (mostly) based on JPA and therefore you should be able to use Apache Open JPA with it. But development of Open JPA was so slow in recent years that the Spring Data Team dropped OpenJPA from the JPA implementations it tests against.
To get a feeling for the development speed, you might look at the releases from the last three years (2019-2021):
Hibernate: 32 (not counting alpha and beta releases)
EclipseLink: 12 (not counting Milestone and release candidates)
OpenJPA: 4
As for the benefits of Apache Open JPA, I consider that an opinion question and therefore off topic for SO. But since people in your company seem to use it, I suggest asking them why they chose Open JPA over the other implementations.
is there a way to access Amazon QLDB as a repository in spring boot applications like MongoDB?
There isn't a library yet that integrates QLDB with spring boot.
I started to look at building exactly what you suggest, I even contacted the lead of spring data to look at adding this (I haven’t raised the ticket yet), however the CrudRepository interface provided enough integration for the demo applications that we have built with Spring Boot. One of the issues that i had when trying to create the Repository was the mapping of fields from the java objects into the partiql fields without explicit knowledge of what was changing.
QLDB does not have a jdbc driver anymore so it is now a proprietary driver which also uses partiql over sql, there could be some further issues getting this to work as a full blown repository in spring boot due to the inner reliance on sql in spring data .
I'm using Spring Boot 2 and Spring Data JPA using Hibernate 5.2. Spring or Hibernate (not sure, which one does it) can create DB tables automatically by setting spring.jpa.hibernate.ddl-auto = create. This automatically uses the connections settings from spring and the #Entity annotated classes to generate a schema for the DB platform I'm using and creates it.
I want to do the same but in code. I want to add a method that automatically uses existing classes and settings to generate the schema SQL and creates the tables. How to do that?
I tried StandardServiceRegistryBuilder and MetadataSources but I have to configure it manually. I assume there should be a way like Spring is doing it by itself.
In my project, there is a requirement to use different databases. We are currently using MySql database with Hibernate as ORM layer. And we are hibernate SessionFactory to query the database.
Now there is a requirement to use SQLite database as well. I have found several examples on the internet but they are all using JdbcTemplate.
https://blog.pranavek.com/using-multiple-datasource-in-spring-boot-application/
https://scattercode.co.uk/2016/01/05/multiple-databases-with-spring-boot-and-spring-data-jpa/
But my requirement is to use separate sessionFactories for both the databases.
Please, help me in receiving that.
I am new to the ORM and till now whatever i read on the internet , it implies that JPA as just a specification and internally we need to use either eclipselink or hibernate or any other implementation .
But i got confuse when i saw Spring transaction management in one of my application. Is spring also a implementation of JPA
Can anybody explain what what is the actual difference between JPA ,
(EclipseLink.hibernate) , Spring.
JPA is an specification for object relational mapping, coming with a whole lot of interfaces and annotations that implementations must implement and support. One of the features provided by this specification is the ability to use local transactions with the JPA API.
Hibernate and EclipseLink are implementations of this specification.
Spring is a dependency injection framework that, among other things, allows you to handle transactions in a declarative way. But it doesn't come with any actual transaction manager. It just offers a common layer of abstraction over actual transaction management systems, one of them being JPA. But it can also use JDBC transactions, or JTA transactions. You just have to configure it to use the appropriate transaction management subsystem based on your requirements and technology choices.