Questions tagged [nativequery]

JPA concept that allows queries in your native database syntax (instead of JPQL)

Related links

355 questions
3
votes
3 answers

Spring JPA - How to create a Pageable with a NativeQuery?

I try to do the following inside a Spring Boot application : create a native query and page it so it can returns a page of a given number of elements from a @RestController. Here's the snippet of my code, where em is the @PersistanceContext…
Sooron
  • 123
  • 1
  • 2
  • 8
3
votes
1 answer

Implementing pagination in JPA EntityManager createNativeQuery

I am writing a query using JPA EntityManager createNativeQuery and I want to apply pagination. Following is the code I have implemented so far: private static final int NO_OF_RESULTS_IN_A_PAGE = 30; public Page getFilteredCars(int page, String…
Kshitij Bajracharya
  • 811
  • 2
  • 14
  • 37
3
votes
1 answer

Getting a jumbled data or wrong data while processing native query in spring boot

i am writing a native query in jpa repository with left join and getting a jumbled output and adding more columns to the query is generating a error of conversion from java.object to my model class. Moreover when i try to return all from the output…
3
votes
2 answers

How to add parameters to IN clause in spring data repository native query

folks, I have a problem finding a way to send parameters for IN clause in a native query through Spring data repository. I tried sending list of strings, concatenated and formatted strings... nothing helped
a.valchev
  • 388
  • 4
  • 10
3
votes
0 answers

Hibernate native query selecting entities with joined many-to-many association

I’m not used to ask for help but I’m really stuck for a few days. No way to find the same issue on Stackoverflow or Google... I have two entities Event and Artist with a many-to-many relationship. The join table is EventArtists. Event <--…
volvotrax
  • 369
  • 3
  • 9
3
votes
0 answers

How to run just arbitrary native query in Spring-Data-JPA environment?

I need to convert "horizontal" data representation into "vertical" one. For this I need to run INSERT query multiple times, one for each column of source table. I can't annotate dozens of @Query or something. Can I just run some native query…
Dims
  • 47,675
  • 117
  • 331
  • 600
3
votes
1 answer

How to get non-mapped column in a result of Doctrine native query

How can I get non-mapped column in result from native query? My query: $query = $this->getEntityManager()->createNativeQuery( "SELECT m.id, m.title, MATCH(m.title) AGAINST('$slug') AS score " . "FROM music AS m " …
3
votes
1 answer

Why do backslashes need to be escaped in JPA native queries?

In JPA, when executing a native query, I have to escape backslash characters to double backslash. E.g. when having a where clause like UPPER(app.NAME) like UPPER(?) escape '\' then I need to create a string which contains: UPPER(app.NAME) like…
3
votes
1 answer

Power Query -- list value in native query

im having a problem using the "in" operator in a native query, where the in argument is a list retrieved by drilling a excel column table: let var = Number.ToText(fnFuncao("externalcode")), Coluna=…
user3682983
  • 177
  • 2
  • 14
3
votes
1 answer

Symfony2 Doctrine2 native queries basics

I am developing a basic web-app in my job. I have to work with some sql server views. I made the decision of trying native queries, and once tested it's functionality, try to write some classes to code all the queries and kinda forget their…
Lucas
  • 55
  • 1
  • 8
3
votes
1 answer

JPA : @SequenceGenerator is not generating the sequence

I my application I have used JPA with Hibernate vendor and Oracle 11G DB. Here I am using the native query as follow on my MST_EMP table .. Query query = this.entityManager.createNativeQuery("INSERT INTO MST_EMP emp (" + …
Gunjan Shah
  • 5,088
  • 16
  • 53
  • 72
2
votes
1 answer

Can I use the JPA 2.0 CriteriaBuilder to fetch a list of non-entity objects?

I asked a similar question to this, but I didn't provide good details, so I am re-asking the question with better details. I have 2 tables that look like this: Table1 A B C PK Table2 D E F PK These 2 tables have JPA…
user1148956
  • 303
  • 1
  • 3
  • 9
2
votes
1 answer

Do native queries in JPA 2.0 bypass the first level cache?

I am new to OpenJPA, and I am wondering if calling a native query will bypass the first level cache and go straight to the database.
user1148956
  • 303
  • 1
  • 3
  • 9
2
votes
1 answer

generate_series function in Hibernate

I have a column total in the table Inv and I want to extract total amount per month in hibernate using generate_series: @Query(value = "SELECT _month," + "sum(inv.total) AS total" + "FROM FUNCTION('generate_series', 1, 12, 1)…
Programmer2B
  • 552
  • 3
  • 14
2
votes
0 answers

Unknown data type issue with native query

I want to execute a simple native query, but it does not work: Query query = entityManager.createNativeQuery("SELECT col1,col2,col3 FROM table(schema.fn_name(?1,?2,?3)) ORDER BY col1,col2"); query.setParameter(1, 1193679); query.setParameter(2,…
Aurora
  • 81
  • 6
1 2
3
23 24