-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SpringJPA: @Query(nativeQuery) support #5348
Comments
That is indeed true. We don't have anything similar in Panache so I wanted to wait and see what we would do on that front before doing anything similar for Spring Data JPA. |
Yeah, that is undeniably useful! If we add native query support to Panache, then transfering it to the Spring Data JPA module should be easy. |
Question is if it can be transformed into a |
Sure it could. There would probably be a few more things involved, but I don't anticipate there being many problems. |
|
I didn't really want to add things to Spring Data JPA that Panache doesn't support. |
That's wise but Panache is building additional helpers on top of Hibernate ORM. I don't expect it would need to also re-export features which ORM already provides? Spring Data JPA could definitely use any feature that ORM has, and combine them with the additional stuff Panache adds. That said, what's the semantics of If so, should be easy to support this:
Careful to not conflict with an explicitly configured howeverwhile it's easy to implement, I'm not persuaded that we should. I guess it depends on the semantics and me not knowing what makes Only downside I see is that it accepts only a single script; which IMO is a sane constraint. |
Existing similar feature: |
Another thing to take into account here is that for the Spring compatiblity we haven't so far utilized any Spring configuration - it's all Quarkus specific. |
Agreed, I don't think supporting all details of Spring is a wise goal, especially with configuration there's things which conceptually can't be mapped. The goal of the "spring like" APIs should be to make it easy and familiar for people with a Spring background, no more. So, up to you... maybe I'm missing something about the flexibility of such scripts; if so let's improve our flexibility as well, then explain to users how this configuration property is different in some migration guide. |
Good idea! @aureamunoz do you want to perhaps look into |
Yes! sure!! @geoand |
Thanks! |
@geoand @aureamunoz Raised [#5371] for |
Thanks @jesperpedersen! |
Hello Guys. What is the status of this feature request. Are there any plans to implement nativequery support? regards |
Hello Team, Is there any update on the nativeQuery support. I am migrating springboot to quarkus and got stuck with native query. I am using hibernate spatial queries for postgres posgis extension. I was using a query template as below. Currently there are 2 issues
@query(value = "SELECT s.id, ST_DISTANCE(geom::geography, ST_SETSRID(ST_MAKEPOINT(), 4326)::geography) AS distance |
We haven't got around to this unfortunately |
Any news on this? I'm considering quarkus for a new project but without native query I'm not sure anymore. |
One can use native queries with our Panache layer without much hassle. It's the Spring Data JPA layer that doesn't have support for them currently |
Oh, that would be perfect. |
There isn't anything in the documentation that I am aware of, but you could certainly do something like this: @ApplicationScoped
public class FruitRepository implements PanacheRepository<Fruit> {
private final EntityManager entityManager;
public FruitRepository(EntityManager entityManager) {
this.entityManager = entityManager;
}
public List<Fruit> nativeQuery() {
return entityManager.createNativeQuery("select * from fruits where name = 'test'", Fruit.class).getResultList();
}
} |
Ok, I'm not blinded then. |
Any updates on the JPA layered to allow the usage of native queries? Currently migrating a project to Quarkus which has a some native querys so would be very usefull 😅 |
There are two things we are missing here:
|
I would suggest reading up on something like https://thorben-janssen.com/jpa-native-queries/ |
+1 on this. Very useful for migrating Spring apps. Here is an example for PostGIS: |
Just as FYI for anyone considering using fun nativeQuery(query: String) = getSession().onItem()
.transformToUni { session -> session.createNativeQuery<Customer>(query).resultList }!! You need to call For Hibernate Reactive, the |
Any update on this? I need to do a Postgres upsert. |
Due to me working on some priority things, this has been moved back in the queue. |
If anyone however wants to take a swing at this, I can certainly point them in the right direction |
Description
The current spring-data-jpa module (1.0.0.CR1) doesn't support the 'nativeQuery' attribute of
org.springframework.data.jpa.repository.Query
@geoand WDYT ?
The text was updated successfully, but these errors were encountered: