Spring boot 3.0.1, I have 2 Strange errors in CreateQuery() function and #Autowire adnnotation - spring

I have this strange error, the code is working, but the queryone is strange anyway and annoy. Thanks - hoping there is a solution
I searched almost everywhere for a solution, I didn't find anything helpful

Hibernate 6 expects implicit SELECT clause in front now, however the old query still compiles, it is recommended now to add SELECT as well.
SELECT e FROM Employee e
EntityManager autowiring error is most likely only because of IntelliJ cannot find the correct configuration for this bean, but should work fine at runtime.

This error is coming from your IDE, or more precisely from some IDE plugin.
I don't know what plugin you're using, but I imagine that the plugin is validating that the query is syntactically correct JPQL, and is not accepting one of HQL's many extensions to the syntax of JPQL.
Your query is perfectly legal HQL, for the record.

Related

How to split GraphQL schema on the server side (spring boot application)

I want to logically separate all my Graphql schemas into diff. entities. I am doing this in a spring-boot project.
I do not want to use Appolo or any other 3rd party libraries.
E.g.
book.graphql
author.graphql
I tried the solution provided, and I got no compile error but I am also not getting results from the query anymore.
Spring GraphQLmultiple schemas with Query per file
Please see below:
Can someone pls point me out if I am doing something incorrectly?
The solution provided here enter link description here works as is.
The reason I was getting errors was that I had not implemented the endpoint.

Issue with "language" keyword, after upgrading h2 database to 2.1.210

I am currently working on spring boot jpa applicaiton. it used to work normally with h2 1.4.196.
After I upgrade to h2 to latest version(2.1.210). I am facing issues with the application.
I am facing issues with using reserved keywords in application. I have used key, value as fields in a class. I am able to solve this problem by using below statement.
spring.jpa.properties.hibernate.auto_quote_keyword = true,
above property puts quotes around the keywords which are used in application.
after using above property I am able to compile the application successfully, but while application is running I am facing issue with a field "language" that I used in application.
what I am guessing is, language is normally generated in liquibase generated database, but while querying, hibernate is putting "quotes" around language, thus producing a mismatch and giving error
Can someone please help to solve the issue.
Below is the generated sql from spring boot
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "USER0_.language" not found; SQL statement:
select user0_.id as id1_1_, user0_.dashboard_order as dashboar2_1_, user0_.date_format as date_for3_1_, user0_.user_email as user_ema4_1_, user0_."language" as language5_1_ from blu_dash_user user0_ where upper(user0_.user_email)=upper(?) [42122-210]
had same situation my manager found on stack overflow a solution,
u can add in connection string list of key words to be permitted, example of connection string jdbc:h2:./test;NON_KEYWORDS=KEY,VALUE
hope will help folks

Spring data JPARepository findById() on an Entity with #Version persists the record when no data is present for the primary key

Am using Spring Data JPA and hibernate in as springboot project for persistence, Whenever the method findyById() method on the Repository(JPA CRUD Repository) returns no data for the Primary key for an entity which uses #Version annotation for optimistic locking, it tries to insert an entity to the database.
I could see the insert query generated in the log file.
Has anyone come across such an issue? Please help.
The things I noticed from your explanation seem very strange to the program because this should not happen, you are just doing a simple query, it should not depend on the output of the query. Consider how much you have to look at different situations in very large application to avoid unexpected behaviors that cause problems.
One of the goals of ORM (Hibernate, etc.) is to ensure that the application meets your needs without worries.
There may be configuration on the side of your existing application that cause this problem.
In my opinion, to understand the problem, create another simple project with the minimum requirements, try again.

Junit test case fails with Method threw 'org.hibernate.LazyInitializationException' exception

I am upgrading Hibernate from 5.1.17 to 5.4.11. I am getting org.hibernate.LazyInitializationException while running Junit on collection whose fetch type is LAZY. I am trying to find different ways to make it work and run it in transaction(still facing some issues). Before that I would like to know what is changed after 5.1.17 which is causing this issue because earlier Junit test cases were working perfectly fine.
So what are the things changed related to lazy loading after 5.1.17?
Many things changed, so it's hard to say. What I suggest is, start upgrading your hibernate by updating 1 minor version at a time (according to https://semver.org).
Once you pinpoint which minor version is causing a problem, check:
https://hibernate.org/orm/releases/
Hope that helps.

Does Spring Data 2.0 change nullability rules about sorting and paging?

I'm making migration from spring-boot 1.5.6 to 2.1.7 and facing so many issues.
When I see discussion about migration, looks simple but not for me. I got 2 very big issues :
I implement a filter to make a process of uncrypt uri and to call filter once again with request dispatcher. In 1.5.6 the code is ok, the request goes into doFilter, be uncrypt, httpRequest.getDispatcher.forward and call a second time doFilter which finally call chain.doFilter.
Now in spring-boot 2.1.7 requestDispatcher's forward didn't reach a second time doFilter... Never found a doc on it.
Basic calls like /api/users (which means a findAll) worked on 1.5.6 but fail with NPE in 2.1.7 cause of sorting. I can't call a findAll like /api/users or /api/users/7/books I always get an error :
java.lang.NullPointerException at
org.springframework.data.jpa.repository.support.Querydsl.applySorting(Querydsl.java:128)
Did someone get explanation for that ?
Yes. Both Sort and Pageable now expose dedicated null-objects via Sort.unsorted() and Pageable.unpaged() to express the absence of sorting or pagination information in particular.
You should already see an IDE warning if you enable the annotation based verification of null values. That said, I just rechecked the Javadoc and referencedocs and think we can do better here. I've filed the following tickets:
DATACMNS-1568 (fixed) - General documentation updates about nullability in the repository reference docs.
DATACMNS-1569 (fixed) - Nullability constraints in Querydsl APIs.
DATAJPA-1594 (fixed) - Tighten nullability constraints in Spring Data JPAs Querydsl integration.

Resources