R
R
Romanov19812020-10-15 10:00:49
Hibernate
Romanov1981, 2020-10-15 10:00:49

How to make sql query in Spring Data JPA?

Greetings dear forum users.

I have a question.

I am using IntelliJ IDEA.

I made such a request:

5f87f0eb53d85605922801.png

In this form, this request works. But the fact that the String type is highlighted in yellow somehow confuses me. I thought that if you specify String instead of User in JpaRepository, this seems to be correct and the yellow highlight disappears, but the request itself stops working, an error message appears " Not a managed type: class java.lang.String "

Please tell me what is wrong am I doing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
askar98, 2020-10-15
@Romanov1981

As answered above, if you want a pure sql query, you can also write in jdbcTemplate.NativeQuery when there are not enough JPQL capabilities. As far as I know, repository methods (without sql query) can get an object and lists of objects, so in this case you can’t do without a query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question