Answer the question
In order to leave comments, you need to log in
How can you filter an Entity without querying the database and without a loop?
Please tell me if there is an analogue of Link from NET in JPA, so that you can filter the TestEntity loaded with records. For example, I made a request and loaded all the records from the TEST table, then, as needed, I select only the necessary records. Thanks in advance!
public List findResult() {
return em.createQuery("SELECT t FROM TestEntity t").getResultList();
}
Answer the question
In order to leave comments, you need to log in
JPA has its own object-oriented query language. In Hibernate it's HQL, in JPA it's JPQL.
https://ru.wikipedia.org/wiki/Java_Persistence_Que...
If you need to filter the list of records retrieved from the database. then this can be done using lambdas and StreamAPI. Something like:
list.stream()
.filter(entity -> "bar".equals(entity.getFoo()))
.collect(Collectors.toList());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question