Benefits of using QueryDSL vs. Spring Data? - spring-data

Im thinking about using QueryDSL in my project where I am already using Spring Data. I am programming a microservice inclidung a REST-Interface.
What are the main differences between Spring Data and QueryDSL? What are the big benefits of using QueryDSL instead of Spring Data?

Querydsl and Spring Data go along well. While both deal with the domain of persistence they have very different goals.
Querydsl provides a type-safe query API.
Spring Data provides a consistent API to accessing persistent stores, inspired by the ideas of Domain Driven Design, without getting in the way of the user and how she wants to formulate queries.
Therefore there exists an extension point to combine Spring Data and Querydsl and you can always implement non-standard queries using Querydsl if they go beyond, what can be easily formulated using the build in Spring Data repositories.

Related

Is there a way for implementing database migrations on Spring JPA without the use of frameworks (e.g.: flyway, liquidbase, etc)?

I'm migrating a system that used to be written in Jdbc Templates to Spring Data JPA. Before, we used to write the SQL queries ourselves, but now that we're modernizing our system, we're going to use Spring Data JPA for this. Due to restrictive factors, i can't implement a database migration framework, such as flyway and liquidbase. Is there any way i can implement those using what i have on Spring JPA?

How to run jpql queries in a console in Spring Data project?

I'm new to Spring Data and trying to learn to projections and DTOs.
If you run a plain Hibernate or JPA project in Idea, there is an access to jpql tool window like View -> Tool Windows -> Persistence.
But when open a Spring Data project in idea the feature is unavailable.
Could i run and debug hql|jpql queries for my DTOs in Idea for Spring Data?
Which is the best tool to debug|run complex jpql queries like joins etc.?
Should i consider another ide or a tool?
Where is a good source of working examples for projections and jpql?

How to make Spring Data JPA work with multiple database vendors?

I'd like to make my application powered by Spring Data JPA transparently compatible with both MSSQL and Oracle. My application contains a few pieces of native SQL queries and ideally I'd like to organize this as the usual common Spring Data repository XXXRepository with vendor-independent JPQL queries and a couple of extensions as the vendor-specific Spring Data repositories like XXXOracleRepository/XXXMSSQLRepository with vendor-specific native queries.
Is it possible ?

Java EE using MongoDB without JPA or EJB?

Could someone give me an explanation of if what I'm doing makes sense?
I am currently developing a Java EE application using MVC architecture, and MongoDB as my database. What I have is several entities written as Java objects with custom mapping methods to persist to and from my MongoDB, as well as a separate controller class to perform Database queries and operations. I am able to store these entities in my session with no problem, but I haven't tested this on a larger scale. I've tried annotating my objects as beans, however I received errors.
My typical method of transmitting data is to query my MongoDB, receive the information, map it to a java object, and store it in a session to be accessed by the front end. Is this the proper way to go about this?
Do my entities need to be EJBs? What do I have to gain from making them EJBs? I'm sorry if this question is presented poorly and seems unintelligent. I just want to have a better understanding of the technology I am trying to utilize before further developing. Most of the reading I have done on such topics has been to no avail. If anyone has some clear reading or an explanation that should help me understand what I am asking, it would be most appreciated.
I assume by "EJBs", you are referring to "Entity Beans"? In EJB 3, entity beans are "replaced" by JPA. Think of JPA as a "specification" for ORM frameworks. JPA/ORM are frameworks for mapping Java objects to and from relational databases. You are using MongoDB, which is not a relational database, and hence not that suitable for JPA. So I would say no, there is no need for you to consider JPA. Instead you should consider other frameworks, like Spring Data, which can simplify the task you are doing.
in my opinion you can use EJB3 with mongodb without JPA and entity manager, but you will have Stateless/Singleton/Startup/MDB beans with 0 configuration and with perfect managable backend.

Database Crawler using JPA

We have a requirement for building a database crawler. The application parses the tnsnames, connects to each database and retrieves some information like version, accounts, etc. We are trying to use JPA across the other parts of the application and to persist this data into the application's database.
So far, I only see creating an EntityManagerFactory programmatically for every database. Is there any other options?
We are using Spring, are there any benefits that Spring brings to the table in this scenario?
Thanks
JPA is clearly not the right tool for this job. JPA allows creating functional entities mapping a well-know database schema. Your tool doesn't know anything about the schemas and tables it will find. There could be 0 tables or 5000, with completely unknow names.
You need a much lower-level API to do what you want, like JDBC.
You could use JPA to store the results of your crawlings in a single schema, though.