Questions tagged [native-sql]
77 questions
3
votes
1 answer
QueryDSL joins and subqueries with native SQL
I use Spring Data and QueryDSL 3.2.4 and I want to implement the following SQL query with QueryDSLs native SQL API:
WITH ORDER_GROUP AS ( -- TODO have to merge this subquery into the main query
SELECT
ordergroup
,count(ID) AS…

M. Lindenmann
- 81
- 1
- 2
- 6
3
votes
3 answers
Write native SQL in Core Data
I need to write a native SQL Query while I'm using Core Data in my project. I really need to do that, since I'm using NSPredicate right now and it's not efficient enough (in just one single case). I just need to write a couple of subqueries and…

gasparuff
- 2,295
- 29
- 48
3
votes
2 answers
Retrieve data from sqlserver in vb.net using entity framework and native sql
I want to retrieve data in Winforms using vb.net, entity framework and native sql. I have used the code below which allows me to add data to the sql:
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim db As New…

Khushi
- 1,031
- 4
- 24
- 48
3
votes
1 answer
Doctrine 2: How can extend entity with sql code column?
I have entity
mh\BTBundle\Entity\Post:
type: entity
table: post
repositoryClass: mh\BTBundle\Repository\PostRepository
fields:
id:
id: true
type: integer
unsigned: true
…

Marseille Talipov
- 31
- 2
2
votes
0 answers
How to make native query for nested projection in Spring Data JPA
I need to write a native query for my projection with nested interfaces.
My TransactionView interface:
public interface TransactionView {
Long getId();
TransactionType getType();
LocalDate getDate();
…

Vladimir
- 33
- 1
- 1
- 5
2
votes
1 answer
How do I execute native SQL with tortoise ORM
I want to use tortoise ORM to execute native SQL. What should I do? I can not find the methods or class to do it.

sx Luo
- 59
- 1
- 3
2
votes
1 answer
org.hibernate.QueryException: Space is not allowed after parameter prefix ':'
I'm trying to execute query , but got
Resolved exception caused by handler execution: org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: Space is not allowed after parameter prefix ':' .
I done as…

art74
- 57
- 1
- 11
2
votes
0 answers
Hibernate Exception -- ast Syntax Query Exception
SELECT GROUP_CONCAT(VALUE) FROM store_variant_option_value
WHERE store_variant_id = '1461' GROUP BY store_variant_id
I want to run this query in java code but getting java
dialect exception
Tried everything from native sql to hibernate named…

A.G
- 489
- 1
- 6
- 17
2
votes
0 answers
org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111 for jsonobject with custom JsonPostgreSQLDialect
1) I added custom dialect by extending PostgreSQL9Dialect which does this.registerColumnType(Types.JAVA_OBJECT, "jsonb");
2) public class JSONObjectUserType implements UserType {
}
3) property name="xxxx" type="org.JSONObjectUserType"…

Sindhu Shashidhar
- 79
- 2
- 7
2
votes
1 answer
Get average of two timestamp difference with hibernate
I want to calculate the average of the time difference of two timestamp fields of an entity, such that; entity has start_date and finish_date attibutes. In SQL, it is like the following:
SELECT SUM(FINISH_TIME - START_TIME) / COUNT(*) FROM…

st.
- 166
- 6
- 24
2
votes
1 answer
SQLException incorrect syntax near 'SELECT'
I can't figure this one out.
this query runs in sqlServer without error:
SELECT COUNT(tjmm.MAINMISSION_PARTICIPANT_SID)
FROM T_MOVEMENT_LEG ml INNER JOIN
TJ_MVLG_PARTMOV tjmp ON ml.MOVEMENTLEG_SID = tjmp.MOVEMENTLEG_SID…

chillworld
- 4,207
- 3
- 23
- 50
2
votes
0 answers
QueryDSL: How to set-up CaseBuilder to return columns instead of constant expressions
I want to setup a SQL case expression via the JPASQLQuery API as follows:
The Oracle SQL is:
SELECT h.ordercode
, h.requesteddeliverytime
, CASE
WHEN h.ordergroup IS NOT NULL
THEN g.minRequestedDeliveryTime
ELSE…

M. Lindenmann
- 81
- 1
- 2
- 6
2
votes
0 answers
QueryDSL, illegal argument type when projecting enum from JPASQLQuery into DTO
we have to use JPASQLQueries for complicated queries with joins on arbitrary columns and subqueries. One such query returns a string from the DB and should project this to an enum into a DTO. This mapping fails with "illegal argument type" when…

M. Lindenmann
- 81
- 1
- 2
- 6
2
votes
1 answer
Cannot insert NULL values into database
We use JPA to load/persist our entities in a prostges database. In one case i must persist a entity with a native query. Heres is the code:
String sql = "INSERT INTO recording…
user652158
1
vote
0 answers
Hibernate ResultTransformer with addEntity - what's the correct syntax?
Consider the following query:
"SELECT a.code as code,{locFrom.*} " +
"FROM audit.auditlogrecord a " +
"LEFT OUTER JOIN iwrs.location locFrom on locFrom.id=old_value "
I want to map the result to this class:
public class MovementHistoryImpl…

mmalmeida
- 1,037
- 9
- 27