Questions tagged [hibernate-native-query]

107 questions
7
votes
3 answers

JPA and JSON operator native query

I'm trying to make this query work in JPA: SELECT * FROM contrat WHERE contrat_json @> '{"nom" :"hever"}'; It works perfectly with postgresql but when I integrate it with JPA, I get the following error: Parameter with that position [1] did not…
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
4 answers

Hibernate createNativeQuery returning Proxy object for Clob

I am forced into a situation where i am using hibernate createNativeQuery to return a List of Objects arrays. One of the (many) columns from which my query returns values is a CLOB. The Object which is returned is com.sun.Proxy object. I have seen…
p45
  • 131
  • 1
  • 3
  • 11
4
votes
0 answers

Hibernate created query from native query contains illegal syntax

I was trying to select from table with native query as follows: entityManager.createNativeQuery("SELECT * FROM B_AccountTransaction " + "accountTransaction WHERE accountTransaction.depositId = '" + depositId + "'") …
Soosh
  • 812
  • 1
  • 8
  • 24
3
votes
1 answer

ERROR: operator does not exist: bigint = character varying for empty list of long

I'm using Hibernate to get data from Postgresql DB, but always getting this error when trying to pass EMPTY or NULL as list of Long values to query: @Repository public interface ProductRepository extends JpaRepository { …
2
votes
0 answers

How to retrieve json column with a native query with projection?

I have a database with a table that contains a column of type JSON. Retrieving all data from the table using the whole entity work without problems. But in a case when I use a native query with some joins and want to retrieve only specific columns…
2
votes
1 answer

SpringDataJPA - What does '?1' in the where clause mean in the below query?

@Query(value="select * from author a where a.last_name= ?1",nativeQuery = true) What does ?1 mean in the above query?
2
votes
1 answer

Multiple parameter in JPA query and method

I want to pass multiple parameters around(20) in my JPA method. So is there any way in which I can pass an Object as a parameter in my JPA method? How can I use @Param annotation which can take values from my object and assign it to my native query…
2
votes
0 answers

Spring JPA Data : Query on ElementCollection

I have the following class called "UserInterest". It follows the following definition: @Table(name = "user_interests") public class UserInterest { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_interest_pk_generator") …
Mamun
  • 375
  • 2
  • 8
  • 17
2
votes
1 answer

Hibernate: returning a DTO that is not an Entity?

I have the following ContactDTO java POJO that is a trimmed down version of my Contact entity that contains over 100 fields/columns ContactDTO: public class ContactDTO { @JsonProperty private Integer contactId; @JsonProperty …
java12399900
  • 1,485
  • 7
  • 26
  • 56
2
votes
2 answers

hibernate native query transformer columns to complex property in dto

I have a native query, and I want to transformer columns (b_id, b_code, b_desc) to complexProperty (a custom object) in ResultDto. SQL select a.id as id, a.name as name, b.id as b_id, b.code as b_code, b.desc as…
xmcx
  • 283
  • 3
  • 18
2
votes
0 answers

Hibernate transaction does not commit changes to database (SQL Server)

We have a function in our application that cleans up the database and resets the data, we call a method cleanup() which at first deletes all the data from the database and then calls a sql script file to insert all the necessary default data of our…
Shahe
  • 964
  • 2
  • 13
  • 34
2
votes
1 answer

how to get list of long values in hibernate from the table while casting from bigint to long

I get the following exception when using the getEvents method: org.hibernate.MappingException: Unknown entity: java.lang.Long public List getEvents(Person person) { String q = "select new java.lang.Long(te.event_id) " + "from…
krltos
  • 313
  • 4
  • 20
2
votes
1 answer

Get many object from result of Oracle view

At my Oracle database I have two example tables: tabel A with columns id, a1, a2, a3 tabel B with columns id, b1, b2, b3 I have view for get information from this two tables: CREATE VIEW Foo ("A.id", "A.a1", "A.a2", "A.a3", "B.id", "B.b1",…
kuba44
  • 1,838
  • 9
  • 34
  • 62
2
votes
0 answers

How can I use a resultclass in EntityManager createNativeQuery?

Looking at EntityManager's interface I see there is a signature to create a native query with a result class. /** * Create an instance of Query for executing * a native SQL query. * @param sqlString a native SQL query string *…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
1
2 3 4 5 6 7 8