Questions tagged [nativequery]

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

Related links

355 questions
0
votes
2 answers

JPA nativeQuery returns cached resultList

I have following classes: Company.class: public class Company { @JoinTable(name = "company_employee", joinColumns = @JoinColumn(name = "company_id") , inverseJoinColumns = @JoinColumn(name = "employee_id") ) @ManyToMany(fetch =…
Battle_Slug
  • 2,055
  • 1
  • 34
  • 60
0
votes
1 answer

OpenJPA:JPQL vs native query

I am using OpenJPA in my work. Sometimes I have to use JPQL and sometimes I have to use native query(em.createNativQuery). I am witnessing a big issue with native query. I have to provide schema name too. Like for JPQL I can…
Mandroid
  • 6,200
  • 12
  • 64
  • 134
0
votes
2 answers

JPA @SequenceGenerator with Manual ID and Auto ID

I have an entity @Entity public class Book { @Id @Column(name = "book_id") @SequenceGenerator(name = "book_book_id_seq", sequenceName = "book_book_id_seq", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE,…
Lee Chee Kiam
  • 11,450
  • 10
  • 65
  • 87
0
votes
1 answer

How to create mapping of composed object with Hibernate when using a complex sqlquery?

I am trying to use the below query with Hibernate's session.createSQLQuery. The Entity object corresponding to user has an attribute called address. The address object is created out of 5 fields from table 'user'. If I do not use an SQLQuery it gets…
0
votes
3 answers

Setting a Clob value in a native query

Oracle DB. Spring JPA using Hibernate. I am having difficulty inserting a Clob value into a native sql query. The code calling the query is as follows: @SuppressWarnings("unchecked") public List findQueryColumnsByNativeQuery(String…
p45
  • 131
  • 1
  • 3
  • 11
0
votes
3 answers

JPA, @Transient field and Native Query mapping

I have this entity: @Entity @Table(name = "entry") @SqlResultSetMapping( name = "viewEntry", entities = @EntityResult(entityClass = ViewEntry.class, fields = { @FieldResult(name="id", column = "id"), …
Aleksandr Kravets
  • 5,750
  • 7
  • 53
  • 72
0
votes
1 answer

Native Query Result Parameter is Not mapped to Class Modal

I have using the Native Query in JPA Repository and my query is as: select u.*, max(a.version_no) as versionNo from users u left join andother_table a on u.id=a.user_id where u.title='abc' group by id; from my Query i get the "versionNo" which is…
Charnjeet Singh
  • 3,056
  • 6
  • 35
  • 65
0
votes
1 answer

Doctrine use count() in NativeQuery with ResultSetMapping

i try to use NativeQuery of Doctrine. If i use my SQL ind Phpmyadmin i have the good result. If i use this, my var_dump return an empty array. I don't understand why. $sql = 'SELECT COUNT(id) as nb FROM app_facture f WHERE…
djoo
  • 685
  • 1
  • 7
  • 24
0
votes
0 answers

Using Native Query Multiple Queries Single Resultset

Using JPA, I am trying to fetch data from different tables and to have it in single result list using query: SELECT x.a, y.b FROM (SELECT * from a) as x, (SELECT * FROM b) as y However it is throwing an exception: Caused by:…
Vipin
  • 1
  • 1
  • 3
0
votes
0 answers

Native query setParameter difference

Query query = em.createNativeQuery("SELECT * FROM IS_CON \n" + "WHERE CONNUMBER=?1 AND REV=?2", IsCon.class).setParameter(1, con).setParameter(2, rev); is query return null. But this query works. Query query =…
0
votes
2 answers

EJB query which uses TRUNC and WITH

I have a query which works fine when I use NativeQuery but I need to use an EJB query for my problem. Can anyone help me reformat my query so it would work for EJB also? Here is the Native version Query query =…
Salman9
  • 245
  • 1
  • 4
  • 17
0
votes
1 answer

Unable to run native JPA queries in testEntityManager container

Note: I had posted this question on eclipse forums but did not receive a reply though I thought my description of the problem was sufficiently clear. I am posting it here. It will be great if someone can help. I have a JPA entity class that does…
bespectacled
  • 2,801
  • 4
  • 25
  • 35
0
votes
0 answers

Native Query Not Map Count(*) variable

i am working on Jpa Native query, I want all my all send with it count but this my query select id,status,COUNT(*) as count from tb_abc where sender_id=?1 group by status But problem is when i will run it on Mysql then it will run fine but when i…
Charnjeet Singh
  • 3,056
  • 6
  • 35
  • 65
0
votes
1 answer

Function call not setting parameter correctly

I have this method: public Long calculateMilisseconds(Calendario calendario, Date inicio, Date fim) throws ApplicationException { try { StringBuffer sb = new StringBuffer(); sb.append("select…
Rafael dAS
  • 119
  • 4
0
votes
1 answer

Why to use doctrine relationships vs native query

I have a simple question. I saw a Symfony2-Tutorial where the blogger used everywhere simple entities without relations and was also using doctrine native-query to do joins and query the different entities. What is better, to use doctrine native…
Slowwie
  • 1,146
  • 2
  • 20
  • 36