Questions tagged [nativequery]

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

Related links

355 questions
5
votes
3 answers

createNativeQuery set parameter

I have the following that contains a NativeQuery where i need to set a parameter but somothing is wrong beacause parameter not set so the query is SELECT movieId, title, genres FROM movies where title like '%%'" so return all the rows. What is…
Giorgos
  • 637
  • 3
  • 13
  • 25
5
votes
2 answers

EntityManager Native Query Syntax?

The following method uses the createNativeQuery() method of the Java entity manager: public List findDogById(String id) { List resultList = new ArrayList<>(); try { resultList =…
java123999
  • 6,974
  • 36
  • 77
  • 121
5
votes
2 answers

Manage @NamedNativeQuery and schema

I have many EntityManager, one per schema that I have (I use entity-mappings file to map EMs with schemas). It works. When I use @NamedQuery it's working like a charm but when I use @NamedNativeQuery schema is not used. I have to qualify with it…
Olivier J.
  • 3,115
  • 11
  • 48
  • 71
5
votes
1 answer

KnpPaginator and native query

I use KnpPaginatorBundle in my Symfony2 project. When i try to pass a Doctrine 2 native query to paginator instance, I got error: One of listeners must count and slice given target Have anyone some example of correct implementation of this for some…
shinji
  • 55
  • 1
  • 4
5
votes
1 answer

How manage a VIEW with Doctrine 2?

I would like mapping a sql-view with Doctrine2. This view is a TempTable containing some statistics that would show without rewriting the sql that generates the view I try to map like a table, but updating schema drop the view and create a table I…
Ephraim
  • 260
  • 1
  • 6
  • 15
4
votes
4 answers

Query resulting into "ERROR: operator does not exist: character varying ~~ bytea"

I have a query where I need to check first if the input parameter is null or compare the column value to pass input parameter. It means that the column value can be null or pass the specified condition (?3 is null or cd.name like %?3%). public…
mevada.yogesh
  • 1,118
  • 3
  • 12
  • 35
4
votes
2 answers

Spring Data JPA having multiple orm.xml files

Based on my last post: Spring JPA long SQL String for NativeQuery I've managed to find a "place" to write clean SQLs so that I can directly copy and paste it in the DB software for faster testing. But another problem comes, if I wan to segregate my…
Henry
  • 631
  • 10
  • 21
4
votes
0 answers

Hibernate: is it possible to add dynamic where clause to a NATIVE query?

In our application we have many native queries (usually, overall when we need to perform some JOIN, LEFT JOIN or FROM clauses using a view on the fly). Moreover, many queries are repeated in many EJBs but the only things they change are some…
SagittariusA
  • 5,289
  • 15
  • 73
  • 127
4
votes
3 answers

NativeQuery Spring Data return object

I need to implement a query in Spring Data like this :- Select User.name, sum(Activity.minutes) From User, Activity, ActivityStatus Where User.id = ActivityStatus.userId And Activity.id = ActivityStatus.activityId AND ActivityStatus =…
Chirrut Imwe
  • 633
  • 10
  • 20
4
votes
1 answer

Why does spring nativeQuery with pagination throw a SQLGrammarException?

I am trying to run the following Query in Spring 4.2.4: @Query(value="SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY i.TYPE_NUMBER ASC) AS RN, i.* FROM Item i) AS g WHERE RN between ?#{ #pageable.offset} and ?#{#pageable.offset +…
user5915295
4
votes
1 answer

JPA native query result returns duplicate child objects

I have a parent table and a child Table in my DB, and have a OneToMany mapping for them in their corresponding entity classes. The child table has a foreign key parent_id. I am using JPA 2 with Hibernate and MySQL DB. I wish to retrieve all the…
4
votes
2 answers

JPA native query returns no records

This is method to get Module entites within specified level for related backend. public List getModulesWithinLevel(Long backendId, ModuleLevel... levels) { String joinedLevels = serializeLevels(levels); Query query =…
DominikM
  • 1,042
  • 3
  • 16
  • 32
4
votes
2 answers

Duplicate rows using Hibernate native query with return-join

I'm using Hibernate (3.3.x) and I have two entities: public class FtChargeAcctPkgDtl { private FtChargeAcctPkgDtlId id; private Set ftChargeAcctPkgRates; } and public class FtChargeAcctPkgRate { private…
Ondrej Skalicka
  • 3,046
  • 9
  • 32
  • 53
3
votes
1 answer

Paging Native SQL Query in JPA with Hibernate without error

Thanks for your attention, and sorry for mi English :S I'm using JPA 2.0 with Hibernate 4.X to do some sql native queries. Te code is very simple: private void doIt() throws Exception { EntityManager em = getEntityManager(); Query q…
Ephyras
  • 83
  • 1
  • 9
3
votes
1 answer

Native Query with array in JPA

I want to make a query verify value as contained into array in Postgres. I made a nativeQuery in JPA the query apparently is correct and is working in DBeaver(DBM), but not in java application. , ERROR: operator does not exist: integer[] @>…
1
2
3
23 24