Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
as i know for Querying from Persistence we have below options
Criteria Query
QueryDsl e.t.c.
i am using queryDSL
so is that good approach? or any other library that i can use
Criteria API is a bit tricky/complicated compared to Query DSL. So, I prefer Query DSL.
Reasons:
Type safety is the core principle of Querydsl and one of the best reasons to prefer it.
Compact implementation.
More like JPQL syntax.
Refer to the Query DSL advantages doc for details.
QueryDSL is
more similar to SQL so it might be easier to learn for people who have not touched Criteria before.
more compact
more type-safety
closer to JPQL syntax
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed yesterday.
Improve this question
I understand that there are so many ways we can get data from the Db, one is using JPA or Typed/Named Query.
Wish to know on an Enterprise level do we use JpaRepository or custom repository and if custom what exactly do we use to fetch data is it Stream API or Criteria API or something else .
I have tried to use JpaRepository, getById() and also Stream API filter
I have been doing enterprise programming for a long time and the best choice for me was JPA because JPA allows you to avoid writing DML in the database specific dialect of SQL. JPA allows you to load and save Java objects without any DML language at all. When you do need to perform queries JPQL allows you to express the queries in terms of the Java entities rather than the (native) SQL tables and columns.
Also many helpful annotations like #DynamicUpdate and #DynamicInsert help ORM to create more efficient queries.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I read about the runtime query builder querydsl. But I could not figure out the best cases or examples, where querydsl is most useful. If somebody can explain, it would be really good.
Querydsl helps you to get rid of hard-coded queries and provides a library that encapsulates the functionality of SQL through the hierarchy of corresponding types and interfaces.
It is a better practice to code your queries using interfaces and parametrize the calls.
You will be able to auto-test your changes during the build time using JUnits.
The above makes querying more robust and improves the maintainability of your codebase.
QueryDSL is type-safe queries purely in Java, no strings involved.
repository.findAll(QProduct.product.owner.name.startsWith("Hello"));
So when is it a good idea to use it?
Whenever you need to query from a database that is supported by QueryDSL, of course. Why use SQL when you can use QueryDSL?
If you need to create dynamic database queries, you should use Querydsl.
The pros of using Querydsl are:
It supports dynamic queries.
It has a very clean API. In other words, it is easy to create complex
queries with Querydsl, and the query generation code is easy to read.
It also supports JDO, Lucene, and MongoDB.
The only “problem” of Querydsl is that it isn’t the standard way to create dynamic queries with the Java Persistence API.
Quite fine tutorial with very good explanation you can find here.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I mean wizards such as JPA Tools in Eclipse which can help me generate tables from entities or entities from tables.
Or is it best practice to do everything manually?
These types of wizards are incredibly useful, but they rarely get everything 100% correct. I suggest using them to create the initial schema but then do any fine tuning yourself and check the result carefully.
Often the quality of the schema created depends greatly on the detail that you supply in your annotations. The better the annotations the more likely your schema is generated correctly (for example make sure you specify the length attribute against String columns to ensure they are sized correctly in the database).
Generating table from entities is ok. If you have to do it the other way around (generating entities from table), it's best to do it manually.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm creating rest service for mobile app in java. For storage process which is best suitable for real time storage (Hibernate , JPA & JDBC).
Your valuable answers will put me on right track.
Basically ORM technologies like Hibernate, JPA etc., provides greater flexibility to the programmer in maintaining the code say for example, direct mapping to java POJO's, object locking mechanisms, Id generation and lot more with little cost of performance. If your application needs light weight calls (taking into consideration of concurrency, ofcourse underling database will provide, small relation etc) you could opt JDBC.
Thanks,
JK
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
In our java project, We decided to use ORM object/relational mapping technique in objects' persisting.
But we hesitate to use a specific framework to do this.So, what is the best framework for java can do this task?
Hibernate is an excellent choice.
As Chris says, Hibernate is an excellent choice.
A (not-exhaustive) list can be found on wikipedia
Hibernate is a superset of JPA. If you stay within the bounds of the JPA, then you can theoretically switch to a differenct JPA implementation at a later point...
As toolkit said about what Chris says, Hibernate is the choice.
:D :D :D :D
Hibernate of course, but if you seek standardizations, then JPA or JDO